25 std::vector<double> Norm;
26 int NumVectors = x.NumVectors();
27 Norm.resize(NumVectors);
30 Ax.Update(1.0,b,-1.0);
32 bool TestPassed =
false;
33 double TotalNorm = 0.0;
34 for (
int i = 0 ; i < NumVectors ; ++i) {
38 std::cout <<
"||Ax - b|| = " << TotalNorm << std::endl;
39 if (TotalNorm < 1e-5 )
44 Ax.Update (1.0,x,-1.0,x_exact,0.0);
46 for (
int i = 0 ; i < NumVectors ; ++i) {
50 std::cout <<
"||Ax - b|| = " << TotalNorm << std::endl;
51 if (TotalNorm < 1e-5 )
61 int main(
int argc,
char *argv[]) {
64 MPI_Init(&argc, &argv);
70 int NumGlobalElements = 1000;
75 if ( argc > 1 && argv[1][0] ==
'-' && argv[1][1] ==
'q' ) verbose = false ;
81 int* part =
new int[NumGlobalElements];
83 if (Comm.
MyPID() == 0) {
86 for(
int i=0 ; i<NumGlobalElements ; ++i ) {
95 int NumMyElements = 0;
96 for (
int i = 0 ; i < NumGlobalElements ; ++i) {
97 if (part[i] == Comm.
MyPID())
102 int* MyGlobalElements =
new int[NumMyElements];
104 for (
int i = 0 ; i < NumGlobalElements ; ++i) {
105 if (part[i] == Comm.
MyPID() )
106 MyGlobalElements[count++] = i;
109 Epetra_Map Map(NumGlobalElements,NumMyElements,MyGlobalElements,
120 int* Indices =
new int[NumGlobalElements];
121 double* Values =
new double[NumGlobalElements];
123 for (
int i = 0 ; i < NumGlobalElements ; ++i)
126 for (
int i = 0 ; i < NumMyElements ; ++i)
128 int iGlobal = MyGlobalElements[i];
129 const int MakeNotDense = 1;
130 int Min_jGlobal = std::min(i,MakeNotDense );
131 for (
int jGlobal = Min_jGlobal ; jGlobal < NumGlobalElements ; ++jGlobal) {
132 if (iGlobal == jGlobal)
133 Values[jGlobal-Min_jGlobal] = 1.0 * (NumGlobalElements + 1 ) *
134 (NumGlobalElements + 1);
135 else if (iGlobal > jGlobal)
136 Values[jGlobal-Min_jGlobal] = -1.0*(jGlobal+1);
138 Values[jGlobal-Min_jGlobal] = 1.0*(iGlobal+1);
141 NumGlobalElements-MakeNotDense, Values, &Indices[Min_jGlobal]);
147 delete[] MyGlobalElements;
186 return(EXIT_SUCCESS);
int Solve()
Solves A X = B (or AT x = B)
Amesos_Superludist: An object-oriented wrapper for Superludist.
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
Amesos_TestRowMatrix: a class to test Epetra_RowMatrix based codes.
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
virtual int MyPID() const =0
int FillComplete(bool OptimizeDataStorage=true)
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
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
int NumericFactorization()
Performs NumericFactorization on the matrix A.
#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
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