10#include "Thyra_EpetraExtAddTransformer.hpp"
11#include "Thyra_AddedLinearOpBase.hpp"
12#include "Thyra_ScaledAdjointLinearOpBase.hpp"
13#include "Thyra_EpetraLinearOp.hpp"
14#include "Thyra_get_Epetra_Operator.hpp"
16#include "Thyra_DiagonalLinearOpBase.hpp"
17#include "Thyra_DefaultDiagonalLinearOp.hpp"
18#include "Thyra_IdentityLinearOpBase.hpp"
19#include "Thyra_VectorStdOps.hpp"
20#include "Epetra_Map.h"
21#include "Epetra_LocalMap.h"
22#include "Epetra_SerialComm.h"
23#include "Epetra_Vector.h"
24#include "Epetra_CrsMatrix.h"
25#include "Teuchos_Assert.hpp"
26#include "EpetraExt_ConfigDefs.h"
27#include "EpetraExt_MatrixMatrix.h"
28#include "EpetraExt_MMHelpers.h"
29#include "EpetraExt_Transpose_RowMatrix.h"
32#include "EpetraExt_RowMatrixOut.h"
61 using EpetraExt::MatrixMatrix;
63 using Teuchos::rcp_dynamic_cast;
71 dyn_cast<const AddedLinearOpBase<double> >(op_in);
80 double A_scalar = 0.0;
83 unwrap( op_A, &A_scalar, &A_transp, &A );
88 double B_scalar = 0.0;
91 unwrap( op_B, &B_scalar, &B_transp, &B );
113 = rcp_dynamic_cast<const DiagonalLinearOpBase<double> >(A);
115 = rcp_dynamic_cast<const DiagonalLinearOpBase<double> >(B);
120 if(dA==Teuchos::null)
121 epetra_A = rcp_dynamic_cast<const Epetra_CrsMatrix>(get_Epetra_Operator(*A),
true);
122 if(dB==Teuchos::null)
123 epetra_B = rcp_dynamic_cast<const Epetra_CrsMatrix>(get_Epetra_Operator(*B),
true);
129 if(epetra_A!=Teuchos::null && epetra_B!=Teuchos::null) {
135 EpetraLinearOp &thyra_epetra_op_inout = dyn_cast<EpetraLinearOp>(*op_inout);
137 rcp_dynamic_cast<Epetra_CrsMatrix>(thyra_epetra_op_inout.
epetra_op());
141 const int add_epetra_B_err
142 = EpetraExt::MatrixMatrix::Add(*epetra_A,A_transp==CONJTRANS,A_scalar,*epetra_B,B_transp==CONJTRANS,B_scalar,epetra_op_raw);
143 if(epetra_op==Teuchos::null)
148 epetra_op->FillComplete(epetra_A->DomainMap(),epetra_A->RangeMap());
153 else if((dA!=Teuchos::null && epetra_B!=Teuchos::null) ||
154 (dB!=Teuchos::null && epetra_A!=Teuchos::null)) {
158 double matScalar = (dA!=Teuchos::null) ? B_scalar : A_scalar;
160 double diagScalar = (dA!=Teuchos::null) ? A_scalar : B_scalar;
166 EpetraLinearOp & thyra_epetra_op_inout = dyn_cast<EpetraLinearOp>(*op_inout);
168 rcp_dynamic_cast<Epetra_CrsMatrix>(thyra_epetra_op_inout.
epetra_op());
170 if(epetra_op==Teuchos::null)
173 *epetra_op = *crsMat;
179 epetra_op->Scale(matScalar);
184 "Thyra::EpetraExtractAddTransformer::transform ExtractDiagonalCopy failed!");;
185 diagonal->Update(diagScalar,*v,1.0);
187 "Thyra::EpetraExtractAddTransformer::transform ReplaceDiagonalValues failed!");;
194 "Your case of adding Epetra operators is not yet implemented! Contact the Thyra developers.");
Interface class for implicitly added linear operators.
virtual Teuchos::RCP< const LinearOpBase< Scalar > > getOp(const int k) const =0
Return the kth constant constituent operator.
virtual int numOps() const =0
Returns the number of constituent operators.
RCP< const LinearOpBase< Scalar > > diagonal(const RCP< VectorBase< Scalar > > &diag, const std::string &label="")
Nonmember constructor function.
Concrete LinearOpBase adapter subclass for Epetra_Operator object.
RCP< EpetraLinearOp > nonconstEpetraLinearOp()
Default nonmember constructor.
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.
RCP< Epetra_Operator > epetra_op()
Interface class for identity linear operators.
Base class for all linear operators.
void V_S(const Ptr< VectorBase< Scalar > > &y, const Scalar &alpha)
y(i) = alpha, i = 0...y->space()->dim()-1.
RCP< VectorBase< Scalar > > createMember(const RCP< const VectorSpaceBase< Scalar > > &vs, const std::string &label="")
Create a vector member from the vector space.
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.
#define TEUCHOS_ASSERT(assertion_test)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
#define TEUCHOS_ASSERT_EQUALITY(val1, val2)
void unwrap(const LinearOpBase< Scalar > &Op, Scalar *scalar, EOpTransp *transp, const LinearOpBase< Scalar > **origOp)
Extract the overallScalar, overallTransp and const origOp from a const LinearOpBase object.
NOTRANS
Type for the dimension of a vector space. `**/ typedef Teuchos::Ordinal Ordinal;.
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
T_To & dyn_cast(T_From &from)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)