klee
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RNG.h
Go to the documentation of this file.
1 //===-- RNG.h ---------------------------------------------------*- C++ -*-===//
2 //
3 // The KLEE Symbolic Virtual Machine
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef KLEE_UTIL_RNG_H
11 #define KLEE_UTIL_RNG_H
12 
13 namespace klee {
14  class RNG {
15  private:
16  /* Period parameters */
17  static const int N = 624;
18  static const int M = 397;
19  static const unsigned int MATRIX_A = 0x9908b0dfUL; /* constant vector a */
20  static const unsigned int UPPER_MASK = 0x80000000UL; /* most significant w-r bits */
21  static const unsigned int LOWER_MASK = 0x7fffffffUL; /* least significant r bits */
22 
23  private:
24  unsigned int mt[N]; /* the array for the state vector */
25  int mti;
26 
27  public:
28  RNG(unsigned int seed=5489UL);
29 
30  void seed(unsigned int seed);
31 
32  /* generates a random number on [0,0xffffffff]-interval */
33  unsigned int getInt32();
34  /* generates a random number on [0,0x7fffffff]-interval */
35  int getInt31();
36  /* generates a random number on [0,1]-real-interval */
37  double getDoubleLR();
38  float getFloatLR();
39  /* generates a random number on [0,1)-real-interval */
40  double getDoubleL();
41  float getFloatL();
42  /* generates a random number on (0,1)-real-interval */
43  double getDouble();
44  float getFloat();
45  /* generators a random flop */
46  bool getBool();
47  };
48 }
49 
50 #endif
Definition: RNG.h:14
static const int M
Definition: RNG.h:18
float getFloatL()
Definition: RNG.cpp:129
bool getBool()
Definition: RNG.cpp:138
static const int N
Definition: RNG.h:17
int mti
Definition: RNG.h:25
float getFloat()
Definition: RNG.cpp:133
static const unsigned int LOWER_MASK
Definition: RNG.h:21
unsigned int mt[N]
Definition: RNG.h:24
int getInt31()
Definition: RNG.cpp:103
double getDouble()
Definition: RNG.cpp:120
float getFloatLR()
Definition: RNG.cpp:125
static const unsigned int MATRIX_A
Definition: RNG.h:19
RNG(unsigned int seed=5489UL)
Definition: RNG.cpp:50
static const unsigned int UPPER_MASK
Definition: RNG.h:20
unsigned int getInt32()
Definition: RNG.cpp:69
void seed(unsigned int seed)
Definition: RNG.cpp:54
double getDoubleL()
Definition: RNG.cpp:114
double getDoubleLR()
Definition: RNG.cpp:108