Grid 0.7.0
MobiusEOFAFermionssp.h
Go to the documentation of this file.
1/*************************************************************************************
2
3Grid physics library, www.github.com/paboyle/Grid
4
5Source file: ./lib/qcd/action/fermion/MobiusEOFAFermionssp.cc
6
7Copyright (C) 2017
8
9Author: Peter Boyle <pabobyle@ph.ed.ac.uk>
10Author: Peter Boyle <paboyle@ph.ed.ac.uk>
11Author: Peter Boyle <peterboyle@Peters-MacBook-Pro-2.local>
12Author: paboyle <paboyle@ph.ed.ac.uk>
13Author: David Murphy <dmurphy@phys.columbia.edu>
14
15This program is free software; you can redistribute it and/or modify
16it under the terms of the GNU General Public License as published by
17the Free Software Foundation; either version 2 of the License, or
18(at your option) any later version.
19
20This program is distributed in the hope that it will be useful,
21but WITHOUT ANY WARRANTY; without even the implied warranty of
22MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23GNU General Public License for more details.
24
25You should have received a copy of the GNU General Public License along
26with this program; if not, write to the Free Software Foundation, Inc.,
2751 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28
29See the full license in the file "LICENSE" in the top level distribution directory
30*************************************************************************************/
31 /* END LEGAL */
32
35
37
38// FIXME -- make a version of these routines with site loop outermost for cache reuse.
39// Pminus fowards
40// Pplus backwards
41template<class Impl>
42void MobiusEOFAFermion<Impl>::M5D(const FermionField& psi, const FermionField& phi,
43 FermionField& chi, Vector<Coeff_t>& lower, Vector<Coeff_t>& diag, Vector<Coeff_t>& upper)
44{
45 Coeff_t one(1.0);
46 int Ls = this->Ls;
47 for(int s=0; s<Ls; s++){
48 if(s==0) {
49 axpby_ssp_pminus(chi, diag[s], phi, upper[s], psi, s, s+1);
50 axpby_ssp_pplus (chi, one, chi, lower[s], psi, s, Ls-1);
51 } else if (s==(Ls-1)) {
52 axpby_ssp_pminus(chi, diag[s], phi, upper[s], psi, s, 0);
53 axpby_ssp_pplus (chi, one, chi, lower[s], psi, s, s-1);
54 } else {
55 axpby_ssp_pminus(chi, diag[s], phi, upper[s], psi, s, s+1);
56 axpby_ssp_pplus(chi, one, chi, lower[s], psi, s, s-1);
57 }
58 }
59}
60
61template<class Impl>
62void MobiusEOFAFermion<Impl>::M5D_shift(const FermionField& psi, const FermionField& phi,
63 FermionField& chi, Vector<Coeff_t>& lower, Vector<Coeff_t>& diag, Vector<Coeff_t>& upper,
64 Vector<Coeff_t>& shift_coeffs)
65{
66 Coeff_t one(1.0);
67 int Ls = this->Ls;
68 for(int s=0; s<Ls; s++){
69 if(s==0) {
70 axpby_ssp_pminus(chi, diag[s], phi, upper[s], psi, s, s+1);
71 axpby_ssp_pplus (chi, one, chi, lower[s], psi, s, Ls-1);
72 } else if (s==(Ls-1)) {
73 axpby_ssp_pminus(chi, diag[s], phi, upper[s], psi, s, 0);
74 axpby_ssp_pplus (chi, one, chi, lower[s], psi, s, s-1);
75 } else {
76 axpby_ssp_pminus(chi, diag[s], phi, upper[s], psi, s, s+1);
77 axpby_ssp_pplus(chi, one, chi, lower[s], psi, s, s-1);
78 }
79 if(this->pm == 1){ axpby_ssp_pplus(chi, one, chi, shift_coeffs[s], psi, s, Ls-1); }
80 else{ axpby_ssp_pminus(chi, one, chi, shift_coeffs[s], psi, s, 0); }
81 }
82}
83
84template<class Impl>
85void MobiusEOFAFermion<Impl>::M5Ddag(const FermionField& psi, const FermionField& phi,
86 FermionField& chi, Vector<Coeff_t>& lower, Vector<Coeff_t>& diag, Vector<Coeff_t>& upper)
87{
88 Coeff_t one(1.0);
89 int Ls = this->Ls;
90 for(int s=0; s<Ls; s++){
91 if(s==0) {
92 axpby_ssp_pplus (chi, diag[s], phi, upper[s], psi, s, s+1);
93 axpby_ssp_pminus(chi, one, chi, lower[s], psi, s, Ls-1);
94 } else if (s==(Ls-1)) {
95 axpby_ssp_pplus (chi, diag[s], phi, upper[s], psi, s, 0);
96 axpby_ssp_pminus(chi, one, chi, lower[s], psi, s, s-1);
97 } else {
98 axpby_ssp_pplus (chi, diag[s], phi, upper[s], psi, s, s+1);
99 axpby_ssp_pminus(chi, one, chi, lower[s], psi, s, s-1);
100 }
101 }
102}
103
104template<class Impl>
105void MobiusEOFAFermion<Impl>::M5Ddag_shift(const FermionField& psi, const FermionField& phi,
106 FermionField& chi, Vector<Coeff_t>& lower, Vector<Coeff_t>& diag, Vector<Coeff_t>& upper,
107 Vector<Coeff_t>& shift_coeffs)
108{
109 Coeff_t one(1.0);
110 int Ls = this->Ls;
111 for(int s=0; s<Ls; s++){
112 if(s==0) {
113 axpby_ssp_pplus (chi, diag[s], phi, upper[s], psi, s, s+1);
114 axpby_ssp_pminus(chi, one, chi, lower[s], psi, s, Ls-1);
115 } else if (s==(Ls-1)) {
116 axpby_ssp_pplus (chi, diag[s], phi, upper[s], psi, s, 0);
117 axpby_ssp_pminus(chi, one, chi, lower[s], psi, s, s-1);
118 } else {
119 axpby_ssp_pplus (chi, diag[s], phi, upper[s], psi, s, s+1);
120 axpby_ssp_pminus(chi, one, chi, lower[s], psi, s, s-1);
121 }
122 if(this->pm == 1){ axpby_ssp_pplus(chi, one, chi, shift_coeffs[s], psi, Ls-1, s); }
123 else{ axpby_ssp_pminus(chi, one, chi, shift_coeffs[s], psi, 0, s); }
124 }
125}
126
127template<class Impl>
128void MobiusEOFAFermion<Impl>::MooeeInv(const FermionField& psi, FermionField& chi)
129{
130 if(this->shift != 0.0){ MooeeInv_shift(psi,chi); return; }
131
132 Coeff_t one(1.0);
133 Coeff_t czero(0.0);
134 chi.Checkerboard() = psi.Checkerboard();
135 int Ls = this->Ls;
136
137 // Apply (L^{\prime})^{-1}
138 axpby_ssp(chi, one, psi, czero, psi, 0, 0); // chi[0]=psi[0]
139 for(int s=1; s<Ls; s++){
140 axpby_ssp_pplus(chi, one, psi, -this->lee[s-1], chi, s, s-1);// recursion Psi[s] -lee P_+ chi[s-1]
141 }
142
143 // L_m^{-1}
144 for(int s=0; s<Ls-1; s++){ // Chi[ee] = 1 - sum[s<Ls-1] -leem[s]P_- chi
145 axpby_ssp_pminus(chi, one, chi, -this->leem[s], chi, Ls-1, s);
146 }
147
148 // U_m^{-1} D^{-1}
149 for(int s=0; s<Ls-1; s++){
150 axpby_ssp_pplus(chi, one/this->dee[s], chi, -this->ueem[s]/this->dee[Ls-1], chi, s, Ls-1);
151 }
152 axpby_ssp(chi, one/this->dee[Ls-1], chi, czero, chi, Ls-1, Ls-1);
153
154 // Apply U^{-1}
155 for(int s=Ls-2; s>=0; s--){
156 axpby_ssp_pminus(chi, one, chi, -this->uee[s], chi, s, s+1); // chi[Ls]
157 }
158}
159
160template<class Impl>
161void MobiusEOFAFermion<Impl>::MooeeInv_shift(const FermionField& psi, FermionField& chi)
162{
163 Coeff_t one(1.0);
164 Coeff_t czero(0.0);
165 chi.Checkerboard() = psi.Checkerboard();
166 int Ls = this->Ls;
167
168 FermionField tmp(psi.Grid());
169
170 // Apply (L^{\prime})^{-1}
171 axpby_ssp(chi, one, psi, czero, psi, 0, 0); // chi[0]=psi[0]
172 axpby_ssp(tmp, czero, tmp, this->MooeeInv_shift_lc[0], psi, 0, 0);
173 for(int s=1; s<Ls; s++){
174 axpby_ssp_pplus(chi, one, psi, -this->lee[s-1], chi, s, s-1);// recursion Psi[s] -lee P_+ chi[s-1]
175 axpby_ssp(tmp, one, tmp, this->MooeeInv_shift_lc[s], psi, 0, s);
176 }
177
178 // L_m^{-1}
179 for(int s=0; s<Ls-1; s++){ // Chi[ee] = 1 - sum[s<Ls-1] -leem[s]P_- chi
180 axpby_ssp_pminus(chi, one, chi, -this->leem[s], chi, Ls-1, s);
181 }
182
183 // U_m^{-1} D^{-1}
184 for(int s=0; s<Ls-1; s++){
185 axpby_ssp_pplus(chi, one/this->dee[s], chi, -this->ueem[s]/this->dee[Ls-1], chi, s, Ls-1);
186 }
187 axpby_ssp(chi, one/this->dee[Ls-1], chi, czero, chi, Ls-1, Ls-1);
188
189 // Apply U^{-1} and add shift term
190 if(this->pm == 1){ axpby_ssp_pplus(chi, one, chi, this->MooeeInv_shift_norm[Ls-1], tmp, Ls-1, 0); }
191 else{ axpby_ssp_pminus(chi, one, chi, this->MooeeInv_shift_norm[Ls-1], tmp, Ls-1, 0); }
192 for(int s=Ls-2; s>=0; s--){
193 axpby_ssp_pminus(chi, one, chi, -this->uee[s], chi, s, s+1); // chi[Ls]
194 if(this->pm == 1){ axpby_ssp_pplus(chi, one, chi, this->MooeeInv_shift_norm[s], tmp, s, 0); }
195 else{ axpby_ssp_pminus(chi, one, chi, this->MooeeInv_shift_norm[s], tmp, s, 0); }
196 }
197}
198
199template<class Impl>
200void MobiusEOFAFermion<Impl>::MooeeInvDag(const FermionField& psi, FermionField& chi)
201{
202 if(this->shift != 0.0){ MooeeInvDag_shift(psi,chi); return; }
203
204 Coeff_t one(1.0);
205 Coeff_t czero(0.0);
206 chi.Checkerboard() = psi.Checkerboard();
207 int Ls = this->Ls;
208
209 // Apply (U^{\prime})^{-dagger}
210 axpby_ssp(chi, one, psi, czero, psi, 0, 0); // chi[0]=psi[0]
211 for(int s=1; s<Ls; s++){
212 axpby_ssp_pminus(chi, one, psi, -conjugate(this->uee[s-1]), chi, s, s-1);
213 }
214
215 // U_m^{-\dagger}
216 for(int s=0; s<Ls-1; s++){
217 axpby_ssp_pplus(chi, one, chi, -conjugate(this->ueem[s]), chi, Ls-1, s);
218 }
219
220 // L_m^{-\dagger} D^{-dagger}
221 for(int s=0; s<Ls-1; s++){
222 axpby_ssp_pminus(chi, one/conjugate(this->dee[s]), chi, -conjugate(this->leem[s]/this->dee[Ls-1]), chi, s, Ls-1);
223 }
224 axpby_ssp(chi, one/conjugate(this->dee[Ls-1]), chi, czero, chi, Ls-1, Ls-1);
225
226 // Apply L^{-dagger}
227 for(int s=Ls-2; s>=0; s--){
228 axpby_ssp_pplus(chi, one, chi, -conjugate(this->lee[s]), chi, s, s+1); // chi[Ls]
229 }
230}
231
232template<class Impl>
233void MobiusEOFAFermion<Impl>::MooeeInvDag_shift(const FermionField& psi, FermionField& chi)
234{
235 Coeff_t one(1.0);
236 Coeff_t czero(0.0);
237 chi.Checkerboard() = psi.Checkerboard();
238 int Ls = this->Ls;
239
240 FermionField tmp(psi.Grid());
241
242 // Apply (U^{\prime})^{-dagger} and accumulate (MooeeInvDag_shift_lc)_{j} \psi_{j} in tmp[0]
243 axpby_ssp(chi, one, psi, czero, psi, 0, 0); // chi[0]=psi[0]
244 axpby_ssp(tmp, czero, tmp, this->MooeeInvDag_shift_lc[0], psi, 0, 0);
245 for(int s=1; s<Ls; s++){
246 axpby_ssp_pminus(chi, one, psi, -conjugate(this->uee[s-1]), chi, s, s-1);
247 axpby_ssp(tmp, one, tmp, this->MooeeInvDag_shift_lc[s], psi, 0, s);
248 }
249
250 // U_m^{-\dagger}
251 for(int s=0; s<Ls-1; s++){
252 axpby_ssp_pplus(chi, one, chi, -conjugate(this->ueem[s]), chi, Ls-1, s);
253 }
254
255 // L_m^{-\dagger} D^{-dagger}
256 for(int s=0; s<Ls-1; s++){
257 axpby_ssp_pminus(chi, one/conjugate(this->dee[s]), chi, -conjugate(this->leem[s]/this->dee[Ls-1]), chi, s, Ls-1);
258 }
259 axpby_ssp(chi, one/conjugate(this->dee[Ls-1]), chi, czero, chi, Ls-1, Ls-1);
260
261 // Apply L^{-dagger} and add shift
262 if(this->pm == 1){ axpby_ssp_pplus(chi, one, chi, this->MooeeInvDag_shift_norm[Ls-1], tmp, Ls-1, 0); }
263 else{ axpby_ssp_pminus(chi, one, chi, this->MooeeInvDag_shift_norm[Ls-1], tmp, Ls-1, 0); }
264 for(int s=Ls-2; s>=0; s--){
265 axpby_ssp_pplus(chi, one, chi, -conjugate(this->lee[s]), chi, s, s+1); // chi[Ls]
266 if(this->pm == 1){ axpby_ssp_pplus(chi, one, chi, this->MooeeInvDag_shift_norm[s], tmp, s, 0); }
267 else{ axpby_ssp_pminus(chi, one, chi, this->MooeeInvDag_shift_norm[s], tmp, s, 0); }
268 }
269}
270
271#ifdef MOBIUS_EOFA_DPERP_LINALG
272
273INSTANTIATE_DPERP_MOBIUS_EOFA(WilsonImplF);
274INSTANTIATE_DPERP_MOBIUS_EOFA(WilsonImplD);
275INSTANTIATE_DPERP_MOBIUS_EOFA(GparityWilsonImplF);
276INSTANTIATE_DPERP_MOBIUS_EOFA(GparityWilsonImplD);
277INSTANTIATE_DPERP_MOBIUS_EOFA(ZWilsonImplF);
278INSTANTIATE_DPERP_MOBIUS_EOFA(ZWilsonImplD);
279
280INSTANTIATE_DPERP_MOBIUS_EOFA(WilsonImplFH);
281INSTANTIATE_DPERP_MOBIUS_EOFA(WilsonImplDF);
282INSTANTIATE_DPERP_MOBIUS_EOFA(GparityWilsonImplFH);
283INSTANTIATE_DPERP_MOBIUS_EOFA(GparityWilsonImplDF);
284INSTANTIATE_DPERP_MOBIUS_EOFA(ZWilsonImplFH);
285INSTANTIATE_DPERP_MOBIUS_EOFA(ZWilsonImplDF);
286
287#endif
288
std::vector< T, uvmAllocator< T > > Vector
#define one
Definition BGQQPX.h:108
GparityWilsonImpl< vComplexF, FundamentalRepresentation, CoeffReal > GparityWilsonImplF
GparityWilsonImpl< vComplexD, FundamentalRepresentation, CoeffReal > GparityWilsonImplD
Lattice< vobj > conjugate(const Lattice< vobj > &lhs)
void axpby_ssp_pplus(Lattice< vobj > &z, Coeff a, const Lattice< vobj > &x, Coeff b, const Lattice< vobj > &y, int s, int sp)
void axpby_ssp_pminus(Lattice< vobj > &z, Coeff a, const Lattice< vobj > &x, Coeff b, const Lattice< vobj > &y, int s, int sp)
void axpby_ssp(Lattice< vobj > &z, Coeff a, const Lattice< vobj > &x, Coeff b, const Lattice< vobj > &y, int s, int sp)
Definition LinalgUtils.h:59
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
WilsonImpl< vComplexF, FundamentalRepresentation, CoeffReal > WilsonImplF
Definition WilsonImpl.h:243
WilsonImpl< vComplexD, FundamentalRepresentation, CoeffComplex > ZWilsonImplD
Definition WilsonImpl.h:249
WilsonImpl< vComplexD, FundamentalRepresentation, CoeffReal > WilsonImplD
Definition WilsonImpl.h:244
WilsonImpl< vComplexF, FundamentalRepresentation, CoeffComplex > ZWilsonImplF
Definition WilsonImpl.h:248
void M5Ddag_shift(const FermionField &psi, const FermionField &phi, FermionField &chi, std::vector< Coeff_t > &lower, std::vector< Coeff_t > &diag, std::vector< Coeff_t > &upper, std::vector< Coeff_t > &shift_coeffs)
virtual void MooeeInv(const FermionField &in, FermionField &out)
virtual void MooeeInvDag_shift(const FermionField &in, FermionField &out)
virtual void M5D(const FermionField &psi, FermionField &chi)
virtual void MooeeInv_shift(const FermionField &in, FermionField &out)
virtual void M5Ddag(const FermionField &psi, FermionField &chi)
virtual void MooeeInvDag(const FermionField &in, FermionField &out)
void M5D_shift(const FermionField &psi, const FermionField &phi, FermionField &chi, std::vector< Coeff_t > &lower, std::vector< Coeff_t > &diag, std::vector< Coeff_t > &upper, std::vector< Coeff_t > &shift_coeffs)