Class thrust::random::xor_combine_engine

An xor_combine_engine adapts two existing base random number engines and produces random values by combining the values produced by each.

The following code snippet shows an example of using an xor_combine_engine instance:

#include <thrust/random/linear_congruential_engine.h>
#include <thrust/random/xor_combine_engine.h>
#include <iostream>

int main()
{
  // create an xor_combine_engine from minstd_rand and minstd_rand0
  // use a shift of 0 for each
  thrust::xor_combine_engine<thrust::minstd_rand,0,thrust::minstd_rand0,0> rng;

  // print a random number to standard output
  std::cout << rng() << std::endl;

  return 0;
}

Template Parameters:

  • Engine1 The type of the first base random number engine to adapt.
  • s1 The size of the first shift to use in the generation algorithm.
  • Engine2 The type of the second base random number engine to adapt.
  • s2 The second of the second shift to use in the generation algorithm. Defaults to 0.

#include <thrust/random/xor_combine_engine.h>
template <typename Engine1,   size_t s1,   typename Engine2,   size_t s2 = 0u> class thrust::random::xor_combine_engine { public:   /* The type of the first adapted base random number engine. */  typedef see below base1_type;
   /* The type of the second adapted base random number engine. */  typedef see below base2_type;
   /* The type of the unsigned integer produced by this xor_combine_engine. */  typedef see below result_type;
  static const size_t shift1 = see below;
  static const size_t shift2 = see below;
  static const result_type min = see below;
  static const result_type max = see below;
  _CCCL_HOST_DEVICE   xor_combine_engine();
  _CCCL_HOST_DEVICE   xor_combine_engine(const base1_type & urng1,     const base2_type & urng2);
  _CCCL_HOST_DEVICE   xor_combine_engine(result_type s);
  _CCCL_HOST_DEVICE void   seed();
  _CCCL_HOST_DEVICE void   seed(result_type s);
  _CCCL_HOST_DEVICE result_type   operator()(void);
  _CCCL_HOST_DEVICE void   discard(unsigned long long z);
  _CCCL_HOST_DEVICE const base1_type &   base1() const;
  _CCCL_HOST_DEVICE const base2_type &   base2() const; };

Member Types

Typedef thrust::random::xor_combine_engine::base1_type

typedef Engine1base1_type; The type of the first adapted base random number engine.

Typedef thrust::random::xor_combine_engine::base2_type

typedef Engine2base2_type; The type of the second adapted base random number engine.

Typedef thrust::random::xor_combine_engine::result_type

typedef thrust::detail::eval_if<(sizeof(typename base2_type::result_type) > sizeof(typename base1_type::result_type)), thrust::detail::identity_< typename base2_type::result_type >, thrust::detail::identity_< typename base1_type::result_type > >::typeresult_type; The type of the unsigned integer produced by this xor_combine_engine.

Member Variables

Variable thrust::random::xor_combine_engine::shift1

static const size_t shift1 = s1; The size of the first shift used in the generation algorithm.

Variable thrust::random::xor_combine_engine::shift2

static const size_t shift2 = s2; The size of the second shift used in the generation algorithm.

Variable thrust::random::xor_combine_engine::min

static const result_type min = 0; The smallest value this xor_combine_engine may potentially produce.

Variable thrust::random::xor_combine_engine::max

static const result_type max = detail::xor_combine_engine_max<Engine1, s1, Engine2, s2, result_type>::value; The largest value this xor_combine_engine may potentially produce.

Member Functions

Function thrust::random::xor_combine_engine::xor_combine_engine

_CCCL_HOST_DEVICE xor_combine_engine(); This constructor constructs a new xor_combine_engine and constructs its adapted engines using their null constructors.

Function thrust::random::xor_combine_engine::xor_combine_engine

_CCCL_HOST_DEVICE xor_combine_engine(const base1_type & urng1,   const base2_type & urng2); This constructor constructs a new xor_combine_engine using given base1_type and base2_type engines to initialize its adapted base engines.

Function Parameters:

  • urng1 A base1_type to use to initialize this xor_combine_engine's first adapted base engine.
  • urng2 A base2_type to use to initialize this xor_combine_engine's first adapted base engine.

Function thrust::random::xor_combine_engine::xor_combine_engine

_CCCL_HOST_DEVICE xor_combine_engine(result_type s); This constructor initializes a new xor_combine_engine with a given seed.

Function Parameters: s: The seed used to intialize this xor_combine_engine's adapted base engines.

Function thrust::random::xor_combine_engine::seed

_CCCL_HOST_DEVICE void seed(); This method initializes the state of this xor_combine_engine's adapted base engines by using their default_seed values.

Function thrust::random::xor_combine_engine::seed

_CCCL_HOST_DEVICE void seed(result_type s); This method initializes the state of this xor_combine_engine's adapted base engines by using the given seed.

Function Parameters: s: The seed with which to intialize this xor_combine_engine's adapted base engines.

Function thrust::random::xor_combine_engine::operator()

_CCCL_HOST_DEVICE result_type operator()(void); This member function produces a new random value and updates this xor_combine_engine's state.

Returns: A new random number.

Function thrust::random::xor_combine_engine::discard

_CCCL_HOST_DEVICE void discard(unsigned long long z); This member function advances this xor_combine_engine's state a given number of times and discards the results.

Note: This function is provided because an implementation may be able to accelerate it.

Function Parameters: z: The number of random values to discard.

Function thrust::random::xor_combine_engine::base1

_CCCL_HOST_DEVICE const base1_type & base1() const; This member function returns a const reference to this xor_combine_engine's first adapted base engine.

Returns: A const reference to the first base engine this xor_combine_engine adapts.

Function thrust::random::xor_combine_engine::base2

_CCCL_HOST_DEVICE const base2_type & base2() const; This member function returns a const reference to this xor_combine_engine's second adapted base engine.

Returns: A const reference to the second base engine this xor_combine_engine adapts.