thrust::random::discard_block_engine#
-
template<typename Engine, size_t p, size_t r>
class discard_block_engine# A
discard_block_engineadapts an existing base random number engine and produces random values by discarding some of the values returned by its base engine. Each cycle of the compound engine begins by returningrvalues successively produced by the base engine and ends by discardingp-rsuch values. The engine’s state is the state of its base engine followed by the number of calls tooperator()that have occurred since the beginning of the current cycle.The following code snippet shows an example of using a
discard_block_engineinstance:#include <thrust/random/linear_congruential_engine.h> #include <thrust/random/discard_block_engine.h> #include <iostream> int main() { // create a discard_block_engine from minstd_rand, with a cycle length of 13 // keep every first 10 values, and discard the next 3 thrust::discard_block_engine<thrust::minstd_rand, 13, 10> rng; // print a random number to standard output std::cout << rng() << std::endl; return 0; }
- Template Parameters:
Engine – The type of the base random number engine to adapt.
p – The discard cycle length.
r – The number of values to return of the base engine. Because
p-rwill be discarded,r <= p.
Public Types
-
typedef typename base_type::result_type result_type#
The type of the unsigned integer produced by this
linear_congruential_engine.
Public Functions
-
discard_block_engine()#
This constructor constructs a new
discard_block_engineand constructs itsbase_typeengine using its null constructor.
-
explicit discard_block_engine(const base_type &urng)#
This constructor constructs a new
discard_block_engineusing a givenbase_typeengine to initialize its adapted base engine.- Parameters:
urng – A
base_typeto use to initialize thisdiscard_block_engine'sadapted base engine.
-
explicit discard_block_engine(result_type s)#
This constructor initializes a new
discard_block_enginewith a given seed.- Parameters:
s – The seed used to initialize this
discard_block_engine'sadapted base engine.
-
void seed()#
This method initializes the state of this
discard_block_engine'sadapted base engine by using itsdefault_seedvalue.
-
void seed(result_type s)#
This method initializes the state of this
discard_block_engine'sadapted base engine by using the given seed.- Parameters:
s – The seed with which to initialize this
discard_block_engine'sadapted base engine.
-
result_type operator()(void)#
This member function produces a new random value and updates this
discard_block_engine'sstate.- Returns:
A new random number.
-
void discard(unsigned long long z)#
This member function advances this
discard_block_engine'sstate a given number of times and discards the results.Note
This function is provided because an implementation may be able to accelerate it.
- Parameters:
z – The number of random values to discard.
-
const base_type &base() const#
This member function returns a const reference to this
discard_block_engine'sadapted base engine.- Returns:
A const reference to the base engine this
discard_block_engineadapts.
Public Static Attributes
-
static const result_type min = base_type::min#
The smallest value this
discard_block_enginemay potentially produce.
-
static const result_type max = base_type::max#
The largest value this
discard_block_enginemay potentially produce.