Bridge++  Ver. 1.1.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
randomNumbers_Mseries.h
Go to the documentation of this file.
1 
14 #ifndef RANDOMNUMBERS_MSERIES_INCLUDED
15 #define RANDOMNUMBERS_MSERIES_INCLUDED
16 
17 #include <assert.h>
18 #include <cmath>
19 #include <fstream>
20 #include <iostream>
21 #include <string>
22 
23 #include "randomNumbers.h"
24 #include "communicator.h"
25 
26 #include "bridgeIO.h"
27 using Bridge::vout;
28 
30 
47 {
48  protected:
50 
51  private:
52  static const int Np = 521, Nq = 32;
53  double Fnorm;
54  int w[Np];
55  int jr, kr;
56 
57  double sq2r;
58  double pi, pi2;
59 
60  public:
61  RandomNumbers_Mseries(const int ndelay)
62  {
63  Fnorm = 4.656612870908988e-10;
64  initset(ndelay);
65  }
66 
67  RandomNumbers_Mseries(const std::string filename)
68  {
69  Fnorm = 4.656612870908988e-10;
70  set_readfile(filename);
71  }
72 
73  double get()
74  {
75  w[jr] = w[jr] ^ w[kr];
76  double rw = w[jr] * Fnorm;
77  jr = jr + 1;
78  if (jr >= Np) jr = jr - Np;
79  kr = kr + 1;
80  if (kr >= Np) kr = kr - Np;
81  return rw;
82  }
83 
84  void writefile(const std::string);
85 
86  private:
87  void set_readfile(const std::string);
88 
89  void initset(const int ndelay);
90 
91  void delay3(const int ndelay);
92 };
93 #endif