11 #ifndef RTOPPACK_ROP_GET_SUB_VECTOR_DEF_HPP
12 #define RTOPPACK_ROP_GET_SUB_VECTOR_DEF_HPP
21 template<
class Scalar>
25 :
RTOpT<Scalar>(
"ROpGetSubVector"), l_(l), u_(u)
29 template<
class Scalar>
39 template<
class Scalar>
51 template<
class Scalar>
59 const int num_prim_objs_per_scalar = PTT::numPrimitiveObjs();
60 *num_values = (u_-l_+1)*num_prim_objs_per_scalar;
66 template<
class Scalar>
73 return defaultReductTarget(
79 template<
class Scalar>
88 DRTSVV &drtsvv_inout_reduct_obj =
dyn_cast<DRTSVV>(*inout_reduct_obj);
91 dyn_cast<
const DRTSVV>(in_reduct_obj).
get();
101 || sub_vec_inout.
stride()!=1
103 #endif // TEUCHOS_DEBUG
108 const_iter_t in_iter = sub_vec_in.
values().
begin();
109 iter_t inout_iter = sub_vec_inout.
values().begin();
111 for(
int k = 0; k < sub_vec_in.
subDim(); ++k ) {
112 *inout_iter++ += *in_iter++;
115 drtsvv_inout_reduct_obj.set(sub_vec_inout);
120 template<
class Scalar>
126 DRTSVV &drtsvv_inout_reduct_obj =
dyn_cast<DRTSVV>(*reduct_obj);
128 std::fill( sub_vec.
values().begin(), sub_vec.
values().end(),
133 template<
class Scalar>
144 const int num_prim_objs_per_scalar = PTT::numPrimitiveObjs();
147 int value_data_off = 0;
151 ++k, value_data_off += num_prim_objs_per_scalar
154 PTT::extractPrimitiveObjs( sub_vec[k],
155 value_data(value_data_off, num_prim_objs_per_scalar),
161 template<
class Scalar>
170 using Teuchos::outArg;
172 using Teuchos::arcp_const_cast;
175 const int num_prim_objs_per_scalar = PTT::numPrimitiveObjs();
176 DRTSVV &drtsvv_reduct_obj =
dyn_cast<DRTSVV>(*reduct_obj);
179 arcp_const_cast<Scalar>(const_sub_vec.
values());
180 int value_data_off = 0;
183 k < const_sub_vec.
subDim();
184 ++k, value_data_off += num_prim_objs_per_scalar
187 PTT::loadPrimitiveObjs(
188 value_data(value_data_off, num_prim_objs_per_scalar), null, null,
189 outArg(sv_values[k]) );
194 template<
class Scalar>
201 template<
class Scalar>
213 sub_vecs, targ_sub_vecs, reduct_obj.
getConst() );
216 const index_type subDim = sub_vecs[0].subDim();
217 const index_type globalOffset = sub_vecs[0].globalOffset();
219 const_iter_t v0_val = sub_vecs[0].values().begin();
220 const ptrdiff_t v0_s = sub_vecs[0].stride();
222 if( u_ < globalOffset || globalOffset + subDim - 1 < l_ ) {
229 i_l = ( l_ <= globalOffset ? 0 : l_ - globalOffset ),
230 i_u = ( u_ >= globalOffset+subDim-1 ? subDim-1 : u_ - globalOffset );
232 DRTSVV &drtsvv_reduct_obj =
dyn_cast<DRTSVV>(*reduct_obj);
238 svt_values[i+(globalOffset-l_)] = v0_val[i*v0_s];
241 drtsvv_reduct_obj.set(sub_vec_targ);
249 #endif // RTOPPACK_ROP_GET_SUB_VECTOR_DEF_HPP
Simple ReductTarget subclass for simple scalar objects.
void load_reduct_obj_state_impl(const ArrayView< const primitive_value_type > &value_data, const ArrayView< const index_type > &index_data, const ArrayView< const char_type > &char_data, const Ptr< ReductTarget > &reduct_obj) const
bool is_null(const boost::shared_ptr< T > &p)
Class for a changeable sub-vector.
void reduce_reduct_objs_impl(const ReductTarget &in_reduct_obj, const Ptr< ReductTarget > &inout_reduct_obj) const
Teuchos_Ordinal index_type
void set_range(const index_type l, const index_type u)
Set the range of global indexes to extract elements for.
Class for a non-changeable sub-vector.
void extract_reduct_obj_state_impl(const ReductTarget &reduct_obj, const ArrayView< primitive_value_type > &value_data, const ArrayView< index_type > &index_data, const ArrayView< char_type > &char_data) const
Templated interface to vector reduction/transformation operators {abstract}.
const ArrayRCP< Scalar > values() const
ROpGetSubVector(const index_type l=0, const index_type u=0)
Specialization where the scalar type is the same as the concrete object type.
Teuchos::RCP< ReductTarget > reduct_obj_create_impl() const
T_To & dyn_cast(T_From &from)
Abstract base class for all reduction objects.
Ordinal globalOffset() const
void apply_op_impl(const ArrayView< const ConstSubVectorView< Scalar > > &sub_vecs, const ArrayView< const SubVectorView< Scalar > > &targ_sub_vecs, const Ptr< ReductTarget > &reduct_obj) const
bool coord_invariant_impl() const
void get_reduct_type_num_entries_impl(const Ptr< int > &num_values, const Ptr< int > &num_indexes, const Ptr< int > &num_chars) const
void reduct_obj_reinit_impl(const Ptr< ReductTarget > &reduct_obj) const
void validate_apply_op(const RTOpT< Scalar > &op, const int allowed_num_sub_vecs, const int allowed_num_targ_sub_vecs, const bool expect_reduct_obj, const ArrayView< const ConstSubVectorView< Scalar > > &sub_vecs, const ArrayView< const SubVectorView< Scalar > > &targ_sub_vecs, const Ptr< const ReductTarget > &reduct_obj)
Validate the input to an apply_op(...) function.
Ptr< const T > getConst() const
const ConstSubVectorView< Scalar > operator()(const ReductTarget &reduct_obj) const
Extract the subvector after all of the reductions are completed.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
const ArrayRCP< const Scalar > values() const