16 #ifdef USE_FACTORY_AUTOREGISTER
18 bool init = Source_Random::register_factory();
27 const string str_vlevel = params.
get_string(
"verbose_level");
32 std::vector<int> source_position;
33 std::vector<int> source_momentum;
34 string str_noise_type;
39 err += params.
fetch_string(
"noise_type", str_noise_type);
53 const std::vector<int>& source_momentum,
54 const string str_noise_type)
58 const int t_dir = Ndim - 1;
61 std::vector<int> Lsize(Ndim);
73 for (
int mu = 0; mu < Ndim; ++mu) {
75 mu, source_position[mu]);
78 for (
int mu = 0; mu < Ndim - 1; ++mu) {
80 mu, source_momentum[mu]);
88 for (
int mu = 0; mu < Ndim; ++mu) {
101 for (
int mu = 0; mu < Ndim; ++mu) {
128 std::vector<int> Nsize(Ndim);
151 const int idx_r = 2 * idx;
152 const int idx_i = 2 * idx + 1;
157 for (
int z = 0; z < Nsize[2]; ++z) {
158 for (
int y = 0; y < Nsize[1]; ++y) {
159 for (
int x = 0; x < Nsize[0]; ++x) {
162 double rn_r = v.
cmp(idx_r, site, 0);
163 double rn_i = v.
cmp(idx_i, site, 0);
166 src.
set(idx_r, site, 0, rn_r);
167 src.
set(idx_i, site, 0, rn_i);
182 const int Lvol3 = Lx * Ly * Lz;
188 for (
int site = 0; site < Nvol; ++site) {
189 src1_r += src.
cmp(idx_r, site, 0);
190 src1_i += src.
cmp(idx_i, site, 0);
196 const double src2 = src.
norm2() / Lvol3;
206 const int idx = i_color + Nc * i_spin;
219 std::vector<int> Nsize(Ndim);
245 for (
int z = 0; z < Nsize[2]; ++z) {
246 for (
int y = 0; y < Nsize[1]; ++y) {
247 for (
int x = 0; x < Nsize[0]; ++x) {
250 for (
int i_color = 0; i_color < Nc; ++i_color) {
251 int idx = i_color + Nc * i_spin;
253 int idx_i = 2 * idx + 1;
255 double rn_r = v.
cmp(idx_r, site, 0);
256 double rn_i = v.
cmp(idx_i, site, 0);
259 src.
set(idx_r, site, 0, rn_r);
260 src.
set(idx_i, site, 0, rn_i);
264 class_name.c_str(), rn_r, rn_i, idx, x, y, z);
276 const int Lvol3 = Lx * Ly * Lz;
284 for (
int site = 0; site < Nvol; ++site) {
285 for (
int idx = 0; idx < Nc * Nd; ++idx) {
287 int idx_i = 2 * idx + 1;
289 src1_r += src.
cmp(idx_r, site, 0);
290 src1_i += src.
cmp(idx_i, site, 0);
297 const double src2 = src.
norm2() / (Lvol3 * Nc * Nd);
311 std::vector<int> Nsize(Ndim);
337 for (
int z = 0; z < Nsize[2]; ++z) {
338 for (
int y = 0; y < Nsize[1]; ++y) {
339 for (
int x = 0; x < Nsize[0]; ++x) {
342 for (
int idx = 0; idx < Nc * Nd; ++idx) {
344 int idx_i = 2 * idx + 1;
346 double rn_r = v.
cmp(idx_r, site, 0);
347 double rn_i = v.
cmp(idx_i, site, 0);
350 src.
set(idx_r, site, 0, rn_r);
351 src.
set(idx_i, site, 0, rn_i);
355 class_name.c_str(), rn_r, rn_i, idx, x, y, z);
367 const int Lvol3 = Lx * Ly * Lz;
373 for (
int site = 0; site < Nvol; ++site) {
374 for (
int idx = 0; idx < Nc * Nd; ++idx) {
376 int idx_i = 2 * idx + 1;
378 src1_r += src.
cmp(idx_r, site, 0);
379 src1_i += src.
cmp(idx_i, site, 0);
386 const double src2 = src.
norm2() / (Lvol3 * Nc * Nd);
398 int Nvol = src.
nvol();
402 assert(Nin >= 2 * nc);
403 int nd = Nin / nc / 2;
408 Field v(2, Nvol, Nex);
422 for (
int ex = 0; ex < Nex; ++ex) {
423 for (
int site = 0; site < Nvol; ++site) {
424 for (
int ri = 0; ri < 2; ++ri) {
425 rn = v.
cmp(ri, site, ex);
426 for (
int id = 0;
id < nd; ++id) {
427 int in = ri + 2 * (ic + nc * id);
431 src.
set(in, site, ex, rn);
446 int Nvol = src.
nvol();
451 assert(Nin == 2 * nc * nd);
453 Field v(2, Nvol, Nex);
471 for (
int ex = 0; ex < Nex; ++ex) {
472 for (
int site = 0; site < Nvol; ++site) {
473 for (
int ri = 0; ri < 2; ++ri) {
474 int in = ri + 2 * (ic + nc * is);
475 rn = v.
cmp(ri, site, ex);
479 src.
set(in, site, ex, rn);
static const std::string class_name
void set(const int jin, const int site, const int jex, double v)
int site(const int &x, const int &y, const int &z, const int &t) const
void general(const char *format,...)
Container of Field-type object.
void set_all_color_spin(Field &src)
virtual void U1_lex_global(Field &)
U(1) random number defined on global lattice.
double cmp(const int jin, const int site, const int jex) const
static int ipe(const int dir)
logical coordinate of current proc.
int fetch_string(const string &key, string &value) const
virtual void gauss_lex_global(Field &)
gaussian random number defined on global lattice.
void set_all_space_time(Field &src, const int ic)
Setting a noise vector. Filling all the sites and spin indices for color index "ic". The same random number is set for all the spin indices at one site.
std::vector< int > m_source_position
std::string m_str_noise_type
void set_all_color(Field &src, const int i_spin)
void paranoiac(const char *format,...)
void crucial(const char *format,...)
std::vector< int > m_source_momentum
virtual void Z2_lex_global(Field &)
Z(2) random number defined on global lattice.
Bridge::VerboseLevel m_vl
int non_negative(const int v)
static int reduce_sum(int count, double *recv_buf, double *send_buf, int pattern=0)
make a global sum of an array of double over the communicator. pattern specifies the dimensions to be...
void set(Field &src, const int idx)
void set_parameters(const Parameters ¶ms)
string get_string(const string &key) const
int fetch_int_vector(const string &key, vector< int > &value) const
static VerboseLevel set_verbose_level(const std::string &str)