43 #ifndef RTOPPACK_ROP_GET_SUB_VECTOR_DEF_HPP
44 #define RTOPPACK_ROP_GET_SUB_VECTOR_DEF_HPP
53 template<
class Scalar>
57 :
RTOpT<Scalar>(
"ROpGetSubVector"), l_(l), u_(u)
61 template<
class Scalar>
71 template<
class Scalar>
83 template<
class Scalar>
91 const int num_prim_objs_per_scalar = PTT::numPrimitiveObjs();
92 *num_values = (u_-l_+1)*num_prim_objs_per_scalar;
98 template<
class Scalar>
105 return defaultReductTarget(
111 template<
class Scalar>
120 DRTSVV &drtsvv_inout_reduct_obj =
dyn_cast<DRTSVV>(*inout_reduct_obj);
123 dyn_cast<
const DRTSVV>(in_reduct_obj).
get();
133 || sub_vec_inout.
stride()!=1
135 #endif // TEUCHOS_DEBUG
140 const_iter_t in_iter = sub_vec_in.
values().
begin();
141 iter_t inout_iter = sub_vec_inout.
values().begin();
143 for(
int k = 0; k < sub_vec_in.
subDim(); ++k ) {
144 *inout_iter++ += *in_iter++;
147 drtsvv_inout_reduct_obj.set(sub_vec_inout);
152 template<
class Scalar>
158 DRTSVV &drtsvv_inout_reduct_obj =
dyn_cast<DRTSVV>(*reduct_obj);
160 std::fill( sub_vec.
values().begin(), sub_vec.
values().end(),
165 template<
class Scalar>
176 const int num_prim_objs_per_scalar = PTT::numPrimitiveObjs();
179 int value_data_off = 0;
183 ++k, value_data_off += num_prim_objs_per_scalar
186 PTT::extractPrimitiveObjs( sub_vec[k],
187 value_data(value_data_off, num_prim_objs_per_scalar),
193 template<
class Scalar>
202 using Teuchos::outArg;
204 using Teuchos::arcp_const_cast;
207 const int num_prim_objs_per_scalar = PTT::numPrimitiveObjs();
208 DRTSVV &drtsvv_reduct_obj =
dyn_cast<DRTSVV>(*reduct_obj);
211 arcp_const_cast<Scalar>(const_sub_vec.
values());
212 int value_data_off = 0;
215 k < const_sub_vec.
subDim();
216 ++k, value_data_off += num_prim_objs_per_scalar
219 PTT::loadPrimitiveObjs(
220 value_data(value_data_off, num_prim_objs_per_scalar), null, null,
221 outArg(sv_values[k]) );
226 template<
class Scalar>
233 template<
class Scalar>
245 sub_vecs, targ_sub_vecs, reduct_obj.
getConst() );
248 const index_type subDim = sub_vecs[0].subDim();
249 const index_type globalOffset = sub_vecs[0].globalOffset();
251 const_iter_t v0_val = sub_vecs[0].values().begin();
252 const ptrdiff_t v0_s = sub_vecs[0].stride();
254 if( u_ < globalOffset || globalOffset + subDim - 1 < l_ ) {
261 i_l = ( l_ <= globalOffset ? 0 : l_ - globalOffset ),
262 i_u = ( u_ >= globalOffset+subDim-1 ? subDim-1 : u_ - globalOffset );
264 DRTSVV &drtsvv_reduct_obj =
dyn_cast<DRTSVV>(*reduct_obj);
270 svt_values[i+(globalOffset-l_)] = v0_val[i*v0_s];
273 drtsvv_reduct_obj.set(sub_vec_targ);
281 #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