Bridge++  Ver. 2.0.2
randomNumbers.h
Go to the documentation of this file.
1 
14 #ifndef RANDOMNUMBERS_INCLUDED
15 #define RANDOMNUMBERS_INCLUDED
16 
17 #include "Field/field.h"
18 
19 #include "IO/bridgeIO.h"
20 using Bridge::vout;
21 
22 #ifdef USE_FACTORY
23 #include "Tools/factory.h"
24 #endif
25 
26 
28 
44 {
45  public:
46  static const std::string class_name;
47 
48  protected:
50 
51  public:
52 
54  : m_vl(CommonParameters::Vlevel()) {}
55 
56  virtual ~RandomNumbers() {}
57 
58  private:
59  // non-copyable
62 
63  public:
65 
66  virtual double get() = 0;
67 
68  void gauss(double& rand1, double& rand2);
69 
70 
71  virtual void lex_global(const std::string&, Field&);
72 
74  virtual void gauss_lex_global(Field&);
75 
77  virtual void uniform_lex_global(Field&);
78 
80  virtual void U1_lex_global(Field&);
81 
83  virtual void Z2_lex_global(Field&);
84 
85 
87  virtual void gauss_eo_global(Field&);
88 
89 
91  virtual void read_file(const std::string&) = 0;
92  virtual void write_file(const std::string&) = 0;
93 
95  virtual void reset(unsigned long seed) = 0;
96 
97 
98  protected:
100  {
101  public:
103  : m_rand_gauss(rand_gauss), m_ptr(f.ptr(0)), m_block(f.nin()) {}
104  void operator()(const bool do_fill);
105  size_t block_size() const;
106 
107  private:
109  double *m_ptr;
110  size_t m_block;
111  };
112 
114  {
115  public:
117  : m_rand_gauss(rand_gauss), m_ptr(f.ptr(0)), m_block(f.nin()) {}
118  void operator()(const bool do_fill);
119  size_t block_size() const;
120 
121  private:
123  double *m_ptr;
124  size_t m_block;
125  };
126 
128  {
129  public:
131  : m_rand_gauss(rand_gauss), m_ptr(f.ptr(0)), m_block(f.nin()) {}
132  void operator()(const bool do_fill);
133  size_t block_size() const;
134 
135  private:
137  double *m_ptr;
138  size_t m_block;
139  };
140 
141  private:
142  template<typename InnerGenerator>
143  void generate_global(Field& f);
144 
145 #ifdef USE_FACTORY
146  public:
147  typedef RandomNumbers *(*ProductCreator_int)(const int& iseed);
148  typedef RandomNumbers *(*ProductCreator_file)(const std::string& filename);
149 
152 
153  static RandomNumbers *New(const IdentifierType& subtype, const int& iseed)
154  {
155  ProductCreator_int p = Factory_int::Find(subtype);
156 
157  return p ? (*p)(iseed) : 0;
158  }
159 
160  static RandomNumbers *New(const IdentifierType& subtype, const std::string& filename)
161  {
162  ProductCreator_file p = Factory_file::Find(subtype);
163 
164  return p ? (*p)(filename) : 0;
165  }
166 
167 #ifdef USE_FACTORY_AUTOREGISTER
168 #else
169  static bool init_factory();
170 #endif
171 #endif
172 };
173 #endif
RandomNumbers::rand_gauss_even
Definition: randomNumbers.h:99
bridgeIO.h
RandomNumbers::rand_gauss_odd::operator()
void operator()(const bool do_fill)
Definition: randomNumbers.cpp:211
CommonParameters
Common parameter class: provides parameters as singleton.
Definition: commonParameters.h:42
RandomNumbers::rand_gauss_even::m_block
size_t m_block
Definition: randomNumbers.h:110
factory.h
RandomNumbers::read_file
virtual void read_file(const std::string &)=0
save and load random number status.
RandomNumbers::rand_uniform::m_block
size_t m_block
Definition: randomNumbers.h:138
RandomNumbers::class_name
static const std::string class_name
Definition: randomNumbers.h:46
RandomNumbers::rand_uniform::rand_uniform
rand_uniform(Field &f, RandomNumbers *rand_gauss)
Definition: randomNumbers.h:130
RandomNumbers::rand_gauss_even::operator()
void operator()(const bool do_fill)
Definition: randomNumbers.cpp:181
RandomNumbers::write_file
virtual void write_file(const std::string &)=0
RandomNumbers::gauss_eo_global
virtual void gauss_eo_global(Field &)
gaussian noise for even-odd perconditioned field (S.UEDA)
Definition: randomNumbers.cpp:169
RandomNumbers::lex_global
virtual void lex_global(const std::string &, Field &)
Definition: randomNumbers.cpp:77
RandomNumbers::rand_gauss_even::m_rand_gauss
RandomNumbers * m_rand_gauss
Definition: randomNumbers.h:108
RandomNumbers
Base class of random number generators.
Definition: randomNumbers.h:43
RandomNumbers::Z2_lex_global
virtual void Z2_lex_global(Field &)
Z(2) random number defined on global lattice.
Definition: randomNumbers.cpp:142
RandomNumbers::U1_lex_global
virtual void U1_lex_global(Field &)
U(1) random number defined on global lattice.
Definition: randomNumbers.cpp:113
RandomNumbers::rand_gauss_even::rand_gauss_even
rand_gauss_even(Field &f, RandomNumbers *rand_gauss)
Definition: randomNumbers.h:102
RandomNumbers::RandomNumbers
RandomNumbers()
Definition: randomNumbers.h:53
RandomNumbers::reset
virtual void reset(unsigned long seed)=0
reset state with new seed.
RandomNumbers::rand_uniform::operator()
void operator()(const bool do_fill)
Definition: randomNumbers.cpp:253
RandomNumbers::rand_uniform::m_rand_gauss
RandomNumbers * m_rand_gauss
Definition: randomNumbers.h:136
ParameterCheck::vl
Bridge::VerboseLevel vl
Definition: parameterCheck.cpp:18
RandomNumbers::get
virtual double get()=0
field.h
RandomNumbers::rand_uniform::block_size
size_t block_size() const
Definition: randomNumbers.cpp:267
RandomNumbers::rand_gauss_odd::rand_gauss_odd
rand_gauss_odd(Field &f, RandomNumbers *rand_gauss)
Definition: randomNumbers.h:116
FactoryTemplate
Definition: factory.h:42
RandomNumbers::rand_gauss_odd::block_size
size_t block_size() const
Definition: randomNumbers.cpp:246
RandomNumbers::rand_gauss_even::block_size
size_t block_size() const
Definition: randomNumbers.cpp:204
RandomNumbers::rand_gauss_odd::m_ptr
double * m_ptr
Definition: randomNumbers.h:123
RandomNumbers::set_parameter_verboselevel
void set_parameter_verboselevel(const Bridge::VerboseLevel vl)
Definition: randomNumbers.h:64
RandomNumbers::uniform_lex_global
virtual void uniform_lex_global(Field &)
uniform random number defined on global lattice.
Definition: randomNumbers.cpp:106
RandomNumbers::rand_uniform::m_ptr
double * m_ptr
Definition: randomNumbers.h:137
RandomNumbers::~RandomNumbers
virtual ~RandomNumbers()
Definition: randomNumbers.h:56
RandomNumbers::m_vl
Bridge::VerboseLevel m_vl
Definition: randomNumbers.h:49
RandomNumbers::rand_gauss_odd::m_rand_gauss
RandomNumbers * m_rand_gauss
Definition: randomNumbers.h:122
RandomNumbers::generate_global
void generate_global(Field &f)
Definition: randomNumbers.cpp:275
RandomNumbers::gauss
void gauss(double &rand1, double &rand2)
Definition: randomNumbers.cpp:62
RandomNumbers::rand_gauss_odd::m_block
size_t m_block
Definition: randomNumbers.h:124
Field
Container of Field-type object.
Definition: field.h:46
RandomNumbers::gauss_lex_global
virtual void gauss_lex_global(Field &)
gaussian random number defined on global lattice.
Definition: randomNumbers.cpp:95
RandomNumbers::rand_uniform
Definition: randomNumbers.h:127
Bridge::VerboseLevel
VerboseLevel
Definition: bridgeIO.h:42
RandomNumbers::rand_gauss_even::m_ptr
double * m_ptr
Definition: randomNumbers.h:109
RandomNumbers::rand_gauss_odd
Definition: randomNumbers.h:113
RandomNumbers::operator=
RandomNumbers & operator=(const RandomNumbers &)
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
IdentifierType
std::string IdentifierType
Definition: factory.h:39