Last change
on this file since 365 was
365,
checked in by Peter, 17 years ago
|
created a random namespace and moved random stuff to this namespace
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Id
|
File size:
467 bytes
|
Line | |
---|
1 | // $Id: Random.cc 365 2005-08-05 08:32:13Z peter $ |
---|
2 | |
---|
3 | #include <c++_tools/utility/Random.h> |
---|
4 | |
---|
5 | namespace theplu { |
---|
6 | namespace random { |
---|
7 | |
---|
8 | |
---|
9 | RNG* RNG::instance_ = NULL; |
---|
10 | |
---|
11 | |
---|
12 | RNG::RNG(void) |
---|
13 | { |
---|
14 | gsl_rng_env_setup(); |
---|
15 | rng_ = gsl_rng_alloc(gsl_rng_default); // Memory is allocated here! |
---|
16 | } |
---|
17 | |
---|
18 | |
---|
19 | |
---|
20 | RNG::~RNG(void) |
---|
21 | { |
---|
22 | gsl_rng_free(rng_); |
---|
23 | rng_=NULL; |
---|
24 | delete instance_; |
---|
25 | } |
---|
26 | |
---|
27 | |
---|
28 | |
---|
29 | RNG* RNG::instance(int seed) |
---|
30 | { |
---|
31 | if (!instance_) |
---|
32 | instance_ = new RNG(); |
---|
33 | return instance_; |
---|
34 | } |
---|
35 | |
---|
36 | |
---|
37 | }} // of namespace random and namespace theplu |
---|
Note: See
TracBrowser
for help on using the repository browser.