Exponent::MathTools::TRandomNumberGenerator< TypeName > Class Template Reference

List of all members.

Detailed Description

template<class TypeName>
class Exponent::MathTools::TRandomNumberGenerator< TypeName >

Generates a (not too) random floating point number.

Date:
02/11/2006
Author:
Paul Chana
Version:
1.0.0 Initial version
Note:
All contents of this source code are copyright 2005 Exp Digital Uk.
This source file is covered by the licence conditions of the Infinity API. You should have recieved a copy
with the source code. If you didnt, please refer to http://www.expdigital.co.uk All content is the Intellectual property of Exp Digital Uk.
Certain sections of this code may come from other sources. They are credited where applicable.
If you have comments, suggestions or bug reports please visit http://support.expdigital.co.uk


The Gaussian1 and Uniform code comes from the book C++ algorithms for DSP (2nd ED.)
By Ambree and Danieli. It generates a gaussian (white) noise source using the
Box-Muller method (see Knuth or Press et al)
ISBN : 0-13-179144-3

The Guassian2 function is based upon tobybears original noise generator, i just
converted it to C++ from the original delphi.
Link for original is: http://www.musicdsp.org/archive.php?classid=0#129

The Gaussian3 function is based upon the work of Steve S Smith in
The Scientist and Engineer's Guide to Digital Signal Processing
which is available at http://www.dspguide.com
Id
TRandomNumberGenerator.hpp,v 1.4 2007/02/08 21:06:44 paul Exp

Definition at line 46 of file TRandomNumberGenerator.hpp.

Public Types

Public Member Functions

Protected Member Functions

Static Protected Attributes


Member Enumeration Documentation

template<class TypeName>
enum Exponent::MathTools::TRandomNumberGenerator::ERandomNumberGenerationType

Type of random number.

Enumerator:
e_standardLibrary  The standard library type of random number, not very random
e_uniform  Uniform distribution
e_gaussian1  Gaussian distribution variant 1
e_gaussian2  Gaussian distribution variant 2
e_gaussian3  Gaussian distribution variant 3

Definition at line 62 of file TRandomNumberGenerator.hpp.


Constructor & Destructor Documentation

template<class TypeName>
Exponent::MathTools::TRandomNumberGenerator< TypeName >::TRandomNumberGenerator (  )  [inline]

Construction

Definition at line 76 of file TRandomNumberGenerator.hpp.

References EXPONENT_CLASS_CONSTRUCTION.

template<class TypeName>
virtual Exponent::MathTools::TRandomNumberGenerator< TypeName >::~TRandomNumberGenerator (  )  [inline, virtual]

Destruction

Definition at line 84 of file TRandomNumberGenerator.hpp.

References EXPONENT_CLASS_DESTRUCTION.


Member Function Documentation

template<class TypeName>
TypeName Exponent::MathTools::TRandomNumberGenerator< TypeName >::gaussian1 (  )  [inline, protected]

Generate gaussian random number

Return values:
TypeName The gaussian number

Definition at line 210 of file TRandomNumberGenerator.hpp.

References Exponent::MathTools::CMathTools::square(), and Exponent::MathTools::TRandomNumberGenerator< TypeName >::uniform().

Referenced by Exponent::MathTools::TRandomNumberGenerator< TypeName >::getNewRandomNumber().

template<class TypeName>
TypeName Exponent::MathTools::TRandomNumberGenerator< TypeName >::gaussian2 (  )  [inline, protected]

Generate gaussian random number

Return values:
TypeName The gaussian number

Definition at line 260 of file TRandomNumberGenerator.hpp.

References Exponent::MathTools::TRandomNumberGenerator< TypeName >::TRANDOM_NUMBER_GENERATOR_GAUSSIAN_COEFFICIENTS.

Referenced by Exponent::MathTools::TRandomNumberGenerator< TypeName >::getNewRandomNumber().

template<class TypeName>
TypeName Exponent::MathTools::TRandomNumberGenerator< TypeName >::gaussian3 (  )  [inline, protected]

Generate gaussian random number

Return values:
TypeName The gaussian number

Definition at line 271 of file TRandomNumberGenerator.hpp.

References Exponent::MathTools::CMathTools::CMATH_2PI_DOUBLE.

Referenced by Exponent::MathTools::TRandomNumberGenerator< TypeName >::getNewRandomNumber().

template<class TypeName>
void Exponent::MathTools::TRandomNumberGenerator< TypeName >::getNewRandomArray ( TCollection< TypeName > &  array,
const ERandomNumberGenerationType  type 
) [inline]

