SST/macro
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
RNG::SHR3 Class Reference

The 3-shift-register random number generator by George Marsaglia (1999; internet posting). More...

#include <rng.h>

Inheritance diagram for RNG::SHR3:
Inheritance graph
Collaboration diagram for RNG::SHR3:
Collaboration graph

Public Member Functions

virtual std::string to_string () const
 
 ~SHR3 ()
 
rngint_t value ()
 
void vec_reseed (const std::vector< rngint_t > &seeds)
 
int nseed ()
 
- Public Member Functions inherited from RNG::UniformInteger
virtual ~UniformInteger ()
 
rngint_t value_in_range (rngint_t range)
 
virtual double realvalue (bool include_zero=true, bool include_one=true)
 Return a random value in the interval [0,1], (0,1], [0,1), or (0,1) More...
 
void reseed ()
 
void reseed (rngint_t)
 
void reseed (rngint_t, rngint_t)
 
void reseed (rngint_t, rngint_t, rngint_t)
 
void reseed (rngint_t, rngint_t, rngint_t, rngint_t)
 

Static Public Member Functions

static SHR3construct ()
 
static SHR3construct (const std::vector< rngint_t > &)
 
static SHR3construct (rngint_t jsrarg)
 

Protected Member Functions

 SHR3 ()
 

Private Attributes

rngint_t jsr
 

Detailed Description

The 3-shift-register random number generator by George Marsaglia (1999; internet posting).

This RNG is fast and has a very low memory footprint. Here is an excerpt from the posting describing this generator: SHR3 is a 3-shift-register generator with period 232-1. It uses y(n)=y(n-1)(I+L17)(I+R13)(I+L5), with the y's viewed as binary vectors, L the 32x32 binary matrix that shifts a vector left 1, and R its transpose. SHR3 seems to pass all except the binary rank test, since 32 successive values, as binary vectors, must be linearly independent, while 32 successive truly random 32-bit integers, viewed as binary vectors, will be linearly independent only about 29% of the time.

Definition at line 160 of file rng.h.

Constructor & Destructor Documentation

RNG::SHR3::SHR3 ( )
protected
RNG::SHR3::~SHR3 ( )

Member Function Documentation

static SHR3* RNG::SHR3::construct ( )
static
static SHR3* RNG::SHR3::construct ( const std::vector< rngint_t > &  )
static
static SHR3* RNG::SHR3::construct ( rngint_t  jsrarg)
static
int RNG::SHR3::nseed ( )
virtual

Implements RNG::UniformInteger.

virtual std::string RNG::SHR3::to_string ( ) const
inlinevirtual

Definition at line 170 of file rng.h.

References RNG::UniformInteger::nseed(), RNG::UniformInteger::value(), and RNG::UniformInteger::vec_reseed().

Here is the call graph for this function:

rngint_t RNG::SHR3::value ( )
virtual

Implements RNG::UniformInteger.

void RNG::SHR3::vec_reseed ( const std::vector< rngint_t > &  seeds)
virtual

Implements RNG::UniformInteger.

Member Data Documentation

rngint_t RNG::SHR3::jsr
private

Definition at line 163 of file rng.h.


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