star-sp

Random number generators and distributions
git clone git://git.meso-star.fr/star-sp.git
Log | Files | Refs | README | LICENSE

commit 2779e45e6db1d2666472181a88ec1f8f5fbef14d
parent 543cf67f1416ff96ed4be215b044d9efda8c3913
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Thu, 26 Oct 2017 13:44:00 +0200

Add assert on param being > 0 for exponential distribution.

Diffstat:
Msrc/ssp_ran.c | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/ssp_ran.c b/src/ssp_ran.c @@ -49,7 +49,7 @@ cosf2sinf(const float d) double ssp_ran_exp(struct ssp_rng* rng, const double mu) { - ASSERT(rng); + ASSERT(rng && mu > 0); rng_cxx rng_cxx(*rng); RAN_NAMESPACE::exponential_distribution<double> distribution(mu); return distribution(rng_cxx); @@ -58,7 +58,7 @@ ssp_ran_exp(struct ssp_rng* rng, const double mu) float ssp_ran_exp_float(struct ssp_rng* rng, const float mu) { - ASSERT(rng); + ASSERT(rng && mu > 0); rng_cxx rng_cxx(*rng); RAN_NAMESPACE::exponential_distribution<float> distribution(mu); return distribution(rng_cxx); @@ -67,14 +67,14 @@ ssp_ran_exp_float(struct ssp_rng* rng, const float mu) double ssp_ran_exp_pdf(const double x, const double mu) { - ASSERT(x >= 0); + ASSERT(x >= 0 && mu > 0); return mu * exp(-x * mu); } float ssp_ran_exp_float_pdf(const float x, const float mu) { - ASSERT(x >= 0); + ASSERT(x >= 0 && mu > 0); return mu * expf(-x * mu); }