46 #include "AbstractLinAlgPack_VectorMutableSubView.hpp"
47 #include "Teuchos_Assert.hpp"
48 #include "Teuchos_Workspace.hpp"
49 #include "Teuchos_dyn_cast.hpp"
51 namespace AbstractLinAlgPack {
60 namespace rcp = MemMngPack;
63 vec.
get() == NULL, std::invalid_argument
64 ,
"VectorSubView::initialize(...) : Error!" );
75 full_vec_ = Teuchos::null;
92 const RTOpPack::RTOp& op
93 ,
const size_t num_vecs,
const Vector* vecs[]
96 ,
const index_type first_ele_in,
const index_type sub_dim_in,
const index_type global_offset_in
104 if( this->
space().is_in_core() ) {
106 op,num_vecs,vecs,num_targ_vecs,targ_vecs,reduct_obj
107 ,first_ele_in,sub_dim_in,global_offset_in
113 const index_type this_dim = this->
dim();
117 || !(1 <= first_ele_in && first_ele_in <= this_dim)
118 || ( sub_dim_in > 0 && (sub_dim_in - (first_ele_in - 1) > this_dim) )
120 ,
"VectorSubView::apply_op(...): Error, first_ele_in = "
121 << first_ele_in <<
", global_offset_in = " << global_offset_in
122 <<
", sub_dim_in = " << sub_dim_in <<
" and this->dim() = this_dim = "
123 << this_dim <<
" are not compatible." );
127 this_sub_dim = ( sub_dim_in
131 Workspace<const Vector*> vecs_full(wss,num_vecs);
132 for( k = 0; k < num_vecs; ++k )
133 vecs_full[k] = dyn_cast<const VectorSubView>(*vecs[k]).full_vec().get();
134 Workspace<VectorMutable*> targ_vecs_full(wss,num_targ_vecs);
135 for( k = 0; k < num_targ_vecs; ++k )
136 targ_vecs_full[k] = dyn_cast<VectorMutableSubView>(*targ_vecs[k]).full_vec().get();
137 AbstractLinAlgPack::apply_op(
139 ,num_vecs, num_vecs ? &vecs_full[0] : NULL
140 ,num_targ_vecs, num_targ_vecs ? &targ_vecs_full[0] : NULL
142 ,this_offset + first_ele_in
151 return full_vec_->get_ele( space_.
rng().
lbound() + i - 1 );
157 namespace rcp = MemMngPack;
158 const index_type this_dim = this->
dim();
159 const Range1D rng = RangePack::full_range(rng_in,1,this_dim);
161 const index_type this_offset = space_.
rng().
lbound() - 1;
166 this_offset + rng.
lbound()
167 ,this_offset + rng.
ubound() )
176 const index_type this_dim = this->
dim();
177 const Range1D rng = RangePack::full_range(rng_in,1,this_dim);
179 const index_type this_offset = space_.
rng().
lbound() - 1;
180 full_vec_->get_sub_vector( rng + this_offset, sub_vec );
181 sub_vec->setGlobalOffset( sub_vec->globalOffset() - this_offset );
189 const index_type this_offset = space_.
rng().
lbound() - 1;
190 sub_vec->setGlobalOffset( sub_vec->globalOffset() + this_offset );
191 full_vec_->free_sub_vector( sub_vec );
void initialize(const space_ptr_t &full_space, const Range1D &rng)
Initialize.
const VectorSpaceSubSpace & space_impl() const
Abstract interface for immutable, finite dimensional, coordinate vectors {abstract}.
void get_sub_vector(const Range1D &rng, RTOpPack::SubVector *sub_vec) const
const VectorSpace & space() const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
T_To & dyn_cast(T_From &from)
value_type get_ele(index_type i) const
void free_sub_vector(RTOpPack::SubVector *sub_vec) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual void has_changed() const
Must be called by any vector subclass that modifies this vector object!
void validate_range(const Range1D &rng) const
Validate rng.
Abstract interface for objects that represent a space for mutable coordinate vectors.
void set_uninitialized()
Set uninitilized.
VectorSubView()
Constructs to uninitialized.
void set_uninitialized()
Set uninitialized()
const Range1D & rng() const
vec_ptr_t sub_view(const Range1D &rng) const
Abstract interface for mutable coordinate vectors {abstract}.
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
void initialize(const vec_ptr_t &full_vec, const Range1D &rng)
Initialize a sub-view based on a full vector.
TEUCHOSCORE_LIB_DLL_EXPORT Teuchos::RCP< WorkspaceStore > get_default_workspace_store()
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
Calls apply_op() on the underlying full vectors.