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.
This commit is contained in:
Alexandre Duret-Lutz 2017-11-02 10:21:45 +01:00
parent 74215eaa4a
commit 0bbcb7f35d
3 changed files with 6 additions and 57 deletions

View file

@ -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;
}
}