From 7fe2bc587a0173e9acc640f527fafe55bb95d502 Mon Sep 17 00:00:00 2001 From: Benjamin BOUVIER Date: Mon, 1 Oct 2012 22:23:07 -0400 Subject: [PATCH] eoRNG: added a clearCache() function for cleaning the normal() cached value --- eo/src/utils/eoRNG.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/eo/src/utils/eoRNG.h b/eo/src/utils/eoRNG.h index 78223c35..ce648cab 100644 --- a/eo/src/utils/eoRNG.h +++ b/eo/src/utils/eoRNG.h @@ -245,6 +245,18 @@ public : double normal(double mean, double stdev) { return mean + normal(stdev); } + /** + * @brief Forgets the last cached value of normal(), so as to be able to perform some repeatable calls to normal(). + * + * As normal() stores a cached value for performance purposes, sequences of pseudo random numbers can't be repeated + * when reseeding, since the cached value can be yield before a number is generated. To avoid that, this method + * allows one to clean the cache and force to regenerate a new pseudo random number. + */ + void clearCache() + { + cached = false; + } + /** Random numbers using a negative exponential distribution @param mean Mean value of distribution