clingo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
Public Member Functions | List of all members

A very simple but fast Pseudo-random number generator. More...

#include <misc_types.h>

Collaboration diagram for Clasp::RNG:
Collaboration graph

Public Member Functions

 RNG (uint32 seed=1)
 
void srand (uint32 seed)
 Sets the starting point for random-number generation. More...
 
uint32 rand ()
 Generates a pseudorandom number. More...
 
double drand ()
 random floating point number in the range [0, 1.0) More...
 
unsigned irand (unsigned max)
 random number in the range [0, max) More...
 
uint32 seed () const
 
uint32 operator() (unsigned max)
 
uint32 operator() ()
 

Detailed Description

A very simple but fast Pseudo-random number generator.

Note
This class is a replacement for the standard rand-function. It is provided in order to get reproducible random numbers among different compilers.

Constructor & Destructor Documentation

Clasp::RNG::RNG ( uint32  seed = 1)
inlineexplicit

Member Function Documentation

double Clasp::RNG::drand ( )
inline

random floating point number in the range [0, 1.0)

Here is the call graph for this function:

unsigned Clasp::RNG::irand ( unsigned  max)
inline

random number in the range [0, max)

Here is the call graph for this function:

uint32 Clasp::RNG::operator() ( unsigned  max)
inline

Here is the call graph for this function:

uint32 Clasp::RNG::operator() ( )
inline

Here is the call graph for this function:

uint32 Clasp::RNG::rand ( )
inline

Generates a pseudorandom number.

The rand function returns a pseudorandom integer in the range 0 to 32767 Use the srand function to seed the pseudorandom-number generator before calling rand.

uint32 Clasp::RNG::seed ( ) const
inline
void Clasp::RNG::srand ( uint32  seed)
inline

Sets the starting point for random-number generation.

The function sets the starting point for generating a series of pseudorandom integers. To reinitialize the generator, use 1 as the seed argument. Any other value for seed sets the generator to a random starting point. Calling rand() before any call to srand() generates the same sequence as calling srand() with seed passed as 1.

Here is the call graph for this function:


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