10 #ifndef QXS_AFIELD_INC_INCLUDED
11 #define QXS_AFIELD_INC_INCLUDED
17 #include "lib_alt_QXS/inline/define_vlen.h"
18 #include "lib_alt_QXS/inline/afield_th-inc.h"
22 template<
typename REALTYPE>
30 template<
typename REALTYPE>
39 template<
typename REALTYPE>
44 v.
axpy(exv, a, w, exw);
49 template<
typename REALTYPE>
59 template<
typename REALTYPE>
62 v.
axpy(real(a), imag(a), w);
67 template<
typename REALTYPE>
72 v.
axpy(ex, real(a), imag(a), w, ex_w);
77 template<
typename REALTYPE>
86 template<
typename REALTYPE>
89 v.
aypx(real(a), imag(a), w);
94 template<
typename REALTYPE>
102 template<
typename REALTYPE>
105 v.
scal(real(a), imag(a));
110 template<
typename REALTYPE>
118 template<
typename REALTYPE>
122 v.
dotc(vw_r, vw_i, w);
128 template<
class INDEX,
class AFIELD>
138 int ith, nth, is, ns;
139 set_threadtask(ith, nth, is, ns, Nvol);
143 for (
int ex = 0; ex < Nex; ++ex) {
144 for (
int site = is; site < ns; ++site) {
145 for (
int in = 0; in < Nin; ++in) {
146 int iw = in + Nin * (site + Nvol * ex);
147 int iv = index.idx(in, Nin, site, ex);
158 template<
class INDEX,
class AFIELD>
166 int ith, nth, is, ns;
167 set_threadtask(ith, nth, is, ns, Nvol);
171 for (
int ex = 0; ex < Nex; ++ex) {
172 for (
int site = is; site < ns; ++site) {
173 for (
int in = 0; in < Nin; ++in) {
174 int iw = in + Nin * (site + Nvol * ex);
175 int iv = index.idx(in, Nin, site, ex);
176 v.
set(iv,
double(w.
cmp(iw)));
186 template<
class INDEX,
class FIELD>
192 assert(v.check_size(Nin, Nvol, Nex));
196 assert(Nin == 2 * Nc * Nd);
198 int ith, nth, is, ns;
199 set_threadtask(ith, nth, is, ns, Nvol);
203 for (
int ex = 0; ex < Nex; ++ex) {
204 for (
int site = is; site < ns; ++site) {
205 for (
int id = 0;
id < Nd; ++id) {
206 for (
int ic = 0; ic < Nc; ++ic) {
207 int iwr = 2 * (ic + Nc * id) + Nin * (site + Nvol * ex);
208 int iwi = 1 + 2 * (ic + Nc * id) + Nin * (site + Nvol * ex);
209 int ivr = index.idx_SPr(ic,
id, site, ex);
210 int ivi = index.idx_SPi(ic,
id, site, ex);
211 v.e(ivr) = w.
cmp(iwr);
212 v.e(ivi) = w.
cmp(iwi);
223 template<
class INDEX,
class FIELD>
229 assert(v.check_size(Nin, Nvol, Nex));
232 assert(Nin == 2 * Nc * Nc);
234 int ith, nth, is, ns;
235 set_threadtask(ith, nth, is, ns, Nvol);
239 for (
int ex = 0; ex < Nex; ++ex) {
240 for (
int site = is; site < ns; ++site) {
241 for (
int ic2 = 0; ic2 < Nc; ++ic2) {
242 for (
int ic1 = 0; ic1 < Nc; ++ic1) {
243 int iwr = 2 * (ic1 + Nc * ic2) + Nin * (site + Nvol * ex);
244 int iwi = 1 + 2 * (ic1 + Nc * ic2) + Nin * (site + Nvol * ex);
245 int ivr = index.idx_Gr(ic1, ic2, site, ex);
246 int ivi = index.idx_Gi(ic1, ic2, site, ex);
247 v.e(ivr) = w.
cmp(iwr);
248 v.e(ivi) = w.
cmp(iwi);
259 template<
class INDEX2,
class FIELD2,
class INDEX1,
class FIELD1>
261 const INDEX1& index1,
const FIELD1& v1)
264 int Nvol = v1.nvol();
266 assert(v2.check_size(Nin, Nvol, Nex));
268 int ith, nth, is, ns;
271 set_threadtask(ith, nth, is, ns, Nvol /
VLENS);
272 for (
int ex = 0; ex < Nex; ++ex) {
273 for (
int vsite = is; vsite < ns; ++vsite) {
274 for (
int in = 0; in < Nin; ++in) {
275 for (
int vin = 0; vin <
VLENS; ++vin) {
276 int site =
VLENS * vsite + vin;
277 int iv1 = index1.idx(in, Nin, site, ex);
278 int iv2 = index2.idx(in, Nin, site, ex);
279 v2.e(iv2) = v1.cmp(iv1);
285 set_threadtask(ith, nth, is, ns, Nvol /
VLEND);
286 for (
int ex = 0; ex < Nex; ++ex) {
287 for (
int vsite = is; vsite < ns; ++vsite) {
288 for (
int in = 0; in < Nin; ++in) {
289 for (
int vin = 0; vin <
VLEND; ++vin) {
290 int site =
VLEND * vsite + vin;
291 int iv1 = index1.idx(in, Nin, site, ex);
292 int iv2 = index2.idx(in, Nin, site, ex);
293 v2.e(iv2) = v1.cmp(iv1);
306 template<
class INDEX2,
class FIELD2,
class INDEX1,
class FIELD1>
308 const INDEX1& index1,
const FIELD1& v1)
311 int Nvol = v1.nvol();
313 assert(v2.check_size(Nin, Nvol, Nex));
315 int ith, nth, is, ns;
317 set_threadtask(ith, nth, is, ns, Nvol /
VLENS);
318 for (
int ex = 0; ex < Nex; ++ex) {
319 for (
int vsite = is; vsite < ns; ++vsite) {
320 for (
int in = 0; in < Nin; ++in) {
321 for (
int vin = 0; vin <
VLENS; ++vin) {
322 int site =
VLENS * vsite + vin;
323 int iv1 = index1.idxh(in, Nin, site, ex);
324 int iv2 = index2.idxh(in, Nin, site, ex);
325 v2.e(iv2) = v1.cmp(iv1);
331 set_threadtask(ith, nth, is, ns, Nvol /
VLEND);
332 for (
int ex = 0; ex < Nex; ++ex) {
333 for (
int vsite = is; vsite < ns; ++vsite) {
334 for (
int in = 0; in < Nin; ++in) {
335 for (
int vin = 0; vin <
VLEND; ++vin) {
336 int site =
VLEND * vsite + vin;
337 int iv1 = index1.idxh(in, Nin, site, ex);
338 int iv2 = index2.idxh(in, Nin, site, ex);
339 v2.e(iv2) = v1.cmp(iv1);
351 template<
class INDEX,
class FIELD>
357 w.check_size(Nin, Nvol, Nex);
359 int ith, nth, is, ns;
360 set_threadtask(ith, nth, is, ns, Nvol);
364 for (
int ex = 0; ex < Nex; ++ex) {
365 for (
int site = is; site < ns; ++site) {
366 for (
int in = 0; in < Nin; ++in) {
367 int iv = in + Nin * (site + Nvol * ex);
368 int iw = index.idx(in, Nin, site, ex);
369 v.
set(iv,
double(w.cmp(iw)));
379 template<
class INDEX,
class FIELD>
385 w.check_size(Nin, Nvol, Nex);
389 assert(Nin == 2 * Nc * Nd);
391 int ith, nth, is, ns;
392 set_threadtask(ith, nth, is, ns, Nvol);
396 for (
int ex = 0; ex < Nex; ++ex) {
397 for (
int site = is; site < ns; ++site) {
398 for (
int id = 0;
id < Nd; ++id) {
399 for (
int ic = 0; ic < Nc; ++ic) {
400 int ivr = 2 * (ic + Nc * id) + Nin * (site + Nvol * ex);
401 int ivi = 1 + 2 * (ic + Nc * id) + Nin * (site + Nvol * ex);
402 int iwr = index.idx_SPr(ic,
id, site, ex);
403 int iwi = index.idx_SPi(ic,
id, site, ex);
404 v.
set(ivr,
double(w.cmp(iwr)));
405 v.
set(ivi,
double(w.cmp(iwi)));
416 template<
class INDEX,
class FIELD>
422 w.check_size(Nin, Nvol, Nex);
425 assert(Nin == 2 * Nc * Nc);
427 int ith, nth, is, ns;
428 set_threadtask(ith, nth, is, ns, Nvol);
432 for (
int ex = 0; ex < Nex; ++ex) {
433 for (
int site = is; site < ns; ++site) {
434 for (
int ic2 = 0; ic2 < Nc; ++ic2) {
435 for (
int ic1 = 0; ic1 < Nc; ++ic1) {
436 int ivr = 2 * (ic1 + Nc * ic2) + Nin * (site + Nvol * ex);
437 int ivi = 1 + 2 * (ic1 + Nc * ic2) + Nin * (site + Nvol * ex);
438 int iwr = index.idx_Gr(ic1, ic2, site, ex);
439 int iwi = index.idx_Gi(ic1, ic2, site, ex);
440 v.
set(ivr,
double(w.cmp(iwr)));
441 v.
set(ivi,
double(w.cmp(iwi)));
452 template<
typename REALTYPE>
462 template<
typename REALTYPE>
464 REALTYPE& v_norm2, REALTYPE& w_norm2,
469 assert(v.
nex() == w.
nex());
471 assert(v.
nin() == w.
nin());
477 #define AFIELD_HAS_DOTC_AND_NORM2