| 
    ROSE 0.11.145.357
    
   | 
 
Linear congruential generator.
Generates a repeatable sequence of pseudo-random numbers.
Definition at line 9 of file LinearCongruentialGenerator.h.
#include <util/LinearCongruentialGenerator.h>
Public Member Functions | |
| LinearCongruentialGenerator () | |
| Initialize the generator with a random seed.   | |
| LinearCongruentialGenerator (int seed) | |
| Initialize the generator with a seed.   | |
| void | init () | 
| Random initialization.   | |
| void | reset () | 
| Reset the sequence back to the first value.   | |
| void | reseed (int seed) | 
| Start a new sequence of random values.   | |
| int | seed () const | 
| Return the seed for the current sequence.   | |
| uint64_t | again () const | 
| Return the last returned value again.   | |
| uint64_t | max () | 
| Return the maximum possible value.  | |
| bool | flip_coin () | 
| Return a random boolean value.  | |
| uint64_t | next (size_t nbits=64, size_t niter=1) | 
| Return the next value in the sequence.   | |
| uint64_t | operator() () | 
| Return the next value in the sequence.   | |
Protected Attributes | |
| int | seed_ | 
| uint64_t | value_ | 
      
  | 
  inline | 
Initialize the generator with a random seed.
Definition at line 12 of file LinearCongruentialGenerator.h.
      
  | 
  inline | 
Initialize the generator with a seed.
The seed determines which sequence of numbers is returned.
Definition at line 15 of file LinearCongruentialGenerator.h.
| void LinearCongruentialGenerator::init | ( | ) | 
Random initialization.
This uses /dev/urandom or /dev/random to initailize the sequence.
      
  | 
  inline | 
Reset the sequence back to the first value.
Definition at line 21 of file LinearCongruentialGenerator.h.
      
  | 
  inline | 
Start a new sequence of random values.
The seed identifies which sequence is returned.
Definition at line 24 of file LinearCongruentialGenerator.h.
      
  | 
  inline | 
Return the seed for the current sequence.
Definition at line 27 of file LinearCongruentialGenerator.h.
      
  | 
  inline | 
Return the last returned value again.
Definition at line 30 of file LinearCongruentialGenerator.h.
| uint64_t LinearCongruentialGenerator::next | ( | size_t | nbits = 64,  | 
        
| size_t | niter = 1  | 
        ||
| ) | 
Return the next value in the sequence.
If nbits is specified, then only the low-order bits are randomized and the high order bits are always cleared. For instance, to get only positive values for casting to a 32-bit signed integer, use nbits=31. The niter indicates the number of values that should be consumed, all of which are exclusive-ORed together to create the return value. If niter is zero this function returns zero without consume any values. 
      
  | 
  inline | 
Return the next value in the sequence.
If nbits is specified, then only the low-order bits are randomized and the high order bits are always cleared. For instance, to get only positive values for casting to a 32-bit signed integer, use nbits=31. The niter indicates the number of values that should be consumed, all of which are exclusive-ORed together to create the return value. If niter is zero this function returns zero without consume any values. 
Definition at line 41 of file LinearCongruentialGenerator.h.
      
  | 
  protected | 
Definition at line 48 of file LinearCongruentialGenerator.h.
      
  | 
  protected | 
Definition at line 49 of file LinearCongruentialGenerator.h.