43 #ifndef THYRA_DEFAULT_SCALED_ADJOINT_LINEAR_OP_DEF_HPP
44 #define THYRA_DEFAULT_SCALED_ADJOINT_LINEAR_OP_DEF_HPP
47 #include "Thyra_DefaultScaledAdjointLinearOp_decl.hpp"
48 #include "Thyra_VectorSpaceBase.hpp"
49 #include "Thyra_AssertOp.hpp"
58 template<
class Scalar>
65 initializeImpl(scalar,transp,Op,
false);
69 template<
class Scalar>
76 initializeImpl(scalar,transp,Op,
false);
80 template<
class Scalar>
84 return getOpImpl().getNonconstObj();
88 template<
class Scalar>
96 template<
class Scalar>
100 origOp_.uninitialize();
101 overallScalar_ = ST::zero();
103 allScalarETransp_ = Teuchos::null;
111 template<
class Scalar>
115 std::ostringstream oss;
117 << overallScalar() <<
","<<
toString(overallTransp())<<
","
118 << origOp_->description() <<
"}";
123 template<
class Scalar>
139 *out << this->description() << std::endl;
147 <<
"rangeDim=" << this->range()->dim()
148 <<
",domainDim=" << this->domain()->dim() <<
"}\n";
151 <<
"overallScalar="<< overallScalar() << std::endl
152 <<
"overallTransp="<<
toString(overallTransp()) << std::endl
153 <<
"Constituent transformations:\n";
154 for(
int i = 0; i <= my_index_; ++i ) {
155 const ScalarETransp<Scalar> &scalar_transp = (*allScalarETransp_)[my_index_-i];
157 if(scalar_transp.scalar != ST::one() && scalar_transp.transp !=
NOTRANS)
158 *out <<
"scalar="<<scalar_transp.scalar<<
",transp="<<
toString(scalar_transp.transp)<<std::endl;
159 else if(scalar_transp.scalar != ST::one())
160 *out <<
"scalar="<<scalar_transp.scalar<<std::endl;
161 else if( scalar_transp.transp !=
NOTRANS )
162 *out <<
"transp="<<
toString(scalar_transp.transp)<<std::endl;
164 *out <<
"no-transformation\n";
166 tab.incrTab(my_index_+2);
167 *out <<
"origOp = " << Teuchos::describe(*origOp_,verbLevel);
179 template<
class Scalar>
185 ? this->getOrigOp()->range() : this->getOrigOp()->domain() );
189 template<
class Scalar>
195 ? this->getOrigOp()->domain() : this->getOrigOp()->range() );
199 template<
class Scalar>
203 return Teuchos::null;
210 template<
class Scalar>
213 return overallScalar_;
217 template<
class Scalar>
220 return overallTransp_;
224 template<
class Scalar>
228 return origOp_.getNonconstObj();
232 template<
class Scalar>
246 template<
class Scalar>
250 return Thyra::opSupported(
251 *this->getOrigOp(),
trans_trans(this->overallTransp(), M_trans) );
255 template<
class Scalar>
267 *this->getOrigOp(),
trans_trans(M_trans, this->overallTransp()),
268 X, Y, as<Scalar>(this->overallScalar()*alpha), beta
276 template<
class Scalar>
287 Op.get()==NULL, std::invalid_argument
288 ,
"DefaultScaledAdjointLinearOp<"<<ST::name()<<
">::initialize(scalar,transp,Op): "
289 "Error!, Op.get()==NULL is not allowed!"
291 #endif // TEUCHOS_DEBUG
295 origOp_ = saOp->origOp_;
296 overallScalar_ = saOp->overallScalar_*scalar;
297 overallTransp_ =
trans_trans(saOp->overallTransp_,transp) ;
298 my_index_ = saOp->my_index_ + 1;
299 allScalarETransp_ = saOp->allScalarETransp_;
303 origOp_.initialize(Op);
305 origOp_.initialize(Teuchos::rcp_const_cast<LinearOpBase<Scalar> >(Op));
306 overallScalar_ = scalar;
307 overallTransp_ = transp;
309 allScalarETransp_ =
Teuchos::rcp(
new allScalarETransp_t());
311 allScalarETransp_->push_back(ScalarETransp<Scalar>(scalar,transp));
313 std::string Op_label = Op->getObjectLabel();
314 if(Op_label.length()==0)
316 std::ostringstream label;
317 if(scalar!=ST::one())
318 label << scalar <<
"*";
334 label <<
"(" << Op_label <<
")";
335 this->setObjectLabel(label.str());
339 template<
class Scalar>
340 typename DefaultScaledAdjointLinearOp<Scalar>::CNLOC
341 DefaultScaledAdjointLinearOp<Scalar>::getOpImpl()
const
344 if( my_index_ > 0 ) {
345 const ScalarETransp<Scalar> &scalar_transp = allScalarETransp_->at(my_index_);
347 Op =
Teuchos::rcp(
new DefaultScaledAdjointLinearOp<Scalar>());
348 Op->origOp_ = origOp_;
349 Op->overallScalar_ = overallScalar_/scalar_transp.scalar;
350 Op->overallTransp_ =
trans_trans(overallTransp_,scalar_transp.transp);
351 Op->my_index_ = my_index_ - 1;
352 Op->allScalarETransp_ = allScalarETransp_;
354 Teuchos::rcp_implicit_cast<LinearOpBase<Scalar> >(Op)
364 #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)