EigenRand  0.3.0
Eigen::Rand::MersenneTwister< Packet, _Nx, _Mx, _Rx, _Px, _Ux, _Dx, _Sx, _Bx, _Tx, _Cx, _Lx, _Fx > Class Template Reference

A vectorized version of Mersenne Twister Engine. More...

#include <PacketRandomEngine.h>

Public Types

using result_type = Packet
 

Public Member Functions

 MersenneTwister (uint64_t x0=default_seed)
 Construct a new Mersenne Twister engine with a scalar seed. More...
 
 MersenneTwister (Packet x0)
 Construct a new Mersenne Twister engine with a packet seed. More...
 
void seed (Packet x0)
 initialize the engine with a given seed More...
 
uint64_t min () const
 minimum value of the result More...
 
uint64_t max () const
 maximum value of the result More...
 
result_type operator() ()
 Generates one random packet and advance the internal state. More...
 
void discard (unsigned long long num)
 Discards num items being generated. More...
 
internal::HalfPacket< Packet >::type half ()
 

Static Public Attributes

static constexpr int word_size = 64
 
static constexpr int state_size = _Nx
 
static constexpr int shift_size = _Mx
 
static constexpr int mask_bits = _Rx
 
static constexpr uint64_t parameter_a = _Px
 
static constexpr int output_u = _Ux
 
static constexpr int output_s = _Sx
 
static constexpr uint64_t output_b = _Bx
 
static constexpr int output_t = _Tx
 
static constexpr uint64_t output_c = _Cx
 
static constexpr int output_l = _Lx
 
static constexpr uint64_t default_seed = 5489U
 

Protected Member Functions

void refill_lower ()
 
void refill_upper ()
 

Protected Attributes

AlignedArray< Packet, _Nx *2 > state
 
size_t stateIdx = 0
 
internal::HalfPacket< Packet >::type cache
 
bool valid = false
 

Static Protected Attributes

static constexpr uint64_t _wMask = (uint64_t)-1
 
static constexpr uint64_t _hMask = (_wMask << _Rx) & _wMask
 
static constexpr uint64_t _lMask = ~_hMask & _wMask
 

Detailed Description

template<typename Packet, int _Nx, int _Mx, int _Rx, uint64_t _Px, int _Ux, uint64_t _Dx, int _Sx, uint64_t _Bx, int _Tx, uint64_t _Cx, int _Lx, uint64_t _Fx>
class Eigen::Rand::MersenneTwister< Packet, _Nx, _Mx, _Rx, _Px, _Ux, _Dx, _Sx, _Bx, _Tx, _Cx, _Lx, _Fx >

A vectorized version of Mersenne Twister Engine.

Template Parameters
Packeta type of integer packet being generated from this engine
_Nx
_Mx
_Rx
_Px
_Ux
_Dx
_Sx
_Bx
_Tx
_Cx
_Lx
_Fx
Note
It is recommended to use the alias, Eigen::Rand::Vmt19937_64 rather than using raw MersenneTwister template class because the definition of Eigen::Rand::Vmt19937_64 is changed to use the appropriate PacketType depending on compile options and the architecture of machines.

Constructor & Destructor Documentation

◆ MersenneTwister() [1/2]

template<typename Packet , int _Nx, int _Mx, int _Rx, uint64_t _Px, int _Ux, uint64_t _Dx, int _Sx, uint64_t _Bx, int _Tx, uint64_t _Cx, int _Lx, uint64_t _Fx>
Eigen::Rand::MersenneTwister< Packet, _Nx, _Mx, _Rx, _Px, _Ux, _Dx, _Sx, _Bx, _Tx, _Cx, _Lx, _Fx >::MersenneTwister ( uint64_t  x0 = default_seed)
inline

Construct a new Mersenne Twister engine with a scalar seed.

Parameters
x0scalar seed for the engine
Note
The seed for the first element of packet is initialized to x0, for the second element to x0 + 1, and the n-th element to is x0 + n - 1.

◆ MersenneTwister() [2/2]

template<typename Packet , int _Nx, int _Mx, int _Rx, uint64_t _Px, int _Ux, uint64_t _Dx, int _Sx, uint64_t _Bx, int _Tx, uint64_t _Cx, int _Lx, uint64_t _Fx>
Eigen::Rand::MersenneTwister< Packet, _Nx, _Mx, _Rx, _Px, _Ux, _Dx, _Sx, _Bx, _Tx, _Cx, _Lx, _Fx >::MersenneTwister ( Packet  x0)
inline

Construct a new Mersenne Twister engine with a packet seed.

Parameters
x0packet seed for the engine

Member Function Documentation

◆ discard()

template<typename Packet , int _Nx, int _Mx, int _Rx, uint64_t _Px, int _Ux, uint64_t _Dx, int _Sx, uint64_t _Bx, int _Tx, uint64_t _Cx, int _Lx, uint64_t _Fx>
void Eigen::Rand::MersenneTwister< Packet, _Nx, _Mx, _Rx, _Px, _Ux, _Dx, _Sx, _Bx, _Tx, _Cx, _Lx, _Fx >::discard ( unsigned long long  num)
inline

Discards num items being generated.

Parameters
numthe number of items being discarded

◆ max()

template<typename Packet , int _Nx, int _Mx, int _Rx, uint64_t _Px, int _Ux, uint64_t _Dx, int _Sx, uint64_t _Bx, int _Tx, uint64_t _Cx, int _Lx, uint64_t _Fx>
uint64_t Eigen::Rand::MersenneTwister< Packet, _Nx, _Mx, _Rx, _Px, _Ux, _Dx, _Sx, _Bx, _Tx, _Cx, _Lx, _Fx >::max ( ) const
inline

maximum value of the result

Returns
uint64_t

◆ min()

template<typename Packet , int _Nx, int _Mx, int _Rx, uint64_t _Px, int _Ux, uint64_t _Dx, int _Sx, uint64_t _Bx, int _Tx, uint64_t _Cx, int _Lx, uint64_t _Fx>
uint64_t Eigen::Rand::MersenneTwister< Packet, _Nx, _Mx, _Rx, _Px, _Ux, _Dx, _Sx, _Bx, _Tx, _Cx, _Lx, _Fx >::min ( ) const
inline

minimum value of the result

Returns
uint64_t

◆ operator()()

template<typename Packet , int _Nx, int _Mx, int _Rx, uint64_t _Px, int _Ux, uint64_t _Dx, int _Sx, uint64_t _Bx, int _Tx, uint64_t _Cx, int _Lx, uint64_t _Fx>
result_type Eigen::Rand::MersenneTwister< Packet, _Nx, _Mx, _Rx, _Px, _Ux, _Dx, _Sx, _Bx, _Tx, _Cx, _Lx, _Fx >::operator() ( )
inline

Generates one random packet and advance the internal state.

Returns
result_type
Note
A value generated from this engine is not scalar, but packet type. If you need to extract scalar values, use Eigen::Rand::makeScalarRng or Eigen::Rand::PacketRandomEngineAdaptor.

◆ seed()

template<typename Packet , int _Nx, int _Mx, int _Rx, uint64_t _Px, int _Ux, uint64_t _Dx, int _Sx, uint64_t _Bx, int _Tx, uint64_t _Cx, int _Lx, uint64_t _Fx>
void Eigen::Rand::MersenneTwister< Packet, _Nx, _Mx, _Rx, _Px, _Ux, _Dx, _Sx, _Bx, _Tx, _Cx, _Lx, _Fx >::seed ( Packet  x0)
inline

initialize the engine with a given seed

Parameters
x0packet seed for the engine

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