Amesos Package Browser (Single Doxygen Collection) Development
Test_KLU/cxx_main.cpp
Go to the documentation of this file.
00001 #include "Amesos_ConfigDefs.h"
00002 
00003 #ifdef HAVE_MPI
00004 #include "mpi.h"
00005 #include "Epetra_MpiComm.h"
00006 #else
00007 #include "Epetra_SerialComm.h"
00008 #endif
00009 #include "Epetra_Map.h"
00010 #include "Epetra_Vector.h"
00011 #include "Epetra_Util.h"
00012 #include "Amesos_Klu.h"
00013 #include "Amesos_TestRowMatrix.h"
00014 #include "Teuchos_ParameterList.hpp"
00015 #include "Galeri_Maps.h"
00016 #include "Galeri_CrsMatrices.h"
00017 #include "Galeri_Utils.h"
00018 
00019 using namespace Galeri;
00020 
00021 //============ //
00022 // main driver //
00023 //============ //
00024 
00025 int main(int argc, char *argv[]) 
00026 {
00027 #ifdef HAVE_MPI
00028   MPI_Init(&argc, &argv);
00029   Epetra_MpiComm Comm(MPI_COMM_WORLD);
00030 #else
00031   Epetra_SerialComm Comm;
00032 #endif
00033 
00034   Teuchos::ParameterList GaleriList;
00035   GaleriList.set("n", 5);
00036 
00037   Epetra_Map* Map = CreateMap("Random", Comm, GaleriList);
00038   Epetra_CrsMatrix* Matrix = CreateCrsMatrix("Minij", Map, GaleriList);
00039  
00040   int NumVectors = 2;
00041   Amesos_TestRowMatrix A(Matrix);
00042   Epetra_MultiVector x(*Map,NumVectors);
00043   Epetra_MultiVector x_exact(*Map,NumVectors);
00044   Epetra_MultiVector b(*Map,NumVectors);
00045   x_exact.Random();
00046   A.Multiply(false,x_exact,b);
00047 
00048   // =========== //
00049   // AMESOS PART //
00050   // =========== //
00051 
00052   Epetra_LinearProblem Problem(&A, &x, &b);
00053   Amesos_Klu Solver(Problem);
00054 
00055   AMESOS_CHK_ERR(Solver.SymbolicFactorization());
00056   AMESOS_CHK_ERR(Solver.NumericFactorization());
00057   AMESOS_CHK_ERR(Solver.Solve());
00058 
00059   double norm = ComputeNorm(Matrix, &x_exact, &b);
00060   if (Comm.MyPID() == 0)
00061     std::cout << "norm = " << norm << std::endl;
00062 
00063   if (norm > 1e-5)
00064     exit(EXIT_FAILURE);
00065 
00066 #ifdef HAVE_MPI
00067   MPI_Finalize();
00068 #endif
00069 
00070   return(EXIT_SUCCESS);
00071 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines