83 const ArrayView<
const ConstSubVectorView<Scalar> > &sub_vecs,
84 const ArrayView<
const SubVectorView<Scalar> > &targ_sub_vecs,
85 const Ptr<ReductTarget> &reduct_obj
89 typedef typename Teuchos::ArrayRCP<Scalar>::iterator iter_t;
90 typedef typename Teuchos::ArrayRCP<const Scalar>::iterator const_iter_t;
91 typedef typename Teuchos::ArrayRCP<const Teuchos_Ordinal>::iterator const_indices_iter_t;
93 validate_apply_op( *
this, 0, 1,
false, sub_vecs, targ_sub_vecs, reduct_obj.getConst() );
96 const SubVectorView<Scalar> &z = targ_sub_vecs[0];
97 const index_type z_global_offset = z.globalOffset();
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 )
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.