2 #ifdef HAVE_AMESOS_LAPACK
24 std::vector<double> Norm;
25 int NumVectors = x.NumVectors();
26 Norm.resize(NumVectors);
29 Ax.Update(1.0,b,-1.0);
31 bool TestPassed =
false;
32 double TotalNorm = 0.0;
33 for (
int i = 0 ; i < NumVectors ; ++i) {
37 std::cout <<
"||Ax - b|| = " << TotalNorm << std::endl;
38 if (TotalNorm < 1e-5 )
43 Ax.Update (1.0,x,-1.0,x_exact,0.0);
45 for (
int i = 0 ; i < NumVectors ; ++i) {
49 std::cout <<
"||Ax - b|| = " << TotalNorm << std::endl;
50 if (TotalNorm < 1e-5 )
59 int main(
int argc,
char *argv[])
62 MPI_Init(&argc, &argv);
68 int NumGlobalElements = 1000;
75 int* part =
new int[NumGlobalElements];
77 if (Comm.
MyPID() == 0) {
80 for(
int i=0 ; i<NumGlobalElements ; ++i ) {
89 int NumMyElements = 0;
90 for (
int i = 0 ; i < NumGlobalElements ; ++i) {
91 if (part[i] == Comm.
MyPID())
96 int* MyGlobalElements =
new int[NumMyElements];
98 for (
int i = 0 ; i < NumGlobalElements ; ++i) {
99 if (part[i] == Comm.
MyPID() )
100 MyGlobalElements[count++] = i;
103 Epetra_Map Map(NumGlobalElements,NumMyElements,MyGlobalElements,
114 int* Indices =
new int[NumGlobalElements];
115 double* Values =
new double[NumGlobalElements];
117 for (
int i = 0 ; i < NumGlobalElements ; ++i)
120 for (
int i = 0 ; i < NumMyElements ; ++i) {
121 int iGlobal = MyGlobalElements[i];
122 for (
int jGlobal = 0 ; jGlobal < NumGlobalElements ; ++jGlobal) {
123 if (iGlobal == jGlobal)
124 Values[jGlobal] = 1.0 * (NumGlobalElements + 1 ) *
125 (NumGlobalElements + 1);
126 else if (iGlobal > jGlobal)
127 Values[jGlobal] = -1.0*(jGlobal+1);
129 Values[jGlobal] = 1.0*(iGlobal+1);
131 Matrix.InsertGlobalValues(MyGlobalElements[i],
132 NumGlobalElements, Values, Indices);
136 Matrix.FillComplete();
138 delete [] MyGlobalElements;
164 Solver.SetUseTranspose(
false);
176 return(EXIT_SUCCESS);
191 int main(
int argc,
char *argv[])
194 MPI_Init(&argc, &argv);
197 puts(
"Please configure AMESOS with --enable-amesos-lapack");
198 puts(
"to run this example");
203 return(EXIT_SUCCESS);
void SetLHS(Epetra_MultiVector *X)
void SetOperator(Epetra_RowMatrix *A)
Amesos_TestRowMatrix: a class to test Epetra_RowMatrix based codes.
virtual int MyPID() const =0
virtual const Epetra_Comm & Comm() const =0
#define AMESOS_CHK_ERR(a)
int main(int argc, char *argv[])
virtual int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
Amesos_Lapack: an interface to LAPACK.
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