10 #ifndef THYRA_DEFAULT_COLUMNWISE_MULTI_VECTOR_DEF_HPP
11 #define THYRA_DEFAULT_COLUMNWISE_MULTI_VECTOR_DEF_HPP
13 #include "Thyra_DefaultColumnwiseMultiVector_decl.hpp"
14 #include "Thyra_MultiVectorDefaultBase.hpp"
15 #include "Thyra_VectorSpaceBase.hpp"
16 #include "Thyra_VectorBase.hpp"
17 #include "Thyra_MultiVectorBase.hpp"
18 #include "Thyra_VectorStdOps.hpp"
19 #include "Thyra_VectorSpaceFactoryBase.hpp"
20 #include "Thyra_AssertOp.hpp"
21 #include "Teuchos_Assert.hpp"
22 #include "Teuchos_as.hpp"
30 template<
class Scalar>
35 template<
class Scalar>
44 template<
class Scalar>
51 this->
initialize(range_in, domain_in, col_vecs_in);
55 template<
class Scalar>
61 const std::string err_msg =
62 "DefaultColumnwiseMultiVector<Scalar>::initialize(...): Error!";
66 range_ = col_vec->space();
67 domain_ = range_->smallVecSpcFcty()->createVecSpc(1);
69 col_vecs_[0] = col_vec;
73 template<
class Scalar>
81 const std::string err_msg =
82 "DefaultColumnwiseMultiVector<Scalar>::initialize(...): Error!";
89 const int domainDim = domain_in->dim();
93 col_vecs_.reserve(domainDim);
94 if (col_vecs.size()) {
95 for(
Ordinal j = 0; j < domainDim; ++j )
96 col_vecs_.push_back(col_vecs[j]);
99 for(
Ordinal j = 0; j < domainDim; ++j )
100 col_vecs_.push_back(createMember(range_));
105 template<
class Scalar>
109 range_ = Teuchos::null;
110 domain_ = Teuchos::null;
117 template<
class Scalar>
125 template<
class Scalar>
136 template<
class Scalar>
139 const Ordinal m = col_vecs_.size();
140 for (
Ordinal col_j = 0; col_j < m; ++col_j) {
141 col_vecs_[col_j]->assign(alpha);
146 template<
class Scalar>
155 for (
Ordinal col_j = 0; col_j < col_vecs_.size(); ++col_j) {
156 col_vecs_[col_j]->assign(*mv.
col(col_j));
161 template<
class Scalar>
164 for (
Ordinal col_j = 0; col_j < col_vecs_.size(); ++col_j) {
165 col_vecs_[col_j]->scale(alpha);
170 template<
class Scalar>
180 for (
Ordinal col_j = 0; col_j < col_vecs_.size(); ++col_j) {
181 col_vecs_[col_j]->update(alpha, *mv.
col(col_j));
186 template<
class Scalar>
195 for (
Ordinal i = 0; i < mv.size(); ++i) {
202 for (
Ordinal col_j = 0; col_j < col_vecs_.size(); ++col_j) {
203 for (
Ordinal i = 0; i < mv.size(); ++i) {
204 v_rcp[i] = mv[i]->col(col_j);
205 v[i] = v_rcp[i].ptr();
207 col_vecs_[col_j]->linear_combination(alpha, v(), beta);
212 template<
class Scalar>
223 for (
Ordinal col_j = 0; col_j < col_vecs_.size(); ++col_j) {
224 prods[col_j] = col_vecs_[col_j]->dot(*mv.
col(col_j));
229 template<
class Scalar>
237 for (
Ordinal col_j = 0; col_j < col_vecs_.size(); ++col_j) {
238 norms[col_j] = col_vecs_[col_j]->norm_1();
243 template<
class Scalar>
251 for (
Ordinal col_j = 0; col_j < col_vecs_.size(); ++col_j) {
252 norms[col_j] = col_vecs_[col_j]->norm_2();
257 template<
class Scalar>
265 for (
Ordinal col_j = 0; col_j < col_vecs_.size(); ++col_j) {
266 norms[col_j] = col_vecs_[col_j]->norm_inf();
275 template<
class Scalar>
279 return ( ST::isComplex ? ( M_trans==
NOTRANS || M_trans==
CONJTRANS ) :
true );
283 template<
class Scalar>
294 "MultiVectorBase<Scalar>::apply()", *
this, M_trans, X, &*Y);
296 const Ordinal nc = this->domain()->dim();
298 for (
Ordinal col_j = 0; col_j < m; ++col_j) {
302 Vt_S(y_j.
ptr(), beta);
310 x_j->acquireDetachedView(
Range1D(), &x_sub_vec);
312 for (
Ordinal j = 0; j < nc; ++j )
313 Vp_StV( y_j.
ptr(), Scalar(alpha*x_sub_vec(j)), *this->col(j) );
315 x_j->releaseDetachedView(&x_sub_vec);
326 y_j->acquireDetachedView(
Range1D(), &y_sub_vec);
328 for (
Ordinal j = 0; j < nc; ++j )
329 y_sub_vec(j) += alpha*dot(*this->col(j), *x_j);
331 y_j->commitDetachedView(&y_sub_vec);
340 template<
class Scalar>
345 const int num_cols = col_vecs_.size();
347 !( 0 <= j && j < num_cols ), std::logic_error
348 ,
"Error, j = " << j <<
" does not fall in the range [0,"<<(num_cols-1)<<
"]!"
354 template<
class Scalar>
360 const Ordinal numCols = domain_->dim();
361 const Range1D col_rng = Teuchos::full_range(col_rng_in,0,numCols-1);
364 !( col_rng.
ubound() < numCols ), std::logic_error
365 ,
"DefaultColumnwiseMultiVector<Scalar>::subView(col_rng):"
366 "Error, the input range col_rng = ["<<col_rng.
lbound()
367 <<
","<<col_rng.
ubound()<<
"] "
368 "is not in the range [0,"<<(numCols-1)<<
"]!"
374 domain_->smallVecSpcFcty()->createVecSpc(col_rng.
size()),
384 #endif // THYRA_DEFAULT_COLUMNWISE_MULTI_VECTOR_DEF_HPP
void initialize(int *argc, char ***argv)
virtual void assignMultiVecImpl(const MultiVectorBase< Scalar > &mv)
virtual void updateImpl(Scalar alpha, const MultiVectorBase< Scalar > &mv)
RCP< const VectorSpaceBase< Scalar > > range() const
bool is_null(const boost::shared_ptr< T > &p)
virtual RCP< const VectorSpaceBase< Scalar > > range() const =0
Return a smart pointer for the range space for this operator.
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
virtual void norms1Impl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
#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...
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.
virtual void norms2Impl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Use the non-transposed operator.
Use the transposed operator with complex-conjugate clements (same as TRANS for real scalar types)...
virtual void scaleImpl(Scalar alpha)
Abstract interface for objects that represent a space for vectors.
virtual void linearCombinationImpl(const ArrayView< const Scalar > &alpha, const ArrayView< const Ptr< const MultiVectorBase< Scalar > > > &mv, const Scalar &beta)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
#define TEUCHOS_TEST_FOR_EXCEPT_MSG(throw_exception_test, msg)
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...
virtual void normsInfImpl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
RCP< MultiVectorBase< Scalar > > nonconstContigSubViewImpl(const Range1D &col_rng)
bool opSupportedImpl(EOpTransp M_trans) const
For complex Scalar types returns true for NOTRANS and CONJTRANS and for real types returns true for a...
virtual RCP< const VectorSpaceBase< Scalar > > domain() const =0
Return a smart pointer for the domain space for this operator.
RCP< const VectorSpaceBase< Scalar > > domain() const
TypeTo as(const TypeFrom &t)
virtual void assignImpl(Scalar alpha)
DefaultColumnwiseMultiVector()
Construct to initialized.
#define TEUCHOS_ASSERT(assertion_test)
#define TEUCHOS_ASSERT_EQUALITY(val1, val2)
void uninitialize()
Set uninitialized.
virtual void dotsImpl(const MultiVectorBase< Scalar > &mv, const ArrayView< Scalar > &prods) const