From 0bbcb7f35d4e009e73c096bd8a773dddcbc6e4b2 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Thu, 2 Nov 2017 10:21:45 +0100 Subject: [PATCH] random: remove bmrand() and prand() We do not need these functions in Spot. * spot/misc/random.cc, spot/misc/random.hh (bmrand, prand): Remove. * NEWS: Mention it. --- NEWS | 4 ++++ spot/misc/random.cc | 44 +------------------------------------------- spot/misc/random.hh | 15 +-------------- 3 files changed, 6 insertions(+), 57 deletions(-) diff --git a/NEWS b/NEWS index ed607fb64..2532f5c4a 100644 --- a/NEWS +++ b/NEWS @@ -158,6 +158,10 @@ New in spot 2.4.1.dev (not yet released) function also do not take to list of atomic propositions as an argument anymore. + - The spot::bmrand() and spot::prand() functions have been removed. + They were not used at all in Spot, and it's not Spot's objective + to provide such random functions. + Bugs fixed: - Automata produced by "genaut --ks-nca=N" were incorrectly marked diff --git a/spot/misc/random.cc b/spot/misc/random.cc index 7c30e979d..8bbe1a67f 100644 --- a/spot/misc/random.cc +++ b/spot/misc/random.cc @@ -1,5 +1,5 @@ // -*- coding: utf-8 -*- -// Copyright (C) 2011, 2012, 2013, 2014, 2015 Laboratoire de Recherche et +// Copyright (C) 2011-2015, 2017 Laboratoire de Recherche et // Développement de l'Epita (LRDE). // Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6), // département Systèmes Répartis Coopératifs (SRC), Université Pierre @@ -87,46 +87,4 @@ namespace spot else return t - (p / q); } - - double - bmrand() - { - static double next; - static bool has_next = false; - - if (has_next) - { - has_next = false; - return next; - } - - double x; - double y; - double r; - do - { - x = 2.0 * drand() - 1.0; - y = 2.0 * drand() - 1.0; - r = x * x + y * y; - } - while (r >= 1.0 || r == 0.0); - r = sqrt(-2 * log(r) / r); - next = y * r; - has_next = true; - return x * r; - } - - int - prand(double p) - { - double s = 0.0; - long x = 0; - - while (s < p) - { - s -= log(1.0 - drand()); - ++x; - } - return x - 1; - } } diff --git a/spot/misc/random.hh b/spot/misc/random.hh index 08fd59069..be0db2c1d 100644 --- a/spot/misc/random.hh +++ b/spot/misc/random.hh @@ -1,5 +1,5 @@ // -*- coding: utf-8 -*- -// Copyright (C) 2015 Laboratoire de Recherche et Développement +// Copyright (C) 2015, 2017 Laboratoire de Recherche et Développement // de l'Epita (LRDE). // Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6), // département Systèmes Répartis Coopératifs (SRC), Université Pierre @@ -66,13 +66,6 @@ namespace spot /// Statistics, 1974, vol 23, pp 96-97. SPOT_API double nrand(); - /// \brief Compute a pseudo-random double value - /// following a standard normal distribution. (Box-Muller) - /// - /// This uses the polar form of the Box-Muller transform - /// to generate random values. - SPOT_API double bmrand(); - /// \brief Compute pseudo-random integer value between 0 /// and \a n included, following a binomial distribution /// with probability \a p. @@ -113,12 +106,6 @@ namespace spot const double s_; }; - /// \brief Return a pseudo-random positive integer value - /// following a Poisson distribution with parameter \a p. - /// - /// \pre p > 0 - SPOT_API int prand(double p); - /// \brief Shuffle the container using mrand function above. /// This allows to get rid off shuffle or random_shuffle that use /// uniform_distribution and RandomIterator that are not portables.