10#ifndef THYRA_DEFAULT_MULTIPLIED_LINEAR_OP_DEF_HPP 
   11#define THYRA_DEFAULT_MULTIPLIED_LINEAR_OP_DEF_HPP 
   13#include "Thyra_DefaultMultipliedLinearOp_decl.hpp" 
   14#include "Thyra_AssertOp.hpp" 
   25void DefaultMultipliedLinearOp<Scalar>::assertInitialized()
 const 
   35std::string DefaultMultipliedLinearOp<Scalar>::getClassName()
 const 
   43Ordinal DefaultMultipliedLinearOp<Scalar>::getRangeDim()
 const 
   45  return (numOps() > 0 ? this->range()->dim() : 0);
 
   51Ordinal DefaultMultipliedLinearOp<Scalar>::getDomainDim()
 const 
   53  return (numOps() > 0 ? this->domain()->dim() : 0);
 
   69  const int nOps = Ops.size();
 
   71  for( 
int k = 0; k < nOps; ++k )
 
   72    Ops_[k].initialize(Ops[k]);
 
   74  setupDefaultObjectLabel();
 
 
   82  const int nOps = Ops.size();
 
   84  for( 
int k = 0; k < nOps; ++k )
 
   85    Ops_[k].initialize(Ops[k]);
 
   87  setupDefaultObjectLabel();
 
 
   95  setupDefaultObjectLabel();
 
 
  102template<
class Scalar>
 
  109template<
class Scalar>
 
  115  return Ops_[k].isConst();
 
 
  119template<
class Scalar>
 
  126  return Ops_[k].getNonconstObj();
 
 
  130template<
class Scalar>
 
  144template<
class Scalar>
 
  149    return getOp(0)->range();
 
 
  155template<
class Scalar>
 
  160    return getOp(numOps()-1)->domain();
 
 
  166template<
class Scalar>
 
  177template<
class Scalar>
 
  180  std::ostringstream oss;
 
  181  oss << getClassName() << 
"{numOps="<<numOps()
 
  182      <<
",rangeDim=" << getRangeDim()
 
  183      << 
",domainDim="<< getDomainDim() <<
"}";
 
 
  187template<
class Scalar>
 
  197  const int nOps = Ops_.size();
 
  201      *out << this->description() << std::endl;
 
  207      *out << this->description() << std::endl;
 
  210        <<  
