class EE::Math::MTRand

Overview

#include <mtrand.hpp>

class MTRand {
public:
    // fields

    static const Uint32 M = 397;
    static const Int32 N = 624;
    static const Uint32 SAVE = N + 1;

    // construction

    MTRand(const Uint32 oneSeed);
    MTRand();
    MTRand(const MTRand& o);

    // methods

    MTRand& operator=(const MTRand& o);
    Uint32 getRandi();
    Uint32 getRandi(const Uint32 n);
    double getRand();
    double getRand(const double n);
    void setSeed(const Uint32 oneSeed);
    void setSeed();
    Float getRandf();
    Float getRandf(const Float n);
    int getRandFromRange(int Min, int Max);
    Float getRandFromRange(Float Min, Float Max);
    void save(Uint32* saveArray) const;
    void load(Uint32*const loadArray);
};

Detailed Documentation

Construction

MTRand(const Uint32 oneSeed)

Initialize with a defined user seed

MTRand()

Initialize with a predefined seed

MTRand(const MTRand& o)

Initialize with a copy of another MTRand object

Methods

MTRand& operator=(const MTRand& o)

Copy MTRand object

Uint32 getRandi()

Returns:

integer in [0,2^32-1]

Uint32 getRandi(const Uint32 n)

Returns:

integer in [0,n] for n < 2^32

double getRand()

Returns:

real number in [0,1]

double getRand(const double n)

Returns:

real number in [0,n]

void setSeed(const Uint32 oneSeed)

Set a new seed

void setSeed()

Set the default seed

Float getRandf()

Returns:

float number in [0,1]

Float getRandf(const Float n)

Returns:

float number in [0,n]

int getRandFromRange(int Min, int Max)

Returns:

int number in [Min,Max]

Float getRandFromRange(Float Min, Float Max)

Returns:

float number in [Min,Max]

void save(Uint32* saveArray) const

Save the state to an allocated array

void load(Uint32*const loadArray)

Load state from an array