Grid 0.7.0
g5HermitianLinop.h
Go to the documentation of this file.
1/*************************************************************************************
2
3 Grid physics library, www.github.com/paboyle/Grid
4
5 Source file: ./lib/qcd/action/fermion/g5HermitianLinop.h
6
7 Copyright (C) 2015
8
9Author: Peter Boyle <paboyle@ph.ed.ac.uk>
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License along
22 with this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24
25 See the full license in the file "LICENSE" in the top level distribution directory
26*************************************************************************************/
27/* END LEGAL */
28#ifndef G5_HERMITIAN_LINOP
29#define G5_HERMITIAN_LINOP
30
32
34// Wrap an already herm matrix
36template<class Matrix,class Field>
38 Matrix &_Mat;
39public:
41 void Op (const Field &in, Field &out){
42 HermOp(in,out);
43 }
44 void AdjOp (const Field &in, Field &out){
45 HermOp(in,out);
46 }
47 void OpDiag (const Field &in, Field &out) {
48 Field tmp(in.Grid());
49 _Mat.Mdiag(in,tmp);
50 G5R5(out,tmp);
51 }
52 void OpDir (const Field &in, Field &out,int dir,int disp) {
53 Field tmp(in.Grid());
54 _Mat.Mdir(in,tmp,dir,disp);
55 G5R5(out,tmp);
56 }
57 void OpDirAll(const Field &in, std::vector<Field> &out) {
58 Field tmp(in.Grid());
59 _Mat.MdirAll(in,out);
60 for(int p=0;p<out.size();p++) {
61 tmp=out[p];
62 G5R5(out[p],tmp);
63 }
64 }
65
66 void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){
67
68 HermOp(in,out);
69
70 ComplexD dot;
71 dot= innerProduct(in,out);
72 n1=real(dot);
73
74 dot = innerProduct(out,out);
75 n2=real(dot);
76 }
77 void HermOp(const Field &in, Field &out){
78 Field tmp(in.Grid());
79 _Mat.M(in,tmp);
80 G5R5(out,tmp);
81 }
82};
83
84
85template<class Matrix,class Field>
87 Matrix &_Mat;
89public:
90 Gamma5HermitianLinearOperator(Matrix &Mat): _Mat(Mat), g5(Gamma::Algebra::Gamma5) {};
91 void Op (const Field &in, Field &out){
92 HermOp(in,out);
93 }
94 void AdjOp (const Field &in, Field &out){
95 HermOp(in,out);
96 }
97 void OpDiag (const Field &in, Field &out) {
98 Field tmp(in.Grid());
99 _Mat.Mdiag(in,tmp);
100 out=g5*tmp;
101 }
102 void OpDir (const Field &in, Field &out,int dir,int disp) {
103 Field tmp(in.Grid());
104 _Mat.Mdir(in,tmp,dir,disp);
105 out=g5*tmp;
106 }
107 void OpDirAll(const Field &in, std::vector<Field> &out) {
108 _Mat.MdirAll(in,out);
109 for(int p=0;p<out.size();p++) {
110 out[p]=g5*out[p];
111 }
112 }
113
114 void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){
115
116 HermOp(in,out);
117
118 ComplexD dot;
119 dot= innerProduct(in,out);
120 n1=real(dot);
121
122 dot = innerProduct(out,out);
123 n2=real(dot);
124 }
125 void HermOp(const Field &in, Field &out){
126 Field tmp(in.Grid());
127 _Mat.M(in,tmp);
128 out=g5*tmp;
129 }
130};
131
133#endif
Lattice< vobj > real(const Lattice< vobj > &lhs)
ComplexD innerProduct(const Lattice< vobj > &left, const Lattice< vobj > &right)
void G5R5(Lattice< vobj > &z, const Lattice< vobj > &x)
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
std::complex< RealD > ComplexD
Definition Simd.h:79
double RealD
Definition Simd.h:61
void OpDiag(const Field &in, Field &out)
void AdjOp(const Field &in, Field &out)
void Op(const Field &in, Field &out)
void OpDir(const Field &in, Field &out, int dir, int disp)
void HermOp(const Field &in, Field &out)
void OpDirAll(const Field &in, std::vector< Field > &out)
void HermOpAndNorm(const Field &in, Field &out, RealD &n1, RealD &n2)
void AdjOp(const Field &in, Field &out)
void HermOpAndNorm(const Field &in, Field &out, RealD &n1, RealD &n2)
void Op(const Field &in, Field &out)
void OpDir(const Field &in, Field &out, int dir, int disp)
void OpDiag(const Field &in, Field &out)
void OpDirAll(const Field &in, std::vector< Field > &out)
void HermOp(const Field &in, Field &out)
Definition Gamma.h:10