#include "AnasaziConfigDefs.hpp"
#include "AnasaziEpetraAdapter.hpp"
#include "AnasaziMVOPTester.hpp"
#include "AnasaziBasicOutputManager.hpp"
#include "Epetra_Map.h"
#include "Epetra_CrsMatrix.h"
#include "Epetra_Comm.h"
#ifdef HAVE_MPI
#include "mpi.h"
#include "Epetra_MpiComm.h"
#else
#include "Epetra_SerialComm.h"
#endif
int main(int argc, char *argv[])
{
#ifdef HAVE_MPI
MPI_Init(&argc,&argv);
Epetra_MpiComm Comm(MPI_COMM_WORLD);
#else
Epetra_SerialComm Comm;
#endif
Teuchos::RefCountPtr<Anasazi::OutputManager<double> > MyOM = Teuchos::rcp( new Anasazi::BasicOutputManager<double>() );
MyOM->setVerbosity( Anasazi::Warnings );
MyOM->stream(Anasazi::Errors) << Anasazi::Anasazi_Version() << endl << endl;
int dim = 100;
int blockSize = 5;
Epetra_Map Map(dim, 0, Comm);
int NumMyElements = Map.NumMyElements();
int * MyGlobalElements = new int[NumMyElements];
Map.MyGlobalElements(MyGlobalElements);
int * NumNz = new int[NumMyElements];
for (int i=0; i<NumMyElements; i++) {
if (MyGlobalElements[i]==0 || MyGlobalElements[i] == dim-1) {
NumNz[i] = 2;
}
else {
NumNz[i] = 3;
}
}
Teuchos::RefCountPtr<Epetra_CrsMatrix> A
= Teuchos::rcp( new Epetra_CrsMatrix(Copy, Map, NumNz) );
double *Values = new double[2];
Values[0] = -1.0; Values[1] = -1.0;
int *Indices = new int[2];
double two = 2.0;
int NumEntries;
for (int i=0; i<NumMyElements; i++) {
if (MyGlobalElements[i]==0) {
Indices[0] = 1;
NumEntries = 1;
}
else if (MyGlobalElements[i] == dim-1) {
Indices[0] = dim-2;
NumEntries = 1;
}
else {
Indices[0] = MyGlobalElements[i]-1;
Indices[1] = MyGlobalElements[i]+1;
NumEntries = 2;
}
int ierr = A->InsertGlobalValues(MyGlobalElements[i],NumEntries,Values,Indices);
assert(ierr==0);
ierr = A->InsertGlobalValues(MyGlobalElements[i],1,&two,MyGlobalElements+i);
assert(ierr==0);
}
int ierr = A->FillComplete();
assert(ierr==0);
typedef Epetra_MultiVector MV;
typedef Epetra_Operator OP;
typedef Anasazi::OperatorTraits<double, MV, OP> OPT;
Teuchos::RefCountPtr<MV> ivec
= Teuchos::rcp( new MV(Map, blockSize) );
ivec->Random();
bool testret;
testret = Anasazi::TestMultiVecTraits<double,MV>(MyOM,ivec);
if (testret) {
MyOM->print(Anasazi::Warnings,"*** PASSED TestMultiVecTraits() ***\n");
}
else {
MyOM->print(Anasazi::Warnings,"*** FAILED TestMultiVecTraits() ***\n");
}
testret = Anasazi::TestOperatorTraits<double,MV,OP>(MyOM,ivec,A);
if (testret) {
MyOM->print(Anasazi::Warnings,"*** PASSED TestOperatorTraits() ***\n");
}
else {
MyOM->print(Anasazi::Warnings,"*** FAILED TestOperatorTraits() ***\n");
}
delete [] NumNz;
delete [] Values;
delete [] Indices;
delete [] MyGlobalElements;
#ifdef HAVE_MPI
MPI_Finalize();
#endif
return 0;
}