Linear congruential uniform pseudo-random number generator. More...
#include <rnd.h>
Public Member Functions | |
RNGLinCon (uint32_t seed) | |
void | type (int v) |
Change the type of equation used. | |
uint32_t | operator[] (uint32_t i) const |
Array get; generates next element. | |
uint32_t & | operator[] (uint32_t i) |
Array set; sets current value. | |
uint32_t | operator() () const |
Generate next value. | |
Public Attributes | |
uint32_t | mul |
Multiplication amount. | |
uint32_t | add |
Addition amount. | |
uint32_t | val |
Value. |
Linear congruential uniform pseudo-random number generator.
This generator is very fast requiring only a single integer multiply and add per iteration. However, the least significant bits of the numbers are less random; the most extreme case being the LSB which at best flips between 0 and 1. This generator also exhibits poor dimensional distribution, therefore it is best to have a different generator for each dimension, rather than sharing one.
RNGLinCon | ( | uint32_t | seed | ) |
[in] | seed | Initial seed value |
void type | ( | int | v | ) |
Change the type of equation used.
0 - Knuth, Numerical Recipes in C
1 - BCPL