SOFA API  cba138a4
Open source framework for multi-physics simuation
sofa::helper::RandomGenerator Class Reference

#include <RandomGenerator.h>

Detailed Description

Generate Random number based on random functions from OpenBSD

Public Member Functions

 RandomGenerator ()
 
 RandomGenerator (long seed)
 
virtual ~RandomGenerator ()
 
void initSeed (long seed)
 
template<class T >
random (T min, T max)
 
template<class T >
symrand (T vmax)
 number between [-vmax, vmax] (vmax has less chance to appear) More...
 
template<class T >
random ()
 
template<>
long random (long min, long max)
 
template<>
double random (double min, double max)
 
template<>
float random (float min, float max)
 
template<>
bool random (bool, bool)
 
template<>
double random ()
 
template<>
float random ()
 

Protected Member Functions

unsigned long int randomBase ()
 integer between [0, 2^32-1) More...
 

Constructor details

sofa::helper::RandomGenerator::RandomGenerator ( )
sofa::helper::RandomGenerator::RandomGenerator ( long  seed)
sofa::helper::RandomGenerator::~RandomGenerator ( )
virtual

Function details

void sofa::helper::RandomGenerator::initSeed ( long  seed)
template<class T >
T sofa::helper::RandomGenerator::random ( min,
max 
)
inline

number between [min, max) (max has less chance to appear) note that "only" 2^32 different values can be generated

Warning
min < max
for floating types a too large range can generate inf
template<class T >
T sofa::helper::RandomGenerator::random ( )
inline

number between [T::min, T::max) (max has less chance to appear) note that "only" 2^32 different values can be generated

Warning
for floating types, min = -(2^32-1) & max = (2^32-1)
template<>
long sofa::helper::RandomGenerator::random ( long  min,
long  max 
)
inline
template<>
double sofa::helper::RandomGenerator::random ( double  min,
double  max 
)
inline
template<>
float sofa::helper::RandomGenerator::random ( float  min,
float  max 
)
inline
template<>
bool sofa::helper::RandomGenerator::random ( bool  ,
bool   
)
inline
template<>
double sofa::helper::RandomGenerator::random ( )
inline
template<>
float sofa::helper::RandomGenerator::random ( )
inline
unsigned long sofa::helper::RandomGenerator::randomBase ( )
protected

integer between [0, 2^32-1)

template<class T >
T sofa::helper::RandomGenerator::symrand ( vmax)
inline

number between [-vmax, vmax] (vmax has less chance to appear)