thrust
Public Types | Public Member Functions | Static Public Attributes | List of all members
thrust::random::discard_block_engine< Engine, p, r > Class Template Reference

A discard_block_engine adapts 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 returning r values successively produced by the base engine and ends by discarding p-r such values. The engine's state is the state of its base engine followed by the number of calls to operator() that have occurred since the beginning of the current cycle. More...

#include <thrust/random/discard_block_engine.h>

Public Types

typedef Engine base_type
 The type of the adapted base random number engine.
 
typedef base_type::result_type result_type
 The type of the unsigned integer produced by this linear_congruential_engine.
 

Public Member Functions

__host__ __device__ discard_block_engine ()
 
__host__ __device__ discard_block_engine (const base_type &urng)
 
__host__ __device__ discard_block_engine (result_type s)
 
__host__ __device__ void seed (void)
 
__host__ __device__ void seed (result_type s)
 
__host__ __device__ result_type operator() (void)
 
__host__ __device__ void discard (unsigned long long z)
 
__host__ __device__ const base_typebase (void) const
 

Static Public Attributes

static const size_t block_size = p
 
static const size_t used_block = r
 
static const result_type min = base_type::min
 
static const result_type max = base_type::max
 

Detailed Description

template<typename Engine, size_t p, size_t r>
class thrust::random::discard_block_engine< Engine, p, r >

A discard_block_engine adapts 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 returning r values successively produced by the base engine and ends by discarding p-r such values. The engine's state is the state of its base engine followed by the number of calls to operator() that have occurred since the beginning of the current cycle.

Template Parameters
EngineThe type of the base random number engine to adapt.
pThe discard cycle length.
rThe number of values to return of the base engine. Because p-r will be discarded, r <= p.

The following code snippet shows an example of using a discard_block_engine instance:

#include <iostream>
int main(void)
{
// create a discard_block_engine from minstd_rand, with a cycle length of 13
// keep every first 10 values, and discard the next 3
// print a random number to standard output
std::cout << rng() << std::endl;
return 0;
}

The documentation for this class was generated from the following file: