Grid 0.7.0
ScalarObjs.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/utils/WilsonLoops.h
6
7 Copyright (C) 2015
8
9Author: neo <cossu@post.kek.jp>
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
26directory
27*************************************************************************************/
28/* END LEGAL */
29#ifndef SCALAR_OBJS_H
30#define SCALAR_OBJS_H
31
33
34// Scalar field obs
35template <class Impl>
36class ScalarObs {
37public:
39 // squared field
41
42 static void phisquared(typename Impl::Field &fsq,
43 const typename Impl::Field &f) {
44 fsq = f * f;
45 }
46
47 // phi^4 interaction term
49
50 static void phifourth(typename Impl::Field &fsq,
51 const typename Impl::Field &f) {
52 fsq = f * f * f * f;
53 }
54
56 // phi(x)phi(x+mu)
58
59 static void phider(typename Impl::Field &fsq,
60 const typename Impl::Field &f) {
61 fsq = Cshift(f, 0, -1) * f;
62 for (int mu = 1; mu < Nd; mu++) fsq += Cshift(f, mu, -1) * f;
63 }
64
66 // Vol sum of the previous obs.
68
69 static RealD sumphider(const typename Impl::Field &f) {
70 typename Impl::Field tmp(f.Grid());
71 tmp = Cshift(f, 0, -1) * f;
72 for (int mu = 1; mu < Nd; mu++) {
73 tmp += Cshift(f, mu, -1) * f;
74 }
75 return -sum(trace(tmp));
76 }
77
78 static RealD sumphisquared(const typename Impl::Field &f) {
79 typename Impl::Field tmp(f.Grid());
80 tmp = f * f;
81 return sum(trace(tmp));
82 }
83
84 static RealD sumphifourth(const typename Impl::Field &f) {
85 typename Impl::Field tmp(f.Grid());
86 phifourth(tmp, f);
87 return sum(trace(tmp));
88 }
89};
90
92
93#endif
auto Cshift(const Expression &expr, int dim, int shift) -> decltype(closure(expr))
Definition Cshift.h:55
accelerator_inline Grid_simd2< S, V > trace(const Grid_simd2< S, V > &arg)
vobj::scalar_object sum(const vobj *arg, Integer osites)
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
static constexpr int Nd
Definition QCD.h:52
double RealD
Definition Simd.h:61
static void phider(typename Impl::Field &fsq, const typename Impl::Field &f)
Definition ScalarObjs.h:59
static void phifourth(typename Impl::Field &fsq, const typename Impl::Field &f)
Definition ScalarObjs.h:50
static void phisquared(typename Impl::Field &fsq, const typename Impl::Field &f)
Definition ScalarObjs.h:42
static RealD sumphisquared(const typename Impl::Field &f)
Definition ScalarObjs.h:78
static RealD sumphider(const typename Impl::Field &f)
Definition ScalarObjs.h:69
static RealD sumphifourth(const typename Impl::Field &f)
Definition ScalarObjs.h:84