#include "ml_config.h"
#include "ml_common.h"
#if defined(HAVE_ML_MLAPI) && defined(HAVE_ML_GALERI)
#include "MLAPI_Space.h"
#include "MLAPI_Operator.h"
#include "MLAPI_MultiVector.h"
#include "MLAPI_Gallery.h"
#include "MLAPI_Expressions.h"
using namespace MLAPI;
int main(int argc, char *argv[])
{
#ifdef HAVE_MPI
MPI_Init(&argc,&argv);
#endif
try {
Init();
int NumGlobalRows = 16;
Space MySpace(NumGlobalRows);
MultiVector x(MySpace), y(MySpace);
Operator A = Gallery("Tridiag", MySpace);
x.Random();
x = x / sqrt(x * x);
int MaxIters = 10;
for (int i = 0 ; i < MaxIters ; ++i) {
y = A * x;
double RQ = (y * x) / (x * x);
if (GetMyPID() == 0)
cout << "iter = " << i << ", RQ = " << RQ << endl;
x = y / sqrt(y * y);
}
Finalize();
}
catch (const int e) {
cout << "Caught integer exception, code = " << e << endl;
}
catch (...) {
cout << "problems here..." << endl;
}
#ifdef HAVE_MPI
MPI_Finalize();
#endif
return(0);
}
#else
#include "ml_include.h"
int main(int argc, char *argv[])
{
#ifdef HAVE_MPI
MPI_Init(&argc,&argv);
#endif
puts("This MLAPI example requires the following configuration options:");
puts("\t--enable-epetra");
puts("\t--enable-teuchos");
puts("\t--enable-ifpack");
puts("\t--enable-amesos");
puts("\t--enable-galeri");
puts("Please check your configure line.");
#ifdef HAVE_MPI
MPI_Finalize();
#endif
return(0);
}
#endif // #if defined(HAVE_ML_MLAPI)