* configure.ac: Check for srand48 and drand48.
* src/misc/random.cc (srand, drand): Use srand48 and drand48 if available.
This commit is contained in:
parent
5bcb6091fd
commit
4a7486bbff
3 changed files with 15 additions and 3 deletions
|
|
@ -1,5 +1,9 @@
|
||||||
2004-11-12 Alexandre Duret-Lutz <adl@src.lip6.fr>
|
2004-11-12 Alexandre Duret-Lutz <adl@src.lip6.fr>
|
||||||
|
|
||||||
|
* configure.ac: Check for srand48 and drand48.
|
||||||
|
* src/misc/random.cc (srand, drand): Use srand48 and drand48 if
|
||||||
|
available.
|
||||||
|
|
||||||
* src/tgbaalgos/randomgraph.cc, src/tgbaalgos/randomgraph.hh: New files.
|
* src/tgbaalgos/randomgraph.cc, src/tgbaalgos/randomgraph.hh: New files.
|
||||||
* src/tgbaalgos/Makefile.am (tgbaalgos_HEADERS)
|
* src/tgbaalgos/Makefile.am (tgbaalgos_HEADERS)
|
||||||
(libtgbaalgos_la_SOURCES): Add them.
|
(libtgbaalgos_la_SOURCES): Add them.
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ AX_CHECK_BUDDY
|
||||||
AX_CHECK_LBTT
|
AX_CHECK_LBTT
|
||||||
AX_CHECK_GSPNLIB
|
AX_CHECK_GSPNLIB
|
||||||
|
|
||||||
|
AC_CHECK_FUNCS([srand48 drand48])
|
||||||
|
|
||||||
AC_LIBTOOL_WIN32_DLL
|
AC_LIBTOOL_WIN32_DLL
|
||||||
AC_PROG_LIBTOOL
|
AC_PROG_LIBTOOL
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,24 +27,30 @@ namespace spot
|
||||||
void
|
void
|
||||||
srand(unsigned int seed)
|
srand(unsigned int seed)
|
||||||
{
|
{
|
||||||
|
#if HAVE_SRAND48 && HAVE_DRAND48
|
||||||
|
::srand48(seed);
|
||||||
|
#else
|
||||||
::srand(seed);
|
::srand(seed);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
drand()
|
drand()
|
||||||
{
|
{
|
||||||
|
#if HAVE_SRAND48 && HAVE_DRAND48
|
||||||
|
return ::drand48();
|
||||||
|
#else
|
||||||
double r = ::rand();
|
double r = ::rand();
|
||||||
return r / (1.0 + RAND_MAX);
|
return r / (1.0 + RAND_MAX);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
mrand(int max)
|
mrand(int max)
|
||||||
{
|
{
|
||||||
int res = static_cast<int>(max * drand());
|
return static_cast<int>(max * drand());
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
rrand(int min, int max)
|
rrand(int min, int max)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue