43 #ifndef RTOPPACK_TOP_SET_SUB_VECTOR_DEF_HPP
44 #define RTOPPACK_TOP_SET_SUB_VECTOR_DEF_HPP
50 template<
class Scalar>
52 :
RTOpT<Scalar>(
"TOpSetSubVector")
56 template<
class Scalar>
58 :
RTOpT<Scalar>(
"TOpSetSubVector")
64 template<
class Scalar>
74 template<
class Scalar>
81 template<
class Scalar>
99 iter_t z_val = z.values().begin();
100 const ptrdiff_t z_val_s = z.stride();
103 const index_type v_global_offset = sub_vec_.globalOffset();
104 const index_type v_sub_dim = sub_vec_.subDim();
106 const_iter_t v_val = sub_vec_.values().begin();
107 const ptrdiff_t v_val_s = sub_vec_.valuesStride();
108 const bool has_v_ind = !
is_null(sub_vec_.indices());
109 const_indices_iter_t v_ind = sub_vec_.indices().begin();
110 const ptrdiff_t v_ind_s = sub_vec_.indicesStride();
111 const ptrdiff_t v_l_off = sub_vec_.localOffset();
118 if( v_global_offset + v_sub_dim < z_global_offset + 1
119 || z_global_offset + z_sub_dim < v_global_offset + 1 )
131 if( v_global_offset <= z_global_offset ) {
132 if( v_global_offset + v_sub_dim >= z_global_offset + z_sub_dim )
133 num_overlap = z_sub_dim;
135 num_overlap = (v_global_offset + v_sub_dim) - z_global_offset;
138 if( z_global_offset + z_sub_dim >= v_global_offset + v_sub_dim )
139 num_overlap = v_sub_dim;
141 num_overlap = (z_global_offset + z_sub_dim) - v_global_offset;
148 if( v_global_offset >= z_global_offset )
149 z_val += (v_global_offset - z_global_offset) * z_val_s;
150 for(
index_type k = 0; k < num_overlap; ++k, z_val += z_val_s )
153 z_val = targ_sub_vecs[0].values().begin();
154 for(
index_type k = 0; k < v_sub_nz; ++k, v_val += v_val_s, v_ind += v_ind_s ) {
155 const index_type i = v_global_offset + v_l_off + (*v_ind);
156 if( z_global_offset < i && i <= z_global_offset + z_sub_dim )
157 z_val[ z_val_s * (i - z_global_offset - 1) ] = *v_val;
164 if( v_global_offset <= z_global_offset )
165 v_val += (z_global_offset - v_global_offset) * v_val_s;
167 z_val += (v_global_offset - z_global_offset) * z_val_s;
168 for(
index_type k = 0; k < num_overlap; ++k, v_val += v_val_s, z_val += z_val_s )
177 #endif // RTOPPACK_TOP_SET_SUB_VECTOR_DEF_HPP
bool is_null(const boost::shared_ptr< T > &p)
bool coord_invariant_impl() const
void set_sub_vec(const SparseSubVectorT< Scalar > &sub_vec)
Class for a changeable sub-vector.
Class for a (sparse or dense) sub-vector.
Teuchos_Ordinal index_type
Class for a non-changeable sub-vector.
Templated interface to vector reduction/transformation operators {abstract}.
Ordinal globalOffset() 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.
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
Ptr< const T > getConst() const