11 #ifndef RTOPPACK_TOP_RANDOMIZE_HPP
12 #define RTOPPACK_TOP_RANDOMIZE_HPP
14 #include "RTOpPack_RTOpTHelpers.hpp"
32 template<
class Scalar>
38 { static_seed_ = static_seed; }
43 const Scalar& l = -ScalarTraits<Scalar>::one(),
44 const Scalar& u = +ScalarTraits<Scalar>::one()
56 void set_seed(
const unsigned int seed ) { seed_ = seed; }
58 unsigned int get_seed()
const {
return seed_; }
65 const Ptr<ReductTarget> &reduct_obj_inout
71 validate_apply_op<Scalar>(*
this, 0, 1,
false,
72 sub_vecs, targ_sub_vecs, reduct_obj_inout.getConst());
75 (void)reduct_obj_inout;
78 const index_type subDim = targ_sub_vecs[0].subDim();
79 const index_type globalOffset = targ_sub_vecs[0].globalOffset();
81 iter_t z0_val = targ_sub_vecs[0].values().begin();
82 const ptrdiff_t z0_s = targ_sub_vecs[0].stride();
85 const Scalar a = Scalar(0.5)*(u_ - l_);
86 const Scalar b = Scalar(0.5)*(u_ + l_);
87 for( index_type i = 0; i < subDim; ++i, z0_val += z0_s )
96 static unsigned int static_seed_;
103 template<
class Scalar>
104 unsigned int TOpRandomize<Scalar>::static_seed_ = 0;
110 #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()