46 #include "AbstractLinAlgPack_VectorSpaceBlocked.hpp"
47 #include "AbstractLinAlgPack_VectorMutableBlocked.hpp"
48 #include "AbstractLinAlgPack_VectorSpaceSubSpace.hpp"
49 #include "AbstractLinAlgPack_VectorSpaceFactory.hpp"
50 #include "AbstractLinAlgPack_GenPermMatrixSlice.hpp"
51 #include "Teuchos_Workspace.hpp"
52 #include "Teuchos_Assert.hpp"
54 namespace AbstractLinAlgPack {
56 VectorSpaceBlocked::VectorSpaceBlocked(
62 initialize(vec_spaces,num_vec_spaces,small_vec_spc_fcty);
71 vector_spaces_.resize(num_vec_spaces);
72 std::copy(vec_spaces,vec_spaces+num_vec_spaces,vector_spaces_.begin());
73 vec_spaces_offsets_.resize(num_vec_spaces+1);
74 vec_spaces_offsets_[0] = 0;
75 for(
int k = 1; k <= num_vec_spaces; ++k )
76 vec_spaces_offsets_[k] = vec_spaces_offsets_[k-1] + vec_spaces[k-1]->
dim();
81 index_type i,
int* kth_vector_space, index_type* kth_global_offset )
const
86 i < 1 || this->
dim() < i, std::out_of_range
87 ,
"VectorSpaceBlocked::get_vector_space_position(...): Error, i = "
88 << i <<
" is not in range [1,"<<this->
dim()<<
"]"
91 *kth_vector_space = 0;
92 *kth_global_offset = 0;
93 while( *kth_vector_space < vector_spaces_.size() ) {
94 const RTOp_index_type off_kp1 = vec_spaces_offsets_[*kth_vector_space+1];
95 if( off_kp1 + 1 > i ) {
96 *kth_global_offset = vec_spaces_offsets_[*kth_vector_space];
99 ++(*kth_vector_space);
112 if( !vec_space_comp || vec_space_comp->vector_spaces_.size() != this->vector_spaces_.size() )
115 for(
int k = 0; k < vector_spaces_.size(); ++k ) {
116 if( !vec_space_comp->vector_spaces_[k]->
is_compatible(*this->vector_spaces_[k]) )
124 return vec_spaces_offsets_[vector_spaces_.size()];
130 return small_vec_spc_fcty_;
136 namespace rcp = MemMngPack;
143 Workspace<VectorMutable::vec_mut_ptr_t>
144 vecs(wss,num_vec_spaces);
145 for(
int k = 0; k < num_vec_spaces; ++k )
159 return Teuchos::null;
171 namespace rcp = MemMngPack;
172 const index_type
dim = this->
dim();
177 dim < rng.
ubound(), std::out_of_range
178 ,
"VectorSpaceBlocked::sub_space(...): Error, rng = "
179 <<
"["<<rng.
lbound()<<
","<<rng.
ubound()<<
"] is not in range [1,"<<dim<<
"]" );
184 int kth_vector_space = -1;
185 index_type kth_global_offset = 0;
188 const vec_spaces_offsets_t &vec_spaces_offsets = vec_spaces_offsets_;
192 if( rng.
lbound() == kth_global_offset + 1
193 && rng.
size() == vec_spaces_offsets[kth_vector_space+1] - vec_spaces_offsets[kth_vector_space] )
195 return vector_spaces[kth_vector_space];
196 if( rng.
ubound() <= vec_spaces_offsets[kth_vector_space+1] )
198 return vector_spaces[kth_vector_space]->
sub_space(rng-vec_spaces_offsets[kth_vector_space]);
201 int end_kth_vector_space = -1;
202 index_type end_kth_global_offset = 0;
206 TEUCHOS_TEST_FOR_EXCEPT( !( end_kth_vector_space > kth_vector_space ) );
212 &vector_spaces[kth_vector_space]
213 ,end_kth_vector_space - kth_vector_space + 1 )
215 if( rng.
lbound() == kth_global_offset + 1
216 && rng.
size() == vec_spaces_offsets[end_kth_vector_space+1] - vec_spaces_offsets[kth_vector_space] )
218 return vec_space_comp;
224 rng.
lbound()-vec_spaces_offsets[kth_vector_space]
225 ,rng.
ubound()-vec_spaces_offsets[kth_vector_space] )
Concrete subclass for a default sub-space of a vector.
void initialize(const VectorSpace::space_ptr_t vec_spaces[], int num_vector_spaces, const VectorSpace::space_fcty_ptr_t &small_vec_spc_fcty=Teuchos::null)
Initialize with a set of vector space objects.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
vec_mut_ptr_t create_member() const
multi_vec_mut_ptr_t create_members(size_type num_vecs) const
Concrete subclass for a blocked vector.
space_fcty_ptr_t small_vec_spc_fcty() const
space_ptr_t clone() const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< const VectorSpace > space_ptr_t
Abstract interface for objects that represent a space for mutable coordinate vectors.
space_ptr_t sub_space(const Range1D &rng) const
VectorSpace subclass for the composite of one or more VectorSpace objects.
const VectorSpace::space_ptr_t * vector_spaces() const
int num_vector_spaces() const
Return the value of num_vec_spaces passed to this->initialize().
Teuchos::RCP< VectorMutable > vec_mut_ptr_t
bool is_compatible(const VectorSpace &vec_space) const
Returns true if same type and has compatible vector spaces.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
void get_vector_space_position(index_type i, int *kth_vector_space, index_type *kth_global_offset) const
Get the position of the vector space object and its offset into the composite vector of the vector sp...
TEUCHOSCORE_LIB_DLL_EXPORT Teuchos::RCP< WorkspaceStore > get_default_workspace_store()