Commit e54ddd46 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

* misc/random.cc, misc/random.hh: New files.

* src/misc/Makefile.am (misc_HEADERS, libmisc_la_SOURCES): Add them.
parent 67e133ae
2004-11-12 Alexandre Duret-Lutz <adl@src.lip6.fr>
* misc/random.cc, misc/random.hh: New files.
* src/misc/Makefile.am (misc_HEADERS, libmisc_la_SOURCES): Add them.
2004-11-10 Alexandre Duret-Lutz <adl@src.lip6.fr>
* src/evtgbaparse/public.hh (evtgba_parse): Fix doxygen comments.
......
......@@ -33,6 +33,7 @@ misc_HEADERS = \
hash.hh \
minato.hh \
modgray.hh \
random.hh \
version.hh
noinst_LTLIBRARIES = libmisc.la
......@@ -43,4 +44,5 @@ libmisc_la_SOURCES = \
freelist.cc \
minato.cc \
modgray.cc \
random.cc \
version.cc
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
#include "random.hh"
#include <cstdlib>
namespace spot
{
void
srand(unsigned int seed)
{
::srand(seed);
}
double
drand()
{
double r = ::rand();
return r / (1.0 + RAND_MAX);
}
int
mrand(int max)
{
int res = static_cast<int>(max * drand());
return res;
}
int
rrand(int min, int max)
{
return min + static_cast<int>((max - min + 1) * drand());
}
}
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
namespace spot
{
/// \brief Reset the seed of the pseudo-random number generator.
///
/// \see drand, mrand, rrand
void srand(unsigned int seed);
/// \brief Compute a pseudo-random integer value between \a min and
/// \a max included.
///
/// \see drand, mrand, srand
int rrand(int min, int max);
/// \brief Compute a pseudo-random integer value between 0 and
/// \a max-1 included.
///
/// \see drand, rrand, srand
int mrand(int max);
/// \brief Compute a pseudo-random double value
/// between 0.0 and 1.0 (1.0 excluded).
///
/// \see mrand, rrand, srand
double drand();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment