10 #ifndef THYRA_DEFAULT_SCALED_ADJOINT_LINEAR_OP_DEF_HPP
11 #define THYRA_DEFAULT_SCALED_ADJOINT_LINEAR_OP_DEF_HPP
14 #include "Thyra_DefaultScaledAdjointLinearOp_decl.hpp"
15 #include "Thyra_VectorSpaceBase.hpp"
16 #include "Thyra_AssertOp.hpp"
25 template<
class Scalar>
32 initializeImpl(scalar,transp,Op,
false);
36 template<
class Scalar>
43 initializeImpl(scalar,transp,Op,
false);
47 template<
class Scalar>
51 return getOpImpl().getNonconstObj();
55 template<
class Scalar>
63 template<
class Scalar>
67 origOp_.uninitialize();
68 overallScalar_ = ST::zero();
70 allScalarETransp_ = Teuchos::null;
78 template<
class Scalar>
82 std::ostringstream oss;
84 << overallScalar() <<
","<<
toString(overallTransp())<<
","
85 << origOp_->description() <<
"}";
90 template<
class Scalar>
106 *out << this->description() << std::endl;
114 <<
"rangeDim=" << this->range()->dim()
115 <<
",domainDim=" << this->domain()->dim() <<
"}\n";
118 <<
"overallScalar="<< overallScalar() << std::endl
119 <<
"overallTransp="<<
toString(overallTransp()) << std::endl
120 <<
"Constituent transformations:\n";
121 for(
int i = 0; i <= my_index_; ++i ) {
122 const ScalarETransp<Scalar> &scalar_transp = (*allScalarETransp_)[my_index_-i];
124 if(scalar_transp.scalar != ST::one() && scalar_transp.transp !=
NOTRANS)
125 *out <<
"scalar="<<scalar_transp.scalar<<
",transp="<<
toString(scalar_transp.transp)<<std::endl;
126 else if(scalar_transp.scalar != ST::one())
127 *out <<
"scalar="<<scalar_transp.scalar<<std::endl;
128 else if( scalar_transp.transp !=
NOTRANS )
129 *out <<
"transp="<<
toString(scalar_transp.transp)<<std::endl;
131 *out <<
"no-transformation\n";
133 tab.incrTab(my_index_+2);
134 *out <<
"origOp = " << Teuchos::describe(*origOp_,verbLevel);
146 template<
class Scalar>
152 ? this->getOrigOp()->range() : this->getOrigOp()->domain() );
156 template<
class Scalar>
162 ? this->getOrigOp()->domain() : this->getOrigOp()->range() );
166 template<
class Scalar>
170 return Teuchos::null;
177 template<
class Scalar>
180 return overallScalar_;
184 template<
class Scalar>
187 return overallTransp_;
191 template<
class Scalar>
195 return origOp_.getNonconstObj();
199 template<
class Scalar>
213 template<
class Scalar>
217 return Thyra::opSupported(
218 *this->getOrigOp(),
trans_trans(this->overallTransp(), M_trans) );
222 template<
class Scalar>
234 *this->getOrigOp(),
trans_trans(M_trans, this->overallTransp()),
235 X, Y, as<Scalar>(this->overallScalar()*alpha), beta
243 template<
class Scalar>
254 Op.get()==NULL, std::invalid_argument
255 ,
"DefaultScaledAdjointLinearOp<"<<ST::name()<<
">::initialize(scalar,transp,Op): "
256 "Error!, Op.get()==NULL is not allowed!"
258 #endif // TEUCHOS_DEBUG
262 origOp_ = saOp->origOp_;
263 overallScalar_ = saOp->overallScalar_*scalar;
264 overallTransp_ =
trans_trans(saOp->overallTransp_,transp) ;
265 my_index_ = saOp->my_index_ + 1;
266 allScalarETransp_ = saOp->allScalarETransp_;
270 origOp_.initialize(Op);
272 origOp_.initialize(Teuchos::rcp_const_cast<LinearOpBase<Scalar> >(Op));
273 overallScalar_ = scalar;
274 overallTransp_ = transp;
276 allScalarETransp_ =
Teuchos::rcp(
new allScalarETransp_t());
278 allScalarETransp_->push_back(ScalarETransp<Scalar>(scalar,transp));
280 std::string Op_label = Op->getObjectLabel();
281 if(Op_label.length()==0)
283 std::ostringstream label;
284 if(scalar!=ST::one())
285 label << scalar <<
"*";
301 label <<
"(" << Op_label <<
")";
302 this->setObjectLabel(label.str());
306 template<
class Scalar>
307 typename DefaultScaledAdjointLinearOp<Scalar>::CNLOC
308 DefaultScaledAdjointLinearOp<Scalar>::getOpImpl()
const
311 if( my_index_ > 0 ) {
312 const ScalarETransp<Scalar> &scalar_transp = allScalarETransp_->at(my_index_);
314 Op =
Teuchos::rcp(
new DefaultScaledAdjointLinearOp<Scalar>());
315 Op->origOp_ = origOp_;
316 Op->overallScalar_ = overallScalar_/scalar_transp.scalar;
317 Op->overallTransp_ =
trans_trans(overallTransp_,scalar_transp.transp);
318 Op->my_index_ = my_index_ - 1;
319 Op->allScalarETransp_ = allScalarETransp_;
321 Teuchos::rcp_implicit_cast<LinearOpBase<Scalar> >(Op)
331 #endif // THYRA_DEFAULT_SCALED_ADJOINT_LINEAR_OP_DEF_HPP
RCP< const VectorSpaceBase< Scalar > > range() const
Return the range space of the logical linear operator.
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
EOpTransp overallTransp() const
Scalar overallScalar() const
RCP< const LinearOpBase< Scalar > > getOrigOp() const
basic_OSTab< char > OSTab
std::string description() const
Outputs DefaultScaledAdjointLinearOp<Scalar>{this->getOrigOp().description()) along with the dimensio...
basic_FancyOStream< char > FancyOStream
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Use the non-transposed operator.
EOpTransp real_trans(EOpTransp transp)
Return NOTRANS or TRANS for real scalar valued operators and this also is used for determining struct...
Use the transposed operator with complex-conjugate clements (same as TRANS for real scalar types)...
RCP< LinearOpBase< Scalar > > getNonconstOp()
Return the non-const linear operator passed into initialize().
void initialize(const Scalar &scalar, const EOpTransp &transp, const RCP< LinearOpBase< Scalar > > &Op)
Initialize with an operator with by defining adjoint (transpose) and scaling arguments.
Use the non-transposed operator with complex-conjugate elements (same as NOTRANS for real scalar type...
Use the transposed operator.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
RCP< const LinearOpBase< Scalar > > getOp() const
Return the const linear operator passed into initialize().
Interface for a collection of column vectors called a multi-vector.
EOpTransp trans_trans(EOpTransp trans1, EOpTransp trans2)
Combine two transpose arguments.
Concrete decorator LinearOpBase subclass that wraps a LinearOpBase object and adds on an extra scalin...
virtual std::string description() const
void uninitialize()
Set to uninitialized and (optionally) extract the objects passed into initialize().
TEUCHOSCORE_LIB_DLL_EXPORT std::string toString(const EVerbosityLevel verbLevel)
void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
Apply the linear operator (or its transpose) to a multi-vector : Y = alpha*op(M)*X + beta*Y...
Base class for all linear operators.
RCP< const LinearOpBase< Scalar > > clone() const
RCP< LinearOpBase< Scalar > > getNonconstOrigOp()
TypeTo as(const TypeFrom &t)
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Prints out the original operator as well as all of the scalings and transpositions in the order that ...
RCP< const VectorSpaceBase< Scalar > > domain() const
Return the domain space of the logical linear operator.
bool opSupportedImpl(EOpTransp M_trans) const
Return if the operation is supported on the logical linear operator.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)