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.");
115 auto pbit = mpfr::digits2bits(
MPDigits);
116 if(mpfr::mpreal::get_default_prec()!=pbit) mpfr::mpreal::set_default_prec(pbit);
124 ostringstream fsofn, sofn, cmd;
126 sofn << pid <<
".so";
127 fsofn << pid <<
"F.so";
130 sofn << key <<
".so";
132 garfn << key <<
".ci.gar";
134 ifstream in(garfn.str());
137 auto c = ar.unarchive_ex(
"c");
138 if(c!=19790923)
throw Error(
"Integrates: *.ci.gar error!");
139 auto gl = ar.unarchive_ex(
"soLimit");
140 eps_lst = ex_to<lst>(ar.unarchive_ex(
"eps_lst"));
142 auto res = ar.unarchive_ex(
"res");
144 for(
auto item : ex_to<lst>(res)) ciResult.push_back(ex_to<lst>(item));
148 if(pkey !=
"") garfn <<
"-" << pkey;
152 ifstream la_in(garfn.str());
155 auto la_c = la_ar.unarchive_ex(
"c");
156 auto la_res = la_ar.unarchive_ex(
"res");
157 if(la_c!=19790923)
throw Error(
"Integrates: *.ci.gar error!");
158 for(
auto item : ex_to<lst>(la_res)) {
159 LambdaMap[item.op(0)] = item.op(1);
167 if(pkey !=
"") garfn <<
"-" << pkey;
170 throw Error(
"Integrates: File Not Found: " + garfn.str());
174 ifstream res_in(garfn.str());
177 auto res_c = res_ar.unarchive_ex(
"c");
178 auto relst = res_ar.unarchive_ex(
"relst");
179 if(res_c!=19790923)
throw Error(
"*.res.gar error with kid!");
180 lstRE = ex_to<lst>(relst);
185 void* main_module = dlopen(sofn.str().c_str(), RTLD_NOW);
186 if(main_module ==
nullptr) {
187 main_module = dlopen((
"./"+sofn.str()).c_str(), RTLD_NOW);
188 if(main_module ==
nullptr) {
189 cout <<
"dlerror(): " << dlerror() << endl;
190 throw Error(
"Integrates: could not open main module!");
194 if(!
Debug && key ==
"") {
195 if(
file_exists(fsofn.str().c_str())) remove(fsofn.str().c_str());
196 remove(sofn.str().c_str());
198 vector<void*> ex_modules;
199 for(
int n=1;
true; n++) {
200 ostringstream ex_sofn;
202 ex_sofn << pid <<
"X" << n <<
".so";
204 ex_sofn << key <<
"X" << n <<
".so";
207 void*
module = dlopen(ex_sofn.str().c_str(), RTLD_NOW);
208 if(module ==
nullptr) {
209 module = dlopen(("./"+ex_sofn.str()).c_str(), RTLD_NOW);
210 if(module ==
nullptr) {
211 cout <<
"dlerror(): " << dlerror() << endl;
212 throw Error(
"Integrates: could not open ex-module!");
215 ex_modules.push_back(module);
216 if(!
Debug && key ==
"") remove(ex_sofn.str().c_str());
223 plRepl.append(PL(kv.first)==kv.second);
224 if(kv.first>npara) npara = kv.first;
229 int total = ciResult.size(), current = 0;
230 qREAL stot = sqrtq(total*1.Q);
234 for(
auto &item : ciResult) {
236 if(kid>0 && current != kid)
continue;
239 cout <<
PRE <<
"\\--Integrating [" <<current<<
"/"<<total<<
"] " << flush;
242 unsigned int xsize = 0;
245 xsize = ex_to<numeric>(item.op(1)).to_int();
253 ex res = VE(
NN(exint),0);
255 cout <<
"XDim=" << xsize << endl;
259 lstRE[kid-1] = res*co;
262 lstRE.append(res*co);
267 ex intid = item.op(0);
268 ex ftid = item.op(3);
279 if(co.has(PL(
w)))
throw Error(
"Integrates: PL found @ " +
ex2str(co));
282 if(
ReIm==3) reim = 3;
284 for(
int si=co.ldegree(
eps); si<=co.degree(
eps); si++) {
285 auto tmp = co.coeff(
eps, si);
286 if(tmp.has(
eps))
throw Error(
"Integrates: eps found @ " +
ex2str(tmp));
288 for(
int i=tmp.ldegree(
ep); i<=tmp.degree(
ep); i++) {
289 auto ccRes =
NN(tmp.coeff(
ep, i)).expand();
292 if(is_a<add>(ccRes)) {
293 for(
auto item : ccRes) css.append(item);
299 eps_map[epi.op(0)] = epn;
303 for(
int ci=0; ci<css.nops(); ci++) {
305 if(nt.has(
ep))
throw Error(
"Integrates: ep found @ nt = "+
ex2str(nt));
308 if(!is_a<numeric>(nt)) {
310 for(
auto nti : cv_lst) {
311 auto nnt = nti.op(0);
312 if(!is_a<numeric>(nnt))
throw Error(
"Integrates: Not a number with nt = "+
ex2str(nnt));
315 }
else nt_lst.append(nt);
317 for(
auto nnt : nt_lst) {
318 if(
ReIm!=3 && reim!=3) {
319 if(ex_to<numeric>(nnt).imag()==0) {
320 if(reim==2) reim = 3;
322 }
else if(ex_to<numeric>(nnt).real()==0) {
323 if(reim==1) reim = 3;
332 if(qnt > cmax) cmax = qnt;
339 if(e.match(log(
w)) && e.op(0)<1) {
340 return -log(1/e.op(0));
341 }
else if(e.match(
w1*log(
w2))) {
342 ex cv = e.subs(
w1*log(
w2)==lst{
w1,
w2});
343 if(ex_to<numeric>(cv.op(0)).is_integer()) {
344 return self(log(pow(cv.op(1), cv.op(0))));
345 }
else return e.map(self);
346 }
else return e.map(self);
352 if(is_zero(co2-co))
break;
355 if(normal(co).is_zero()) {
359 throw Error(
"Integrates: cmax<=0 with co = "+
ex2str(co));
361 if(reim!=3 &&
ReIm!=3) {
364 else if(reim==2) reim=1;
369 sprintf(d1,
"%.6G", (
double)(
EpsAbs/cmax/stot));
370 sprintf(d2,
"%.6G", (
double)cmax);
371 if(
Verbose>5) cout <<
"XDim=" << xsize <<
", EpsAbs=" << d1 <<
"/" << d2 << endl;
373 auto las = LambdaMap[ftid];
374 bool hasF = (ftid>0);
375 if(hasF && las.is_zero())
throw Error(
"Integrates: lambda with the key(ft_n=" +
ex2str(ftid) +
") is NOT found!");
377 if(hasF && !is_a<lst>(las)) {
378 if(!is_zero(las-ex(1979))) {
379 throw Error(
"Integrates: something is wrong with the F-term @ ft_n = "+
ex2str(ftid) +
", las=" +
ex2str(las));
389 int idx = ex_to<numeric>(intid).to_int();
390 auto module = main_module;
391 if(idx>=
soLimit)
module = ex_modules[idx/soLimit-1];
393 if(hasF) fname <<
"C";
394 fname <<
"SDD_" << idx;
398 cout <<
"dlerror(): " << dlerror() << endl;
399 throw Error(
"Integrates: fpD==NULL");
404 if(hasF) fname <<
"C";
405 fname <<
"SDQ_" << idx;
408 cout <<
"dlerror(): " << dlerror() << endl;
409 throw Error(
"Integrates: fpQ==NULL");
414 if(hasF) fname <<
"C";
415 fname <<
"SDMP_" << idx;
418 cout <<
"dlerror(): " << dlerror() << endl;
419 throw Error(
"Integrates: fpMP==NULL");
425 fname <<
"FT_" << idx;
428 cout <<
"dlerror(): " << dlerror() << endl;
429 throw Error(
"Integrates: ftp==NULL.");
433 dREAL dlas[las.nops()], dpl[npara];
434 qREAL qlas[las.nops()], qpl[npara];
435 mpREAL mplas[las.nops()], mppl[npara];
437 qpl[kv.first] =
ex2q(kv.second);
438 dpl[kv.first] = (
dREAL)qpl[kv.first];
439 mppl[kv.first] = qpl[kv.first];
461 qREAL lamax =
ex2q(las.op(las.nops()-1));
463 int ctryR = 0, ctry = 0, ctryL = 0;
467 qREAL log_lamax = log10q(lamax);
468 qREAL log_lamin = log_lamax-1.Q;
470 ostringstream las_fn;
472 if(pkey !=
"") las_fn <<
"-" << pkey;
473 las_fn <<
"-" << current <<
".las";
475 std::ifstream las_ifs;
476 las_ifs.open(las_fn.str(), ios::in);
477 if (!las_ifs)
throw Error(
"Integrates: failed to open *.las file!");
478 for(
int i=0; i<las.nops()-1; i++) {
487 auto res_tmp = res.subs(VE(
w1,
w2)==
w2);
488 auto err = real_part(res_tmp);
489 if(err < imag_part(res_tmp)) err = imag_part(res_tmp);
494 auto prec = cout.precision();
500 bool err_break =
false;
503 if(ctryR>0 || ctry>0 || ctryL>0)
504 cout <<
" ------------------------------" << endl;
506 auto log_cla = (log_lamin + s * (log_lamax-log_lamin) /
LambdaSplit);
507 auto cla = powq(10.Q, log_cla);
508 if(cla < 1E-10)
throw Error(
"NIntegrate: too small lambda.");
509 for(
int i=0; i<las.nops()-1; i++) {
510 qlas[i] =
ex2q(las.op(i)) * cla;
512 dlas[i] = (
dREAL)qlas[i];
522 if(res.has(
NaN) && s==0)
continue;
523 else if(res.has(
NaN))
break;
524 ex res_abs =
NN(abs(res.subs(VE(
w1,
w2)==
w1)));
525 if(lastResErr.is_zero()) lastResErr = res;
527 diff = diff.subs(VE(0,0)==0);
529 diff.find(VE(
w0,
w1), ves);
531 auto ve0 = abs(ve.op(0));
533 if(numeric(
"1.E10")*ve0<res_abs)
continue;
534 if(numeric(
"1.E10")*ve0<
q2ex(
EpsAbs))
continue;
545 auto res_tmp = res.subs(VE(
w1,
w2)==
w2);
546 auto err = real_part(res_tmp);
547 if(err < imag_part(res_tmp)) err = imag_part(res_tmp);
548 if(smin<0 || err < min_err) {
561 if(kid>0) lstRE[kid-1] = co * min_res;
562 else lstRE.append(co * min_res);
565 if(err > 100 * min_err)
break;
567 if(smin == -2)
break;
568 if(smin == -1)
throw Error(
"Integrates: smin = -1, too small lambda (<1E-10)!");
571 if((!err_break) && (ctryL >=
CTryL || ctryR>0))
break;
572 log_lamax = log_lamin;
574 if(!err_break) ctryL++;
576 if(ctryR >=
CTryR || ctryL>0)
break;
577 log_lamin = log_lamax;
581 if(ctry >=
CTryM)
break;
582 auto la1 = log_lamin + (smin-1) * (log_lamax-log_lamin) /
LambdaSplit;
583 auto la2 = log_lamin + (smin+1) * (log_lamax-log_lamin) /
LambdaSplit;
589 cout.precision(prec);
596 auto log_cla = (log_lamin + smin * (log_lamax-log_lamin) /
LambdaSplit);
597 auto cla = powq(10.Q, log_cla);
599 for(
int i=0; i<las.nops()-1; i++) {
600 qlas[i] =
ex2q(las.op(i)) * cla;
601 dlas[i] = (
dREAL)qlas[i];
615 dREAL oo[las.nops()-1], ip[las.nops()-1];
616 for(
int i=0; i<las.nops()-1; i++) ip[i] = oo[i] = (
dREAL)qlas[i];
625 for(
int i=0; i<las.nops()-1; i++) {
627 dlas[i] = (
dREAL)qlas[i];
636 for(
int i=0; i<xsize; i++) {
638 quadmath_snprintf(buffer,
sizeof buffer,
"%.6QG", qlas[i]);
639 cout << buffer <<
" ";
641 cout << endl <<
" ------------------------------" << endl;
647 std::ofstream las_ofs;
648 las_ofs.open(las_fn.str(), ios::out);
650 for(
int i=0; i<las.nops()-1; i++) {
652 las_ofs << la_tmp <<
" ";
668 if(kid>0) lstRE[kid-1] =
NaN;
669 else lstRE.append(
NaN);
673 lstRE[kid-1] = co * res;
675 }
else lstRE.append(co * res);
682 for(
auto module : ex_modules) dlclose(module);
683 dlclose(main_module);
694 if(pkey !=
"") garfn <<
"-" << pkey;
698 ar.archive_ex(lstRE,
"relst");
699 ar.archive_ex(19790923,
"c");
700 ofstream out(garfn.str());
719 ostringstream fsofn, sofn, cmd;
722 sofn << key <<
".so";
724 garfn << key <<
".ci.gar";
726 ifstream in(garfn.str());
729 auto c = ar.unarchive_ex(
"c");
730 if(c!=19790923)
throw Error(
"Integrates: *.ci.gar error!");
731 auto gl = ar.unarchive_ex(
"soLimit");
732 eps_lst = ex_to<lst>(ar.unarchive_ex(
"eps_lst"));
734 auto res = ar.unarchive_ex(
"res");
736 for(
auto item : ex_to<lst>(res)) ciResult.push_back(ex_to<lst>(item));
740 if(pkey !=
"") garfn <<
"-" << pkey;
744 ifstream la_in(garfn.str());
747 auto la_c = la_ar.unarchive_ex(
"c");
748 auto la_res = la_ar.unarchive_ex(
"res");
749 if(la_c!=19790923)
throw Error(
"Integrates: *.ci.gar error!");
750 for(
auto item : ex_to<lst>(la_res)) {
751 LambdaMap[item.op(0)] = item.op(1);
759 if(pkey !=
"") garfn <<
"-" << pkey;
762 throw Error(
"Integrates: File Not Found: " + garfn.str());
766 ifstream res_in(garfn.str());
769 auto res_c = res_ar.unarchive_ex(
"c");
770 auto relst = res_ar.unarchive_ex(
"relst");
771 if(res_c!=19790923)
throw Error(
"*.res.gar error with ReIntegrates!");
772 lstRE = ex_to<lst>(relst);
776 if(lstRE.nops()!=ciResult.size())
throw Error(
"Error: the size is not same between ciResult and lstRE!");
779 void* main_module = dlopen(sofn.str().c_str(), RTLD_NOW);
780 if(main_module ==
nullptr) {
781 main_module = dlopen((
"./"+sofn.str()).c_str(), RTLD_NOW);
782 if(main_module ==
nullptr) {
783 cout <<
"dlerror(): " << dlerror() << endl;
784 throw Error(
"Integrates: could not open main module!");
788 vector<void*> ex_modules;
789 for(
int n=1;
true; n++) {
790 ostringstream ex_sofn;
791 ex_sofn << key <<
"X" << n <<
".so";
793 void*
module = dlopen(ex_sofn.str().c_str(), RTLD_NOW);
794 if(module ==
nullptr) {
795 module = dlopen(("./"+ex_sofn.str()).c_str(), RTLD_NOW);
796 if(module ==
nullptr) {
797 cout <<
"dlerror(): " << dlerror() << endl;
798 throw Error(
"Integrates: could not open ex-module!");
801 ex_modules.push_back(module);
802 if(!
Debug && key ==
"") remove(ex_sofn.str().c_str());
809 plRepl.append(PL(kv.first)==kv.second);
810 if(kv.first>npara) npara = kv.first;
815 int total = ciResult.size(), current = 0;
816 qREAL stot = sqrtq(total*1.Q);
820 for(
auto &item : ciResult) {
823 if(cmerr < err)
continue;
826 quadmath_snprintf(es,
sizeof es,
"%.10QG", cmerr);
827 cout <<
PRE <<
"\\--Current Err: " << es << endl;
831 cout <<
PRE <<
"\\--ReIntegrating [" <<current<<
"/"<<total<<
"] " << flush;
834 unsigned int xsize = 0;
837 xsize = ex_to<numeric>(item.op(1)).to_int();
845 ex res = VE(
NN(exint),0);
847 cout <<
"XDim=" << xsize << endl;
850 lstRE[current-1] = res*co;
855 ex intid = item.op(0);
856 ex ftid = item.op(3);
859 lstRE[current-1] = 0;
864 lstRE[current-1] = 0;
867 if(co.has(PL(
w)))
throw Error(
"Integrates: PL found @ " +
ex2str(co));
870 if(
ReIm==3) reim = 3;
872 for(
int si=co.ldegree(
eps); si<=co.degree(
eps); si++) {
873 auto tmp = co.coeff(
eps, si);
874 if(tmp.has(
eps))
throw Error(
"Integrates: eps found @ " +
ex2str(tmp));
876 for(
int i=tmp.ldegree(
ep); i<=tmp.degree(
ep); i++) {
877 auto ccRes =
NN(tmp.coeff(
ep, i)).expand();
880 if(is_a<add>(ccRes)) {
881 for(
auto item : ccRes) css.append(item);
887 eps_map[epi.op(0)] = epn;
891 for(
int ci=0; ci<css.nops(); ci++) {
893 if(nt.has(
ep))
throw Error(
"Integrates: ep found @ nt = "+
ex2str(nt));
896 if(!is_a<numeric>(nt)) {
898 for(
auto nti : cv_lst) {
899 auto nnt = nti.op(0);
900 if(!is_a<numeric>(nnt))
throw Error(
"Integrates: Not a number with nt = "+
ex2str(nnt));
903 }
else nt_lst.append(nt);
905 for(
auto nnt : nt_lst) {
906 if(
ReIm!=3 && reim!=3) {
907 if(ex_to<numeric>(nnt).imag()==0) {
908 if(reim==2) reim = 3;
910 }
else if(ex_to<numeric>(nnt).real()==0) {
911 if(reim==1) reim = 3;
920 if(qnt > cmax) cmax = qnt;
927 if(e.match(log(
w)) && e.op(0)<1) {
928 return -log(1/e.op(0));
929 }
else if(e.match(
w1*log(
w2))) {
930 ex cv = e.subs(
w1*log(
w2)==lst{
w1,
w2});
931 if(ex_to<numeric>(cv.op(0)).is_integer()) {
932 return self(log(pow(cv.op(1), cv.op(0))));
933 }
else return e.map(self);
934 }
else return e.map(self);
940 if(is_zero(co2-co))
break;
943 if(normal(co).is_zero()) {
944 lstRE[current-1] = 0;
947 throw Error(
"Integrates: cmax<=0 with co = "+
ex2str(co));
949 if(reim!=3 &&
ReIm!=3) {
952 else if(reim==2) reim=1;
957 sprintf(d1,
"%.6G", (
double)(
EpsAbs/cmax/stot));
958 sprintf(d2,
"%.6G", (
double)cmax);
959 if(
Verbose>5) cout <<
"XDim=" << xsize <<
", EpsAbs=" << d1 <<
"/" << d2 << endl;
960 auto las = LambdaMap[ftid];
961 bool hasF = (ftid>0);
962 if(hasF && las.is_zero())
throw Error(
"Integrates: lambda with the key(ft_n=" +
ex2str(ftid) +
") is NOT found!");
963 if(hasF && !is_a<lst>(las)) {
964 if(!is_zero(las-ex(1979))) {
965 throw Error(
"Integrates: something is wrong with the F-term @ ft_n = "+
ex2str(ftid) +
", las=" +
ex2str(las));
975 int idx = ex_to<numeric>(intid).to_int();
976 auto module = main_module;
977 if(idx>=
soLimit)
module = ex_modules[idx/soLimit-1];
979 if(hasF) fname <<
"C";
980 fname <<
"SDD_" << idx;
983 cout <<
"dlerror(): " << dlerror() << endl;
984 throw Error(
"Integrates: fpD==NULL");
989 if(hasF) fname <<
"C";
990 fname <<
"SDQ_" << idx;
993 cout <<
"dlerror(): " << dlerror() << endl;
994 throw Error(
"Integrates: fpQ==NULL");
999 if(hasF) fname <<
"C";
1000 fname <<
"SDMP_" << idx;
1003 if(is_a<lst>(las)) {
1006 fname <<
"FT_" << idx;
1009 cout <<
"dlerror(): " << dlerror() << endl;
1010 throw Error(
"Integrates: ftp==NULL.");
1014 dREAL dlas[las.nops()], dpl[npara];
1015 qREAL qlas[las.nops()], qpl[npara];
1016 mpREAL mplas[las.nops()], mppl[npara];
1018 qpl[kv.first] =
ex2q(kv.second);
1019 dpl[kv.first] = (
dREAL)qpl[kv.first];
1020 mppl[kv.first] = qpl[kv.first];
1039 qREAL lamax =
ex2q(las.op(las.nops()-1));
1042 int ctryR = 0, ctry = 0, ctryL = 0;
1044 ex min_err, min_res;
1046 qREAL log_lamax = log10q(lamax);
1047 qREAL log_lamin = log_lamax-1.Q;
1049 ostringstream las_fn;
1051 if(pkey !=
"") las_fn <<
"-" << pkey;
1052 las_fn <<
"-" << current <<
".las";
1054 std::ifstream las_ifs;
1055 las_ifs.open(las_fn.str(), ios::in);
1056 if (!las_ifs)
throw Error(
"Integrates: failed to open *.las file!");
1057 for(
int i=0; i<las.nops()-1; i++) {
1061 dlas[i] = (
dREAL)qlas[i];
1066 auto res_tmp = res.subs(VE(
w1,
w2)==
w2);
1067 auto err = real_part(res_tmp);
1068 if(err < imag_part(res_tmp)) err = imag_part(res_tmp);
1077 bool err_break =
false;
1080 if(ctryR>0 || ctry>0 || ctryL>0)
1081 cout <<
" ------------------------------" << endl;
1083 auto log_cla = (log_lamin + s * (log_lamax-log_lamin) /
LambdaSplit);
1084 auto cla = powq(10.Q, log_cla);
1085 if(cla < 1E-10)
throw Error(
"NIntegrate: too small lambda.");
1086 for(
int i=0; i<las.nops()-1; i++) {
1087 qlas[i] =
ex2q(las.op(i)) * cla;
1088 dlas[i] = (
dREAL)qlas[i];
1099 if(res.has(
NaN) && s==0)
continue;
1100 else if(res.has(
NaN))
break;
1101 ex res_abs =
NN(abs(res.subs(VE(
w1,
w2)==
w1)));
1102 if(lastResErr.is_zero()) lastResErr = res;
1104 diff = diff.subs(VE(0,0)==0);
1106 diff.find(VE(
w0,
w1), ves);
1107 for(
auto ve : ves) {
1108 auto ve0 = abs(ve.op(0));
1110 if(numeric(
"1.E10")*ve0<res_abs)
continue;
1111 if(numeric(
"1.E10")*ve0<
q2ex(
EpsAbs))
continue;
1122 auto res_tmp = res.subs(VE(
w1,
w2)==
w2);
1123 auto err = real_part(res_tmp);
1124 if(err < imag_part(res_tmp)) err = imag_part(res_tmp);
1125 if(smin<0 || err < min_err) {
1131 if(s>0 && min_err <
q2ex(
EpsAbs/cmax/stot)) {
1138 lstRE[current-1] = co * min_res;
1141 if(err > 100 * min_err)
break;
1143 if(smin == -2)
break;
1144 if(smin == -1)
throw Error(
"Integrates: smin = -1, too small lambda (<1E-10)!");
1147 if((!err_break) && (ctryL >=
CTryL || ctryR>0))
break;
1148 log_lamax = log_lamin;
1150 if(!err_break) ctryL++;
1152 if(ctryR >=
CTryR || ctryL>0)
break;
1153 log_lamin = log_lamax;
1157 if(ctry >=
CTryM)
break;
1158 auto la1 = log_lamin + (smin-1) * (log_lamax-log_lamin) /
LambdaSplit;
1159 auto la2 = log_lamin + (smin+1) * (log_lamax-log_lamin) /
LambdaSplit;
1166 if(smin == -2)
continue;
1168 auto log_cla = (log_lamin + smin * (log_lamax-log_lamin) /
LambdaSplit);
1169 auto cla = powq(10.Q, log_cla);
1171 for(
int i=0; i<las.nops()-1; i++) {
1172 qlas[i] =
ex2q(las.op(i)) * cla;
1173 dlas[i] = (
dREAL)qlas[i];
1187 dREAL oo[las.nops()-1], ip[las.nops()-1];
1188 for(
int i=0; i<las.nops()-1; i++) ip[i] = oo[i] = (
dREAL)qlas[i];
1197 for(
int i=0; i<las.nops()-1; i++) {
1199 dlas[i] = (
dREAL)qlas[i];
1208 for(
int i=0; i<xsize; i++) {
1210 quadmath_snprintf(buffer,
sizeof buffer,
"%.6QG", qlas[i]);
1211 cout << buffer <<
" ";
1213 cout << endl <<
" ------------------------------" << endl;
1219 std::ofstream las_ofs;
1220 las_ofs.open(las_fn.str(), ios::out);
1222 for(
int i=0; i<las.nops()-1; i++) {
1224 las_ofs << la_tmp <<
" ";
1238 lstRE[current-1] =
NaN;
1240 lstRE[current-1] = co * res;
1248 for(
auto module : ex_modules) dlclose(module);
1249 dlclose(main_module);
1259 ostringstream garfn;
1261 if(pkey !=
"") garfn <<
"-" << pkey;
1262 garfn <<
".res.gar";
1265 ar.archive_ex(lstRE,
"relst");
1266 ar.archive_ex(19790923,
"c");
1267 ofstream out(garfn.str());