[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-gsl] gsl_ran_flat: bug or improper usage ?
From: |
Brad Bell |
Subject: |
[Bug-gsl] gsl_ran_flat: bug or improper usage ? |
Date: |
Thu, 14 Dec 2006 12:53:52 -0800 (PST) |
I seem to be getting some strange results when I use gsl_ran_flat on some
systems (and not on other systems). The attached bash script extracts a c
program, compiles it and runs it twice: once using gsl_rng_uniform and then
using gsl_ran_flat. In the case where gsl_ran_flat is used, the value gamma, on
some systems, comes out as nan, and on other systems comes out as 1 (as it
should be).
Here are the results I get with Fedora:
gcc -g gsl_ran_flat.c -L/usr/lib -lgsl -lgslcblas -lm -o gsl_ran_flat
./gsl_ran_flat uniform
gamma = 1.000000
./gsl_ran_flat flat
gamma = nan
gsl-config --version
1.7
uname -sr
Linux 2.6.17-1.2174_FC5
rpm -q gsl
gsl-1.7-1.2.1
cat /etc/redhat-release
Fedora Core release 5 (Bordeaux)
Here are the results I get with Cygwin
gcc -g gsl_ran_flat.c -L/usr/lib -lgsl -lgslcblas -lm -o gsl_ran_flat
Info: resolving _gsl_rng_default by linking to __imp__gsl_rng_default
(auto-import)
./gsl_ran_flat uniform
gamma = 1.000000
./gsl_ran_flat flat
gamma = 1.000000
gsl-config --version
1.7
uname -sr
CYGWIN_NT-5.0 1.5.19(0.150/4/2)
I am including a copy of the c program below for your inspection:
# include <stdio.h>
# include <gsl/gsl_rng.h>
# include <string.h>
int main(int argc, char *argv[])
{ size_t i;
int uniform;
int flat;
double gamma;
double w[] = {1., 2.};
uniform = strcmp(argv[1], "uniform") == 0;
flat = strcmp(argv[1], "flat") == 0;
// initialize random number generator
const gsl_rng_type *T;
gsl_rng_env_setup();
T = gsl_rng_default;
gsl_rng *rng = gsl_rng_alloc(T);
for(i = 1; i < 7; i++)
{
if( uniform )
gsl_rng_uniform(rng);
if( flat )
gsl_ran_flat(rng, 0., 1.);
}
gamma = w[0] + 0. * w[1];
printf("gamma = %f\n", gamma);
gsl_rng_free(rng);
return 0;
}
gsl_ran_flat.sh
Description: Bourne shell script
- [Bug-gsl] gsl_ran_flat: bug or improper usage ?,
Brad Bell <=