42 #ifndef THYRA_DEFAULT_COLUMNWISE_MULTI_VECTOR_DEF_HPP 43 #define THYRA_DEFAULT_COLUMNWISE_MULTI_VECTOR_DEF_HPP 45 #include "Thyra_DefaultColumnwiseMultiVector_decl.hpp" 46 #include "Thyra_MultiVectorDefaultBase.hpp" 47 #include "Thyra_VectorSpaceBase.hpp" 48 #include "Thyra_VectorBase.hpp" 49 #include "Thyra_MultiVectorBase.hpp" 50 #include "Thyra_VectorStdOps.hpp" 51 #include "Thyra_VectorSpaceFactoryBase.hpp" 52 #include "Thyra_AssertOp.hpp" 53 #include "Teuchos_Assert.hpp" 54 #include "Teuchos_as.hpp" 62 template<
class Scalar>
67 template<
class Scalar>
72 this->initialize(col_vec);
76 template<
class Scalar>
83 this->initialize(range_in, domain_in, col_vecs_in);
87 template<
class Scalar>
93 const std::string err_msg =
94 "DefaultColumnwiseMultiVector<Scalar>::initialize(...): Error!";
95 TEUCHOS_TEST_FOR_EXCEPT_MSG( is_null(col_vec), err_msg );
96 TEUCHOS_TEST_FOR_EXCEPT_MSG( is_null(col_vec->space()), err_msg );
98 range_ = col_vec->space();
99 domain_ = range_->smallVecSpcFcty()->createVecSpc(1);
101 col_vecs_[0] = col_vec;
105 template<
class Scalar>
113 const std::string err_msg =
114 "DefaultColumnwiseMultiVector<Scalar>::initialize(...): Error!";
115 TEUCHOS_TEST_FOR_EXCEPT_MSG( is_null(range_in), err_msg );
116 TEUCHOS_TEST_FOR_EXCEPT_MSG( is_null(domain_in), err_msg );
117 TEUCHOS_TEST_FOR_EXCEPT_MSG( range_in->dim() == 0, err_msg );
118 TEUCHOS_TEST_FOR_EXCEPT_MSG( domain_in->dim() == 0, err_msg );
121 const int domainDim = domain_in->dim();
125 col_vecs_.reserve(domainDim);
126 if (col_vecs.size()) {
127 for(
Ordinal j = 0; j < domainDim; ++j )
128 col_vecs_.push_back(col_vecs[j]);
131 for(
Ordinal j = 0; j < domainDim; ++j )
132 col_vecs_.push_back(createMember(range_));
137 template<
class Scalar>
141 range_ = Teuchos::null;
142 domain_ = Teuchos::null;
149 template<
class Scalar>
150 RCP<const VectorSpaceBase<Scalar> >
157 template<
class Scalar>
158 RCP<const VectorSpaceBase<Scalar> >
168 template<
class Scalar>
171 const Ordinal m = col_vecs_.size();
172 for (
Ordinal col_j = 0; col_j < m; ++col_j) {
173 col_vecs_[col_j]->assign(alpha);
182 template<
class Scalar>
185 typedef Teuchos::ScalarTraits<Scalar> ST;
186 return ( ST::isComplex ? ( M_trans==
NOTRANS || M_trans==
CONJTRANS ) :
true );
190 template<
class Scalar>
201 "MultiVectorBase<Scalar>::apply()", *
this, M_trans, X, &*Y);
203 const Ordinal nc = this->domain()->dim();
205 for (
Ordinal col_j = 0; col_j < m; ++col_j) {
206 const RCP<const VectorBase<Scalar> > x_j = X.
col(col_j);
207 const RCP<VectorBase<Scalar> > y_j = Y->col(col_j);
209 Vt_S(y_j.ptr(), beta);
217 x_j->acquireDetachedView(
Range1D(), &x_sub_vec);
219 for (
Ordinal j = 0; j < nc; ++j )
220 Vp_StV( y_j.ptr(), Scalar(alpha*x_sub_vec(j)), *this->col(j) );
222 x_j->releaseDetachedView(&x_sub_vec);
233 y_j->acquireDetachedView(
Range1D(), &y_sub_vec);
235 for (
Ordinal j = 0; j < nc; ++j )
236 y_sub_vec(j) += alpha*dot(*this->col(j), *x_j);
238 y_j->commitDetachedView(&y_sub_vec);
247 template<
class Scalar>
248 RCP<VectorBase<Scalar> >
252 const int num_cols = col_vecs_.size();
253 TEUCHOS_TEST_FOR_EXCEPTION(
254 !( 0 <= j && j < num_cols ), std::logic_error
255 ,
"Error, j = " << j <<
" does not fall in the range [0,"<<(num_cols-1)<<
"]!" 261 template<
class Scalar>
262 RCP<MultiVectorBase<Scalar> >
267 const Ordinal numCols = domain_->dim();
268 const Range1D col_rng = Teuchos::full_range(col_rng_in,0,numCols-1);
270 TEUCHOS_TEST_FOR_EXCEPTION(
271 !( col_rng.ubound() < numCols ), std::logic_error
272 ,
"DefaultColumnwiseMultiVector<Scalar>::subView(col_rng):" 273 "Error, the input range col_rng = ["<<col_rng.lbound()
274 <<
","<<col_rng.ubound()<<
"] " 275 "is not in the range [0,"<<(numCols-1)<<
"]!" 281 domain_->smallVecSpcFcty()->createVecSpc(col_rng.size()),
282 col_vecs_(col_rng.lbound(),col_rng.size())
291 #endif // THYRA_DEFAULT_COLUMNWISE_MULTI_VECTOR_DEF_HPP EOpTransp
Enumeration for determining how a linear operator is applied. `*.
#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...
Use the non-transposed operator.
RCP< const VectorSpaceBase< Scalar > > domain() const
Use the transposed operator with complex-conjugate clements (same as TRANS for real scalar types)...
Abstract interface for objects that represent a space for vectors.
bool opSupportedImpl(EOpTransp M_trans) const
For complex Scalar types returns true for NOTRANS and CONJTRANS and for real types returns true for a...
void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
This function is implemented in terms of the multi-vector applyOp() function.
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
Interface for a collection of column vectors called a multi-vector.
RCP< const VectorBase< Scalar > > col(Ordinal j) const
Calls colImpl().
RCP< VectorBase< Scalar > > nonconstColImpl(Ordinal j)
Abstract interface for finite-dimensional dense vectors.
void initialize(const RCP< VectorBase< Scalar > > &col_vec)
Initialize given a single vector object.
Default subclass for MultiVectorBase implemented using columns of separate abstract vectors...
RCP< MultiVectorBase< Scalar > > nonconstContigSubViewImpl(const Range1D &col_rng)
RCP< const VectorSpaceBase< Scalar > > range() const
virtual RCP< const VectorSpaceBase< Scalar > > domain() const =0
Return a smart pointer for the domain space for this operator.
void assignImpl(Scalar alpha)
DefaultColumnwiseMultiVector()
Construct to initialized.
void uninitialize()
Set uninitialized.