20 static symbol xwra(
"xwra");
23 expr.find(sqrt(
w), pows_set);
24 expr.find(pow(
w1,
w2), pows_set);
26 for(
auto item : pows_set) {
27 if(item.has(WRA(
w))) {
28 if(item.match(pow(
w1,
w2)) && !item.op(1).info(info_flags::integer)) {
29 pow_map[item] = exp(log(item.op(0)) * item.op(1));
30 }
else if(item.match(sqrt(
w))) {
31 pow_map[item] = exp(log(item.op(0))/2);
36 expr = expr.subs(pow_map);
41 expr.find(log(
w), logs_set);
44 for(
auto item : logs_set){
45 if(item.has(WRA(
w))) {
47 id_logz_lst.append(iWF(log_id,item.op(0)));
48 log_map[item] = iWF(log_id);
51 if(log_id<1)
return expr.subs(WRA(
w)==
w);
53 expr = expr.subs(log_map).subs(WRA(
w)==
w);
56 for(
auto id_logz : id_logz_lst) {
57 auto id = id_logz.op(0);
58 auto zz = id_logz.op(1);
60 zz.find(WRA(
w), wra_set);
61 if(wra_set.size()<1)
return expr;
62 if(wra_set.size()!=1) {
64 throw Error(
"ContinuousWRA: too many WRA.");
66 zz = zz.subs(WRA(
w)==xwra);
67 ex wra = (*(wra_set.begin())).op(0);
69 ex ret = log(zz.subs(xwra==wra));
71 log_map2[iWF(
id)] = ret;
76 for(
int k=0; k<=nc; k++) {
78 if(k==0) zzk =
NN(zz.subs(xwra==wra/(25*nc)));
79 else zzk =
NN(zz.subs(xwra==k*wra/nc));
80 if(!is_a<numeric>(zzk))
throw Error(
"ContinuousWRA: zzk is not numeric: "+
ex2str(zzk));
81 auto nzzk = ex_to<numeric>(zzk);
82 auto curR = real(nzzk);
83 auto curI = imag(nzzk);
84 if(is_zero(curI) && k==0 && curR<0)
ReIm[total][1] = -1;
85 else if(is_zero(curR) || is_zero(curR))
continue;
86 else ReIm[total][1] = curI>0 ? 1 : -1;
87 ReIm[total][0] = curR>0 ? 1 : -1;
92 for(
int k=0; k<total-1; k++) {
93 if(
ReIm[k][0]*
ReIm[k+1][0]<0 &&
ReIm[k][1]*
ReIm[k+1][1]<0)
throw Error(
"ContinuousWRA: 1<->3 or 2<->4 happened.");
95 if(
ReIm[k][1]>0) cutN++;
99 if(cutN!=0) ret += I * cutN * 2 * Pi;
100 log_map2[iWF(
id)] = ret;
102 expr = expr.subs(log_map2);
103 if(expr.has(iWF(
w)))
throw Error(
"ContinuousWRA: iWF(w) still exists in final result.");
121 ostringstream fsofn, sofn, cmd;
123 sofn << pid <<
".so";
124 fsofn << pid <<
"F.so";
127 sofn << key <<
".so";
129 garfn << key <<
".ci.gar";
131 ifstream in(garfn.str());
134 auto c = ar.unarchive_ex(
"c");
135 if(c!=19790923)
throw Error(
"Integrates: *.ci.gar error!");
136 auto gl = ar.unarchive_ex(
"soLimit");
137 eps_lst = ex_to<lst>(ar.unarchive_ex(
"eps_lst"));
139 auto res = ar.unarchive_ex(
"res");
141 for(
auto item : ex_to<lst>(res)) ciResult.push_back(ex_to<lst>(item));
145 if(pkey !=
"") garfn <<
"-" << pkey;
149 ifstream la_in(garfn.str());
152 auto la_c = la_ar.unarchive_ex(
"c");
153 auto la_res = la_ar.unarchive_ex(
"res");
154 if(la_c!=19790923)
throw Error(
"Integrates: *.ci.gar error!");
155 for(
auto item : ex_to<lst>(la_res)) {
156 LambdaMap[item.op(0)] = item.op(1);
164 if(pkey !=
"") garfn <<
"-" << pkey;
167 throw Error(
"Integrates: File Not Found: " + garfn.str());
171 ifstream res_in(garfn.str());
174 auto res_c = res_ar.unarchive_ex(
"c");
175 auto relst = res_ar.unarchive_ex(
"relst");
176 if(res_c!=19790923)
throw Error(
"*.res.gar error with kid!");
177 lstRE = ex_to<lst>(relst);
182 void* main_module = dlopen(sofn.str().c_str(), RTLD_NOW);
183 if(main_module ==
nullptr) {
184 main_module = dlopen((
"./"+sofn.str()).c_str(), RTLD_NOW);
185 if(main_module ==
nullptr) {
186 cout <<
"dlerror(): " << dlerror() << endl;
187 throw Error(
"Integrates: could not open main module!");
191 if(!
Debug && key ==
"") {
192 if(
file_exists(fsofn.str().c_str())) remove(fsofn.str().c_str());
193 remove(sofn.str().c_str());
195 vector<void*> ex_modules;
196 for(
int n=1;
true; n++) {
197 ostringstream ex_sofn;
199 ex_sofn << pid <<
"X" << n <<
".so";
201 ex_sofn << key <<
"X" << n <<
".so";
204 void* module = dlopen(ex_sofn.str().c_str(), RTLD_NOW);
205 if(module ==
nullptr) {
206 module = dlopen((
"./"+ex_sofn.str()).c_str(), RTLD_NOW);
207 if(module ==
nullptr) {
208 cout <<
"dlerror(): " << dlerror() << endl;
209 throw Error(
"Integrates: could not open ex-module!");
212 ex_modules.push_back(module);
213 if(!
Debug && key ==
"") remove(ex_sofn.str().c_str());
220 plRepl.append(PL(kv.first)==kv.second);
221 if(kv.first>npara) npara = kv.first;
226 int total = ciResult.size(), current = 0;
227 qREAL stot = sqrtq(total*1.Q);
231 for(
auto &item : ciResult) {
233 if(kid>0 && current != kid)
continue;
236 cout <<
PRE <<
"\\--Integrating [" <<current<<
"/"<<total<<
"] " << flush;
239 unsigned int xsize = 0;
242 xsize = ex_to<numeric>(item.op(1)).to_int();
250 ex res = VE(
NN(exint),0);
252 cout <<
"XDim=" << xsize << endl;
256 lstRE.let_op(kid-1) = res*co;
259 lstRE.append(res*co);
264 ex intid = item.op(0);
265 ex ftid = item.op(3);
267 if(co.is_zero())
continue;
269 if(co.is_zero())
continue;
270 if(co.has(PL(
w)))
throw Error(
"Integrates: PL found @ " +
ex2str(co));
273 if(
ReIm==3) reim = 3;
275 for(
int si=co.ldegree(
eps); si<=co.degree(
eps); si++) {
276 auto tmp = co.coeff(
eps, si);
277 if(tmp.has(
eps))
throw Error(
"Integrates: eps found @ " +
ex2str(tmp));
279 for(
int i=tmp.ldegree(
ep); i<=tmp.degree(
ep); i++) {
280 auto ccRes =
NN(tmp.coeff(
ep, i)).expand();
283 if(is_a<add>(ccRes)) {
284 for(
auto item : ccRes) css.append(item);
290 eps_map[epi.op(0)] = epn;
294 for(
int ci=0; ci<css.nops(); ci++) {
296 if(nt.has(
ep))
throw Error(
"Integrates: ep found @ nt = "+
ex2str(nt));
299 if(!is_a<numeric>(nt)) {
301 for(
auto nti : cv_lst) {
302 auto nnt = nti.op(0);
303 if(!is_a<numeric>(nnt))
throw Error(
"Integrates: Not a number with nt = "+
ex2str(nnt));
306 }
else nt_lst.append(nt);
308 for(
auto nnt : nt_lst) {
309 if(
ReIm!=3 && reim!=3) {
310 if(ex_to<numeric>(nnt).imag()==0) {
311 if(reim==2) reim = 3;
313 }
else if(ex_to<numeric>(nnt).real()==0) {
314 if(reim==1) reim = 3;
323 if(qnt > cmax) cmax = qnt;
331 if(is_zero(co2-co))
break;
334 if(normal(co).is_zero())
continue;
335 throw Error(
"Integrates: cmax<=0 with co = "+
ex2str(co));
337 if(reim!=3 &&
ReIm!=3) {
340 else if(reim==2) reim=1;
345 sprintf(d1,
"%.6G", (
double)(
EpsAbs/cmax/stot));
346 sprintf(d2,
"%.6G", (
double)cmax);
347 if(
Verbose>5) cout <<
"XDim=" << xsize <<
", EpsAbs=" << d1 <<
"/" << d2 << endl;
349 auto las = LambdaMap[ftid];
350 bool hasF = (ftid>0);
351 if(hasF && las.is_zero())
throw Error(
"Integrates: lambda with the key(ft_n=" +
ex2str(ftid) +
") is NOT found!");
353 if(hasF && !is_a<lst>(las)) {
354 if(!is_zero(las-ex(1979))) {
355 throw Error(
"Integrates: something is wrong with the F-term @ ft_n = "+
ex2str(ftid) +
", las=" +
ex2str(las));
365 int idx = ex_to<numeric>(intid).to_int();
366 auto module = main_module;
369 if(hasF) fname <<
"C";
370 fname <<
"SDD_" << idx;
374 cout <<
"dlerror(): " << dlerror() << endl;
375 throw Error(
"Integrates: fpD==NULL");
380 if(hasF) fname <<
"C";
381 fname <<
"SDQ_" << idx;
384 cout <<
"dlerror(): " << dlerror() << endl;
385 throw Error(
"Integrates: fpQ==NULL");
390 if(hasF) fname <<
"C";
391 fname <<
"SDMP_" << idx;
394 cout <<
"dlerror(): " << dlerror() << endl;
395 throw Error(
"Integrates: fpMP==NULL");
401 fname <<
"FT_" << idx;
404 cout <<
"dlerror(): " << dlerror() << endl;
405 throw Error(
"Integrates: ftp==NULL.");
409 dREAL dlas[las.nops()], dpl[npara];
410 qREAL qlas[las.nops()], qpl[npara];
411 mpREAL mplas[las.nops()], mppl[npara];
413 qpl[kv.first] =
ex2q(kv.second);
414 dpl[kv.first] = (
dREAL)qpl[kv.first];
415 mppl[kv.first] = qpl[kv.first];
437 qREAL lamax =
ex2q(las.op(las.nops()-1));
439 int ctryR = 0, ctry = 0, ctryL = 0;
443 qREAL log_lamax = log10q(lamax);
444 qREAL log_lamin = log_lamax-1.Q;
446 ostringstream las_fn;
448 if(pkey !=
"") las_fn <<
"-" << pkey;
449 las_fn <<
"-" << current <<
".las";
451 std::ifstream las_ifs;
452 las_ifs.open(las_fn.str(), ios::in);
453 if (!las_ifs)
throw Error(
"Integrates: failed to open *.las file!");
454 for(
int i=0; i<las.nops()-1; i++) {
463 auto res_tmp = res.subs(VE(
w1,
w2)==
w2);
464 auto err = real_part(res_tmp);
465 if(err < imag_part(res_tmp)) err = imag_part(res_tmp);
470 auto prec = cout.precision();
476 bool err_break =
false;
479 if(ctryR>0 || ctry>0 || ctryL>0)
480 cout <<
" ------------------------------" << endl;
482 auto log_cla = (log_lamin + s * (log_lamax-log_lamin) /
LambdaSplit);
483 auto cla = powq(10.Q, log_cla);
484 if(cla < 1E-10)
throw Error(
"NIntegrate: too small lambda.");
485 for(
int i=0; i<las.nops()-1; i++) {
486 qlas[i] =
ex2q(las.op(i)) * cla;
488 dlas[i] = (
dREAL)qlas[i];
498 if(res.has(
NaN) && s==0)
continue;
499 else if(res.has(
NaN))
break;
500 ex res_abs =
NN(abs(res.subs(VE(
w1,
w2)==
w1)));
501 if(lastResErr.is_zero()) lastResErr = res;
503 diff = diff.subs(VE(0,0)==0);
505 diff.find(VE(
w0,
w1), ves);
507 auto ve0 = abs(ve.op(0));
509 if(numeric(
"1.E10")*ve0<res_abs)
continue;
510 if(numeric(
"1.E10")*ve0<
q2ex(
EpsAbs))
continue;
521 auto res_tmp = res.subs(VE(
w1,
w2)==
w2);
522 auto err = real_part(res_tmp);
523 if(err < imag_part(res_tmp)) err = imag_part(res_tmp);
524 if(smin<0 || err < min_err) {
537 if(kid>0) lstRE.let_op(kid-1) = co * min_res;
538 else lstRE.append(co * min_res);
541 if(err > 100 * min_err)
break;
543 if(smin == -2)
break;
544 if(smin == -1)
throw Error(
"Integrates: smin = -1, too small lambda (<1E-10)!");
547 if((!err_break) && (ctryL >=
CTryL || ctryR>0))
break;
548 log_lamax = log_lamin;
550 if(!err_break) ctryL++;
552 if(ctryR >=
CTryR || ctryL>0)
break;
553 log_lamin = log_lamax;
557 if(ctry >=
CTryM)
break;
558 auto la1 = log_lamin + (smin-1) * (log_lamax-log_lamin) /
LambdaSplit;
559 auto la2 = log_lamin + (smin+1) * (log_lamax-log_lamin) /
LambdaSplit;
565 cout.precision(prec);
572 auto log_cla = (log_lamin + smin * (log_lamax-log_lamin) /
LambdaSplit);
573 auto cla = powq(10.Q, log_cla);
575 for(
int i=0; i<las.nops()-1; i++) {
576 qlas[i] =
ex2q(las.op(i)) * cla;
577 dlas[i] = (
dREAL)qlas[i];
591 dREAL oo[las.nops()-1], ip[las.nops()-1];
592 for(
int i=0; i<las.nops()-1; i++) ip[i] = oo[i] = (
dREAL)qlas[i];
601 for(
int i=0; i<las.nops()-1; i++) {
603 dlas[i] = (
dREAL)qlas[i];
612 for(
int i=0; i<xsize; i++) {
614 quadmath_snprintf(buffer,
sizeof buffer,
"%.6QG", qlas[i]);
615 cout << buffer <<
" ";
617 cout << endl <<
" ------------------------------" << endl;
623 std::ofstream las_ofs;
624 las_ofs.open(las_fn.str(), ios::out);
626 for(
int i=0; i<las.nops()-1; i++) {
628 las_ofs << la_tmp <<
" ";
644 if(kid>0) lstRE.let_op(kid-1) =
NaN;
645 else lstRE.append(
NaN);
649 lstRE.let_op(kid-1) = co * res;
651 }
else lstRE.append(co * res);
657 for(
auto module : ex_modules) dlclose(module);
658 dlclose(main_module);
670 if(pkey !=
"") garfn <<
"-" << pkey;
674 ar.archive_ex(lstRE,
"relst");
675 ar.archive_ex(19790923,
"c");
676 ofstream out(garfn.str());
694 ostringstream fsofn, sofn, cmd;
697 sofn << key <<
".so";
699 garfn << key <<
".ci.gar";
701 ifstream in(garfn.str());
704 auto c = ar.unarchive_ex(
"c");
705 if(c!=19790923)
throw Error(
"Integrates: *.ci.gar error!");
706 auto gl = ar.unarchive_ex(
"soLimit");
707 eps_lst = ex_to<lst>(ar.unarchive_ex(
"eps_lst"));
709 auto res = ar.unarchive_ex(
"res");
711 for(
auto item : ex_to<lst>(res)) ciResult.push_back(ex_to<lst>(item));
715 if(pkey !=
"") garfn <<
"-" << pkey;
719 ifstream la_in(garfn.str());
722 auto la_c = la_ar.unarchive_ex(
"c");
723 auto la_res = la_ar.unarchive_ex(
"res");
724 if(la_c!=19790923)
throw Error(
"Integrates: *.ci.gar error!");
725 for(
auto item : ex_to<lst>(la_res)) {
726 LambdaMap[item.op(0)] = item.op(1);
734 if(pkey !=
"") garfn <<
"-" << pkey;
737 throw Error(
"Integrates: File Not Found: " + garfn.str());
741 ifstream res_in(garfn.str());
744 auto res_c = res_ar.unarchive_ex(
"c");
745 auto relst = res_ar.unarchive_ex(
"relst");
746 if(res_c!=19790923)
throw Error(
"*.res.gar error with ReIntegrates!");
747 lstRE = ex_to<lst>(relst);
752 void* main_module = dlopen(sofn.str().c_str(), RTLD_NOW);
753 if(main_module ==
nullptr) {
754 main_module = dlopen((
"./"+sofn.str()).c_str(), RTLD_NOW);
755 if(main_module ==
nullptr) {
756 cout <<
"dlerror(): " << dlerror() << endl;
757 throw Error(
"Integrates: could not open main module!");
761 vector<void*> ex_modules;
762 for(
int n=1;
true; n++) {
763 ostringstream ex_sofn;
764 ex_sofn << key <<
"X" << n <<
".so";
766 void* module = dlopen(ex_sofn.str().c_str(), RTLD_NOW);
767 if(module ==
nullptr) {
768 module = dlopen((
"./"+ex_sofn.str()).c_str(), RTLD_NOW);
769 if(module ==
nullptr) {
770 cout <<
"dlerror(): " << dlerror() << endl;
771 throw Error(
"Integrates: could not open ex-module!");
774 ex_modules.push_back(module);
775 if(!
Debug && key ==
"") remove(ex_sofn.str().c_str());
782 plRepl.append(PL(kv.first)==kv.second);
783 if(kv.first>npara) npara = kv.first;
788 int total = ciResult.size(), current = 0;
789 qREAL stot = sqrtq(total*1.Q);
793 for(
auto &item : ciResult) {
796 if(cmerr < err)
continue;
799 quadmath_snprintf(es,
sizeof es,
"%.10QG", cmerr);
800 cout <<
PRE <<
"\\--Current Err: " << es << endl;
804 cout <<
PRE <<
"\\--Integrating [" <<current<<
"/"<<total<<
"] " << flush;
807 unsigned int xsize = 0;
810 xsize = ex_to<numeric>(item.op(1)).to_int();
818 ex res = VE(
NN(exint),0);
820 cout <<
"XDim=" << xsize << endl;
823 lstRE.let_op(current-1) = res*co;
828 ex intid = item.op(0);
829 ex ftid = item.op(3);
831 if(co.is_zero())
continue;
833 if(co.is_zero())
continue;
834 if(co.has(PL(
w)))
throw Error(
"Integrates: PL found @ " +
ex2str(co));
837 if(
ReIm==3) reim = 3;
839 for(
int si=co.ldegree(
eps); si<=co.degree(
eps); si++) {
840 auto tmp = co.coeff(
eps, si);
841 if(tmp.has(
eps))
throw Error(
"Integrates: eps found @ " +
ex2str(tmp));
843 for(
int i=tmp.ldegree(
ep); i<=tmp.degree(
ep); i++) {
844 auto ccRes =
NN(tmp.coeff(
ep, i)).expand();
847 if(is_a<add>(ccRes)) {
848 for(
auto item : ccRes) css.append(item);
854 eps_map[epi.op(0)] = epn;
858 for(
int ci=0; ci<css.nops(); ci++) {
860 if(nt.has(
ep))
throw Error(
"Integrates: ep found @ nt = "+
ex2str(nt));
863 if(!is_a<numeric>(nt)) {
865 for(
auto nti : cv_lst) {
866 auto nnt = nti.op(0);
867 if(!is_a<numeric>(nnt))
throw Error(
"Integrates: Not a number with nt = "+
ex2str(nnt));
870 }
else nt_lst.append(nt);
872 for(
auto nnt : nt_lst) {
873 if(
ReIm!=3 && reim!=3) {
874 if(ex_to<numeric>(nnt).imag()==0) {
875 if(reim==2) reim = 3;
877 }
else if(ex_to<numeric>(nnt).real()==0) {
878 if(reim==1) reim = 3;
887 if(qnt > cmax) cmax = qnt;
895 if(is_zero(co2-co))
break;
898 if(normal(co).is_zero())
continue;
899 throw Error(
"Integrates: cmax<=0 with co = "+
ex2str(co));
901 if(reim!=3 &&
ReIm!=3) {
904 else if(reim==2) reim=1;
909 sprintf(d1,
"%.6G", (
double)(
EpsAbs/cmax/stot));
910 sprintf(d2,
"%.6G", (
double)cmax);
911 if(
Verbose>5) cout <<
"XDim=" << xsize <<
", EpsAbs=" << d1 <<
"/" << d2 << endl;
912 auto las = LambdaMap[ftid];
913 bool hasF = (ftid>0);
914 if(hasF && las.is_zero())
throw Error(
"Integrates: lambda with the key(ft_n=" +
ex2str(ftid) +
") is NOT found!");
915 if(hasF && !is_a<lst>(las)) {
916 if(!is_zero(las-ex(1979))) {
917 throw Error(
"Integrates: something is wrong with the F-term @ ft_n = "+
ex2str(ftid) +
", las=" +
ex2str(las));
927 int idx = ex_to<numeric>(intid).to_int();
928 auto module = main_module;
931 if(hasF) fname <<
"C";
932 fname <<
"SDD_" << idx;
935 cout <<
"dlerror(): " << dlerror() << endl;
936 throw Error(
"Integrates: fpD==NULL");
941 if(hasF) fname <<
"C";
942 fname <<
"SDQ_" << idx;
945 cout <<
"dlerror(): " << dlerror() << endl;
946 throw Error(
"Integrates: fpQ==NULL");
951 if(hasF) fname <<
"C";
952 fname <<
"SDMP_" << idx;
958 fname <<
"FT_" << idx;
961 cout <<
"dlerror(): " << dlerror() << endl;
962 throw Error(
"Integrates: ftp==NULL.");
966 dREAL dlas[las.nops()], dpl[npara];
967 qREAL qlas[las.nops()], qpl[npara];
968 mpREAL mplas[las.nops()], mppl[npara];
970 qpl[kv.first] =
ex2q(kv.second);
971 dpl[kv.first] = (
dREAL)qpl[kv.first];
972 mppl[kv.first] = qpl[kv.first];
991 qREAL lamax =
ex2q(las.op(las.nops()-1));
994 int ctryR = 0, ctry = 0, ctryL = 0;
998 qREAL log_lamax = log10q(lamax);
999 qREAL log_lamin = log_lamax-1.Q;
1001 ostringstream las_fn;
1003 if(pkey !=
"") las_fn <<
"-" << pkey;
1004 las_fn <<
"-" << current <<
".las";
1006 std::ifstream las_ifs;
1007 las_ifs.open(las_fn.str(), ios::in);
1008 if (!las_ifs)
throw Error(
"Integrates: failed to open *.las file!");
1009 for(
int i=0; i<las.nops()-1; i++) {
1013 dlas[i] = (
dREAL)qlas[i];
1018 auto res_tmp = res.subs(VE(
w1,
w2)==
w2);
1019 auto err = real_part(res_tmp);
1020 if(err < imag_part(res_tmp)) err = imag_part(res_tmp);
1029 bool err_break =
false;
1032 if(ctryR>0 || ctry>0 || ctryL>0)
1033 cout <<
" ------------------------------" << endl;
1035 auto log_cla = (log_lamin + s * (log_lamax-log_lamin) /
LambdaSplit);
1036 auto cla = powq(10.Q, log_cla);
1037 if(cla < 1E-10)
throw Error(
"NIntegrate: too small lambda.");
1038 for(
int i=0; i<las.nops()-1; i++) {
1039 qlas[i] =
ex2q(las.op(i)) * cla;
1040 dlas[i] = (
dREAL)qlas[i];
1051 if(res.has(
NaN) && s==0)
continue;
1052 else if(res.has(
NaN))
break;
1053 ex res_abs =
NN(abs(res.subs(VE(
w1,
w2)==
w1)));
1054 if(lastResErr.is_zero()) lastResErr = res;
1056 diff = diff.subs(VE(0,0)==0);
1058 diff.find(VE(
w0,
w1), ves);
1059 for(
auto ve : ves) {
1060 auto ve0 = abs(ve.op(0));
1062 if(numeric(
"1.E10")*ve0<res_abs)
continue;
1063 if(numeric(
"1.E10")*ve0<
q2ex(
EpsAbs))
continue;
1074 auto res_tmp = res.subs(VE(
w1,
w2)==
w2);
1075 auto err = real_part(res_tmp);
1076 if(err < imag_part(res_tmp)) err = imag_part(res_tmp);
1077 if(smin<0 || err < min_err) {
1083 if(s>0 && min_err <
q2ex(
EpsAbs/cmax/stot)) {
1090 lstRE.let_op(current-1) = co * min_res;
1093 if(err > 100 * min_err)
break;
1095 if(smin == -2)
break;
1096 if(smin == -1)
throw Error(
"Integrates: smin = -1, too small lambda (<1E-10)!");
1099 if((!err_break) && (ctryL >=
CTryL || ctryR>0))
break;
1100 log_lamax = log_lamin;
1102 if(!err_break) ctryL++;
1104 if(ctryR >=
CTryR || ctryL>0)
break;
1105 log_lamin = log_lamax;
1109 if(ctry >=
CTryM)
break;
1110 auto la1 = log_lamin + (smin-1) * (log_lamax-log_lamin) /
LambdaSplit;
1111 auto la2 = log_lamin + (smin+1) * (log_lamax-log_lamin) /
LambdaSplit;
1118 if(smin == -2)
continue;
1120 auto log_cla = (log_lamin + smin * (log_lamax-log_lamin) /
LambdaSplit);
1121 auto cla = powq(10.Q, log_cla);
1123 for(
int i=0; i<las.nops()-1; i++) {
1124 qlas[i] =
ex2q(las.op(i)) * cla;
1125 dlas[i] = (
dREAL)qlas[i];
1139 dREAL oo[las.nops()-1], ip[las.nops()-1];
1140 for(
int i=0; i<las.nops()-1; i++) ip[i] = oo[i] = (
dREAL)qlas[i];
1149 for(
int i=0; i<las.nops()-1; i++) {
1151 dlas[i] = (
dREAL)qlas[i];
1160 for(
int i=0; i<xsize; i++) {
1162 quadmath_snprintf(buffer,
sizeof buffer,
"%.6QG", qlas[i]);
1163 cout << buffer <<
" ";
1165 cout << endl <<
" ------------------------------" << endl;
1171 std::ofstream las_ofs;
1172 las_ofs.open(las_fn.str(), ios::out);
1174 for(
int i=0; i<las.nops()-1; i++) {
1176 las_ofs << la_tmp <<
" ";
1190 lstRE.let_op(current-1) =
NaN;
1192 lstRE.let_op(current-1) = co * res;
1198 for(
auto module : ex_modules) dlclose(module);
1199 dlclose(main_module);
1209 ostringstream garfn;
1211 if(pkey !=
"") garfn <<
"-" << pkey;
1212 garfn <<
".res.gar";
1215 ar.archive_ex(lstRE,
"relst");
1216 ar.archive_ex(19790923,
"c");
1217 ofstream out(garfn.str());
class used to wrap error message
static IntegratorBase * Integrator
static MinimizeBase * miner
static dREAL IntError(int nvars, dREAL *las, dREAL *n1, dREAL *n2)
numerical integrator using HCubature
class to minimize a function using HookeJeeves
qREAL(* FT_Type)(const qREAL xx[], const qREAL pl[])
int(* SDD_Type)(const unsigned int xn, const dREAL x[], const unsigned int yn, dREAL y[], const dREAL pl[], const dREAL las[])
int(* SDQ_Type)(const unsigned int xn, const qREAL x[], const unsigned int yn, qREAL y[], const qREAL pl[], const qREAL las[])
virtual ex Integrate(size_t n=0)=0
int(* SDMP_Type)(const unsigned int xn, const mpREAL x[], const unsigned int yn, mpREAL y[], const mpREAL pl[], const mpREAL las[])
const mpREAL * mpParameter
map< int, numeric > Parameter
IntegratorBase * Integrator
void Integrates(const string &key="", const string &pkey="", int kid=0)
Contours, note that here we need to provide the specific Parameter.
static ex ContinuousWRA(ex expr_in, int nc=15)
ContinuousWRA, note that here we need to provide the specific Parameter.
void ReIntegrates(const string &key, const string &pkey, qREAL err)
Contours, note that here we need to provide the specific Parameter.
static bool has(const ex &e)
namespace for Numerical integration with Sector Decomposition method
ex xyz_pow_simplify(const ex expr_in)
ex exp_simplify(const ex expr_in)
const char * Color_HighLight
__float128 ex2q(ex num)
ex of numeric to __float128
ex q2ex(__float128 num)
__float128 to ex
ex NN(ex expr, int digits)
the nuerical evaluation
ex collect_ex(ex const &expr_in, std::function< bool(const ex &)> has_func, int opt)
the collect function like Mathematica
bool file_exists(string fn)
string now(bool use_date)
date/time string
lst collect_lst(ex const &expr_in, std::function< bool(const ex &)> has_func, int opt)
the collect function like Mathematica, reture the lst { {c1,v1}, {c2,v2}, ... }
string ex2str(const ex &expr)
convert ex to output string, the defalut printer format will be used
void set_precision(long prec, bool push)
int ex2int(ex num)
ex to integer
ex subs(const ex &e, init_list sl)