Bridge++  Ver. 1.2.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  // static const double Fnorm = 4.656612870908988e-10;
49  static const double Fnorm;
50 
51  public:
52  static const std::string class_name;
53 
54  private:
55  static const int Np = 521, Nq = 32;
56  int w[Np];
57  int jr, kr;
58 
59  double sq2r;
60  double pi, pi2;
61 
62  public:
63  RandomNumbers_Mseries(const int ndelay)
64  {
65  initset(ndelay);
66  }
67 
68  RandomNumbers_Mseries(const std::string& filename)
69  {
70  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  void readfile(const std::string&);
86 
87  private:
88 
89  void initset(const int ndelay);
90 
91  void delay3(const int ndelay);
92 };
93 #endif
void readfile(const std::string &)
Random number generator base on M-series.
BridgeIO vout
Definition: bridgeIO.cpp:207
RandomNumbers_Mseries(const int ndelay)
void delay3(const int ndelay)
void initset(const int ndelay)
RandomNumbers_Mseries(const std::string &filename)
Base class of random number generators.
Definition: randomNumbers.h:40
static const double Fnorm
initialized in .cpp file.
void writefile(const std::string &)
static const std::string class_name