"Constituent LinearOpBase objects for M = Op[0]*...*Op[numOps-1]:\n";
 
  212      for( 
int k = 0; k < nOps; ++k ) {
 
  213        *out << 
"Op["<<k<<
"] = " << Teuchos::describe(*getOp(k),verbLevel);
 
 
  229template<
class Scalar>
 
  232  bool overallOpSupported = 
true;
 
  233  for( 
int k = 0; k < static_cast<int>(Ops_.size()); ++k )
 
  234    if(!Thyra::opSupported(*getOp(k),M_trans)) overallOpSupported = 
false;
 
  235  return overallOpSupported;
 
 
  239template<
class Scalar>
 
  241  const int nOps = Ops_.size();
 
  242  if ((T_k_.size() != 
Teuchos::as<size_t>(nOps+1)) || ((nOps > 0) && (T_k_[0]->domain()->dim() != dim))) {
 
  249    for( 
int k = 0; k < nOps; ++k ) {
 
  250      T_k_.push_back(createMembers(getOp(k)->range(), dim));
 
  252    T_k_.push_back(createMembers(getOp(nOps-1)->domain(), dim));
 
  257template<
class Scalar>
 
  266  using Teuchos::rcpFromPtr;
 
  267  using Teuchos::rcpFromRef;
 
  270    getClassName()+
"::apply(...)", *
this, M_trans, X, &*Y
 
  273  const int nOps = Ops_.size();
 
  283    for( 
int k = nOps-1; k >= 0; --k ) {
 
  286      if(k==0) Y_k = rcpFromPtr(Y);  
else Y_k = T_k = T_k_[k];
 
  287      if(k==nOps-1) X_k = rcpFromRef(X); 
else X_k = T_kp1;
 
  289        Thyra::apply(*getOp(k), M_trans, *X_k, Y_k.
ptr());
 
  291        Thyra::apply(*getOp(k), M_trans, *X_k, Y_k.
ptr(), alpha, beta);
 
  302    for( 
int k = 0; k <= nOps-1; ++k ) {
 
  305      if(k==nOps-1) Y_k = rcpFromPtr(Y);  
else Y_k = T_k = T_k_[k+1];
 
  306      if(k==0) X_k = rcpFromRef(X); 
else X_k = T_km1;
 
  308        Thyra::apply(*getOp(k), M_trans, *X_k, Y_k.
ptr());
 
  310        Thyra::apply(*getOp(k), M_trans, *X_k, Y_k.
ptr(), alpha, beta);
 
 
  320template<
class Scalar>
 
  326    const int nOps = Ops_.size();
 
  327    for( 
int k = 0; k < nOps; ++k ) {
 
  331          getClassName()+
"::initialize(...)" 
  346template<
class Scalar>
 
  347void DefaultMultipliedLinearOp<Scalar>::setupDefaultObjectLabel()
 
  349  std::ostringstream label;
 
  350  const int nOps = Ops_.size();
 
  351  for( 
int k = 0; k < nOps; ++k ) {
 
  352    std::string Op_k_label = Ops_[k]->getObjectLabel();
 
  353    if (Op_k_label.length() == 0)
 
  357    label << 
"("<<Op_k_label<<
")";
 
  359  this->setObjectLabel(label.str());
 
  371template<
class Scalar>
 
  373Thyra::nonconstMultiply(
 
  374  const RCP<LinearOpBase<Scalar> > &A,
 
  375  const RCP<LinearOpBase<Scalar> > &B,
 
  376  const std::string &M_label
 
  379  using Teuchos::tuple;
 
  380  RCP<DefaultMultipliedLinearOp<Scalar> > multOp = 
 
  381    defaultMultipliedLinearOp<Scalar>(tuple(A, B)());
 
  383    multOp->setObjectLabel(M_label);
 
  388template<
class Scalar>
 
  391  const RCP<
const LinearOpBase<Scalar> > &A,
 
  392  const RCP<
const LinearOpBase<Scalar> > &B,
 
  393  const std::string &M_label
 
  396  using Teuchos::tuple;
 
  397  RCP<DefaultMultipliedLinearOp<Scalar> > multOp =
 
  398    defaultMultipliedLinearOp<Scalar>(tuple(A, B)());
 
  400    multOp->setObjectLabel(M_label);
 
  405template<
class Scalar>
 
  408  const RCP<
const LinearOpBase<Scalar> > &A,
 
  409  const RCP<
const LinearOpBase<Scalar> > &B,
 
  410  const RCP<
const LinearOpBase<Scalar> > &C,
 
  411  const std::string &M_label
 
  414  using Teuchos::tuple;
 
  415  RCP<DefaultMultipliedLinearOp<Scalar> > multOp =
 
  416    defaultMultipliedLinearOp<Scalar>(tuple(A, B, C)());
 
  418    multOp->setObjectLabel(M_label);
 
  430#define THYRA_DEFAULT_MULTIPLIED_LINEAR_OP_INSTANT(SCALAR) \ 
  432  template class DefaultMultipliedLinearOp<SCALAR >; \ 
  434  template RCP<LinearOpBase<SCALAR > > \ 
  436    const RCP<LinearOpBase<SCALAR > > &A, \ 
  437    const RCP<LinearOpBase<SCALAR > > &B, \ 
  438    const std::string &M_label \ 
  441  template RCP<const LinearOpBase<SCALAR > > \ 
  443    const RCP<const LinearOpBase<SCALAR > > &A, \ 
  444    const RCP<const LinearOpBase<SCALAR > > &B, \ 
  445    const std::string &M_label \ 
  448  template RCP<const LinearOpBase<SCALAR > > \ 
  450    const RCP<const LinearOpBase<SCALAR > > &A, \ 
  451    const RCP<const LinearOpBase<SCALAR > > &B, \ 
  452    const RCP<const LinearOpBase<SCALAR > > &C, \ 
  453    const std::string &M_label \ 
virtual std::string description() const
 
Concrete composite LinearOpBase subclass that creates an implicitly multiplied linear operator out of...
 
bool opIsConst(const int k) const
 
RCP< const LinearOpBase< Scalar > > getOp(const int k) const
 
void uninitialize()
Set to uninitialized.
 
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Prints the details about the constituent linear operators.
 
RCP< const VectorSpaceBase< Scalar > > range() const
Returns this->getOp(0).range() if <t>this->numOps() > 0 and returns Teuchos::null otherwise.
 
void initialize(const ArrayView< const RCP< LinearOpBase< Scalar > > > &Ops)
Initialize given a list of non-const linear operators.
 
DefaultMultipliedLinearOp()
Constructs to uninitialized.
 
RCP< const VectorSpaceBase< Scalar > > domain() const
Returns this->getOp(this->numOps()-1).domain() if <t>this->numOps() > 0 and returns Teuchos::null oth...
 
std::string description() const
Prints just the name DefaultMultipliedLinearOp along with the overall dimensions and the number of co...
 
RCP< const LinearOpBase< Scalar > > clone() const
 
RCP< LinearOpBase< Scalar > > getNonconstOp(const int k)
 
bool opSupportedImpl(EOpTransp M_trans) const
Returns true only if all constituent operators support M_trans.
 
void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
 
Base class for all linear operators.
 
virtual RCP< const VectorSpaceBase< Scalar > > domain() const =0
Return a smart pointer for the domain space for this operator.
 
Interface for a collection of column vectors called a multi-vector.
 
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
 
#define THYRA_ASSERT_LINEAR_OP_TIMES_LINEAR_OP_SPACES_NAMES(FUNC_NAME, M1, M1_T, M1_N, M2, M2_T, M2_N)
Assert that a linear operator multiplication matches up.
 
#define THYRA_ASSERT_LINEAR_OP_MULTIVEC_APPLY_SPACES(FUNC_NAME, M, M_T, X, Y)
This is a very useful macro that should be used to validate that the spaces for the multi-vector vers...
 
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
 
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
 
const char * toString(EConj conj)
Return a string name for a EOpTransp value. `*.
 
EOpTransp real_trans(EOpTransp transp)
Return NOTRANS or TRANS for real scalar valued operators and this also is used for determining struct...
 
@ NOTRANS
Use the non-transposed operator.
 
T_To & dyn_cast(T_From &from)
 
std::string toString(const T &t)