COPASI API  4.16.103
Cr250.h
Go to the documentation of this file.
1 /* Begin CVS Header
2  $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/randomGenerator/Cr250.h,v $
3  $Revision: 1.9 $
4  $Name: $
5  $Author: shoops $
6  $Date: 2006/07/21 18:15:48 $
7  End CVS Header */
8 
9 // Copyright 2005 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc. and EML Research, gGmbH.
11 // All rights reserved.
12 
13 /**
14  * Cr250 class implementing the R250 random number generator, by W. L. Maier
15  *
16  * Created for Copasi by Stefan Hoops
17  * (C) Stefan Hoops 2002
18  */
19 
20 #ifndef COPASI_Cr250
21 #define COPASI_Cr250
22 
23 class Cr250 : public CRandom
24  {
26  unsigned C_INT32 seed);
27 
28  // Attributes
29  private:
31 
32  unsigned C_INT32 mSeed;
33 
34  unsigned C_INT16 mBuffer[250];
35 
36  // Operations
37  private:
38  /**
39  * Default/Named constructor.
40  * Seeds the random number generator with the given seed.
41  * @param C_INT32 seed
42  */
43  Cr250(unsigned C_INT32 seed);
44 
45  public:
46  /**
47  * The destructor.
48  */
49  ~Cr250();
50 
51  /**
52  * Initialize or reinitialize the random number generator with
53  * the given seed.
54  * Note: seed = 12345 gives the default initilization as in W. L. Maier code
55  * @param unsigned C_INT32 seed (default system seed)
56  */
57  void initialize(unsigned C_INT32 seed = CRandom::getSystemSeed());
58 
59  /**
60  * Get a random number in 0 <= n <= Modulus
61  * @return unsigned C_INT32 random
62  */
63  unsigned C_INT32 getRandomU();
64 
65  /**
66  * Get a random number in 0 <= n <= (Modulus & 0x7ffffff)
67  * @return C_INT32 random
68  */
70 
71  /**
72  * Produces a uniformly distributed random number in 0 <= x <= 1.
73  * @return C_FLOAT64 random
74  */
76 
77  /**
78  * Produces a uniformly distributed random number in 0 <= x < 1.
79  * Note: 0 < x <= 1 may be achieved by 1.0 - getRandomCO().
80  * @return const C_FLOAT64 & random
81  */
83 
84  /**
85  * Produces a uniformly distributed random number in 0 < x < 1.
86  * @return const C_FLOAT64 & random
87  */
89 
90  private:
91  /**
92  * Number returned by r250() is in the interval 0 <= k <= 65535.
93  * @return unsigned C_INT32 random
94  */
95  unsigned C_INT32 r250(void);
96 
97  /**
98  * Number returned by r250() is in the interval 0 <= k < max.
99  * @param unsigned C_INT16 max
100  * @return unsigned C_INT32 random
101  */
102  unsigned C_INT32 r250n(const unsigned C_INT16 & max);
103 
104  /**
105  * Number returned by dr250() is in range [0,1)
106  * @return C_FLOAT64 random
107  */
108  C_FLOAT64 dr250(void);
109 
110  /**
111  * Linear congruent pseudorandom number generator for initialization.
112  * Return a pseudorandom number in the interval 0 <= n <= 32767.
113  */
114  unsigned C_INT16 myrand();
115  };
116 #endif // COPASI_Cr250
Definition: Cr250.h:23
C_FLOAT64 getRandomCO()
Definition: Cr250.cpp:106
static unsigned C_INT32 getSystemSeed()
Definition: CRandom.cpp:136
unsigned C_INT32 mSeed
Definition: Cr250.h:32
void initialize(unsigned C_INT32 seed=CRandom::getSystemSeed())
Definition: Cr250.cpp:63
unsigned C_INT32 r250n(const unsigned C_INT16 &max)
Definition: Cr250.cpp:131
C_INT32 getRandomS()
Definition: Cr250.cpp:100
C_FLOAT64 getRandomCC()
Definition: Cr250.cpp:103
C_FLOAT64 getRandomOO()
Definition: Cr250.cpp:109
#define C_INT32
Definition: copasi.h:90
~Cr250()
Definition: Cr250.cpp:61
C_FLOAT64 dr250(void)
Definition: Cr250.cpp:147
unsigned C_INT32 r250(void)
Definition: Cr250.cpp:112
Cr250(unsigned C_INT32 seed)
Definition: Cr250.cpp:54
static CRandom * createGenerator(CRandom::Type type=CRandom::mt19937, unsigned C_INT32 seed=0)
Definition: CRandom.cpp:49
#define C_INT16
Definition: copasi.h:91
C_INT32 mIndex
Definition: Cr250.h:30
unsigned C_INT16 mBuffer[250]
Definition: Cr250.h:34
unsigned C_INT16 myrand()
Definition: Cr250.cpp:153
#define C_FLOAT64
Definition: copasi.h:92
unsigned C_INT32 getRandomU()
Definition: Cr250.cpp:97
#define max(a, b)
Definition: f2c.h:176