libcoyotl - A Library of C++ Tools

Created by Scott Robert Ladd at Coyote Gulch Productions.


Public Member Functions | List of all members
libcoyotl::kissrng Class Reference

Implements KISS, a peudorandom number generator. More...

#include <kissrng.h>

Inheritance diagram for libcoyotl::kissrng:
libcoyotl::prng

Public Member Functions

 kissrng ()
 Default constructor, reading seed from/dev/urandom or the time.
 kissrng (uint32_t seed)
 Default constructor, with optional seed.
virtual void init (uint32_t seed)
 Initializes the generator with "seed".
virtual uint32_t get_rand ()
 Get the next integer.
- Public Member Functions inherited from libcoyotl::prng
 prng ()
 Default constructor, reading seed from/dev/urandom or the time.
 prng (uint32_t seed)
 Default constructor, with optional seed.
uint32_t get_seed ()
 Returns the original seed value.
uint32_t get_rand_range (uint32_t lo, uint32_t hi)
 Get the next integer in the range [lo,hi].
size_t get_rand_index (size_t length)
 Get the next random value as a size_t index.
double get_rand_real1 ()
 Get the next number in the range [0,1].
double get_rand_real2 ()
 Get the next number in the range [0,1)
double get_rand_real3 ()
 Get the next number in the range (0,1)
double get_rand_real53 ()
 Get the next number in the range [0,1)

Additional Inherited Members

- Protected Attributes inherited from libcoyotl::prng
uint32_t m_seed
 Initialization seed.

Detailed Description

The popular "Keep It Simple Stupid" psuedorandom number generator. It has a period of around 2^125, which is shorter than most other algorithms, but certainly adequate for many applications.

Constructor & Destructor Documentation

libcoyotl::kissrng::kissrng ( )

The constructor initializes the prng seed from either the time or some stochastic source such as /dev/random or /dev/urandom.

libcoyotl::kissrng::kissrng ( uint32_t  seed)

The constructor uses an explicit value for the seed.

Parameters
seed- Seed value used to "start" or seed the generator

Member Function Documentation

virtual uint32_t libcoyotl::kissrng::get_rand ( )
virtual

Returns the next uint32_t in sequence.

Returns
A pseudorandom uint32_t value

Implements libcoyotl::prng.

virtual void libcoyotl::kissrng::init ( uint32_t  seed)
virtual

Resets the generator using the provided seed value.

Parameters
seed- Seed value used to "start" or seed the generator

Reimplemented from libcoyotl::prng.


The documentation for this class was generated from the following file:

© 1996-2005 Scott Robert Ladd. All rights reserved.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.