46 #include "Thyra_DefaultScaledAdjointLinearOp.hpp" 
   47 #include "Thyra_DefaultMultipliedLinearOp.hpp" 
   48 #include "Thyra_DefaultDiagonalLinearOp.hpp" 
   49 #include "Thyra_VectorStdOps.hpp" 
   50 #include "Thyra_TestingTools.hpp" 
   51 #include "Thyra_LinearOpTester.hpp" 
   55 #include "EpetraExt_readEpetraLinearSystem.h" 
   67 #  include "Epetra_MpiComm.h" 
   69 #  include "Epetra_SerialComm.h" 
   81 using Thyra::epetraExtDiagScalingTransformer;
 
   82 using Thyra::VectorBase;
 
   83 using Thyra::LinearOpBase;
 
   84 using Thyra::createMember;
 
   85 using Thyra::LinearOpTester;
 
   87 using Thyra::multiply;
 
   88 using Thyra::diagonal;
 
   91 std::string matrixFile = 
"";
 
   97     "matrix-file", &matrixFile,
 
   98     "Defines the Epetra_CrsMatrix to read in."  );
 
  103 buildADOperator(
int scenario,
const Teuchos::RCP<
const Thyra::LinearOpBase<double> > & 
A,
 
  104                               const double vecScale, std::ostream & out)
 
  110    RCP<const LinearOpBase<double> > M;
 
  111    RCP<VectorBase<double> > d;
 
  113       d = createMember(
A->domain(), 
"d");
 
  115       d = createMember(
A->range(), 
"d");
 
  116    V_S( d.ptr(), vecScale ); 
 
  122       M = multiply( scale(scalea,
A), scale(scaled,diagonal(d)), 
"M" );
 
  123       out << 
" Testing A*D" << std::endl;
 
  126       M = multiply( scale(scaled,diagonal(d)), scale(scalea,
A), 
"M" );
 
  127       out << 
" Testing D*A" << std::endl;
 
  130       M = multiply( 
A, scale(scaled,diagonal(d)), 
"M" );
 
  131       out << 
" Testing adj(A)*D" << std::endl;
 
  134       M = multiply( scale(scaled,diagonal(d)), 
A, 
"M" );
 
  135       out << 
" Testing D*adj(A)" << std::endl;
 
  140    out << 
"\nM = " << *M;
 
  147    out << 
"\nReading linear system in Epetra format from the file \'"<<matrixFile<<
"\'\n";
 
  150    Epetra_MpiComm comm(MPI_COMM_WORLD);
 
  152    Epetra_SerialComm comm;
 
  155    RCP<Epetra_CrsMatrix> epetra_A;
 
  156    RCP<Epetra_CrsMatrix> epetra_B;
 
  157    EpetraExt::readEpetraLinearSystem( matrixFile, comm, &epetra_A, NULL, NULL, NULL );
 
  158    EpetraExt::readEpetraLinearSystem( matrixFile, comm, &epetra_B, NULL, NULL, NULL );
 
  159    const RCP<const Thyra::LinearOpBase<double> > 
A = Thyra::epetraLinearOp(epetra_A);
 
  160    const RCP<const Thyra::LinearOpBase<double> > 
B = Thyra::epetraLinearOp(epetra_B);
 
  162    RCP<VectorBase<double> > d = createMember(B->domain(), 
"d");
 
  165    const RCP<EpetraExtDiagScalingTransformer> BD_transformer =
 
  170    RCP<const LinearOpBase<double> > M;
 
  175    M = multiply(A,scale(3.9,diagonal(d)));
 
  178    M = multiply(scale(3.0,diagonal(d)),scale(9.0,B));
 
  181    M = multiply(B,scale(3.0,diagonal(d)),scale(9.0,B));
 
  191   out << 
"\nReading linear system in Epetra format from the file \'"<<matrixFile<<
"\'\n";
 
  194   Epetra_MpiComm comm(MPI_COMM_WORLD);
 
  196   Epetra_SerialComm comm;
 
  198   RCP<Epetra_CrsMatrix> epetra_A;
 
  199   EpetraExt::readEpetraLinearSystem( matrixFile, comm, &epetra_A, NULL, NULL, NULL );
 
  205   const RCP<const Thyra::LinearOpBase<double> > A = Thyra::epetraLinearOp(epetra_A);
 
  207   RCP<const Thyra::LinearOpBase<double> > M;
 
  210   for(
int scenario=1;scenario<=2;scenario++) {
 
  211      out << 
"**********************************************************" << std::endl;
 
  212      out << 
"**************** Starting Scenario = " << scenario << std::endl;
 
  213      out << 
"**********************************************************" << std::endl;
 
  218      const RCP<EpetraExtDiagScalingTransformer> BD_transformer =
 
  227      const RCP<LinearOpBase<double> > M_explicit = BD_transformer->createOutputOp();
 
  231      M = buildADOperator(scenario,A,4.5,out);
 
  232      BD_transformer->transform( *M, M_explicit.ptr() );
 
  235      M = buildADOperator(scenario,A,7.5,out);
 
  236      BD_transformer->transform( *M, M_explicit.ptr() );
 
  242      out << 
"\nM_explicit = " << *M_explicit;
 
  248      LinearOpTester<double> M_explicit_tester;
 
  249      M_explicit_tester.show_all_tests(
true);;
 
  251      const bool result = M_explicit_tester.compare( *M, *M_explicit, Teuchos::inoutArg(out) );
 
  252      if (!result) success = 
false;
 
  263   out << 
"\nReading linear system in Epetra format from the file \'"<<matrixFile<<
"\'\n";
 
  266   Epetra_MpiComm comm(MPI_COMM_WORLD);
 
  268   Epetra_SerialComm comm;
 
  270   RCP<Epetra_CrsMatrix> epetra_A;
 
  271   EpetraExt::readEpetraLinearSystem( matrixFile, comm, &epetra_A, NULL, NULL, NULL );
 
  277   const RCP<const Thyra::LinearOpBase<double> > A = Thyra::epetraLinearOp(epetra_A);
 
  284   for(
int scenario=1;scenario<=4;scenario++) {
 
  285      out << 
"**********************************************************" << std::endl;
 
  286      out << 
"**************** Starting Scenario = " << scenario << std::endl;
 
  287      out << 
"**********************************************************" << std::endl;
 
  289      RCP<const Thyra::LinearOpBase<double> > M = buildADOperator(scenario,A,4.5,out);
 
  294      const RCP<EpetraExtDiagScalingTransformer> BD_transformer =
 
  299      BD_transformer->isCompatible(*M);
 
  305      const RCP<LinearOpBase<double> > M_explicit = BD_transformer->createOutputOp();
 
  306      BD_transformer->transform( *M, M_explicit.ptr() );
 
  308      out << 
"\nM_explicit = " << *M_explicit;
 
  314      LinearOpTester<double> M_explicit_tester;
 
  315      M_explicit_tester.show_all_tests(
true);
 
  317      const bool result = M_explicit_tester.compare( *M, *M_explicit, Teuchos::inoutArg(out) );
 
  318      if (!result) success = 
false;
 
static CommandLineProcessor & getCLP()
 
TEUCHOS_UNIT_TEST(EpetraOperatorWrapper, basic)
 
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
 
Teuchos::RCP< Epetra_Operator > get_Epetra_Operator(LinearOpBase< double > &op)
Full specialization for Scalar=double. 
 
#define TEST_EQUALITY(v1, v2)
 
#define TEUCHOS_ASSERT(assertion_test)