arbitraryprecisioncalculation::FastLinearCongruenceRandomNumberGenerator Class Reference

This is a fast random number generator which uses linear congruences. More...

#include <random_number_generator.h>

Inheritance diagram for arbitraryprecisioncalculation::FastLinearCongruenceRandomNumberGenerator:

Public Member Functions

 FastLinearCongruenceRandomNumberGenerator (unsigned long long multiplier, unsigned long long adder, unsigned long long modulus, unsigned long long seed)
 The constructor. More...
 
std::string GetName ()
 Returns a string representation of this object. More...
 
void LoadData (std::ifstream *)
 Loads data to reset the state of the random number generator to the state which was stored. More...
 
long long RandomLongLong ()
 Creates a random long long value. More...
 
mpf_t * RandomMpft ()
 Creates a random mpf_t value in the interval [0,1]. More...
 
void StoreData (std::ofstream *)
 Stores the current state of this random number generator, such that it can completely restore the current state with this data. More...
 
- Public Member Functions inherited from arbitraryprecisioncalculation::RandomNumberGenerator
virtual ~RandomNumberGenerator ()
 The destructor. More...
 

Detailed Description

This is a fast random number generator which uses linear congruences.

Constructor & Destructor Documentation

arbitraryprecisioncalculation::FastLinearCongruenceRandomNumberGenerator::FastLinearCongruenceRandomNumberGenerator ( unsigned long long  multiplier,
unsigned long long  adder,
unsigned long long  modulus,
unsigned long long  seed 
)

The constructor.

Parameters
multiplierThe factor in the linear congruence.
adderThe additive value in the linear congruence.
modulusThe modulus value in the linear congruence.
seedThe initial seed of the random number generator.

Member Function Documentation

std::string arbitraryprecisioncalculation::FastLinearCongruenceRandomNumberGenerator::GetName ( )
virtual

Returns a string representation of this object.

Returns
The name of the object.

Implements arbitraryprecisioncalculation::RandomNumberGenerator.

void arbitraryprecisioncalculation::FastLinearCongruenceRandomNumberGenerator::LoadData ( std::ifstream *  input_stream)
virtual

Loads data to reset the state of the random number generator to the state which was stored.

Parameters
input_streamThe stream which contains the data about the state of the random number generator.

Implements arbitraryprecisioncalculation::RandomNumberGenerator.

long long arbitraryprecisioncalculation::FastLinearCongruenceRandomNumberGenerator::RandomLongLong ( )
virtual

Creates a random long long value.

Calculates the next random by the equation (adder + multiplier · S) mod modulus, where S is the previous random value or the initial seed (if it is the first call of this function) and mod means the modulo operation.

Returns
The random value.

Implements arbitraryprecisioncalculation::RandomNumberGenerator.

mpf_t* arbitraryprecisioncalculation::FastLinearCongruenceRandomNumberGenerator::RandomMpft ( )
virtual

Creates a random mpf_t value in the interval [0,1].

The random value is generated by a call of the random long long function and a division by the modulus.

Returns
The random value.

Implements arbitraryprecisioncalculation::RandomNumberGenerator.

void arbitraryprecisioncalculation::FastLinearCongruenceRandomNumberGenerator::StoreData ( std::ofstream *  output_stream)
virtual

Stores the current state of this random number generator, such that it can completely restore the current state with this data.

Parameters
output_streamThe output stream where the state should be stored.

Implements arbitraryprecisioncalculation::RandomNumberGenerator.


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