5 #define OUR_CHK_ERR(a) { { int epetra_err = a; \
6 if (epetra_err != 0) { std::cerr << "Amesos ERROR " << epetra_err << ", " \
7 << __FILE__ << ", line " << __LINE__ << std::endl; \
8 relerror = 1.3e15; relresidual=1e15; return(1);} }\
97 bool AddToAllDiagonalElements = ParamList.
get(
"AddZeroToDiag",
false ) ;
100 bool TrustMe = ParamList.
get(
"TrustMe",
false );
102 bool MyVerbose = false ;
113 assert ( EpetraMatrixType >= 0 && EpetraMatrixType <= 2 );
114 switch ( EpetraMatrixType ) {
128 assert( OptStorage) ;
138 const std::string AC = AmesosClass ;
139 if ( ExpectedError == 0 ) {
140 if ( AC !=
"Amesos_Pardiso" ) {
142 ParamList, MatPtr, Rcond ) );
144 if (MyVerbose) std::cout <<
" AC = " << AC <<
" not tested in Partial Factorization" <<std::endl ;
149 int oldtracebackmode = InMat->GetTracebackMode( ) ;
160 if ( AddToAllDiagonalElements ) {
163 InMat->SetTracebackMode(
EPETRA_MIN(oldtracebackmode,1) ) ;
169 double AddToDiag = ParamList.
get(
"AddToDiag", 0.0 );
172 AddConstVecToDiag.PutScalar( AddToDiag );
179 Diag.Update( 1.0, AddConstVecToDiag, 1.0 ) ;
186 InMat->SetTracebackMode( oldtracebackmode ) ;
191 if ( MyVerbose ) std::cout <<
" Partial Factorization complete " << std::endl ;
196 assert( Levels >= 1 && Levels <= 3 ) ;
198 int iam = Comm.
MyPID() ;
253 if (MyVerbose) ParamList.
set(
"DebugLevel", 1 );
254 if (MyVerbose) ParamList.
set(
"OutputLevel", 1 );
258 Problem.
SetLHS( &FixedLHS );
259 Problem.
SetRHS( &FixedRHS );
260 assert( OptStorage) ;
271 int oldtracebackmode = ECM->GetTracebackMode( ) ;
272 ECM->SetTracebackMode(0);
275 ECM->SetTracebackMode(oldtracebackmode);
278 if ( iam == 0 && SymbolicFactorizationReturn != ExpectedError ) {
279 std::cout <<
" SymbolicFactorization returned " << SymbolicFactorizationReturn
280 <<
" should be " << ExpectedError << std::endl ;
291 int oldtracebackmode = ECM->GetTracebackMode( ) ;
292 ECM->SetTracebackMode(0);
295 ECM->SetTracebackMode(oldtracebackmode);
298 if ( iam == 0 && NumericFactorizationReturn != ExpectedError ) {
299 std::cout <<
" NumericFactorization returned " << NumericFactorizationReturn
300 <<
" should be " << ExpectedError << std::endl ;
313 xexact.PutScalar(1.0);
322 if ( MyMatWithDiag->
MyGRID( 0 ) ) {
325 MyMatWithDiag->
Multiply( transpose, xexact, cAx ) ;
328 if ( MyMatWithDiag->
MyGRID( 0 ) )
342 if ( MyMatWithDiag->
MyGRID( 0 ) )
344 MyMatWithDiag->
Multiply( transpose, cAx, cAAx ) ;
347 if ( MyMatWithDiag->
MyGRID( 0 ) )
355 if ( MyVerbose ) std::cout <<
" Compute b = A x2 = A A' A'' xexact " << std::endl ;
357 MyMatWithDiag->
Multiply( transpose, cAAx, b ) ;
377 if ( TrustMe ) sAAx = FixedLHS ;
393 if ( TrustMe ) sAx = FixedLHS ;
410 if ( TrustMe ) x = FixedLHS ;
420 if ( MyMat->
MyGRID( 0 ) ) {
422 std::cout <<
" TestOptions requires a non-zero entry in A(1,1) " << std::endl ;
435 if ( MyMatWithDiag->
MyGRID( 0 ) )
437 MyMatWithDiag->
Multiply( transpose, x, kAx ) ;
439 if ( MyMatWithDiag->
MyGRID( 0 ) )
450 if ( MyMatWithDiag->
MyGRID( 0 ) )
452 MyMatWithDiag->
Multiply( transpose, kAx, kAAx ) ;
454 if ( MyMatWithDiag->
MyGRID( 0 ) )
462 MyMatWithDiag->
Multiply( transpose, kAAx, bcheck ) ;
467 DomainDiff.Update( 1.0, sAAx, -1.0, cAAx, 0.0 ) ;
468 DomainDiff.Norm2( &norm_diff ) ;
469 sAAx.Norm2( &norm_one ) ;
470 if (MyVerbose) std::cout << __FILE__ <<
"::" << __LINE__
471 <<
" norm( sAAx - cAAx ) / norm(sAAx ) = "
472 << norm_diff /norm_one << std::endl ;
477 DomainDiff.Update( 1.0, sAx, -1.0, cAx, 0.0 ) ;
478 DomainDiff.Norm2( &norm_diff ) ;
479 sAx.Norm2( &norm_one ) ;
480 if (MyVerbose) std::cout
481 << __FILE__ <<
"::" << __LINE__
482 <<
" norm( sAx - cAx ) / norm(sAx ) = "
483 << norm_diff /norm_one << std::endl ;
486 DomainDiff.Update( 1.0, x, -1.0, xexact, 0.0 ) ;
487 DomainDiff.Norm2( &norm_diff ) ;
488 x.Norm2( &norm_one ) ;
489 if (MyVerbose) std::cout
490 << __FILE__ <<
"::" << __LINE__
491 <<
" norm( x - xexact ) / norm(x) = "
492 << norm_diff /norm_one << std::endl ;
494 relerror = norm_diff / norm_one ;
496 DomainDiff.Update( 1.0, sAx, -1.0, kAx, 0.0 ) ;
497 DomainDiff.Norm2( &norm_diff ) ;
498 sAx.Norm2( &norm_one ) ;
499 if (MyVerbose) std::cout
500 << __FILE__ <<
"::" << __LINE__
501 <<
" norm( sAx - kAx ) / norm(sAx ) = "
502 << norm_diff /norm_one << std::endl ;
505 DomainDiff.Update( 1.0, sAAx, -1.0, kAAx, 0.0 ) ;
506 DomainDiff.Norm2( &norm_diff ) ;
507 sAAx.Norm2( &norm_one ) ;
508 if (MyVerbose) std::cout
509 << __FILE__ <<
"::" << __LINE__
510 <<
" norm( sAAx - kAAx ) / norm(sAAx ) = "
511 << norm_diff /norm_one << std::endl ;
514 RangeDiff.Update( 1.0, bcheck, -1.0, b, 0.0 ) ;
515 RangeDiff.Norm2( &norm_diff ) ;
516 bcheck.Norm2( &norm_one ) ;
517 if (MyVerbose) std::cout
518 << __FILE__ <<
"::" << __LINE__
519 <<
" norm( bcheck - b ) / norm(bcheck ) = "
520 << norm_diff /norm_one << std::endl ;
522 relresidual = norm_diff / norm_one ;
525 if ( relresidual * Rcond < 1e-16 ) {
526 if (MyVerbose) std::cout <<
" Test 1 Passed " << std::endl ;
528 std::cout << __FILE__ <<
"::" << __LINE__ <<
529 " relresidual = " << relresidual <<
531 " ParamList = " << ParamList << std::endl ;
int ReplaceDiagonalValues(const Epetra_Vector &Diagonal)
bool MyGRID(int GRID_in) const
void SetLHS(Epetra_MultiVector *X)
void SetOperator(Epetra_RowMatrix *A)
bool StorageOptimized() const
virtual int Solve()=0
Solves A X = B (or AT x = B)
int ExtractDiagonalCopy(Epetra_Vector &Diagonal) const
int Multiply(bool TransA, const Epetra_Vector &x, Epetra_Vector &y) const
T & get(ParameterList &l, const std::string &name)
virtual int NumericFactorization()=0
Performs NumericFactorization on the matrix A.
virtual int SymbolicFactorization()=0
Performs SymbolicFactorization on the matrix A.
virtual int SetParameters(Teuchos::ParameterList &ParameterList)=0
Updates internal variables.
int PartialFactorization(const char *AmesosClass, const Epetra_Comm &Comm, bool transpose, bool verbose, Teuchos::ParameterList ParamList, Epetra_CrsMatrix *&Amat, double Rcond)
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)
const Epetra_Map & OperatorDomainMap() const
virtual int MyPID() const =0
const Epetra_Map & RowMap() const
bool isParameter(const std::string &name) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Factory for binding a third party direct solver to an Epetra_LinearProblem.
virtual int SetUseTranspose(bool UseTranspose)=0
If set true, X will be set to the solution of AT X = B (not A X = B)
RCP< Epetra_CrsMatrix > NewMatNewMap(Epetra_CrsMatrix &In, int Diagonal, int ReindexRowMap, int ReindexColMap, int RangeMapType, int DomainMapType)
int SumIntoMyValues(int MyRow, int NumEntries, const double *Values, const int *Indices)
void SetRHS(Epetra_MultiVector *B)
Amesos_BaseSolver * Create(const char *ClassType, const Epetra_LinearProblem &LinearProblem)
Amesos Create method.
const Epetra_Map & OperatorRangeMap() const
const int NumericallySingularMatrixError
const int StructurallySingularMatrixError