[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] accessing random number generator from functions
From: |
Brian Gough |
Subject: |
Re: [Help-gsl] accessing random number generator from functions |
Date: |
Tue, 23 Nov 2004 17:25:40 +0000 |
Joakim Hove writes:
> Nathan Moore <address@hidden> writes:
>
> > This is a general question about the scope of random number
> > generators.
>
> A (gsl) random number generator is implemented as a struct, and %100
> normal scoping rules apply.
Just to add to Joakim's response, if you're writing traditional
single-threaded code and not worried about multi-threading you can
define the rng as a global variable.
gsl_rng * dice;
int main () {
...
dice = gsl_rng_alloc(...);
...
}
Then put "extern gsl_rng * dice" in your header files to access it from
other source files. This saves passing it around as an argument.
--
best regards
Brian Gough
Network Theory Ltd,
Commercial support for GSL --- http://www.network-theory.co.uk/gsl/