Bridge++  Ver. 2.0.2
aindex_lex.h
Go to the documentation of this file.
1 
10 #ifndef QXS_AINDEX_LEX_INCLUDED
11 #define QXS_AINDEX_LEX_INCLUDED
12 
13 #include <string>
14 
16 
18 
19 #include "lib_alt_QXS/inline/define_vlen.h"
20 #include "lib_alt_QXS/inline/define_params.h"
21 
22 namespace AIndex_lex_qxs {
23  template<typename REALTYPE>
24  inline int idx(const int in, const int Nin, const int ist,
25  const int Nx, const int Ny, const int Nxv,
26  const int Nyv, const int Nstv, const int ex)
27  {
28  int ix = ist % Nx;
29  int iy = (ist / Nx) % Ny;
30  int kx = ix % VLENXD;
31  int ky = iy % VLENYD;
32  int k = kx + VLENXD * ky;
33  int ixv = ix / VLENXD;
34  int iyv = iy / VLENYD;
35  int izt = ist / (Nx * Ny);
36  int istv = ixv + Nxv * (iyv + Nyv * izt);
37  return k + VLEND * (in + Nin * (istv + Nstv * ex));
38  }
39 
40 
41  template<>
42  inline int idx<float>(const int in, const int Nin, const int ist,
43  const int Nx, const int Ny, const int Nxv,
44  const int Nyv, const int Nstv, const int ex)
45  {
46  int ix = ist % Nx;
47  int iy = (ist / Nx) % Ny;
48  int kx = ix % VLENXS;
49  int ky = iy % VLENYS;
50  int k = kx + VLENXS * ky;
51  int ixv = ix / VLENXS;
52  int iyv = iy / VLENYS;
53  int izt = ist / (Nx * Ny);
54  int istv = ixv + Nxv * (iyv + Nyv * izt);
55  return k + VLENS * (in + Nin * (istv + Nstv * ex));
56  }
57 
58 
59  template<typename REALTYPE>
60  inline int set_Nxv(const int Nx) { return Nx / VLENXD; }
61 
62  template<>
63  inline int set_Nxv<float>(const int Nx) { return Nx / VLENXS; }
64 
65  template<typename REALTYPE>
66  inline int set_Nyv(const int Ny) { return Ny / VLENYD; }
67 
68  template<>
69  inline int set_Nyv<float>(const int Ny) { return Ny / VLENYS; }
70 }
71 
73 
79 template<typename REALTYPE>
80 class AIndex_lex<REALTYPE, QXS>
81 {
82  protected:
83  int m_Nc, m_Nd, m_Ndf, m_Nvcd;
84  int m_Nx, m_Ny, m_Nz, m_Nt, m_Nst;
85  int m_Nxv, m_Nyv, m_Nzt, m_Nstv;
86 
87  public:
89  {
90  m_Nx = CommonParameters::Nx();
91  m_Ny = CommonParameters::Ny();
92  m_Nz = CommonParameters::Nz();
93  m_Nt = CommonParameters::Nt();
94  init_common();
95  }
96 
97  AIndex_lex(int Nx, int Ny, int Nz, int Nt)
98  {
99  m_Nx = Nx;
100  m_Ny = Ny;
101  m_Nz = Nz;
102  m_Nt = Nt;
103  init_common();
104  }
105 
106  private:
107  void init_common()
108  {
109  m_Nc = CommonParameters::Nc();
110  m_Nd = CommonParameters::Nd();
111  m_Ndf = 2 * m_Nc * m_Nc;
112  m_Nvcd = 2 * m_Nc * m_Nd;
113  m_Nst = m_Nx * m_Ny * m_Nz * m_Nt;
114  m_Nxv = AIndex_lex_qxs::set_Nxv<REALTYPE>(m_Nx);
115  m_Nyv = AIndex_lex_qxs::set_Nyv<REALTYPE>(m_Ny);
116  m_Nzt = m_Nz * m_Nt;
117  m_Nstv = m_Nxv * m_Nyv * m_Nzt;
118  }
119 
120  public:
121 
122  int site(const int x, const int y, const int z, const int t) const
123  { return x + m_Nx * (y + m_Ny * (z + m_Nz * t)); }
124 
125  int idx(const int in, const int Nin, const int ist, const int ex) const
126  {
127  return AIndex_lex_qxs::idx<REALTYPE>(in, Nin, ist, m_Nx, m_Ny,
128  m_Nxv, m_Nyv, m_Nstv, ex);
129  }
130 
131  int idx_G(const int idf, const int ist, const int ex) const
132  { return idx(idf, m_Ndf, ist, ex); }
133 
134  int idx_Gr(const int ic1, const int ic2, const int ist, const int ex) const
135  {
136  int idf = 2 * (ic2 + m_Nc * ic1);
137  return idx_G(idf, ist, ex);
138  }
139 
140  int idx_Gi(const int ic1, const int ic2, const int ist, const int ex) const
141  {
142  int idf = 1 + 2 * (ic2 + m_Nc * ic1);
143  return idx_G(idf, ist, ex);
144  }
145 
146  int idx_SP(const int in, const int ist, const int ex) const
147  { return idx(in, m_Nvcd, ist, ex); }
148 
149  int idx_SPr(const int ic, const int id, const int ist, const int ex) const
150  {
151  int in = 2 * (id + m_Nd * ic);
152  return idx_SP(in, ist, ex);
153  }
154 
155  int idx_SPi(const int ic, const int id, const int ist, const int ex) const
156  {
157  int in = 1 + 2 * (id + m_Nd * ic);
158  return idx_SP(in, ist, ex);
159  }
160 };
161 
162 #endif
CommonParameters::Ny
static int Ny()
Definition: commonParameters.h:106
CommonParameters::Nz
static int Nz()
Definition: commonParameters.h:107
VLEND
#define VLEND
Definition: define_vlen.h:42
AIndex_lex< REALTYPE, QXS >::m_Nvcd
int m_Nvcd
Definition: aindex_lex.h:83
AIndex_lex< REALTYPE, QXS >::m_Nzt
int m_Nzt
Definition: aindex_lex.h:85
AIndex_lex< REALTYPE, QXS >::AIndex_lex
AIndex_lex()
Definition: aindex_lex.h:88
AIndex_lex_qxs::set_Nyv
int set_Nyv(const int Ny)
Definition: aindex_lex.h:66
AIndex_lex
Definition: aindex_lex_base.h:17
AIndex_lex< REALTYPE, QXS >::idx_SPr
int idx_SPr(const int ic, const int id, const int ist, const int ex) const
Definition: aindex_lex.h:149
VLENYS
#define VLENYS
Definition: define_vlen.h:27
VLENS
#define VLENS
Definition: define_vlen.h:41
AIndex_lex_qxs::set_Nyv< float >
int set_Nyv< float >(const int Ny)
Definition: aindex_lex.h:69
AIndex_lex< REALTYPE, QXS >::init_common
void init_common()
Definition: aindex_lex.h:107
AIndex_lex< REALTYPE, QXS >::idx_SPi
int idx_SPi(const int ic, const int id, const int ist, const int ex) const
Definition: aindex_lex.h:155
AIndex_lex< REALTYPE, QXS >::idx_SP
int idx_SP(const int in, const int ist, const int ex) const
Definition: aindex_lex.h:146
CommonParameters::Nx
static int Nx()
Definition: commonParameters.h:105
AIndex_lex< REALTYPE, QXS >::site
int site(const int x, const int y, const int z, const int t) const
Definition: aindex_lex.h:122
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
AIndex_lex< REALTYPE, QXS >::idx_Gi
int idx_Gi(const int ic1, const int ic2, const int ist, const int ex) const
Definition: aindex_lex.h:140
CommonParameters::Nt
static int Nt()
Definition: commonParameters.h:108
AIndex_lex_qxs::set_Nxv
int set_Nxv(const int Nx)
Definition: aindex_lex.h:60
AIndex_lex_qxs::idx< float >
int idx< float >(const int in, const int Nin, const int ist, const int Nx, const int Ny, const int Nxv, const int Nyv, const int Nstv, const int ex)
Definition: aindex_lex.h:42
VLENXD
#define VLENXD
Definition: define_vlen.h:23
AIndex_lex< REALTYPE, QXS >::idx
int idx(const int in, const int Nin, const int ist, const int ex) const
Definition: aindex_lex.h:125
AIndex_lex< REALTYPE, QXS >::m_Nz
int m_Nz
Definition: aindex_lex.h:84
QXS
@ QXS
Definition: alt_impl.h:15
CommonParameters::Nd
static int Nd()
Definition: commonParameters.h:116
AIndex_lex_qxs::idx
int idx(const int in, const int Nin, const int ist, const int Nx, const int Ny, const int Nxv, const int Nyv, const int Nstv, const int ex)
Definition: aindex_lex.h:24
AIndex_lex_qxs::set_Nxv< float >
int set_Nxv< float >(const int Nx)
Definition: aindex_lex.h:63
AIndex_lex< REALTYPE, QXS >::idx_G
int idx_G(const int idf, const int ist, const int ex) const
Definition: aindex_lex.h:131
VLENYD
#define VLENYD
Definition: define_vlen.h:24
commonParameters.h
aindex_lex_base.h
AIndex_lex< REALTYPE, QXS >::idx_Gr
int idx_Gr(const int ic1, const int ic2, const int ist, const int ex) const
Definition: aindex_lex.h:134
AIndex_lex< REALTYPE, QXS >::AIndex_lex
AIndex_lex(int Nx, int Ny, int Nz, int Nt)
Definition: aindex_lex.h:97
VLENXS
#define VLENXS
Definition: define_vlen.h:26
AIndex_lex_qxs
Definition: aindex_lex.h:22