My Project
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes
RandomGenerator Class Reference

Public Member Functions

 RandomGenerator ()
 
 RandomGenerator (int ss)
 
 ~RandomGenerator ()
 
int generate ()
 
void seed (int ss)
 

Private Member Functions

void seedInit (int ss)
 

Private Attributes

const int ia
 
const int im
 
const int iq
 
const int ir
 
const int deflt
 
int s
 

Detailed Description

Definition at line 29 of file cf_random.cc.

Constructor & Destructor Documentation

◆ RandomGenerator() [1/2]

RandomGenerator::RandomGenerator ( )

Definition at line 44 of file cf_random.cc.

44 : ia(16807), im(2147483647), iq(127773), ir(2836), deflt(123459876)
45{
46 seedInit( (int)time( 0 ) );
47}
const int deflt
Definition: cf_random.cc:31
const int ia
Definition: cf_random.cc:31
const int ir
Definition: cf_random.cc:31
const int im
Definition: cf_random.cc:31
const int iq
Definition: cf_random.cc:31
void seedInit(int ss)
Definition: cf_random.cc:35

◆ RandomGenerator() [2/2]

RandomGenerator::RandomGenerator ( int  ss)

Definition at line 49 of file cf_random.cc.

49 : ia(16807), im(2147483647), iq(127773), ir(2836), deflt(123459876)
50{
51 seedInit( ss );
52}

◆ ~RandomGenerator()

RandomGenerator::~RandomGenerator ( )
inline

Definition at line 39 of file cf_random.cc.

39{}

Member Function Documentation

◆ generate()

int RandomGenerator::generate ( )

Definition at line 55 of file cf_random.cc.

56{
57 int k;
58
59 k = s/iq;
60 s = ia*(s-k*iq)-ir*k;
61 if ( s < 0 ) s += im;
62
63 return s;
64}
int k
Definition: cfEzgcd.cc:99

◆ seed()

void RandomGenerator::seed ( int  ss)
inline

Definition at line 41 of file cf_random.cc.

41{ seedInit( ss ); }

◆ seedInit()

void RandomGenerator::seedInit ( int  ss)
inlineprivate

Definition at line 35 of file cf_random.cc.

35{ s = ((ss == 0) ? deflt : ss); }

Field Documentation

◆ deflt

const int RandomGenerator::deflt
private

Definition at line 31 of file cf_random.cc.

◆ ia

const int RandomGenerator::ia
private

Definition at line 31 of file cf_random.cc.

◆ im

const int RandomGenerator::im
private

Definition at line 31 of file cf_random.cc.

◆ iq

const int RandomGenerator::iq
private

Definition at line 31 of file cf_random.cc.

◆ ir

const int RandomGenerator::ir
private

Definition at line 31 of file cf_random.cc.

◆ s

int RandomGenerator::s
private

Definition at line 32 of file cf_random.cc.


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