NanoMagMC  v0.2
Monte Carlo Simulation Software for Atomistic Models of Magnetic Materials
stdrand.hpp
Go to the documentation of this file.
1 #ifndef _STDRAND
2 #define _STDRAND
3 
4 #include "xoroshiro128.hpp"
5 
6 #include <random>
7 
8 namespace stdrand
9 {
14  {
15  protected:
17  // std::mt19937_64 generator;
18  public:
32  void change_seed(int seed)
33  {
34  generator = rng::rng128(seed);
35  // generator.seed(seed);
36  }
40  virtual double gen(){return 0;}
44  void jump()
45  {
46  generator.jump();
47  // for(int i=0; i < 1e6; i++)
48  // {this->gen();}
49  }
50  };
51 
55  class std_d_unirand : public std_randbase
56  {
57  private:
58  std::uniform_real_distribution<double> distribution;
59  public:
65  std_d_unirand(int seed);
72  std_d_unirand(int size, int seed) : std_d_unirand(seed) {}
80  double gen(){return distribution(generator);}
81  };
82 
86  class std_i_unirand : public std_randbase
87  {
88  private:
89  std::uniform_int_distribution<int> distribution;
90  public:
96  std_i_unirand(int seed);
103  std_i_unirand(int size, int seed) : std_i_unirand(seed=seed) {}
111  double gen(){return distribution(generator);}
112  };
113 
117  class std_normrand : public std_randbase
118  {
119  private:
120  std::normal_distribution<double> distribution;
121  public:
130  std_normrand(double m, double sdin, int seed=1);
138  double gen(){return distribution(generator);}
139  };
140 
145  {
146  private:
147  std::lognormal_distribution<double> distribution;
148  public:
157  std_lognormrand(double m, double sdin, int seed);
167  std_lognormrand(double m, double sdin, int size, int seed)
168  : std_lognormrand(m, sdin, seed) {}
176  double gen(){return distribution(generator);}
177  };
178 }
179 
180 #endif
double gen()
Return a single random number.
Definition: stdrand.hpp:176
~std_i_unirand()
Default destructor.
Definition: stdrand.hpp:107
void jump()
Definition: xoroshiro128.hpp:166
Generator for uniform integers between 0 and 1.
Definition: stdrand.hpp:86
double gen()
Return a single random number.
Definition: stdrand.hpp:111
void jump()
Jump forward 2^64 places.
Definition: stdrand.hpp:44
std_d_unirand(int size, int seed)
Constructor with dummy size input.
Definition: stdrand.hpp:72
Definition: xoroshiro128.hpp:130
~std_normrand()
Default destructor.
Definition: stdrand.hpp:134
Generator for random numbers on a normal distribution.
Definition: stdrand.hpp:117
Definition: stdrand.hpp:8
std_i_unirand(int size, int seed)
Constructor with dummy size input.
Definition: stdrand.hpp:103
Generator for uniform numbers between 0 and 1.
Definition: stdrand.hpp:55
std_randbase()
Default constructor.
Definition: stdrand.hpp:22
Base class for the random number generators.
Definition: stdrand.hpp:13
virtual double gen()
Return a single random number.
Definition: stdrand.hpp:40
double gen()
Return a single random number.
Definition: stdrand.hpp:80
rng::rng128 generator
Definition: stdrand.hpp:16
Generator for random numbers on a lognormal distribution.
Definition: stdrand.hpp:144
double gen()
Return a single random number.
Definition: stdrand.hpp:138
~std_lognormrand()
Default destructor.
Definition: stdrand.hpp:172
std_lognormrand(double m, double sdin, int size, int seed)
Constructor with dummy size.
Definition: stdrand.hpp:167
~std_d_unirand()
Default destructor.
Definition: stdrand.hpp:76
~std_randbase()
Default destructor.
Definition: stdrand.hpp:26
void change_seed(int seed)
Change the current random seed.
Definition: stdrand.hpp:32