Fill an array with random numbers (Fills with doubles up to size)

Parameters:
array The array to fill with elements of TypeName. Note that this array must be initialised to the correct size
type The type of random numbers

Definition at line 173 of file TRandomNumberGenerator.hpp.

References Exponent::Collections::TCollection< TypeName >::getArraySize(), Exponent::Collections::TCollection< TypeName >::getMutableInternalBuffer(), and Exponent::MathTools::TRandomNumberGenerator< TypeName >::getNewRandomArray().

template<class TypeName>
void Exponent::MathTools::TRandomNumberGenerator< TypeName >::getNewRandomArray ( TypeName *  array,
const long  numberToGenerate,
const ERandomNumberGenerationType  type 
) [inline]

Fill an array with random numbers (Fills with doubles up to size)

Parameters:
array The array to fill with CDoubles
numberToGenerate Total number of random numbers to generate. Should be the number of elements in array
type The type of random numbers

Definition at line 126 of file TRandomNumberGenerator.hpp.

References Exponent::MathTools::TRandomNumberGenerator< TypeName >::e_gaussian1, Exponent::MathTools::TRandomNumberGenerator< TypeName >::e_gaussian2, Exponent::MathTools::TRandomNumberGenerator< TypeName >::e_gaussian3, Exponent::MathTools::TRandomNumberGenerator< TypeName >::e_standardLibrary, and Exponent::MathTools::TRandomNumberGenerator< TypeName >::e_uniform.

Referenced by Exponent::MathTools::TRandomNumberGenerator< TypeName >::getNewRandomArray().

template<class TypeName>
TypeName Exponent::MathTools::TRandomNumberGenerator< TypeName >::getNewRandomNumber ( const ERandomNumberGenerationType  type  )  [inline]

Get a new random number

Parameters:
type The type of random number
Return values:
TypeName The new random number in range 0 - 1

Definition at line 107 of file TRandomNumberGenerator.hpp.

References Exponent::MathTools::TRandomNumberGenerator< TypeName >::e_gaussian1, Exponent::MathTools::TRandomNumberGenerator< TypeName >::e_gaussian2, Exponent::MathTools::TRandomNumberGenerator< TypeName >::e_gaussian3, Exponent::MathTools::TRandomNumberGenerator< TypeName >::e_standardLibrary, Exponent::MathTools::TRandomNumberGenerator< TypeName >::e_uniform, Exponent::MathTools::TRandomNumberGenerator< TypeName >::gaussian1(), Exponent::MathTools::TRandomNumberGenerator< TypeName >::gaussian2(), Exponent::MathTools::TRandomNumberGenerator< TypeName >::gaussian3(), Exponent::MathTools::TRandomNumberGenerator< TypeName >::standardLibrary(), and Exponent::MathTools::TRandomNumberGenerator< TypeName >::uniform().

template<class TypeName>
void Exponent::MathTools::TRandomNumberGenerator< TypeName >::seed (  )  [inline]

Seed the signal

Note:
Call this once before starting to generate numbers

Definition at line 95 of file TRandomNumberGenerator.hpp.

template<class TypeName>
TypeName Exponent::MathTools::TRandomNumberGenerator< TypeName >::standardLibrary (  )  [inline, protected]

Generate a std lib random number between 0 and 1

Return values:
TypeName The random number

Definition at line 201 of file TRandomNumberGenerator.hpp.

Referenced by Exponent::MathTools::TRandomNumberGenerator< TypeName >::getNewRandomNumber().

template<class TypeName>
TypeName Exponent::MathTools::TRandomNumberGenerator< TypeName >::uniform (  )  [inline, protected]

Generate a random number between -1 and 1

Return values:
TypeName The random number

Definition at line 192 of file TRandomNumberGenerator.hpp.

Referenced by Exponent::MathTools::TRandomNumberGenerator< TypeName >::gaussian1(), and Exponent::MathTools::TRandomNumberGenerator< TypeName >::getNewRandomNumber().


Member Data Documentation

template<class TypeName>
const TypeName Exponent::MathTools::TRandomNumberGenerator< TypeName >::TRANDOM_NUMBER_GENERATOR_GAUSSIAN_COEFFICIENTS[3] [static, protected]

The variables required for gaussian 2

Definition at line 184 of file TRandomNumberGenerator.hpp.

Referenced by Exponent::MathTools::TRandomNumberGenerator< TypeName >::gaussian2().


Infinity API - Exponent::MathTools::TRandomNumberGenerator< TypeName > Class Template Reference generated on 7 Mar 2007