ZEDA  1.6.18
Data Structures | Macros | Functions
default random number generator

Data Structures

struct  zRandMT
 random number generator based on Mersenne twister. More...
 

Macros

#define zRandInit()   zRandInitMT( NULL )
 
#define zRandI(min, max)   zRandMTI( NULL, min, max )
 
#define zRandF(min, max)   zRandMTF( NULL, min, max )
 
#define zRandN()   zRandMTN( NULL )
 
#define zRandNU()   zRandMTNU( NULL )
 

Functions

void zRandInitMT (zRandMT *mt)
 initialize a random number generator based on Mersenne twister. More...
 
int zRandMTI (zRandMT *mt, int min, int max)
 a pseudo-random integer between min and max. More...
 
double zRandMTF (zRandMT *mt, double min, double max)
 a pseudo-random double-precision floating-point value between min and max. More...
 
double zRandMTN (zRandMT *mt)
 a pseudo-random double-precision floating-point value in the range of [0,1]. More...
 
double zRandMTNU (zRandMT *mt)
 a pseudo-random value in the range of [0,1). More...
 
zRandMTzRandMTDefault (void)
 return a pointer to the default random number generator. More...
 

Detailed Description

random number operations are not available in the kernel space

convenient reimplementations of the standard rand() function. Note that they are naive implementations of pseudo-random byte sequences.

Macro Definition Documentation

◆ zRandInit

#define zRandInit ( )    zRandInitMT( NULL )

◆ zRandI

#define zRandI (   min,
  max 
)    zRandMTI( NULL, min, max )

◆ zRandF

#define zRandF (   min,
  max 
)    zRandMTF( NULL, min, max )

◆ zRandN

#define zRandN ( )    zRandMTN( NULL )

◆ zRandNU

#define zRandNU ( )    zRandMTNU( NULL )

Function Documentation

◆ zRandInitMT()

void zRandInitMT ( zRandMT mt)

initialize a random number generator based on Mersenne twister.

zRandInitMT() initializes Mersenne twister mt by seeding the current time for a new history. If the null pointer is given for mt, it makes use of the internal default instance.

◆ zRandMTI()

int zRandMTI ( zRandMT mt,
int  min,
int  max 
)

a pseudo-random integer between min and max.

◆ zRandMTF()

double zRandMTF ( zRandMT mt,
double  min,
double  max 
)

a pseudo-random double-precision floating-point value between min and max.

◆ zRandMTN()

double zRandMTN ( zRandMT mt)

a pseudo-random double-precision floating-point value in the range of [0,1].

◆ zRandMTNU()

double zRandMTNU ( zRandMT mt)

a pseudo-random value in the range of [0,1).

◆ zRandMTDefault()

zRandMT* zRandMTDefault ( void  )

return a pointer to the default random number generator.