Web Analytics Made Easy - Statcounter
Skip to content

Class SBDTypeRandom#

ClassList > SBDTypeRandom

This class implements a random number generator. More...

  • #include <SBDTypeRandom.hpp>

Public Functions#

Type Name
SBDTypeRandom ()
Constructs a random generator with fixed seed.
SBDTypeRandom (unsigned long s)
Constructs a random generator with custom seed.
SB_DECLARE_DATA (SBDTypeRandom)
double randDouble1 ()
Generates a random number on [0,1]-real-interval.
double randDouble2 ()
Generates a random number on [0,1)-real-interval.
double randDouble3 ()
Generates a random number on (0,1)-real-interval.
long randLong ()
Generates a random number on [0,0x7fffffff]-interval.
double randRes53 ()
Generates a random number on [0,1) with 53-bit resolution.
SBCContainerUUID randUUID ()
Generates a random 32-character hexadecimal chain with the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.
SBVector3 randUnitSphere3 ()
Generates a point on the unit 3D sphere with uniform spherical distribution.
unsigned long randUnsignedLong ()
Generates a random number on [0,0xffffffff]-interval.
void seed (unsigned long s)
Reseed the random generator.
~SBDTypeRandom ()
Destructs the random generator.

Protected Attributes#

Type Name
SBDTypeRandomData * dataPointer

Detailed Description#

The class SBDTypeRandom generator implements the Mersenne Twister generator from the paper: M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-dimensionally equidistributed uniform pseudorandom number generator", ACM Trans. on Modeling and Computer Simulation Vol. 8, No. 1, January pp.3-30 (1998).

Note that the default constructor of SBDTypeRandom, SBDTypeRandom::SBDTypeRandom(), has a fixed seed. This is useful when debugging code, since it allows for reproducible results. For a "production run", though, a SBDTypeRandom object should be seeded with a random number, for example using SAMSON::getTime():

SBRandom r(SAMSON::getTime());
SBUUID UUID=r.randUUID(); // create a random UUID

Short name: SBRandom

See also: SBUUID

Public Functions Documentation#

function SBDTypeRandom [1/2]#

Constructs a random generator with fixed seed.

SBDTypeRandom::SBDTypeRandom () 


function SBDTypeRandom [2/2]#

Constructs a random generator with custom seed.

SBDTypeRandom::SBDTypeRandom (
    unsigned long s
) 


function SB_DECLARE_DATA#

SBDTypeRandom::SB_DECLARE_DATA (
    SBDTypeRandom
) 

function randDouble1#

Generates a random number on [0,1]-real-interval.

double SBDTypeRandom::randDouble1 () 


function randDouble2#

Generates a random number on [0,1)-real-interval.

double SBDTypeRandom::randDouble2 () 


function randDouble3#

Generates a random number on (0,1)-real-interval.

double SBDTypeRandom::randDouble3 () 


function randLong#

Generates a random number on [0,0x7fffffff]-interval.

long SBDTypeRandom::randLong () 


function randRes53#

Generates a random number on [0,1) with 53-bit resolution.

double SBDTypeRandom::randRes53 () 


function randUUID#

Generates a random 32-character hexadecimal chain with the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.

SBCContainerUUID SBDTypeRandom::randUUID () 


function randUnitSphere3#

Generates a point on the unit 3D sphere with uniform spherical distribution.

SBVector3 SBDTypeRandom::randUnitSphere3 () 


function randUnsignedLong#

Generates a random number on [0,0xffffffff]-interval.

unsigned long SBDTypeRandom::randUnsignedLong () 


function seed#

Reseed the random generator.

void SBDTypeRandom::seed (
    unsigned long s
) 


function ~SBDTypeRandom#

Destructs the random generator.

SBDTypeRandom::~SBDTypeRandom () 


Protected Attributes Documentation#

variable dataPointer#

SBDTypeRandomData* dataPointer;