HepLib
IBP.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include "BASIC.h"
9 
13 namespace HepLib {
14 
15  using namespace std;
16  using namespace GiNaC;
17  using namespace HepLib;
18 
19  DECLARE_FUNCTION_1P(a)
20 
21 
24  class IBP {
25  public:
26  virtual ~IBP() { }
27  lst Internal;
28  lst External;
31  lst Integral; // lst of index lst
32  lst Cut; // index start from 1
33  lst DSP; // { {q1,q1}, {q1,p}, ... } Diff SP
34  lst ISP; // { q1*q1, q1*p } Independent SP
35  lst SECTOR; // highest sector
36  map<int,ex> Shift; // index start from 1
37  bool reCut = false;
38  string WorkingDir;
39  int ProblemNumber = 0;
40  lst PIntegral;
41 
42  lst MIntegral;
43  lst Rules;
44  bool IsAlwaysZero = false;
45 
46  virtual void Export() { throw Error("Export() not implemented!"); };
47  virtual void Run() { throw Error("Run() not implemented!"); };
48  virtual void Import() { throw Error("Import() not implemented!"); };
49  pair<exmap,lst> FindRules(bool mi=true);
50  bool IsZero(ex sector);
51  void Reduce();
52  void garExport(string garfn); // Export to .gar
53  void garImport(string garfn); // Import from .gar
54  ex TO(); // to single list for output
55  void FROM(ex s); // from a single expression
56  exmap SP2Pn();
57  exmap Dinv(const lst & ns);
58  ex D(const ex & x, const lst &ns);
59  void RM(bool keep_start_config=false);
60  void rm(const string & pat);
61 
62  static void ReShare(const vector<IBP*> & fs);
63  };
64 
68  class FIRE : public IBP {
69  public:
70  bool allIBP = false;
71  void Export() override;
72  void Run() override;
73  void Import() override;
74  int PosPref = 1;
75  int T1 = 4;
76  int LT1 = 2;
77  int T2 = 4;
78  int LT2 = 2;
79  string opt = "";
80  string Execute = InstallPrefix + "/FIRE/M/FIRE";
81  exmap NVariables;
82  static int Version;
83  static void RRTables(const string & filename, int pnum);
84  static void ThieleTables(const string & filename, int si, int ei);
85  };
86 
90  class KIRA : public IBP {
91  public:
92 
93  static string KArgs;
94 
95  int ra = 2;
96  int sa = 3;
97  int dmax = -1;
98 
99  void Export() override;
100  void Run() override;
101  void Import() override;
102 
103  private:
104  string Fout(const ex & expr);
105  ex Fin(const string & expr);
106  map<ex,unsigned long long,ex_is_less> i2w;
107  map<unsigned long long,ex> w2i;
108  };
109 
110 
114  class UKIRA : public IBP {
115  public:
116 
117  static string KArgs; // check kira --help
118 
119  bool using_uw = true;
120 
121  void Export() override;
122  void Run() override;
123  void Import() override;
124 
125  int ra = 1;
126  int sa = 1;
127  int rap = 1;
128  int sap = 1;
129  int sort_option = 0;
130  int seed_option = 0;
131 
132  private:
133  lst ibps;
134 
135  string Fout(const ex & expr);
136  ex Fin(const string & expr);
137  map<ex,unsigned long long,ex_is_less> i2w;
138  map<unsigned long long,ex> w2i;
139  };
140 
144  class Direct : public IBP {
145  public:
146  class Condition {
147  public:
148  vector<pair<int,int>> cs; // (1st==-1 for <=, 1st==1 for >=, 1st==0 for ==) 2nd
149  inline bool IsOK(ex ns) {
150  if(ns.nops() != cs.size()) return false;
151  for(int i=0; cs.size()-i>0; i++) {
152  if(cs[i].first==-1 && ns.op(i)>cs[i].second) return false;
153  else if(cs[i].first==1 && ns.op(i)<cs[i].second) return false;
154  else if(cs[i].first==0 && !ns.op(i).is_equal(cs[i].second)) return false;
155  }
156  return true;
157  }
158  inline ex cs2ex() {
159  lst ret;
160  for(auto item : cs) ret.append(lst{item.first, item.second});
161  return ret;
162  }
163  inline void ex2cs(ex e) {
164  cs.clear();
165  for(auto item : e) {
166  cs.push_back(make_pair(ex2int(item.op(0)), ex2int(item.op(1))));
167  }
168  }
169  };
170 
171  void Export() override;
172  void Run() override;
173  void Import() override;
174 
175  private:
176  lst ibps;
177  vector<pair<Condition,ex>> ConSolVec; // the conditional solution vector
178  };
179 
180  class Laporta : public IBP {
181 
182  public:
183 
184  bool using_uw = true;
185 
186  void Export() override;
187  void Run() override;
188  void Import() override;
189 
190  int ra = 1;
191  int sa = 1;
192  int rap = 1;
193  int sap = 1;
194  int sort_option = 0;
195  int seed_option = 1;
196 
197  private:
198  lst ibps;
199  int Round = 0;
200  lst _Integral;
201  lst _Rules;
202  lst RIntegral;
203 
204  string Fout(const ex & expr);
205  ex Fin(const string & expr);
206  map<ex,long long,ex_is_less> i2w;
207  map<long long,ex> w2i;
208 
209  };
210 
214  class Solver : public IBP {
215  public:
216  void Export() override;
217  void Run() override;
218  void Import() override;
219  void IBP();
220  void Solve(const ex & sector, const map<int,int> & a2n={});
221  void SolveSparse(const ex & sector, const map<int,int> & a2n={});
222  private:
223  lst IBPs;
224  };
225 
226  extern exmap MapPreSP;
227  exmap SortPermutation(const ex & in_expr, const lst & xs);
228  lst LoopUF(const IBP & fire, const ex & corner);
229  lst UF(const ex & ps, const ex & ns, const ex & loops, const ex & tloops, const ex & lsubs, const ex & tsubs);
230  pair<exmap,lst> FindRules(vector<IBP*> fs, bool mi=true, std::function<lst(const IBP &, const ex &)> uf=LoopUF);
231  inline pair<exmap,lst> FindRules(IBP& ibp, bool mi=true, std::function<lst(const IBP &, const ex &)> uf=LoopUF) {
232  vector<IBP*> fs;
233  fs.push_back(&ibp);
234  return FindRules(fs, mi, uf);
235  }
236 
237  ex GPolynomial(const IBP & IBP);
238  void GPermutation(const ex & uf, const lst & xs);
239 }
int * a
Definition: Functions.cpp:234
Basic header file.
bool IsOK(ex ns)
Definition: IBP.h:149
vector< pair< int, int > > cs
Definition: IBP.h:148
void ex2cs(ex e)
Definition: IBP.h:163
IBP reduction using Direc method.
Definition: IBP.h:144
class used to wrap error message
Definition: BASIC.h:242
IBP reduction using FIRE program.
Definition: IBP.h:68
static int Version
Definition: IBP.h:82
exmap NVariables
Definition: IBP.h:81
IBP base class for IBP reduction.
Definition: IBP.h:24
lst Internal
Definition: IBP.h:27
lst MIntegral
Definition: IBP.h:42
map< int, ex > Shift
Definition: IBP.h:36
lst PIntegral
Definition: IBP.h:40
lst ISP
Definition: IBP.h:34
lst Replacement
Definition: IBP.h:29
virtual void Export()
Definition: IBP.h:46
void Reduce()
lst DSP
Definition: IBP.h:33
lst Cut
Definition: IBP.h:32
lst Integral
Definition: IBP.h:31
lst External
Definition: IBP.h:28
lst Propagator
Definition: IBP.h:30
virtual void Import()
Definition: IBP.h:48
virtual ~IBP()
Definition: IBP.h:26
string WorkingDir
Definition: IBP.h:38
virtual void Run()
Definition: IBP.h:47
lst Rules
Definition: IBP.h:43
lst SECTOR
Definition: IBP.h:35
IBP reduction using KIRA program.
Definition: IBP.h:90
static string KArgs
Definition: IBP.h:93
IBP reduction using Solver method.
Definition: IBP.h:214
IBP reduction using KIRA program with user-defined equations.
Definition: IBP.h:114
static string KArgs
Definition: IBP.h:117
HepLib namespace.
Definition: BASIC.cpp:17
void GPermutation(const ex &uf, const lst &xs)
Definition: IBP.cpp:1022
ex GPolynomial(const IBP &ibp)
Definition: IBP.cpp:984
exmap MapPreSP
Definition: Init.cpp:335
void ReShare(const ex &e)
Definition: BASIC.cpp:2240
lst LoopUF(const IBP &ibp, const ex &idx)
UF function.
Definition: IBP.cpp:310
pair< exmap, lst > FindRules(vector< IBP * > fs, bool mi, std::function< lst(const IBP &, const ex &)> uf)
Find Rules for Integral or Master Integral.
Definition: IBP.cpp:566
lst UF(const ex &props, const ex &ns, const ex &loops, const ex &tloops, const ex &lsubs, const ex &tsubs)
UF function, from FIRE.m.
Definition: IBP.cpp:420
exmap SortPermutation(const ex &in_expr, const lst &xs)
Sort for all permuations, and return xs w.r.t. 1st permutation.
Definition: IBP.cpp:196
string InstallPrefix
Definition: Init.cpp:159
bool IsZero(const ex &e)
int ex2int(ex num)
ex to integer
Definition: BASIC.cpp:893