Documentation of MARTY
A Modern ARtificial Theoretical phYsicist
wilson.h
Go to the documentation of this file.
1 // This file is part of MARTY.
2 //
3 // MARTY is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // MARTY is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with MARTY. If not, see <https://www.gnu.org/licenses/>.
15 
23 #ifndef WILSON_H_INCLUDED
24 #define WILSON_H_INCLUDED
25 
26 #include <csl.h>
27 #include "kinematics.h"
28 #include "cache.h"
29 #include "feynOptions.h"
30 
31 namespace mty {
32 
33 class Model;
34 class FermionCurrent;
35 class QuantumField;
36 
38 
39  public:
40 
41  WilsonCoefficient(csl::Expr const& t_coefficient);
42  WilsonCoefficient() = default;
43  WilsonCoefficient(WilsonCoefficient const&) = default;
45  WilsonCoefficient& operator=(WilsonCoefficient const& other) = default;
46  WilsonCoefficient& operator=(WilsonCoefficient&& other) = default;
47  ~WilsonCoefficient() = default;
48 
49  csl::Expr getCoefficient() const;
50  void setCoefficient(csl::Expr const& t_coefficient);
51 
52  private:
53 
54  csl::Expr coefficient;
55 };
56 
58 
59  public:
60 
61  WilsonOperator(csl::Expr const& t_op,
62  csl::Expr const& t_factor = CSL_1);
63  WilsonOperator() = default;
64  WilsonOperator(WilsonOperator const&) = default;
65  WilsonOperator(WilsonOperator&&) = default;
66  WilsonOperator& operator=(WilsonOperator const& other) = default;
67  WilsonOperator& operator=(WilsonOperator&& other) = default;
68  ~WilsonOperator() = default;
69 
70  csl::Expr getOp() const;
71  void setOp(csl::Expr const& t_op);
72 
73  csl::Expr getFactor() const;
74  void setFactor(csl::Expr const& t_factor);
75 
76  csl::Expr getExpression() const;
77  void setExpression(csl::Expr const& t_expression);
78 
79  static bool hardComparison(csl::Expr const& A,
80  csl::Expr const& B);
81 
82  bool operator< (WilsonOperator const& other) const;
83  bool operator==(WilsonOperator const& other) const;
84 
85  private:
86 
87  csl::Expr factor;
88  csl::Expr op;
89 };
90 
91 struct Wilson {
92 
93  WilsonCoefficient coef;
94  WilsonOperator op;
95 
96  bool isNull() const {
97  return coef.getCoefficient() == CSL_0
98  or op.getExpression() == CSL_0;
99  }
100 
101  void print(std::ostream& out = std::cout) const {
102  out << "Operator : " << std::endl;
103  out << "O = ";
104  op.getExpression()->print(0, out);
105  out << "C = ";
106  coef.getCoefficient()->print(0, out);
107  }
108 
109  csl::Expr getExpression() const {
110  return csl::prod_s({op.getFactor(), coef.getCoefficient(), op.getOp()});
111  }
112 
113  friend
114  std::ostream& operator<<(std::ostream& out,
115  Wilson const& wil) {
116  wil.print(out);
117  return out;
118  }
119 };
120 
121 struct WilsonSet: public std::vector<Wilson> {
122 
123  using std::vector<Wilson>::vector;
124 
125  WilsonSet(WilsonSet const &) = default;
126  WilsonSet(WilsonSet &&) = default;
127  WilsonSet &operator=(WilsonSet const &) = default;
128  WilsonSet &operator=(WilsonSet &&) = default;
129 
130  std::vector<csl::Expr> obtainExpressions() const {
131  std::vector<csl::Expr> res(size());
132  for (size_t i = 0; i != size(); ++i) {
133  res[i] = (*this)[i].getExpression();
134  }
135  return res;
136  }
137 
138  void merge(bool sorted = false);
139  void sort();
140  static void sort(std::vector<Wilson> &wilsons);
141  static void mergeSorted(std::vector<Wilson> &wilsons);
142 
143  Kinematics kinematics {};
144  FeynOptions options {};
145  std::vector<std::shared_ptr<wick::Graph>> graphs;
146 };
147 
148 std::vector<Wilson> copyWilsons(std::vector<Wilson> const &wilsons);
149 
150 inline Cache<
151  csl::Expr, // Key type
152  csl::Expr // Result type
153  > cachedWilson(
154  [](csl::Expr const &A, csl::Expr const &B) {
155  return (A == B) || csl::hardComparison(A, B);
156  });
157 
158 void parseStructures(
159  csl::Expr &arg,
160  std::vector<csl::Expr> &inOperator,
161  csl::IndexStructure &quantumStructure
162  );
163 
164 std::vector<csl::Expr> parseStructures(
165  csl::Expr& product
166  );
167 
168 std::vector<Wilson> cachedWilsonCalculation(
169  csl::Expr const& product,
170  csl::Expr const& operatorFactor,
171  Wilson res,
172  csl::Expr op,
173  bool standardBasis,
174  bool recursive
175  );
176 
177 std::vector<Wilson> sglSimplifyForWilson(
178  csl::Expr const &op,
179  csl::Expr const &operatorFactor,
180  Wilson res,
181  bool standardBasis,
182  bool recursive
183  );
184 
185 std::vector<Wilson> parseExpression(
186  csl::Expr const& product,
187  csl::Expr const& operatorFactor = CSL_1,
188  bool standardBasis = false,
189  bool recursive = false
190  );
191 
192 std::vector<Wilson> parseSum(
193  csl::Expr const& sum,
194  csl::Expr const& operatorFactor = CSL_1,
195  bool standardBasis = false,
196  bool recursive = false
197  );
198 
199 void addWilson(
200  Wilson const &wil,
201  std::vector<Wilson> &wilsons,
202  bool merge = true
203  );
204 
205 void addSortedWilson(
206  Wilson const &wil,
207  std::vector<Wilson> &wilsons
208  );
209 
210 WilsonSet match(
211  std::vector<csl::Expr> &amplitudes,
212  csl::Expr const &operatorFactor,
213  bool standardBasis = false,
214  bool squaredAfter = false
215  );
216 
217 }
218 
219 #endif
Definition: wilson.h:57
Definition: wilson.h:91
void sort(std::vector< Expr > &argument)
std::ostream & operator<<(std::ostream &fout, csl::Type type)
Namespace of MARTY.
Definition: 2HDM.h:31
Instances of this class can be given to mty::Model when launching a calculation to customize the outp...
Definition: feynOptions.h:44
Definition: wilson.h:121
Contains the mty::Kinematics class.
Stores insertion and momenta data and provides a simple interface to manipulate it.
Definition: kinematics.h:39
Contains the FeynOptions object used by the mty::Model class to set calculation options.
Definition: wilson.h:37
bool operator==(const Expr &a, const Expr &b)
Definition: cache.h:9