23 std::vector<double> Norm;
24 int NumVectors = x.NumVectors();
25 Norm.resize(NumVectors);
28 Ax.Update(1.0,b,-1.0);
30 bool TestPassed =
false;
31 double TotalNorm = 0.0;
32 for (
int i = 0 ; i < NumVectors ; ++i) {
36 std::cout <<
"||Ax - b|| = " << TotalNorm << std::endl;
37 if (TotalNorm < 1e-5 )
42 Ax.Update (1.0,x,-1.0,x_exact,0.0);
44 for (
int i = 0 ; i < NumVectors ; ++i) {
48 std::cout <<
"||Ax - b|| = " << TotalNorm << std::endl;
49 if (TotalNorm < 1e-5 )
58 int main(
int argc,
char *argv[]) {
61 MPI_Init(&argc, &argv);
67 int NumGlobalElements = 1000;
74 int* part =
new int[NumGlobalElements];
76 if (Comm.
MyPID() == 0)
80 for(
int i=0 ; i<NumGlobalElements ; ++i )
90 int NumMyElements = 0;
91 for (
int i = 0 ; i < NumGlobalElements ; ++i)
93 if (part[i] == Comm.
MyPID())
98 int* MyGlobalElements =
new int[NumMyElements];
100 for (
int i = 0 ; i < NumGlobalElements ; ++i)
102 if (part[i] == Comm.
MyPID() )
103 MyGlobalElements[count++] = i;
106 Epetra_Map Map(NumGlobalElements,NumMyElements,MyGlobalElements,
117 int* Indices =
new int[NumGlobalElements];
118 double* Values =
new double[NumGlobalElements];
120 for (
int i = 0 ; i < NumGlobalElements ; ++i)
123 for (
int i = 0 ; i < NumMyElements ; ++i) {
124 int iGlobal = MyGlobalElements[i];
125 for (
int jGlobal = 0 ; jGlobal < NumGlobalElements ; ++jGlobal) {
126 if (iGlobal == jGlobal)
127 Values[jGlobal] = 1.0 * (NumGlobalElements + 1 ) *
128 (NumGlobalElements + 1);
129 else if (iGlobal > jGlobal)
130 Values[jGlobal] = -1.0*(jGlobal+1);
132 Values[jGlobal] = 1.0*(iGlobal+1);
135 NumGlobalElements, Values, Indices);
141 delete[] MyGlobalElements;
173 return(EXIT_SUCCESS);
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
Amesos_TestRowMatrix: a class to test Epetra_RowMatrix based codes.
virtual int MyPID() const =0
int FillComplete(bool OptimizeDataStorage=true)
virtual int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_RowMatrix multiplied by a Epetra_MultiVector X in Y.
virtual const Epetra_Comm & Comm() const =0
#define AMESOS_CHK_ERR(a)
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
int main(int argc, char *argv[])
virtual int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
int Solve()
Solves A X = B (or AT x = B)
int NumericFactorization()
Performs NumericFactorization on the matrix A.
bool CheckError(const std::string SolverType, const std::string Descriptor, const Epetra_RowMatrix &A, const Epetra_MultiVector &x, const Epetra_MultiVector &b, const Epetra_MultiVector &x_exact)
int Broadcast(double *MyVals, int Count, int Root) const
Class Amesos_Umfpack: An object-oriented wrapper for UMFPACK.