source: trunk/lib/utility/Random.cc @ 362

Last change on this file since 362 was 362, checked in by Jari Häkkinen, 17 years ago

First usable minimal version of new Random.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 469 bytes
Line 
1// $Id: Random.cc 362 2005-08-04 22:22:23Z jari $
2
3#include <c++_tools/utility/Random.h>
4
5namespace theplu {
6namespace utility {
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 utility and namespace theplu
Note: See TracBrowser for help on using the repository browser.