9 #ifndef Thyra_MultiVectorLinearOp_hpp
10 #define Thyra_MultiVectorLinearOp_hpp
12 #include "Thyra_RowStatLinearOpBase.hpp"
13 #include "Thyra_ScaledLinearOpBase.hpp"
14 #include "Thyra_DefaultMultiVectorProductVectorSpace.hpp"
15 #include "Thyra_DefaultMultiVectorProductVector.hpp"
16 #include "Teuchos_ConstNonconstObjectContainer.hpp"
17 #include "Thyra_VectorStdOps.hpp"
18 #include "Thyra_MultiVectorStdOps.hpp"
19 #include "Thyra_AssertOp.hpp"
20 #include "Teuchos_dyn_cast.hpp"
28 template<
class Scalar>
30 virtual public RowStatLinearOpBase<Scalar>,
31 virtual public ScaledLinearOpBase<Scalar>
42 const RCP<LinearOpBase<Scalar> > &op,
43 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
44 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
53 const RCP<
const LinearOpBase<Scalar> > &op,
54 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
55 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
63 RCP<LinearOpBase<Scalar> >
66 RCP<const LinearOpBase<Scalar> >
84 RCP<const LinearOpBase<Scalar> >
clone()
const {
return Teuchos::null;
93 return Thyra::opSupported(*
op_.getConstObj(),M_trans);
97 const EOpTransp M_trans,
98 const MultiVectorBase<Scalar> &XX,
99 const Ptr<MultiVectorBase<Scalar> > &YY,
104 using Teuchos::dyn_cast;
105 typedef DefaultMultiVectorProductVector<Scalar> MVPV;
107 const Ordinal numCols = XX.domain()->dim();
109 for (Ordinal col_j = 0; col_j < numCols; ++col_j) {
111 const RCP<const VectorBase<Scalar> > x = XX.col(col_j);
112 const RCP<VectorBase<Scalar> > y = YY->col(col_j);
114 RCP<const MultiVectorBase<Scalar> >
115 X = dyn_cast<
const MVPV>(*x).getMultiVector().assert_not_null();
116 RCP<MultiVectorBase<Scalar> >
117 Y = dyn_cast<MVPV>(*y).getNonconstMultiVector().assert_not_null();
119 Thyra::apply( *
op_.getConstObj(), M_trans, *X, Y.ptr(), alpha, beta );
130 const RowStatLinearOpBaseUtils::ERowStat rowStat
132 {
using Teuchos::rcp_dynamic_cast;
133 return rcp_dynamic_cast<
const RowStatLinearOpBase<Scalar> >(
op_.getConstObj())->rowStatIsSupported(rowStat); }
140 const RowStatLinearOpBaseUtils::ERowStat rowStat,
141 const Ptr<VectorBase<Scalar> > &rowStatVec
144 TEUCHOS_ASSERT(this->rowStatIsSupported(rowStat));
150 typedef DefaultMultiVectorProductVector<Scalar> MVPV;
151 using Teuchos::dyn_cast;
152 using Teuchos::rcp_dynamic_cast;
153 RCP<MultiVectorBase<Scalar> > rowStatMultiVec =
154 dyn_cast<MVPV>(*rowStatVec).getNonconstMultiVector().assert_not_null();
155 const Ordinal numCols = rowStatMultiVec->domain()->dim();
157 rcp_dynamic_cast<
const RowStatLinearOpBase<Scalar> >(
op_.getConstObj())->getRowStat(rowStat, rowStatMultiVec->col(0).ptr());
158 for (Ordinal col=1; col<numCols; ++col) {
159 Thyra::copy(*(rowStatMultiVec->col(0)),
160 rowStatMultiVec->col(col).ptr());
171 using Teuchos::rcp_dynamic_cast;
172 return rcp_dynamic_cast<
const ScaledLinearOpBase<Scalar> >(
op_.getConstObj())->supportsScaleLeft();
176 using Teuchos::rcp_dynamic_cast;
177 return rcp_dynamic_cast<
const ScaledLinearOpBase<Scalar> >(
op_.getConstObj())->supportsScaleRight();
181 TEUCHOS_ASSERT(this->supportsScaleLeft());
184 typedef DefaultMultiVectorProductVector<Scalar> MVPV;
185 using Teuchos::dyn_cast;
186 using Teuchos::rcp_dynamic_cast;
187 RCP<const MultiVectorBase<Scalar> > row_scaling_mv =
188 dyn_cast<
const MVPV>(row_scaling).getMultiVector().assert_not_null();
189 const Ordinal numCols = row_scaling_mv->domain()->dim();
191 rcp_dynamic_cast<ScaledLinearOpBase<Scalar> >(
op_.getNonconstObj())->scaleLeft(*(row_scaling_mv->col(0)));
198 TEUCHOS_ASSERT(this->supportsScaleRight());
201 typedef DefaultMultiVectorProductVector<Scalar> MVPV;
202 using Teuchos::dyn_cast;
203 using Teuchos::rcp_dynamic_cast;
204 RCP<const MultiVectorBase<Scalar> > col_scaling_mv =
205 dyn_cast<
const MVPV>(col_scaling).getMultiVector().assert_not_null();
206 const Ordinal numCols = col_scaling_mv->domain()->dim();
208 rcp_dynamic_cast<ScaledLinearOpBase<Scalar> >(
op_.getNonconstObj())->scaleRight(*(col_scaling_mv->col(0)));
219 typedef Teuchos::ConstNonconstObjectContainer<LinearOpBase<Scalar> >
CNOP;
232 const RCP<
const LinearOpBase<Scalar> > &op,
233 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
234 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
237 TEUCHOS_TEST_FOR_EXCEPT(is_null(op));
238 TEUCHOS_TEST_FOR_EXCEPT(is_null(multiVecRange));
239 TEUCHOS_TEST_FOR_EXCEPT(is_null(multiVecDomain));
240 TEUCHOS_TEST_FOR_EXCEPT( multiVecRange->numBlocks() != multiVecDomain->numBlocks() );
241 if (op->range() != Teuchos::null)
242 THYRA_ASSERT_VEC_SPACES(
243 "MultiVectorLinearOp<Scalar>::initialize(op,multiVecRange,multiVecDomain)",
244 *op->range(), *multiVecRange->getBlock(0) );
245 if (op->domain() != Teuchos::null)
246 THYRA_ASSERT_VEC_SPACES(
247 "MultiVectorLinearOp<Scalar>::initialize(op,multiVecRange,multiVecDomain)",
248 *op->domain(), *multiVecDomain->getBlock(0) );
252 (void)multiVecDomain;
262 template<
class Scalar>
263 RCP<MultiVectorLinearOp<Scalar> >
273 template<
class Scalar>
274 RCP<MultiVectorLinearOp<Scalar> >
276 const RCP<LinearOpBase<Scalar> > &op,
277 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
278 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
281 RCP<MultiVectorLinearOp<Scalar> >
283 mvop->nonconstInitialize(op,multiVecRange,multiVecDomain);
291 template<
class Scalar>
292 RCP<MultiVectorLinearOp<Scalar> >
294 const RCP<LinearOpBase<Scalar> > &op,
298 RCP<MultiVectorLinearOp<Scalar> >
300 RCP<const Thyra::DefaultMultiVectorProductVectorSpace<Scalar> > mv_domain =
301 Thyra::multiVectorProductVectorSpace(op->domain(), num_blocks);
302 RCP<const Thyra::DefaultMultiVectorProductVectorSpace<Scalar> > mv_range =
303 Thyra::multiVectorProductVectorSpace(op->range(), num_blocks);
304 mvop->nonconstInitialize(op,mv_range,mv_domain);
312 template<
class Scalar>
313 RCP<MultiVectorLinearOp<Scalar> >
315 const RCP<
const LinearOpBase<Scalar> > &op,
316 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
317 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
320 RCP<MultiVectorLinearOp<Scalar> >
322 mvop->initialize(op,multiVecRange,multiVecDomain);
330 template<
class Scalar>
331 RCP<MultiVectorLinearOp<Scalar> >
333 const RCP<
const LinearOpBase<Scalar> > &op,
337 RCP<MultiVectorLinearOp<Scalar> >
339 RCP<const Thyra::DefaultMultiVectorProductVectorSpace<Scalar> > mv_domain =
340 Thyra::multiVectorProductVectorSpace(op->domain(), num_blocks);
341 RCP<const Thyra::DefaultMultiVectorProductVectorSpace<Scalar> > mv_range =
342 Thyra::multiVectorProductVectorSpace(op->range(), num_blocks);
343 mvop->initialize(op,mv_range,mv_domain);
RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > multiVecRange_
static void validateInitialize(const RCP< const LinearOpBase< Scalar > > &op, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecRange, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecDomain)
RCP< const VectorSpaceBase< Scalar > > domain() const
RCP< MultiVectorLinearOp< Scalar > > multiVectorLinearOp()
Nonmember constructor function.
virtual void scaleRightImpl(const VectorBase< Scalar > &col_scaling)
void nonconstInitialize(const RCP< LinearOpBase< Scalar > > &op, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecRange, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecDomain)
RCP< LinearOpBase< Scalar > > getNonconstLinearOp()
void getRowStatImpl(const RowStatLinearOpBaseUtils::ERowStat rowStat, const Ptr< VectorBase< Scalar > > &rowStatVec) const
Get some statistics about a supported row.
void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &XX, const Ptr< MultiVectorBase< Scalar > > &YY, const Scalar alpha, const Scalar beta) const
Teuchos::ConstNonconstObjectContainer< LinearOpBase< Scalar > > CNOP
RCP< const LinearOpBase< Scalar > > clone() const
RCP< MultiVectorLinearOp< Scalar > > multiVectorLinearOp(const RCP< const LinearOpBase< Scalar > > &op, const int num_blocks)
Nonmember constructor function.
MultiVectorLinearOp()
Construct to uninitialized.
RCP< MultiVectorLinearOp< Scalar > > multiVectorLinearOp(const RCP< const LinearOpBase< Scalar > > &op, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecRange, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecDomain)
Nonmember constructor function.
RCP< MultiVectorLinearOp< Scalar > > nonconstMultiVectorLinearOp(const RCP< LinearOpBase< Scalar > > &op, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecRange, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecDomain)
Nonmember constructor function.
RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > multiVecDomain_
bool opSupportedImpl(EOpTransp M_trans) const
virtual void scaleLeftImpl(const VectorBase< Scalar > &row_scaling)
virtual bool supportsScaleLeftImpl() const
Implicit concrete LinearOpBase subclass that takes a flattended out multi-vector and performs a multi...
RCP< MultiVectorLinearOp< Scalar > > nonconstMultiVectorLinearOp(const RCP< LinearOpBase< Scalar > > &op, const int num_blocks)
Nonmember constructor function.
bool rowStatIsSupportedImpl(const RowStatLinearOpBaseUtils::ERowStat rowStat) const
Determine if a given row stat is supported.
void initialize(const RCP< const LinearOpBase< Scalar > > &op, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecRange, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecDomain)
RCP< const VectorSpaceBase< Scalar > > range() const
virtual bool supportsScaleRightImpl() const
RCP< const LinearOpBase< Scalar > > getLinearOp() const