49 #include "AbstractLinAlgPack_apply_op_helper.hpp"
50 #include "AbstractLinAlgPack_VectorSpace.hpp"
51 #include "AbstractLinAlgPack_VectorMutable.hpp"
52 #include "Teuchos_Workspace.hpp"
53 #include "Teuchos_Assert.hpp"
55 void AbstractLinAlgPack::apply_op_validate_input(
56 const char func_name[]
57 ,
const RTOpPack::RTOp& op
58 ,
const size_t num_vecs,
const Vector* vecs[]
59 ,
const size_t num_targ_vecs, VectorMutable* targ_vecs[]
61 ,
const index_type first_ele_in,
const index_type sub_dim_in,
const index_type global_offset_in
65 &space = (num_vecs ? vecs[0]->space() : targ_vecs[0]->space() );
69 global_offset_in < 0, std::logic_error
70 ,func_name <<
" : Error! global_offset_in = "
71 <<global_offset_in<<
" is not valid" );
73 first_ele_in > dim, std::logic_error
74 ,func_name <<
" : Error! first_ele_in = "
75 <<first_ele_in<<
" is not compatible with space.dim() = " << dim );
77 sub_dim_in < 0 || (sub_dim_in > 0 && sub_dim_in > dim-(first_ele_in-1)), std::logic_error
78 ,func_name <<
" : Error! first_ele_in = "
79 <<first_ele_in<<
" and sub_dim_in = "<<sub_dim_in
80 <<
" is not compatible with space.dim() = " << dim );
81 {
for(
size_t k = 0; k < num_vecs; ++k) {
82 const bool is_compatible = space.is_compatible(vecs[k]->space());
84 !is_compatible, VectorSpace::IncompatibleVectorSpaces
85 ,func_name <<
" : Error! vecs["<<k<<
"]->space() of type \'"
86 <<
typeName(vecs[k]->space()) <<
"\' "
87 <<
" with dimension vecs["<<k<<
"].dim() = " << vecs[k]->dim()
88 <<
" is not compatible with space of type \'"
89 <<
typeName(space) <<
" with dimmension space.dim() = " << dim );
91 {
for(
size_t k = 0; k < num_targ_vecs; ++k) {
92 const bool is_compatible = space.is_compatible(targ_vecs[k]->space());
94 !is_compatible, VectorSpace::IncompatibleVectorSpaces
95 ,func_name <<
" : Error! targ_vecs["<<k<<
"]->space() of type \'"
96 <<
typeName(targ_vecs[k]->space()) <<
"\' "
97 <<
" with dimension targ_vecs["<<k<<
"].dim() = " << targ_vecs[k]->dim()
98 <<
" is not compatible with space of type \'"
99 <<
typeName(space) <<
" with dimmension space.dim() = " << dim );
103 void AbstractLinAlgPack::apply_op_serial(
104 const RTOpPack::RTOp& op
105 ,
const size_t num_vecs,
const Vector* vecs[]
106 ,
const size_t num_targ_vecs, VectorMutable* targ_vecs[]
108 ,
const index_type first_ele_in,
const index_type sub_dim_in,
const index_type global_offset_in
116 &space = ( num_vecs ? vecs[0]->space() : targ_vecs[0]->space() );
118 full_dim = space.dim(),
119 global_sub_dim = sub_dim_in ? sub_dim_in : full_dim - (first_ele_in-1);
121 global_sub_rng = Range1D(first_ele_in,(first_ele_in-1)+global_sub_dim);
127 Workspace<RTOpPack::ConstSubVectorView<value_type> > local_vecs(wss,num_vecs);
128 Workspace<RTOpPack::SubVectorView<value_type> > local_targ_vecs(wss,num_targ_vecs);
130 for(k = 0; k < num_vecs; ++k) {
131 RTOpPack::SubVector _v;
132 vecs[k]->get_sub_vector( global_sub_rng, &_v );
133 (local_vecs[k] = _v).setGlobalOffset( _v.globalOffset() + global_offset_in );
135 for(k = 0; k < num_targ_vecs; ++k) {
136 RTOpPack::MutableSubVector _v;
137 targ_vecs[k]->get_sub_vector( global_sub_rng, &_v );
138 (local_targ_vecs[k] = _v).setGlobalOffset( _v.globalOffset() + global_offset_in );
145 op.apply_op( local_vecs(), local_targ_vecs(), Teuchos::ptr(reduct_obj) );
153 for(k = 0; k < num_vecs; ++k) {
156 RTOpPack::SubVector _v = v;
157 vecs[k]->free_sub_vector(&_v);
159 for(k = 0; k < num_targ_vecs; ++k) {
162 RTOpPack::MutableSubVector _v = v;
163 targ_vecs[k]->commit_sub_vector(&_v);
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Ordinal globalOffset() const
void setGlobalOffset(Ordinal globalOffset_in)
TEUCHOSCORE_LIB_DLL_EXPORT Teuchos::RCP< WorkspaceStore > get_default_workspace_store()
std::string typeName(const T &t)