Grid 0.7.0
SchurDiagTwoKappa.h
Go to the documentation of this file.
1/*************************************************************************************
2
3 Grid physics library, www.github.com/paboyle/Grid
4
5 Source file: SchurDiagTwoKappa.h
6
7 Copyright (C) 2017
8
9Author: Christoph Lehner
10Author: Peter Boyle <paboyle@ph.ed.ac.uk>
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License along
23 with this program; if not, write to the Free Software Foundation, Inc.,
24 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25
26 See the full license in the file "LICENSE" in the top level distribution directory
27*************************************************************************************/
28/* END LEGAL */
29#pragma once
30
32
33// This is specific to (Z)mobius fermions
34template<class Matrix, class Field>
36public:
38 std::vector<Coeff_t> kappa, kappaDag, kappaInv, kappaInvDag;
39
40 KappaSimilarityTransform (Matrix &zmob) {
41 for (int i=0;i<(int)zmob.bs.size();i++) {
42 Coeff_t k = 1.0 / ( 2.0 * (zmob.bs[i] *(4 - zmob.M5) + 1.0) );
43 kappa.push_back( k );
44 kappaDag.push_back( conj(k) );
45 kappaInv.push_back( 1.0 / k );
46 kappaInvDag.push_back( 1.0 / conj(k) );
47 }
48 }
49
50 template<typename vobj>
51 void sscale(const Lattice<vobj>& in, Lattice<vobj>& out, Coeff_t* s) {
52 GridBase *grid=out.Grid();
53 out.Checkerboard() = in.Checkerboard();
54 assert(grid->_simd_layout[0] == 1); // should be fine for ZMobius for now
55 int Ls = grid->_rdimensions[0];
56 thread_for(ss, grid->oSites(),
57 {
58 vobj tmp = s[ss % Ls]*in[ss];
59 vstream(out[ss],tmp);
60 });
61 }
62
63 RealD sscale_norm(const Field& in, Field& out, Coeff_t* s) {
64 sscale(in,out,s);
65 return norm2(out);
66 }
67
68 virtual RealD M (const Field& in, Field& out) { return sscale_norm(in,out,&kappa[0]); }
69 virtual RealD MDag (const Field& in, Field& out) { return sscale_norm(in,out,&kappaDag[0]);}
70 virtual RealD MInv (const Field& in, Field& out) { return sscale_norm(in,out,&kappaInv[0]);}
71 virtual RealD MInvDag (const Field& in, Field& out) { return sscale_norm(in,out,&kappaInvDag[0]);}
72
73};
74
75template<class Matrix,class Field>
77public:
80
81 SchurDiagTwoKappaOperator (Matrix &Mat): _S(Mat), _Mat(Mat) {};
82
83 virtual RealD Mpc (const Field &in, Field &out) {
84 Field tmp(in.Grid());
85
86 _S.MInv(in,out);
87 _Mat.Mpc(out,tmp);
88 return _S.M(tmp,out);
89
90 }
91 virtual RealD MpcDag (const Field &in, Field &out){
92 Field tmp(in.Grid());
93
94 _S.MDag(in,out);
95 _Mat.MpcDag(out,tmp);
96 return _S.MInvDag(tmp,out);
97 }
98};
99
101
102
#define conj(a, b, i)
RealD norm2(const Lattice< vobj > &arg)
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
double RealD
Definition Simd.h:61
#define thread_for(i, num,...)
Definition Threads.h:60
int oSites(void) const
Coordinate _rdimensions
Coordinate _simd_layout
KappaSimilarityTransform(Matrix &zmob)
virtual RealD MInvDag(const Field &in, Field &out)
std::vector< Coeff_t > kappa
std::vector< Coeff_t > kappaInvDag
RealD sscale_norm(const Field &in, Field &out, Coeff_t *s)
virtual RealD MDag(const Field &in, Field &out)
virtual RealD MInv(const Field &in, Field &out)
virtual RealD M(const Field &in, Field &out)
void sscale(const Lattice< vobj > &in, Lattice< vobj > &out, Coeff_t *s)
std::vector< Coeff_t > kappaInv
std::vector< Coeff_t > kappaDag
accelerator_inline int Checkerboard(void) const
GridBase * Grid(void) const
virtual RealD Mpc(const Field &in, Field &out)
virtual RealD MpcDag(const Field &in, Field &out)
SchurDiagTwoOperator< Matrix, Field > _Mat
KappaSimilarityTransform< Matrix, Field > _S