43 #ifndef RTOPPACK_TOP_RANDOMIZE_HPP
44 #define RTOPPACK_TOP_RANDOMIZE_HPP
46 #include "RTOpPack_RTOpTHelpers.hpp"
64 template<
class Scalar>
70 { static_seed_ = static_seed; }
75 const Scalar& l = -ScalarTraits<Scalar>::one(),
76 const Scalar& u = +ScalarTraits<Scalar>::one()
88 void set_seed(
const unsigned int seed ) { seed_ = seed; }
90 unsigned int get_seed()
const {
return seed_; }
97 const Ptr<ReductTarget> &reduct_obj_inout
103 validate_apply_op<Scalar>(*
this, 0, 1,
false,
104 sub_vecs, targ_sub_vecs, reduct_obj_inout.getConst());
107 (void)reduct_obj_inout;
110 const index_type subDim = targ_sub_vecs[0].subDim();
111 const index_type globalOffset = targ_sub_vecs[0].globalOffset();
113 iter_t z0_val = targ_sub_vecs[0].values().begin();
114 const ptrdiff_t z0_s = targ_sub_vecs[0].stride();
117 const Scalar a = Scalar(0.5)*(u_ - l_);
118 const Scalar b = Scalar(0.5)*(u_ + l_);
119 for( index_type i = 0; i < subDim; ++i, z0_val += z0_s )
128 static unsigned int static_seed_;
135 template<
class Scalar>
136 unsigned int TOpRandomize<Scalar>::static_seed_ = 0;
142 #endif // RTOPPACK_TOP_RANDOMIZE_HPP
void set_bounds(const Scalar &l, const Scalar &u)
unsigned int get_seed() const
Generate a random vector in the range [l,u]: z0[i] = 0.5*((u-l)*Teuchos::ScalarTraits<Scalar>::random...
TOpRandomize(const Scalar &l=-ScalarTraits< Scalar >::one(), const Scalar &u=+ScalarTraits< Scalar >::one())
static void seedrandom(unsigned int s)
void setOpNameBase(const std::string &op_name_base)
static void set_static_seed(const unsigned int static_seed)
void apply_op_impl(const ArrayView< const ConstSubVectorView< Scalar > > &sub_vecs, const ArrayView< const SubVectorView< Scalar > > &targ_sub_vecs, const Ptr< ReductTarget > &reduct_obj_inout) const
void set_seed(const unsigned int seed)
static unsigned int get_static_seed()