| MADNESS
    version 0.9
    | 
A random number generator (portable, vectorized, and thread-safe) More...
#include <ran.h>


| Public Member Functions | |
| Random (unsigned int seed=5461) | |
| virtual | ~Random () | 
| double | get () | 
| template<typename T > | |
| void | getv (int n, T *restrict v) | 
| Returns a vector of uniform doubles in [0,1)  More... | |
| void | getbytes (int n, unsigned char *restrict v) | 
| Returns vector of random bytes in [0,256)  More... | |
| RandomState | getstate () const | 
| Returns full state of the generator.  More... | |
| void | setstate (const RandomState &s) | 
| Restores state of the generator.  More... | |
| void | setstate (unsigned int seed) | 
| Sets state of the generator from integer.  More... | |
| Static Public Member Functions | |
| static void | test () | 
| Test the generator.  More... | |
A random number generator (portable, vectorized, and thread-safe)
Following Brent 1992, we use a 48-bit generalized Fibonacci generator
with alpha=1, beta=7, r=1279, s=861, m=2^48. Double precision numbers are used to perform exact integer arithmetic. 48-bit because we have 52 bits of mantissa, alpha+1 is 3 bits and 1 bit spare.
The period is nominally 2^m (2^r - 1) / 2 but if p is the period, X[n] and X[n+p/2k] differ by at most k bits (0 < k < 48) so usage should be limited to the first 2^r-1 entries (about 10^385 values).
Each instance provides a separate stream, but it is up to the user to partition the sequence by selecting distinct seeds or other means.
The streams are thread safe.
A default stream is provided as madness::default_random_generator.
| madness::Random::Random | ( | unsigned int | seed = 5461 | ) | 
References setstate().
| 
 | virtual | 
| 
 | inline | 
Referenced by noise::noise(), madness::RandomValue< double >(), and madness::RandomValue< float >().
| void madness::Random::getbytes | ( | int | n, | 
| unsigned char *restrict | v | ||
| ) | 
| RandomState madness::Random::getstate | ( | ) | const | 
Returns full state of the generator.
References madness::RandomState::cur, and madness::RandomState::u.
| 
 | inline | 
Returns a vector of uniform doubles in [0,1)
References mpfr::min(), and std::tr1::T().
Referenced by madness::RandomVector< double >(), madness::RandomVector< double_complex >(), madness::RandomVector< float >(), madness::RandomVector< float_complex >(), and test().
| void madness::Random::setstate | ( | const RandomState & | s | ) | 
Restores state of the generator.
References madness::RandomState::cur, and madness::RandomState::u.
| void madness::Random::setstate | ( | unsigned int | seed | ) | 
Sets state of the generator from integer.
| 
 | static | 
Test the generator.
References b(), madness::f, getbytes(), and getv().
 1.8.8
 1.8.8