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) {
79 for(
int i=0 ; i<NumGlobalElements ; ++i ) {
88 int NumMyElements = 0;
89 for (
int i = 0 ; i < NumGlobalElements ; ++i) {
90 if (part[i] == Comm.
MyPID())
95 int* MyGlobalElements =
new int[NumMyElements];
97 for (
int i = 0 ; i < NumGlobalElements ; ++i) {
98 if (part[i] == Comm.
MyPID() )
99 MyGlobalElements[count++] = i;
102 Epetra_Map Map(NumGlobalElements,NumMyElements,MyGlobalElements,
113 int* Indices =
new int[NumGlobalElements];
114 double* Values =
new double[NumGlobalElements];
116 for (
int i = 0 ; i < NumGlobalElements ; ++i)
119 for (
int i = 0 ; i < NumMyElements ; ++i) {
120 int iGlobal = MyGlobalElements[i];
121 for (
int jGlobal = 0 ; jGlobal < NumGlobalElements ; ++jGlobal) {
122 if (iGlobal == jGlobal)
123 Values[jGlobal] = 1.0 * (NumGlobalElements + 1 ) *
124 (NumGlobalElements + 1);
125 else if (iGlobal > jGlobal)
126 Values[jGlobal] = -1.0*(jGlobal+1);
128 Values[jGlobal] = 1.0*(iGlobal+1);
131 NumGlobalElements, Values, Indices);
137 delete [] MyGlobalElements;
167 bool TestPassed =
true;
169 TestPassed = TestPassed &&
179 return(EXIT_SUCCESS);
void SetLHS(Epetra_MultiVector *X)
void SetOperator(Epetra_RowMatrix *A)
int Solve()
Solves A X = B (or AT x = B)
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
Amesos_TestRowMatrix: a class to test Epetra_RowMatrix based codes.
Amesos_Superlu: Amesos interface to Xioye Li's SuperLU 3.0 serial code.
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
void SetRHS(Epetra_MultiVector *B)
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
int NumericFactorization()
Performs NumericFactorization on the matrix A.