The simplest way to use this library is to pick a generator and use the
rand()
interface to access it. You can accomplish this using a few
simple steps.
rand()
, random()
, randomize()
,
srand()
, or MAX_RAND
.
setup_rand()
with a heap-based your chosen generator as the argument.
rand()
, random()
, randomize()
, and
srand()
as described in the C++ standard library documentation.
Here are six examples of the correct use of this function. Each of these generators take an optional seed argument when they are constructed.
setup_rand( new Knuth27RandGen() ); | // found in erndmcnm.h | |
setup_rand( new BoroshNiederreiterRandGen() ); | // found in erndmcon.h | |
setup_rand( new WatermanRandGen() ); | // found in erndmcon.h | |
setup_rand( new LavauxJanssensRandGen() ); | // found in erndmcon.h | |
setup_rand( new MarsagliaMCRandGen() ); | // found in erndmcon.h | |
setup_rand( new Knuth28RandGen() ); | // found in erndsecm.h | |
Unlike the standard rand()
function that returns short int
s,
the ThinAir rand()
function returns long int
s. If you use the
random( limit )
function instead of rand()
, you will not notice
any difference. For an example and further information on this interface, see
Section 5.2.