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

A subtract with borrow random number generator by George Marsaglia (1999; internet posting). More...

#include <rng.h>

Inheritance diagram for RNG::SWB:
Inheritance graph
Collaboration diagram for RNG::SWB:
Collaboration graph

Public Member Functions

virtual std::string to_string () const
 
rngint_t value ()
 
 ~SWB ()
 
void vec_reseed (const std::vector< rngint_t > &seeds)
 
int nseed ()
 
- Public Member Functions inherited from RNG::Table256
 ~Table256 ()
 
- 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 SWBconstruct ()
 
static SWBconstruct (const std::vector< rngint_t > &)
 

Protected Member Functions

 SWB ()
 
- Protected Member Functions inherited from RNG::Table256
 Table256 ()
 

Private Attributes

rngint_t x
 
rngint_t y
 

Additional Inherited Members

- Protected Attributes inherited from RNG::Table256
UniformIntegerseeder_
 
rngint_t t [256]
 
unsigned char c
 

Detailed Description

A subtract with borrow random number generator by George Marsaglia (1999; internet posting).

Here is an excerpt from the posting describing this generator: SWB is a subtract-with-borrow generator that I developed to give a simple method for producing extremely long periods: x(n)=x(n-222)-x(n-237)-borrow mod 232. The 'borrow' is 0 unless set to 1 if computing x(n-1) caused overflow in 32-bit integer arithmetic. This generator has a very long period, 27098(2480-1), about 27578. It seems to pass all tests of randomness, but, suspicious of a generator so simple and fast (62 nanosecs at 300MHz), I would suggest combining SWB with KISS, MWC, SHR3, or CONG.

Definition at line 451 of file rng.h.

Constructor & Destructor Documentation

RNG::SWB::SWB ( )
protected
RNG::SWB::~SWB ( )

Member Function Documentation

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

Reimplemented from RNG::Table256.

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

Definition at line 461 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::SWB::value ( )
virtual

Implements RNG::UniformInteger.

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

Reimplemented from RNG::Table256.

Member Data Documentation

rngint_t RNG::SWB::x
private

Definition at line 454 of file rng.h.

rngint_t RNG::SWB::y
private

Definition at line 454 of file rng.h.


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