Added few convenience functions
This commit is contained in:
parent
cbfff8fda9
commit
462fbaad66
1 changed files with 20 additions and 0 deletions
|
|
@ -439,5 +439,25 @@ inline double eoRng::normal(void)
|
|||
return (var2 * factor);
|
||||
}
|
||||
|
||||
namespace eo {
|
||||
// a few convenience functions for generating numbers
|
||||
|
||||
/**
|
||||
* Templatized random function, works with most basic types such as:
|
||||
* char
|
||||
* int
|
||||
* unsigned
|
||||
* float
|
||||
* double
|
||||
*/
|
||||
template <typename T>
|
||||
inline
|
||||
T random(const T& mx) { return static_cast<T>(rng.uniform() * mx); }
|
||||
|
||||
/** Normal distribution */
|
||||
inline double normal() { return rng.normal(); }
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Reference in a new issue