From 462fbaad6625feca04ddcf61737785265139cd7c Mon Sep 17 00:00:00 2001 From: maartenkeijzer Date: Sun, 25 Sep 2005 19:32:10 +0000 Subject: [PATCH] Added few convenience functions --- eo/src/utils/eoRNG.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/eo/src/utils/eoRNG.h b/eo/src/utils/eoRNG.h index 6fe52e01..9821d6c8 100644 --- a/eo/src/utils/eoRNG.h +++ b/eo/src/utils/eoRNG.h @@ -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 + inline + T random(const T& mx) { return static_cast(rng.uniform() * mx); } + + /** Normal distribution */ + inline double normal() { return rng.normal(); } +} + + #endif