58 if (Solver->
Solve())
return(
false);
61 double d = 0.0, d_tot = 0.0;
64 for (
int j = 0 ; j < lhs->NumVectors() ; ++j)
65 d += ((*lhs)[j][i] - 1.0) * ((*lhs)[j][i] - 1.0);
70 std::vector<double> Norm(rhs->NumVectors());
74 Ax.Update(1.0, *rhs, -1.0);
77 std::string msg = ProblemType;
81 std::cout << std::endl;
82 std::cout << msg <<
" : Using " << A->
Comm().
NumProc() <<
" processes, UseTranspose = " << UseTranspose << std::endl;
83 for (
int j = 0 ; j < rhs->NumVectors() ; ++j)
84 std::cout << msg <<
" : eq " << j
85 <<
", ||A x - b||_2 = " << Norm[j] << std::endl;
86 std::cout << msg <<
" : ||x_exact - x||_2 = " << sqrt(d_tot) << std::endl;
91 std::cerr << std::endl << msg <<
" WARNING : TEST FAILED!" << std::endl;
104 int main(
int argc,
char *argv[])
107 MPI_Init(&argc, &argv);
113 int NumGlobalRows = 100 * Comm.
NumProc();
126 for (
int LRID = 0 ; LRID < NumMyRows ; ++LRID)
128 int GRID = MyGlobalElements[LRID];
136 Indices[NumEntries] = GRID - 1;
137 Values[NumEntries] = -1.0;
140 if (GRID != NumGlobalRows - 1)
142 Indices[NumEntries] = GRID + 1;
143 Values[NumEntries] = -1.0;
157 std::vector<std::string> SolverType;
158 SolverType.push_back(
"Amesos_Lapack");
159 SolverType.push_back(
"Amesos_Klu");
160 SolverType.push_back(
"Amesos_Umfpack");
162 SolverType.push_back(
"Amesos_Taucs");
163 SolverType.push_back(
"Amesos_Superlu");
164 SolverType.push_back(
"Amesos_Superludist");
165 SolverType.push_back(
"Amesos_Mumps");
166 SolverType.push_back(
"Amesos_Dscpack");
167 SolverType.push_back(
"Amesos_Scalapack");
173 for (
unsigned int i = 0 ; i < SolverType.size() ; ++i)
175 std::string
Solver = SolverType[i];
177 if (Factory.
Query((
char*)Solver.c_str()))
185 TestAmesos((
char*)Solver.c_str(), AmesosList,
false,
186 &Matrix, &LHS, &RHS);
187 assert (res ==
true);
191 if (Solver !=
"Amesos_Superludist") {
196 TestAmesos((
char*)Solver.c_str(), AmesosList,
true,
197 &Matrix, &LHS, &RHS);
198 assert (res ==
true);
205 std::cerr << std::endl;
206 std::cerr <<
"WARNING: SOLVER `" << Solver <<
"' NOT TESTED" << std::endl;
207 std::cerr << std::endl;
void SetLHS(Epetra_MultiVector *X)
void SetOperator(Epetra_RowMatrix *A)
bool TestAmesos(char ProblemType[], Teuchos::ParameterList &AmesosList, bool UseTranspose, Epetra_RowMatrix *A, Epetra_MultiVector *lhs, Epetra_MultiVector *rhs)
virtual int Solve()=0
Solves A X = B (or AT x = B)
int MyGlobalElements(int *MyGlobalElementList) const
virtual int NumericFactorization()=0
Performs NumericFactorization on the matrix A.
virtual int SymbolicFactorization()=0
Performs SymbolicFactorization on the matrix A.
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
virtual int SetParameters(Teuchos::ParameterList &ParameterList)=0
Updates internal variables.
virtual int MyPID() const =0
int FillComplete(bool OptimizeDataStorage=true)
virtual int SumAll(double *PartialSums, double *GlobalSums, int Count) const =0
int NumMyElements() const
virtual const Epetra_Comm & Comm() const =0
virtual const Epetra_BlockMap & Map() const =0
int main(int argc, char *argv[])
Factory for binding a third party direct solver to an Epetra_LinearProblem.
virtual int SetUseTranspose(bool UseTranspose)=0
If set true, X will be set to the solution of AT X = B (not A X = B)
virtual int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
void SetRHS(Epetra_MultiVector *B)
Amesos_BaseSolver * Create(const char *ClassType, const Epetra_LinearProblem &LinearProblem)
Amesos Create method.
virtual int NumProc() const =0
Amesos_BaseSolver: A pure virtual class for direct solution of real-valued double-precision operators...
bool Query(const char *ClassType)
Queries whether a given interface is available or not.