MC_HAMR  v0.01
Monte Carlo Simulation Software for Atomistic Models of Magnetic Materials for Heat Assisted Magnetic Recording
mklrand.hpp
Go to the documentation of this file.
1 #ifndef _MKLRAND
2 #define _MKLRAND
3 
4 #include "mkl.h"
5 
6 namespace mklrand
7 {
12  {
13  protected:
14  int arr_size;
15  int curr;
16  VSLStreamStatePtr stream;
17  public:
25  ~mkl_randbase(){vslDeleteStream(&stream);}
29  virtual void fill(){}
35  void change_seed(int seed);
41  void save(const char* name) {vslSaveStreamF(stream, name);}
47  void load(const char* name) {vslDeleteStream(&stream); vslLoadStreamF(&stream, name);}
48  };
49 
53  class mkl_drand: public mkl_randbase
54  {
55  private:
56  double *randarr;
57 
58  public:
65  mkl_drand(int size, int seed=1);
69  ~mkl_drand();
73  double gen();
77  void fill();
78  };
79 
83  class mkl_irand: public mkl_randbase
84  {
85  private:
86  int *randarr;
87 
88  public:
95  mkl_irand(int size, int seed=1);
99  ~mkl_irand();
103  int gen();
107  void fill();
108  };
109 
113  class mkl_lnrand: public mkl_randbase
114  {
115  private:
116  double *randarr;
117  double lmean, lsd;
118 
119  public:
128  mkl_lnrand(double m, double sd, int size, int seed=1);
132  ~mkl_lnrand();
136  double gen();
140  void fill();
141  };
142 }
143 
144 #endif
Generator for random numbers on a lognormal distribution.
Definition: mklrand.hpp:113
void load(const char *name)
Load a random number generator state.
Definition: mklrand.hpp:47
Base class for the random number generators.
Definition: mklrand.hpp:11
~mkl_randbase()
Default destructor.
Definition: mklrand.hpp:25
void save(const char *name)
Save the state of the random number generator.
Definition: mklrand.hpp:41
VSLStreamStatePtr stream
Definition: mklrand.hpp:16
Generator for uniform numbers between 0 and 1.
Definition: mklrand.hpp:53
int curr
Definition: mklrand.hpp:15
int arr_size
Definition: mklrand.hpp:14
mkl_randbase()
Default constructor.
Definition: mklrand.hpp:21
virtual void fill()
Fill the buffer with new random numbers.
Definition: mklrand.hpp:29
Generator for uniform integers between 0 and 1.
Definition: mklrand.hpp:83
void change_seed(int seed)
Change the current random seed.
Definition: mklrand.hpp:6