Bridge++
Ver. 2.0.2
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/communicator.h
"
25
26
#include "
IO/bridgeIO.h
"
27
using
Bridge::vout
;
28
30
46
class
RandomNumbers_Mseries
:
public
RandomNumbers
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
static
constexpr
int
Np
= 521;
57
static
constexpr
int
Nq
= 32;
58
int
w
[
Np
];
59
int
jr
,
kr
;
60
61
double
sq2r
;
62
double
pi
,
pi2
;
63
64
public
:
65
RandomNumbers_Mseries
(
const
int
ndelay)
66
{
67
initset
(ndelay);
68
}
69
70
RandomNumbers_Mseries
(
const
std::string& filename)
71
{
72
read_file
(filename);
73
}
74
75
double
get
()
76
{
77
w
[
jr
] =
w
[
jr
] ^
w
[
kr
];
78
double
rw =
w
[
jr
] *
Fnorm
;
79
jr
=
jr
+ 1;
80
if
(
jr
>=
Np
)
jr
=
jr
-
Np
;
81
kr
=
kr
+ 1;
82
if
(
kr
>=
Np
)
kr
=
kr
-
Np
;
83
return
rw;
84
}
85
86
void
write_file
(
const
std::string&);
87
void
read_file
(
const
std::string&);
88
89
void
reset
(
unsigned
long
seed);
90
91
private
:
92
93
void
initset
(
const
int
ndelay);
94
95
void
delay3
(
const
int
ndelay);
96
97
#ifdef USE_FACTORY
98
private
:
99
static
RandomNumbers
*create_object_with_int(
const
int
& iseed)
100
{
101
return
new
RandomNumbers_Mseries
(iseed);
102
}
103
104
static
RandomNumbers
*create_object_with_file(
const
std::string& filename)
105
{
106
return
new
RandomNumbers_Mseries
(filename);
107
}
108
109
public
:
110
static
bool
register_factory()
111
{
112
bool
init1 = RandomNumbers::Factory_int::Register(
"Mseries"
, create_object_with_int);
113
bool
init2 = RandomNumbers::Factory_file::Register(
"Mseries"
, create_object_with_file);
114
115
return
init1 && init2;
116
}
117
#endif
118
};
119
#endif
bridgeIO.h
RandomNumbers_Mseries::pi2
double pi2
Definition:
randomNumbers_Mseries.h:62
randomNumbers.h
RandomNumbers_Mseries::class_name
static const std::string class_name
Definition:
randomNumbers_Mseries.h:52
RandomNumbers_Mseries::RandomNumbers_Mseries
RandomNumbers_Mseries(const int ndelay)
Definition:
randomNumbers_Mseries.h:65
RandomNumbers_Mseries::get
double get()
Definition:
randomNumbers_Mseries.h:75
RandomNumbers_Mseries::w
int w[Np]
Definition:
randomNumbers_Mseries.h:58
RandomNumbers
Base class of random number generators.
Definition:
randomNumbers.h:43
RandomNumbers_Mseries::delay3
void delay3(const int ndelay)
Definition:
randomNumbers_Mseries.cpp:78
RandomNumbers_Mseries::Nq
static constexpr int Nq
Definition:
randomNumbers_Mseries.h:57
RandomNumbers_Mseries::Np
static constexpr int Np
Definition:
randomNumbers_Mseries.h:56
RandomNumbers_Mseries::initset
void initset(const int ndelay)
Definition:
randomNumbers_Mseries.cpp:35
RandomNumbers_Mseries
Random number generator base on M-series.
Definition:
randomNumbers_Mseries.h:46
RandomNumbers_Mseries::reset
void reset(unsigned long seed)
reset state with new seed.
Definition:
randomNumbers_Mseries.cpp:28
RandomNumbers_Mseries::Fnorm
static const double Fnorm
initialized in .cpp file.
Definition:
randomNumbers_Mseries.h:49
RandomNumbers_Mseries::pi
double pi
Definition:
randomNumbers_Mseries.h:62
RandomNumbers_Mseries::write_file
void write_file(const std::string &)
Definition:
randomNumbers_Mseries.cpp:146
RandomNumbers_Mseries::RandomNumbers_Mseries
RandomNumbers_Mseries(const std::string &filename)
Definition:
randomNumbers_Mseries.h:70
RandomNumbers_Mseries::kr
int kr
Definition:
randomNumbers_Mseries.h:59
RandomNumbers_Mseries::sq2r
double sq2r
Definition:
randomNumbers_Mseries.h:61
communicator.h
RandomNumbers_Mseries::read_file
void read_file(const std::string &)
save and load random number status.
Definition:
randomNumbers_Mseries.cpp:171
Bridge::vout
BridgeIO vout
Definition:
bridgeIO.cpp:512
RandomNumbers_Mseries::jr
int jr
Definition:
randomNumbers_Mseries.h:59
src
lib
Tools
randomNumbers_Mseries.h
Generated on Sat Feb 10 2024 14:20:00 for Bridge++ by
1.8.17