11 #include "Thyra_MultipliedLinearOpBase.hpp"
12 #include "Thyra_DiagonalLinearOpBase.hpp"
13 #include "Thyra_ScaledAdjointLinearOpBase.hpp"
17 #include "Epetra_Map.h"
18 #include "Epetra_LocalMap.h"
19 #include "Epetra_SerialComm.h"
20 #include "Epetra_CrsMatrix.h"
21 #include "EpetraExt_MatrixMatrix.h"
32 const LinearOpBase<double> &)
const
42 return nonconstEpetraLinearOp();
47 const LinearOpBase<double> &op_in,
48 const Ptr<LinearOpBase<double> > &op_inout)
const
51 using EpetraExt::MatrixMatrix;
53 using Teuchos::rcp_dynamic_cast;
60 const MultipliedLinearOpBase<double> &multi_op =
61 dyn_cast<
const MultipliedLinearOpBase<double> >(op_in);
63 bool haveDiagScaling = (multi_op.numOps()==3);
67 double B_scalar = 0.0;
70 unwrap( op_B, &B_scalar, &B_transp, &B );
75 double D_scalar = 1.0;
80 unwrap( op_D, &D_scalar, &D_transp, &D );
81 d = rcp_dynamic_cast<
const DiagonalLinearOpBase<double> >(D,
true)->getDiag();
86 double G_scalar = 0.0;
89 unwrap( op_G, &G_scalar, &G_transp, &G );
103 if(haveDiagScaling) {
113 const Epetra_Map op_inout_row_map
114 = (B_transp==
CONJTRANS ? epetra_B->ColMap() : epetra_B->RowMap());
115 const Epetra_Map op_inout_col_map
116 = (G_transp==
CONJTRANS ? epetra_B->RowMap() : epetra_B->ColMap());
128 rcp_dynamic_cast<Epetra_CrsMatrix>(thyra_epetra_op_inout.
epetra_op());
131 new Epetra_CrsMatrix(::
Copy, op_inout_row_map, 0));
136 if(haveDiagScaling) {
142 epetra_BD_temp->LeftScale(*epetra_d);
144 epetra_BD_temp->RightScale(*epetra_d);
146 epetra_BD = epetra_BD_temp;
149 epetra_BD = epetra_B;
152 int mm_error = MatrixMatrix::Multiply( *epetra_BD, B_transp==
CONJTRANS,
153 *epetra_G, G_transp==
CONJTRANS, *epetra_op);
155 "EpetraExt::MatrixMatrix::Multiply failed returning error code " << mm_error <<
".");
158 if(B_scalar*G_scalar*D_scalar!=1.0)
159 epetra_op->Scale(B_scalar*G_scalar*D_scalar);
Concrete LinearOpBase adapter subclass for Epetra_Operator object.
bool is_null(const boost::shared_ptr< T > &p)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void initialize(const RCP< Epetra_Operator > &op, EOpTransp opTrans=NOTRANS, EApplyEpetraOpAs applyAs=EPETRA_OP_APPLY_APPLY, EAdjointEpetraOp adjointSupport=EPETRA_OP_ADJOINT_SUPPORTED, const RCP< const VectorSpaceBase< double > > &range=Teuchos::null, const RCP< const VectorSpaceBase< double > > &domain=Teuchos::null)
Fully initialize.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
T_To & dyn_cast(T_From &from)
RCP< Epetra_Vector > get_Epetra_Vector(const Epetra_Map &map, const RCP< VectorBase< double > > &v)
Get a non-const Epetra_Vector view from a non-const VectorBase object if possible.
Teuchos::RCP< Epetra_Operator > get_Epetra_Operator(LinearOpBase< double > &op)
Full specialization for Scalar=double.
#define TEUCHOS_ASSERT(assertion_test)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
RCP< Epetra_Operator > epetra_op()