87If[Length[$ScriptCommandLine]<2, Print["Usage: wolframescript -f "<>ToString[$ScriptCommandLine[[1]]]<>" <n>"];Quit[]];
88current = DirectoryName@If[$FrontEnd===Null,$InputFileName,NotebookFileName[]];
92SetReductionOptions["IBPReducer"->"Blade"];
93ID = ToExpression[$ScriptCommandLine[[2]]];
94PropsInts=Get[FileNameJoin[{current,ToString[ID]<>".m"}]];
96AMFlowInfo["Family"] = Symbol["I"<>ToString[ID]];
97AMFlowInfo["Loop"] = <<Loop>>;
98AMFlowInfo["Leg"] = <<Leg>>;
99AMFlowInfo["Conservation"] = { };
100AMFlowInfo["Replacement"] = <<Replacement>>;
101AMFlowInfo["Propagator"] = PropsInts[[1]]/.<<M2M2>>;
102AMFlowInfo["Numeric"] = <<Numeric>>;
103AMFlowInfo["NThread"] = <<NThread>>;
105integrals = Map[(j[Symbol["I"<>ToString[ID]], Sequence@@#])&, PropsInts[[2]]];
106precision = <<Precision>>;
107epsorder = 2*Length@AMFlowInfo["Loop"]-PropsInts[[3]] + <<Order>>;
108sol = SolveIntegrals[integrals, precision, epsorder];
109Put[sol, FileNameJoin[{current, "sol"<>ToString[ID]<>".m"}]];
134 system((
"mkdir -p "+dir).c_str());
140 cout <<
"Replacing linear propagators ..." << endl;
143 find(res, F(
w1,
w2), pq_fs);
145 for(
auto f : pq_fs) {
146 lst ps = ex_to<lst>(f.op(0));
147 lst ns = ex_to<lst>(f.op(1));
149 for(
int i=0; i<ps.nops(); i++) {
152 if(ps.op(i).has(ip*ip)) {
159 if(!is_a<mul>(pi) || !pi.nops()==2) {
160 cout <<
"prop: " << pi << endl;
161 cout <<
"prop is NOT the form of a*b" << endl;
167 }
else if(ns.op(i)!=0) {
169 cout <<
"n of qi.pi is NOT -1" << endl;
172 auto pa = pi.op(0), pb = pi.op(1);
175 bool ic = is_complete(ps, sp2x);
176 if(!ic && is_loop(pa)) {
178 ic = is_complete(ps, sp2x);
180 if(!ic && is_loop(pb)) {
182 ic = is_complete(ps, sp2x);
185 cout <<
"1st: ic is NOT true!" << endl;
194 }
else if(ns_p.nops()>0) {
195 auto idx =
ex2int(ns_p.op(0));
197 auto pidx = ps.op(idx);
204 bool ic = is_complete(ps, sp2x);
205 if(!ic && is_loop(pa)) {
207 ic = is_complete(ps, sp2x);
209 if(!ic && is_loop(pb)) {
211 ic = is_complete(ps, sp2x);
214 cout <<
"2nd: ic is NOT true!" << endl;
218 auto xps =
subs(ps,sp2x);
219 auto xpidx = pidx.subs(sp2x);
222 cout <<
"xps still has ip" << endl;
223 cout <<
"xps: " << xps << endl;
227 cout <<
"xpidx still has ip" << endl;
228 cout <<
"xpidx: " << xpidx << endl;
233 ex xeq = 0, eq = 0, fres = 0;
235 for(
int ii=0; ii<ps.nops(); ii++) {
237 xeq += yi*xps.op(ii);
240 nn[ii] = ns.op(ii)-1;
241 fres += yi*F(ps, nn);
245 for(
int ii=0; ii<ps.nops(); ii++) {
247 eqs.append(xeq.coeff(xi)==xpidx.coeff(xi));
249 auto sol = lsolve(eqs,ys);
251 if(sol.nops()<1 || sol.has(x(
w))) {
252 cout <<
"wrong sol: " << sol << endl;
255 auto rem = pidx-eq.subs(sol);
256 fres = fres.subs(sol);
258 fres += rem * F(ps, ns);
264 cout <<
"Failed: chk=" << chk << endl;
266 }
else if(!f.op(0).is_equal(ps)) {
267 pq_f2f[f] = F(ps, ns);
270 cout <<
"Failed: chk=" << chk << endl;
275 cout <<
"Collecting ..." << endl;
278 if(e.match(F(
w1,
w2))) {
279 auto itr = pq_f2f.find(e);
280 if(itr==pq_f2f.end())
return e;
281 else return itr->second;
282 }
else return e.map(self);
288 find(res, F(
w1,
w2), fs);
289 map<ex,Family,ex_is_less> p2f;
293 auto itr = p2f.find(f.op(0));
294 if(itr == p2f.end()) {
295 itr = p2f.insert({f.op(0), Family(
pn)}).first;
298 itr->second.intg.append(f.op(1));
299 f2f[f] = F(itr->second.pn, f.op(1));
303 if(e.match(F(
w1,
w2))) {
304 auto itr = f2f.find(e);
306 cout <<
"F Not Found" << endl;
310 }
else return e.map(self);
313 cout <<
"Exporting res.txt ..." << endl;
318current = If[$FrontEnd===Null,$InputFileName,NotebookFileName[]]//DirectoryName;
321sols = Flatten@Table[Import[FileNameJoin[{current,"sol"<>ToString[i]<>".m"}]], {i,0,<<NN>>}];
322res = C2M@Import[FileNameJoin[{current, "res.txt"}]];
323res = res/.{F[p_, n_] :> j[Symbol["I"<>ToString[p]], Sequence@@n]} /. Dispatch@sols;
331 int tot = p2f.size(), cur = 0;
334 cout <<
"[ " << cur <<
" / " << tot <<
"] pn = " << kv.second.pn << endl;
335 cout << kv.first << endl;
336 cout << kv.second.intg << endl;