44 #include "AbstractLinAlgPack_VectorMutableThyra.hpp"
45 #include "AbstractLinAlgPack_ThyraAccessors.hpp"
46 #include "AbstractLinAlgPack_VectorDenseEncap.hpp"
47 #include "AbstractLinAlgPack_GenPermMatrixSliceOp.hpp"
48 #include "RTOpPack_RTOpSubRangeDecorator.hpp"
49 #include "Teuchos_Assert.hpp"
50 #include "Teuchos_Workspace.hpp"
51 #include "Teuchos_dyn_cast.hpp"
52 #include "Teuchos_as.hpp"
54 namespace AbstractLinAlgPack {
72 namespace mmp = MemMngPack;
74 thyra_vec.get()==NULL, std::invalid_argument
75 ,
"VectorMutableThyra::initialize(thyra_vec): Error!"
86 thyra_vec_ = Teuchos::null;
101 const RTOpPack::RTOp &op
102 ,
const size_t num_vecs
104 ,
const size_t num_targ_vecs
107 ,
const index_type first_ele
108 ,
const index_type sub_dim
109 ,
const index_type global_offset
115 using Teuchos::rcpFromRef;
124 op,num_vecs,vecs,num_targ_vecs,targ_vecs,reduct_obj
125 ,first_ele,sub_dim,global_offset
131 Workspace< Teuchos::RCP<const Thyra::VectorBase<value_type> > > thyra_vecs_sptr(wss,num_vecs);
132 Workspace<Ptr<const Thyra::VectorBase<value_type> > > thyra_vecs(wss,num_vecs);
133 for(
int k = 0; k < as<int>(num_vecs); ++k ) {
134 get_thyra_vector( space_, *vecs[k], &thyra_vecs_sptr[k] );
135 thyra_vecs[k] = thyra_vecs_sptr[k].ptr();
139 Workspace< Teuchos::RCP<Thyra::VectorBase<value_type> > > targ_thyra_vecs_sptr(wss,num_targ_vecs);
140 Workspace<Ptr<Thyra::VectorBase<value_type> > > targ_thyra_vecs(wss,num_targ_vecs);
141 for(
int k = 0; k < as<int>(num_targ_vecs); ++k ) {
142 get_thyra_vector( space_, targ_vecs[k], &targ_thyra_vecs_sptr[k] );
143 targ_thyra_vecs[k] = targ_thyra_vecs_sptr[k].ptr();
148 subRangeOp(rcpFromRef(op), first_ele-1, sub_dim==0 ? -1 : sub_dim);
149 Thyra::applyOp<value_type>(subRangeOp, thyra_vecs(), targ_thyra_vecs(),
150 Teuchos::ptr(reduct_obj), global_offset);
153 for(
int k = 0; k < as<int>(num_vecs); ++k ) {
154 free_thyra_vector( space_, *vecs[k], &thyra_vecs_sptr[k] );
156 for(
int k = 0; k < as<int>(num_targ_vecs); ++k ) {
157 commit_thyra_vector( space_, targ_vecs[k], &targ_thyra_vecs_sptr[k] );
169 const Range1D& rng, RTOpPack::SubVector* sub_vec
173 thyra_vec_->acquireDetachedView(convert(rng),&_sub_vec);
178 RTOpPack::SubVector* sub_vec
182 thyra_vec_->releaseDetachedView(&_sub_vec);
191 thyra_vec_->acquireDetachedView(convert(rng),&_sub_vec);
198 thyra_vec_->commitDetachedView(&_sub_vec);
205 thyra_vec_->setSubVector(sub_vec);
void set_sub_vector(const RTOpPack::SparseSubVector &sub_vec)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
T_To & dyn_cast(T_From &from)
Teuchos::RCP< const Thyra::VectorSpaceBase< value_type > > set_uninitialized()
Set to uninitialized and return smart pointer to the internal Thyra::VectorSpaceBase<value_type> obj...
const VectorSpace & space() const
virtual void has_changed() const
void get_sub_vector(const Range1D &rng, RTOpPack::SubVector *sub_vec) const
void commit_sub_vector(RTOpPack::MutableSubVector *sub_vec)
void Vp_StMtV(VectorMutable *v_lhs, value_type alpha, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2, value_type beta=1.0)
void apply_op(const RTOpPack::RTOp &op, const size_t num_vecs, const Vector *vecs[], const size_t num_targ_vecs, VectorMutable *targ_vecs[], RTOpPack::ReductTarget *reduct_obj, const index_type first_ele, const index_type sub_dim, const index_type global_offset) const
void Vp_StMtV(value_type alpha, const GenPermMatrixSlice &P, BLAS_Cpp::Transp P_trans, const Vector &x, value_type beta)
VectorMutableThyra()
Construct to uninitialized.
void initialize(const Teuchos::RCP< const Thyra::VectorSpaceBase< value_type > > &thyra_vec_spc, const inner_prod_ptr_t &inner_prod=Teuchos::null)
Initalize given a smart pointer to a Thyra::VetorSpace object.
void free_sub_vector(RTOpPack::SubVector *sub_vec) const
Teuchos::RCP< Thyra::VectorBase< value_type > > set_uninitialized()
Set to uninitialized and return smart pointer to the internal Thyra::VectorBase object.
TypeTo as(const TypeFrom &t)
void apply_op_serial(const RTOpPack::RTOp &op, const size_t num_vecs, const Vector *vecs[], const size_t num_targ_vecs, VectorMutable *targ_vecs[], RTOpPack::ReductTarget *reduct_obj, const index_type first_ele, const index_type sub_dim, const index_type global_offset) const
Teuchos::RCP< const Thyra::VectorBase< value_type > > thyra_vec() const
Return a (converted) smart pointer to the internal smart pointer to the Thyra::VectorBase object...
void initialize(const Teuchos::RCP< Thyra::VectorBase< value_type > > &thyra_vec)
Initalize given a smart pointer to a Thyra::Vetor object.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
TEUCHOSCORE_LIB_DLL_EXPORT Teuchos::RCP< WorkspaceStore > get_default_workspace_store()