15 #ifndef FIELD_INCLUDED
16 #define FIELD_INCLUDED
54 int myindex(
const int jin,
const int site,
const int jex)
const
56 return jin + m_Nin * (site + m_Nvol * jex);
64 m_Nin(0), m_Nvol(0), m_Nex(0), m_element_type(
COMPLEX),
72 m_Nin(Nin), m_Nvol(Nvol), m_Nex(Nex), m_element_type(cmpl),
81 return Field(m_Nin, m_Nvol, m_Nex, m_element_type);
84 void reset(
const int Nin,
const int Nvol,
const int Nex,
90 (m_element_type == cmpl))
return;
95 m_element_type = cmpl;
104 assert(m_Nin == v.
nin());
105 assert(m_Nvol == v.
nvol());
106 assert(m_Nex == v.
nex());
123 double cmp(
const int jin,
const int site,
const int jex)
const
125 return field[
myindex(jin, site, jex)];
128 double cmp(
const int i)
const
133 const double *
ptr(
const int jin,
const int site,
const int jex)
const
136 return &(
const_cast<std::valarray<double>&
>(
field)[
myindex(jin, site, jex)]);
139 double *
ptr(
const int jin,
const int site,
const int jex)
141 return &field[
myindex(jin, site, jex)];
144 const double *
ptr(
const int i)
const
147 return &(
const_cast<std::valarray<double>&
>(
field)[i]);
155 void set(
const int jin,
const int site,
const int jex,
double v)
157 field[
myindex(jin, site, jex)] = v;
160 void set(
const int i,
double v)
167 void add(
const int jin,
const int site,
const int jex,
double v)
169 field[
myindex(jin, site, jex)] += v;
172 void add(
const int i,
double v)
180 assert(exw < w.
nex());
186 return copy(*
this, ex, w, exw);
192 assert(exw < w.
nex());
198 return axpy(*
this, ex, 1.0, w, exw);
204 assert(exw < w.
nex());
211 return axpy(*
this, ex, prf, w, exw);
238 double norm2()
const;
246 double dot(
const Field& y,
const int exy,
const Field& x,
const int exx);
252 dcomplex
dotc(
const Field& y,
const int exy,
const Field& x,
const int exx);
258 void axpy(
Field& y,
const int exy,
const double a,
const Field& x,
const int exx);
264 void axpy(
Field& y,
const int exy,
const dcomplex a,
const Field& x,
const int exx);
270 void scal(
Field& x,
const int exx,
const double a);
276 void scal(
Field& x,
const int exx,
const dcomplex a);
282 void copy(
Field& y,
const int exy,
const Field& x,
const int exx);
296 void stat(
double& Fave,
double& Fmax,
double& Fdev)
const;
343 double dot(
const Field& y,
const int exy,
const Field& x,
const int exx);
350 dcomplex
dotc(
const Field& y,
const int exy,
const Field& x,
const int nexx);
356 void axpy(
Field& y,
const int exy,
const double a,
const Field& x,
const int exx);
363 void axpy(
Field& y,
const int exy,
const dcomplex a,
const Field& x,
const int exx);
369 void scal(
Field& x,
const int exx,
const double a);
376 void scal(
Field& x,
const int exx,
const dcomplex a);
382 void copy(
Field& y,
const int exy,
const Field& x,
const int exx);
void report_field_stat(const Bridge::VerboseLevel vl, const std::string &msg, const Field &f)
void scal(Field &x, const double a)
scal(x, a): x = a * x
friend void scal(Field &x, const double a)
scal(x, a): x = a * x
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
const double * ptr(const int jin, const int site, const int jex) const
void set(const int jin, const int site, const int jex, double v)
const double * ptr(const int i) const
double * ptr(const int i)
double * ptr(const int jin, const int site, const int jex)
Container of Field-type object.
Bridge::VerboseLevel m_vl
friend void copy(Field &y, const Field &x)
copy(y, x): y = x
double cmp(const int jin, const int site, const int jex) const
friend void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Field & operator=(const Field &v)
void addpart_ex(int ex, const Field &w, int exw)
static int send_1to1(int count, double *recv_buf, double *send_buf, int p_to, int p_from, int tag)
send array of double from rank p_from to rank p_to. communication distinguished by tag...
friend double dot(const Field &y, const Field &x)
void addpart_ex(int ex, const Field &w, int exw, double prf)
element_type m_element_type
void aypx(const double a, Field &y, const Field &x)
aypx(y, a, x): y := a * y + x
void set(const int i, double v)
friend dcomplex dotc(const Field &y, const Field &x)
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=COMPLEX)
dcomplex dotc(const Field &y, const Field &x)
static int exchange(int count, double *recv_buf, double *send_buf, int idir, int ipm, int tag)
receive array of double from upstream specified by idir and ipm, and send array to downstream...
Common parameter class: provides parameters as singleton.
double dot(const Field &y, const Field &x)
std::valarray< double > field
void add(const int i, double v)
int send_1to1(int count, Field *recv_buf, Field *send_buf, int p_to, int p_from, int tag)
friend void aypx(const double a, Field &y, const Field &x)
aypx(y, a, x): y := a * y + x
Field(const int Nin, const int Nvol, const int Nex, const element_type cmpl=COMPLEX)
element_type field_element_type() const
void add(const int jin, const int site, const int jex, double v)
void stat(double &Fave, double &Fmax, double &Fdev) const
determines the statistics of the field. average, maximum value, and deviation is determined over glob...
void copy(Field &y, const Field &x)
copy(y, x): y = x
void setpart_ex(int ex, const Field &w, int exw)
int myindex(const int jin, const int site, const int jex) const
int exchange(int count, Field *recv_buf, Field *send_buf, int idir, int ipm, int tag)
double cmp(const int i) const