29 std::vector<double> Norm;
30 int NumVectors = x.NumVectors();
31 Norm.resize(NumVectors);
34 Ax.Update(1.0,b,-1.0);
36 bool TestPassed =
false;
37 double TotalNorm = 0.0;
38 for (
int i = 0 ; i < NumVectors ; ++i) {
42 std::cout <<
"||Ax - b|| = " << TotalNorm << std::endl;
43 if (TotalNorm < 1e-5 )
48 Ax.Update (1.0,x,-1.0,x_exact,0.0);
50 for (
int i = 0 ; i < NumVectors ; ++i) {
54 std::cout <<
"||Ax - b|| = " << TotalNorm << std::endl;
55 if (TotalNorm < 1e-5 )
64 int main(
int argc,
char *argv[]) {
67 MPI_Init(&argc, &argv);
73 int NumGlobalElements = 1000;
80 int* part =
new int[NumGlobalElements];
82 if (Comm.
MyPID() == 0) {
85 for(
int i=0 ; i<NumGlobalElements ; ++i ) {
94 int NumMyElements = 0;
95 for (
int i = 0 ; i < NumGlobalElements ; ++i) {
96 if (part[i] == Comm.
MyPID())
101 int* MyGlobalElements =
new int[NumMyElements];
103 for (
int i = 0 ; i < NumGlobalElements ; ++i) {
104 if (part[i] == Comm.
MyPID() )
105 MyGlobalElements[count++] = i;
108 Epetra_Map Map(NumGlobalElements,NumMyElements,MyGlobalElements,
119 int* Indices =
new int[NumGlobalElements];
120 double* Values =
new double[NumGlobalElements];
122 for (
int i = 0 ; i < NumGlobalElements ; ++i)
125 for (
int i = 0 ; i < NumMyElements ; ++i) {
126 int iGlobal = MyGlobalElements[i];
127 for (
int jGlobal = 0 ; jGlobal < NumGlobalElements ; ++jGlobal) {
128 if (iGlobal == jGlobal)
129 Values[jGlobal] = 1.0 * (NumGlobalElements + 1 ) *
130 (NumGlobalElements + 1);
131 else if (iGlobal > jGlobal)
132 Values[jGlobal] = 1.0*(jGlobal+1);
134 Values[jGlobal] = 1.0*(iGlobal+1);
137 NumGlobalElements, Values, Indices);
143 delete [] MyGlobalElements;
void SetLHS(Epetra_MultiVector *X)
void SetOperator(Epetra_RowMatrix *A)
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
int Multiply(bool TransA, const Epetra_Vector &x, Epetra_Vector &y) const
Amesos_Dscpack: An object-oriented wrapper for Dscpack.
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
Amesos_TestRowMatrix: a class to test Epetra_RowMatrix based codes.
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)
virtual const Epetra_Comm & Comm() const =0
#define AMESOS_CHK_ERR(a)
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
int main(int argc, char *argv[])
int NumericFactorization()
Performs NumericFactorization on the matrix A.
#define EPETRA_CHK_ERR(xxx)
virtual int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
void SetRHS(Epetra_MultiVector *B)
int Solve()
Solves A X = B (or AT x = 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