58 #include "RTOpPack_TOpRandomize.hpp"
83 static RTOpPack::TOpRandomize<AbstractLinAlgPack::value_type> random_vector_op;
90 class init_rtop_server_t {
92 init_rtop_server_t() {
95 sum_targ = sum_op.reduct_obj_create();
98 dot_prod_targ = dot_prod_op.reduct_obj_create();
116 init_rtop_server_t init_rtop_server;
123 sum_op.reduct_obj_reinit(sum_targ.
ptr());
124 const Vector* vecs[1] = { &v_rhs };
125 apply_op(sum_op,1,vecs,0,NULL,&*sum_targ);
132 dot_prod_op.reduct_obj_reinit(dot_prod_targ.
ptr());
133 const Vector* vecs[2] = { &v_rhs1, &v_rhs2 };
134 apply_op(dot_prod_op,2,vecs,0,NULL,&*dot_prod_targ);
146 return dot(v_rhs1,*v_rhs2);
159 const Vector* vecs[1] = { &v };
160 apply_op(op,1,vecs,0,NULL,&*reduct_obj);
162 *max_v_j = val.
value;
173 apply_op(add_scalar_op,0,NULL,1,targ_vecs,NULL);
184 else if( alpha != 1.0 ) {
187 apply_op(scale_vector_op,0,NULL,1,targ_vecs,NULL);
198 const Vector* vecs[1] = { &v_rhs };
200 apply_op(axpy_op,1,vecs,1,targ_vecs,NULL);
223 const Vector* vecs[2] = { &v_rhs1, &v_rhs2 };
225 apply_op(ele_wise_prod_op,2,vecs,1,targ_vecs,NULL);
236 const int num_vecs = 2;
237 const Vector* vecs[2] = { &v_rhs1, &v_rhs2 };
239 apply_op(ele_wise_divide_op,2,vecs,1,targ_vecs,NULL);
244 random_vector_op.set_seed(s);
253 random_vector_op.set_bounds(l,u);
255 apply_op(random_vector_op,0,NULL,1,targ_vecs,NULL);
266 const Vector* vecs[1] = { &v };
268 apply_op(op,1,vecs,1,targ_vecs,NULL);
virtual const VectorSpace & space() const =0
Return the vector space that this vector belongs to.
Adapter subclass that uses a RTOp_RTOp object.
Abstract interface for immutable, finite dimensional, coordinate vectors {abstract}.
RTOp_index_type index_type
void sign(const Vector &v, VectorMutable *z)
Compute the sign of each element in an input vector.
void Vt_S(VectorMutable *v_lhs, const value_type &alpha)
v_lhs *= alpha
void seed_random_vector_generator(unsigned int)
Seed the random number generator.
int RTOp_TOp_scale_vector_set_alpha(RTOp_value_type alpha, struct RTOp_RTOp *op)
RTOp_value_type value_type
Sparse Vector Slice class template.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void Vp_StV(VectorMutable *v_lhs, const value_type &alpha, const Vector &v_rhs)
v_lhs = alpha * v_rhs + v_lhs
int RTOp_TOp_ele_wise_divide_set_alpha(RTOp_value_type alpha, struct RTOp_RTOp *op)
int RTOp_TOp_ele_wise_prod_construct(RTOp_value_type alpha, struct RTOp_RTOp *op)
RTOpPack::SparseSubVector sub_vec_view(const SpVectorSlice &sv, const Range1D &rng=Range1D())
Create an RTOpPack::SparseSubVector view object from a SpVectorSlice object.
void ele_wise_divide(const value_type &alpha, const Vector &v_rhs1, const Vector &v_rhs2, VectorMutable *v_lhs)
v_lhs(i) = alpha * v_rhs1(i) / v_rhs2(i), i = 1,,,dim.
int RTOp_TOp_axpy_set_alpha(RTOp_value_type alpha, struct RTOp_RTOp *op)
void Vp_V_assert_compatibility(VectorMutable *v_lhs, const Vector &v_rhs)
v_lhs += op v_rhs
int RTOp_ROp_dot_prod_construct(struct RTOp_RTOp *op)
int RTOp_TOp_ele_wise_divide_construct(RTOp_value_type alpha, struct RTOp_RTOp *op)
struct RTOp_value_index_type RTOp_ROp_max_abs_ele_val(RTOp_ReductTarget targ_obj)
void ele_wise_prod(const value_type &alpha, const Vector &v_rhs1, const Vector &v_rhs2, VectorMutable *v_lhs)
v_lhs(i) += alpha * v_rhs1(i) * v_rhs2(i), i = 1,,,dim.
RTOp_value_type RTOp_ROp_sum_val(RTOp_ReductTarget targ_obj)
const f_int f_dbl_prec a[]
int RTOp_ROp_sum_construct(struct RTOp_RTOp *op)
int RTOp_TOp_ele_wise_prod_set_alpha(RTOp_value_type alpha, struct RTOp_RTOp *op)
value_type dot(const Vector &v_rhs1, const Vector &v_rhs2)
result = v_rhs1' * v_rhs2
int RTOp_ROp_max_abs_ele_construct(struct RTOp_RTOp *op)
RTOp_value_type RTOp_ROp_dot_prod_val(RTOp_ReductTarget targ_obj)
Abstract interface for mutable coordinate vectors {abstract}.
void Vp_S(VectorMutable *v_lhs, const value_type &alpha)
v_lhs += alpha
void max_abs_ele(const Vector &v, value_type *max_v_j, index_type *max_j)
Compute the maximum element in a vector.
value_type sum(const Vector &v_rhs)
result = sum( v_rhs(i), i = 1,,,dim )
void apply_op(EApplyBy apply_by, const RTOpPack::RTOp &primary_op, const size_t num_multi_vecs, const MultiVector *multi_vecs[], const size_t num_targ_multi_vecs, MultiVectorMutable *targ_multi_vecs[], RTOpPack::ReductTarget *reduct_objs[]=NULL, const index_type primary_first_ele=1, const index_type primary_sub_dim=0, const index_type primary_global_offset=0, const index_type secondary_first_ele=1, const index_type secondary_sub_dim=0)
Apply a reduction/transformation operator column by column and return an array of the reduction objec...
virtual vec_mut_ptr_t create_member() const =0
Create a vector member from the vector space.
int RTOp_TOp_sign_construct(struct RTOp_RTOp *op)
int RTOp_TOp_add_scalar_set_alpha(RTOp_value_type alpha, struct RTOp_RTOp *op)
int RTOp_TOp_add_scalar_construct(RTOp_value_type alpha, struct RTOp_RTOp *op)
const f_int f_dbl_prec const f_int f_int const f_int f_int const f_dbl_prec & u
void random_vector(value_type l, value_type u, VectorMutable *v)
Generate a random vector with elements uniformly distrubuted elements.
int RTOp_TOp_scale_vector_construct(RTOp_value_type alpha, struct RTOp_RTOp *op)
size_type nz() const
Return the number of non-zero elements.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
int RTOp_TOp_axpy_construct(RTOp_value_type alpha, struct RTOp_RTOp *op)
void VopV_assert_compatibility(const Vector &v_rhs1, const Vector &v_rhs2)
v_rhs1 op v_rhs2