random_number_generator.h
Go to the documentation of this file.
1 
40 #ifndef ARBITRARY_PRECISION_CALCULATION_RANDOM_NUMBER_GENERATOR_H_
41 #define ARBITRARY_PRECISION_CALCULATION_RANDOM_NUMBER_GENERATOR_H_
42 
43 #include <fstream>
44 #include <gmp.h>
45 #include <string>
46 
48 
53 public:
57  virtual ~RandomNumberGenerator();
63  virtual mpf_t* RandomMpft() = 0;
69  virtual long long RandomLongLong() = 0;
70 
76  virtual void LoadData(std::ifstream* input_stream) = 0;
83  virtual void StoreData(std::ofstream* output_stream) = 0;
89  virtual std::string GetName() = 0;
90 };
91 
97 public:
105  FastM2P63LinearCongruenceRandomNumberGenerator(unsigned long long multiplier, unsigned long long adder, unsigned long long seed);
113  mpf_t* RandomMpft();
124  long long RandomLongLong();
125 
126  void LoadData(std::ifstream*);
127  void StoreData(std::ofstream*);
128  std::string GetName();
129 
130 private:
131  const unsigned long long multiplier_;
132  const unsigned long long adder_;
133  const unsigned long long initial_seed_;
134  unsigned long long seed_;
135 };
136 
141 public:
150  IntenseM2P63LinearCongruenceRandomNumberGenerator(unsigned long long multiplier, unsigned long long adder, unsigned long long seed, int accept_bits);
159  mpf_t* RandomMpft();
170  long long RandomLongLong();
171 
172  void LoadData(std::ifstream*);
173  void StoreData(std::ofstream*);
174  std::string GetName();
175 
176 private:
177  const unsigned long long multiplier_;
178  const unsigned long long adder_;
179  const unsigned long long initial_seed_;
180  unsigned long long seed_;
181  int accept_bits_;
182 };
183 
188 public:
197  FastLinearCongruenceRandomNumberGenerator(unsigned long long multiplier, unsigned long long adder, unsigned long long modulus, unsigned long long seed);
205  mpf_t* RandomMpft();
216  long long RandomLongLong();
217 
218  void LoadData(std::ifstream*);
219  void StoreData(std::ofstream*);
220  std::string GetName();
221 
222 private:
223  unsigned long long multiplier_;
224  unsigned long long adder_;
225  unsigned long long modulus_;
226  const unsigned long long initial_seed_;
227  unsigned long long seed_;
228 };
229 
234 public:
243  IntenseLinearCongruenceRandomNumberGenerator(unsigned long long multiplier, unsigned long long adder, unsigned long long modulus, unsigned long long seed);
251  mpf_t* RandomMpft();
262  long long RandomLongLong();
263 
264  void LoadData(std::ifstream*);
265  void StoreData(std::ofstream*);
266  std::string GetName();
267 
268 private:
269  unsigned long long multiplier_;
270  unsigned long long adder_;
271  unsigned long long modulus_;
272  const unsigned long long initial_seed_;
273  unsigned long long seed_;
274 };
275 
276 } // namespace arbitraryprecisioncalculation
277 
278 #endif /* ARBITRARY_PRECISION_CALCULATION_RANDOM_NUMBER_GENERATOR_H_ */
virtual void LoadData(std::ifstream *input_stream)=0
Loads data to reset the state of the random number generator to the state which was stored...
virtual void StoreData(std::ofstream *output_stream)=0
Stores the current state of this random number generator, such that it can completely restore the cur...
virtual long long RandomLongLong()=0
Creates a random long long value.
This is a fast random number generator which uses linear congruences.
Definition: random_number_generator.h:187
virtual mpf_t * RandomMpft()=0
Creates a random mpf_t value in the interval [0,1].
This is a random number generator which uses linear congruences.
Definition: random_number_generator.h:233
base namespace for arbitrary precision calculation.
Definition: check_condition.h:45
This is a random number generator which uses linear congruences. It uses the modulus 263...
Definition: random_number_generator.h:140
This class is an abstract class. It supplies the interface for random number generators.
Definition: random_number_generator.h:52
This is a fast random number generator, which uses linear congruences. It uses the modulus 263...
Definition: random_number_generator.h:96
virtual std::string GetName()=0
Returns a string representation of this object.