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.");
120 if(mpfr::mpreal::get_default_prec()!=pbit) mpfr::mpreal::set_default_prec(pbit);
126 ostringstream fsofn, sofn, cmd;
128 sofn << pid <<
".so";
129 fsofn << pid <<
"F.so";
132 sofn << key <<
".so";
134 garfn << key <<
".ci.gar";
136 ifstream in(garfn.str());
139 auto c = ar.unarchive_ex(
"c");
140 if(c!=19790923)
throw Error(
"Integrates: *.ci.gar error!");
141 auto gl = ar.unarchive_ex(
"soLimit");
142 eps_lst = ex_to<lst>(ar.unarchive_ex(
"eps_lst"));
144 auto res = ar.unarchive_ex(
"res");
146 for(
auto item : ex_to<lst>(res)) ciResult.push_back(ex_to<lst>(item));
150 if(pkey !=
"") garfn <<
"-" << pkey;
154 ifstream la_in(garfn.str());
157 auto la_c = la_ar.unarchive_ex(
"c");
158 auto la_res = la_ar.unarchive_ex(
"res");
159 if(la_c!=19790923)
throw Error(
"Integrates: *.ci.gar error!");
160 for(
auto item : ex_to<lst>(la_res)) {
161 LambdaMap[item.op(0)] = item.op(1);
169 if(pkey !=
"") garfn <<
"-" << pkey;
172 throw Error(
"Integrates: File Not Found: " + garfn.str());
176 ifstream res_in(garfn.str());
179 auto res_c = res_ar.unarchive_ex(
"c");
180 auto relst = res_ar.unarchive_ex(
"relst");
181 if(res_c!=19790923)
throw Error(
"*.res.gar error with kid!");
182 lstRE = ex_to<lst>(relst);
187 void* main_module = dlopen(sofn.str().c_str(), RTLD_NOW);
188 if(main_module ==
nullptr) {
189 main_module = dlopen((
"./"+sofn.str()).c_str(), RTLD_NOW);
190 if(main_module ==
nullptr) {
191 cout <<
"dlerror(): " << dlerror() << endl;
192 throw Error(
"Integrates: could not open main module!");
196 if(!
Debug && key ==
"") {
197 if(
file_exists(fsofn.str().c_str())) remove(fsofn.str().c_str());
198 remove(sofn.str().c_str());
200 vector<void*> ex_modules;
201 for(
int n=1;
true; n++) {
202 ostringstream ex_sofn;
204 ex_sofn << pid <<
"X" << n <<
".so";
206 ex_sofn << key <<
"X" << n <<
".so";
209 void*
module = dlopen(ex_sofn.str().c_str(), RTLD_NOW);
210 if(module ==
nullptr) {
211 module = dlopen(("./"+ex_sofn.str()).c_str(), RTLD_NOW);
212 if(module ==
nullptr) {
213 cout <<
"dlerror(): " << dlerror() << endl;
214 throw Error(
"Integrates: could not open ex-module!");
217 ex_modules.push_back(module);
218 if(!
Debug && key ==
"") remove(ex_sofn.str().c_str());
225 plRepl.append(PL(kv.first)==kv.second);
226 if(kv.first>npara) npara = kv.first;
231 int total = ciResult.size(), current = 0;
232 qREAL stot = sqrtq(total*1.Q);
236 for(
auto &item : ciResult) {
238 if(kid>0 && current != kid)
continue;
241 cout <<
PRE <<
"\\--Integrating [" <<current<<
"/"<<total<<
"] " << flush;
244 unsigned int xsize = 0;
247 xsize = ex_to<numeric>(item.op(1)).to_int();
255 ex res = VE(
NN(exint),0);
257 cout <<
"XDim=" << xsize << endl;
261 lstRE[kid-1] = res*co;
264 lstRE.append(res*co);
269 ex intid = item.op(0);
270 ex ftid = item.op(3);
281 if(co.has(PL(
w)))
throw Error(
"Integrates: PL found @ " +
ex2str(co));
284 if(
ReIm==3) reim = 3;
286 for(
int si=co.ldegree(
eps); si<=co.degree(
eps); si++) {
287 auto tmp = co.coeff(
eps, si);
288 if(tmp.has(
eps))
throw Error(
"Integrates: eps found @ " +
ex2str(tmp));
290 for(
int i=tmp.ldegree(
ep); i<=tmp.degree(
ep); i++) {
291 auto ccRes =
NN(tmp.coeff(
ep, i)).expand();
294 if(is_a<add>(ccRes)) {
295 for(
auto item : ccRes) css.append(item);
301 eps_map[epi.op(0)] = epn;
305 for(
int ci=0; ci<css.nops(); ci++) {
307 if(nt.has(
ep))
throw Error(
"Integrates: ep found @ nt = "+
ex2str(nt));
310 if(!is_a<numeric>(nt)) {
312 for(
auto nti : cv_lst) {
313 auto nnt = nti.op(0);
314 if(!is_a<numeric>(nnt))
throw Error(
"Integrates: Not a number with nt = "+
ex2str(nnt));
317 }
else nt_lst.append(nt);
319 for(
auto nnt : nt_lst) {
320 if(
ReIm!=3 && reim!=3) {
321 if(ex_to<numeric>(nnt).imag()==0) {
322 if(reim==2) reim = 3;
324 }
else if(ex_to<numeric>(nnt).real()==0) {
325 if(reim==1) reim = 3;
334 if(qnt > cmax) cmax = qnt;
341 if(e.match(log(
w)) && e.op(0)<1) {
342 return -log(1/e.op(0));
343 }
else if(e.match(
w1*log(
w2))) {
344 ex cv = e.subs(
w1*log(
w2)==lst{
w1,
w2});
345 if(ex_to<numeric>(cv.op(0)).is_integer()) {
346 return self(log(pow(cv.op(1), cv.op(0))));
347 }
else return e.map(self);
348 }
else return e.map(self);
354 if(is_zero(co2-co))
break;
357 if(normal(co).is_zero()) {
361 throw Error(
"Integrates: cmax<=0 with co = "+
ex2str(co));
363 if(reim!=3 &&
ReIm!=3) {
366 else if(reim==2) reim=1;
371 sprintf(d1,
"%.6G", (
double)(
EpsAbs/cmax/stot));
372 sprintf(d2,
"%.6G", (
double)cmax);
373 if(
Verbose>5) cout <<
"XDim=" << xsize <<
", EpsAbs=" << d1 <<
"/" << d2 << endl;
375 auto las = LambdaMap[ftid];
376 bool hasF = (ftid>0);
377 if(hasF && las.is_zero())
throw Error(
"Integrates: lambda with the key(ft_n=" +
ex2str(ftid) +
") is NOT found!");
379 if(hasF && !is_a<lst>(las)) {
380 if(!is_zero(las-ex(1979))) {
381 throw Error(
"Integrates: something is wrong with the F-term @ ft_n = "+
ex2str(ftid) +
", las=" +
ex2str(las));
391 int idx = ex_to<numeric>(intid).to_int();
392 auto module = main_module;
393 if(idx>=
soLimit)
module = ex_modules[idx/soLimit-1];
395 if(hasF) fname <<
"C";
396 fname <<
"SDD_" << idx;
400 cout <<
"dlerror(): " << dlerror() << endl;
401 throw Error(
"Integrates: fpD==NULL");
406 if(hasF) fname <<
"C";
407 fname <<
"SDQ_" << idx;
410 cout <<
"dlerror(): " << dlerror() << endl;
411 throw Error(
"Integrates: fpQ==NULL");
416 if(hasF) fname <<
"C";
417 fname <<
"SDMP_" << idx;
420 cout <<
"dlerror(): " << dlerror() << endl;
421 throw Error(
"Integrates: fpMP==NULL");
427 fname <<
"FT_" << idx;
430 cout <<
"dlerror(): " << dlerror() << endl;
431 throw Error(
"Integrates: ftp==NULL.");
435 dREAL dlas[las.nops()], dpl[npara];
436 qREAL qlas[las.nops()], qpl[npara];
437 mpREAL mplas[las.nops()], mppl[npara];
439 qpl[kv.first] =
ex2q(kv.second);
440 dpl[kv.first] = (
dREAL)qpl[kv.first];
441 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];
519 cout <<
" λ=" << (double)cla;
521 cout <<
": " <<
NaN << endl;
523 cout <<
" λ=" << (double)cla;
529 if(res.has(
NaN) && s==0)
continue;
530 else if(res.has(
NaN))
break;
531 ex res_abs =
NN(abs(res.subs(VE(
w1,
w2)==
w1)));
532 if(lastResErr.is_zero()) lastResErr = res;
534 diff = diff.subs(VE(0,0)==0);
536 diff.find(VE(
w0,
w1), ves);
538 auto ve0 = abs(ve.op(0));
539 if(ve0>1.5*ve.op(1)) {
540 if(numeric(
"1.E10")*ve0<res_abs)
continue;
541 if(numeric(
"1.E10")*ve0<
q2ex(
EpsAbs))
continue;
552 auto res_tmp = res.subs(VE(
w1,
w2)==
w2);
553 auto err = real_part(res_tmp);
554 if(err < imag_part(res_tmp)) err = imag_part(res_tmp);
555 if(smin<0 || err < min_err) {
568 if(kid>0) lstRE[kid-1] = co * min_res;
569 else lstRE.append(co * min_res);
572 if(err > 100 * min_err)
break;
574 if(smin == -2)
break;
575 if(smin == -1)
throw Error(
"Integrates: smin = -1, too small lambda (<1E-10)!");
578 if((!err_break) && (ctryL >=
CTryL || ctryR>0))
break;
579 log_lamax = log_lamin;
581 if(!err_break) ctryL++;
583 if(ctryR >=
CTryR || ctryL>0)
break;
584 log_lamin = log_lamax;
588 if(ctry >=
CTryM)
break;
589 auto la1 = log_lamin + (smin-1) * (log_lamax-log_lamin) /
LambdaSplit;
590 auto la2 = log_lamin + (smin+1) * (log_lamax-log_lamin) /
LambdaSplit;
596 cout.precision(prec);
603 auto log_cla = (log_lamin + smin * (log_lamax-log_lamin) /
LambdaSplit);
604 auto cla = powq(10.Q, log_cla);
606 for(
int i=0; i<las.nops()-1; i++) {
607 qlas[i] =
ex2q(las.op(i)) * cla;
608 dlas[i] = (
dREAL)qlas[i];
622 dREAL oo[las.nops()-1], ip[las.nops()-1];
623 for(
int i=0; i<las.nops()-1; i++) ip[i] = oo[i] = (
dREAL)qlas[i];
632 for(
int i=0; i<las.nops()-1; i++) {
634 dlas[i] = (
dREAL)qlas[i];
643 for(
int i=0; i<xsize; i++) {
645 quadmath_snprintf(buffer,
sizeof buffer,
"%.6QG", qlas[i]);
646 cout << buffer <<
" ";
648 cout << endl <<
" ------------------------------" << endl;
654 std::ofstream las_ofs;
655 las_ofs.open(las_fn.str(), ios::out);
657 for(
int i=0; i<las.nops()-1; i++) {
659 las_ofs << la_tmp <<
" ";
675 if(kid>0) lstRE[kid-1] =
NaN;
676 else lstRE.append(
NaN);
680 lstRE[kid-1] = co * res;
682 }
else lstRE.append(co * res);
689 for(
auto module : ex_modules) dlclose(module);
690 dlclose(main_module);
701 if(pkey !=
"") garfn <<
"-" << pkey;
705 ar.archive_ex(lstRE,
"relst");
706 ar.archive_ex(19790923,
"c");
707 ofstream out(garfn.str());
727 if(mpfr::mpreal::get_default_prec()!=pbit) mpfr::mpreal::set_default_prec(pbit);
732 ostringstream fsofn, sofn, cmd;
735 sofn << key <<
".so";
737 garfn << key <<
".ci.gar";
739 ifstream in(garfn.str());
742 auto c = ar.unarchive_ex(
"c");
743 if(c!=19790923)
throw Error(
"ReIntegrates: *.ci.gar error!");
744 auto gl = ar.unarchive_ex(
"soLimit");
745 eps_lst = ex_to<lst>(ar.unarchive_ex(
"eps_lst"));
747 auto res = ar.unarchive_ex(
"res");
749 for(
auto item : ex_to<lst>(res)) ciResult.push_back(ex_to<lst>(item));
753 if(pkey !=
"") garfn <<
"-" << pkey;
757 ifstream la_in(garfn.str());
760 auto la_c = la_ar.unarchive_ex(
"c");
761 auto la_res = la_ar.unarchive_ex(
"res");
762 if(la_c!=19790923)
throw Error(
"ReIntegrates: *.ci.gar error!");
763 for(
auto item : ex_to<lst>(la_res)) {
764 LambdaMap[item.op(0)] = item.op(1);
772 if(pkey !=
"") garfn <<
"-" << pkey;
775 throw Error(
"ReIntegrates: File Not Found: " + garfn.str());
779 ifstream res_in(garfn.str());
782 auto res_c = res_ar.unarchive_ex(
"c");
783 auto relst = res_ar.unarchive_ex(
"relst");
784 if(res_c!=19790923)
throw Error(
"*.res.gar error with ReIntegrates!");
785 lstRE = ex_to<lst>(relst);
789 if(lstRE.nops()!=ciResult.size())
throw Error(
"Error: the size is not same between ciResult and lstRE!");
792 void* main_module = dlopen(sofn.str().c_str(), RTLD_NOW);
793 if(main_module ==
nullptr) {
794 main_module = dlopen((
"./"+sofn.str()).c_str(), RTLD_NOW);
795 if(main_module ==
nullptr) {
796 cout <<
"dlerror(): " << dlerror() << endl;
797 throw Error(
"ReIntegrates: could not open main module!");
801 vector<void*> ex_modules;
802 for(
int n=1;
true; n++) {
803 ostringstream ex_sofn;
804 ex_sofn << key <<
"X" << n <<
".so";
806 void*
module = dlopen(ex_sofn.str().c_str(), RTLD_NOW);
807 if(module ==
nullptr) {
808 module = dlopen(("./"+ex_sofn.str()).c_str(), RTLD_NOW);
809 if(module ==
nullptr) {
810 cout <<
"dlerror(): " << dlerror() << endl;
811 throw Error(
"ReIntegrates: could not open ex-module!");
814 ex_modules.push_back(module);
815 if(!
Debug && key ==
"") remove(ex_sofn.str().c_str());
822 plRepl.append(PL(kv.first)==kv.second);
823 if(kv.first>npara) npara = kv.first;
828 int total = ciResult.size(), current = 0;
829 qREAL stot = sqrtq(total*1.Q);
833 for(
auto &item : ciResult) {
836 if(cmerr < err)
continue;
839 quadmath_snprintf(es,
sizeof es,
"%.10QG", cmerr);
840 cout <<
PRE <<
"\\--Current Err: " << es << endl;
844 cout <<
PRE <<
"\\--ReIntegrating [" <<current<<
"/"<<total<<
"] " << flush;
847 unsigned int xsize = 0;
850 xsize = ex_to<numeric>(item.op(1)).to_int();
858 ex res = VE(
NN(exint),0);
860 cout <<
"XDim=" << xsize << endl;
863 lstRE[current-1] = res*co;
868 ex intid = item.op(0);
869 ex ftid = item.op(3);
872 lstRE[current-1] = 0;
877 lstRE[current-1] = 0;
880 if(co.has(PL(
w)))
throw Error(
"ReIntegrates: PL found @ " +
ex2str(co));
883 if(
ReIm==3) reim = 3;
885 for(
int si=co.ldegree(
eps); si<=co.degree(
eps); si++) {
886 auto tmp = co.coeff(
eps, si);
887 if(tmp.has(
eps))
throw Error(
"ReIntegrates: eps found @ " +
ex2str(tmp));
889 for(
int i=tmp.ldegree(
ep); i<=tmp.degree(
ep); i++) {
890 auto ccRes =
NN(tmp.coeff(
ep, i)).expand();
893 if(is_a<add>(ccRes)) {
894 for(
auto item : ccRes) css.append(item);
900 eps_map[epi.op(0)] = epn;
904 for(
int ci=0; ci<css.nops(); ci++) {
906 if(nt.has(
ep))
throw Error(
"ReIntegrates: ep found @ nt = "+
ex2str(nt));
909 if(!is_a<numeric>(nt)) {
911 for(
auto nti : cv_lst) {
912 auto nnt = nti.op(0);
913 if(!is_a<numeric>(nnt))
throw Error(
"ReIntegrates: Not a number with nt = "+
ex2str(nnt));
916 }
else nt_lst.append(nt);
918 for(
auto nnt : nt_lst) {
919 if(
ReIm!=3 && reim!=3) {
920 if(ex_to<numeric>(nnt).imag()==0) {
921 if(reim==2) reim = 3;
923 }
else if(ex_to<numeric>(nnt).real()==0) {
924 if(reim==1) reim = 3;
933 if(qnt > cmax) cmax = qnt;
940 if(e.match(log(
w)) && e.op(0)<1) {
941 return -log(1/e.op(0));
942 }
else if(e.match(
w1*log(
w2))) {
943 ex cv = e.subs(
w1*log(
w2)==lst{
w1,
w2});
944 if(ex_to<numeric>(cv.op(0)).is_integer()) {
945 return self(log(pow(cv.op(1), cv.op(0))));
946 }
else return e.map(self);
947 }
else return e.map(self);
953 if(is_zero(co2-co))
break;
956 if(normal(co).is_zero()) {
957 lstRE[current-1] = 0;
960 throw Error(
"ReIntegrates: cmax<=0 with co = "+
ex2str(co));
962 if(reim!=3 &&
ReIm!=3) {
965 else if(reim==2) reim=1;
970 sprintf(d1,
"%.6G", (
double)(
EpsAbs/cmax/stot));
971 sprintf(d2,
"%.6G", (
double)cmax);
972 if(
Verbose>5) cout <<
"XDim=" << xsize <<
", EpsAbs=" << d1 <<
"/" << d2 << endl;
973 auto las = LambdaMap[ftid];
974 bool hasF = (ftid>0);
975 if(hasF && las.is_zero())
throw Error(
"ReIntegrates: lambda with the key(ft_n=" +
ex2str(ftid) +
") is NOT found!");
976 if(hasF && !is_a<lst>(las)) {
977 if(!is_zero(las-ex(1979))) {
978 throw Error(
"ReIntegrates: something is wrong with the F-term @ ft_n = "+
ex2str(ftid) +
", las=" +
ex2str(las));
988 int idx = ex_to<numeric>(intid).to_int();
989 auto module = main_module;
990 if(idx>=
soLimit)
module = ex_modules[idx/soLimit-1];
992 if(hasF) fname <<
"C";
993 fname <<
"SDD_" << idx;
996 cout <<
"dlerror(): " << dlerror() << endl;
997 throw Error(
"ReIntegrates: fpD==NULL");
1002 if(hasF) fname <<
"C";
1003 fname <<
"SDQ_" << idx;
1006 cout <<
"dlerror(): " << dlerror() << endl;
1007 throw Error(
"ReIntegrates: fpQ==NULL");
1012 if(hasF) fname <<
"C";
1013 fname <<
"SDMP_" << idx;
1016 cout <<
"dlerror(): " << dlerror() << endl;
1017 throw Error(
"ReIntegrates: fpMP==NULL");
1020 if(is_a<lst>(las)) {
1023 fname <<
"FT_" << idx;
1026 cout <<
"dlerror(): " << dlerror() << endl;
1027 throw Error(
"ReIntegrates: ftp==NULL.");
1031 dREAL dlas[las.nops()], dpl[npara];
1032 qREAL qlas[las.nops()], qpl[npara];
1033 mpREAL mplas[las.nops()], mppl[npara];
1035 qpl[kv.first] =
ex2q(kv.second);
1036 dpl[kv.first] = (
dREAL)qpl[kv.first];
1037 mppl[kv.first] = qpl[kv.first];
1057 qREAL lamax =
ex2q(las.op(las.nops()-1));
1060 int ctryR = 0, ctry = 0, ctryL = 0;
1062 ex min_err, min_res;
1064 qREAL log_lamax = log10q(lamax);
1065 qREAL log_lamin = log_lamax-1.Q;
1067 ostringstream las_fn;
1069 if(pkey !=
"") las_fn <<
"-" << pkey;
1070 las_fn <<
"-" << current <<
".las";
1072 std::ifstream las_ifs;
1073 las_ifs.open(las_fn.str(), ios::in);
1074 if (!las_ifs)
throw Error(
"ReIntegrates: failed to open *.las file!");
1075 for(
int i=0; i<las.nops()-1; i++) {
1079 dlas[i] = (
dREAL)qlas[i];
1084 auto res_tmp = res.subs(VE(
w1,
w2)==
w2);
1085 auto err = real_part(res_tmp);
1086 if(err < imag_part(res_tmp)) err = imag_part(res_tmp);
1095 bool err_break =
false;
1098 if(ctryR>0 || ctry>0 || ctryL>0)
1099 cout <<
" ------------------------------" << endl;
1101 auto log_cla = (log_lamin + s * (log_lamax-log_lamin) /
LambdaSplit);
1102 auto cla = powq(10.Q, log_cla);
1103 if(cla < 1E-10)
throw Error(
"ReIntegrates: too small lambda.");
1104 for(
int i=0; i<las.nops()-1; i++) {
1105 qlas[i] =
ex2q(las.op(i)) * cla;
1106 dlas[i] = (
dREAL)qlas[i];
1114 cout <<
" λ=" << (double)cla;
1116 cout <<
": " <<
NaN << endl;
1118 cout <<
" λ=" << (double)cla;
1124 if(res.has(
NaN) && s==0)
continue;
1125 else if(res.has(
NaN))
break;
1126 ex res_abs =
NN(abs(res.subs(VE(
w1,
w2)==
w1)));
1127 if(lastResErr.is_zero()) lastResErr = res;
1129 diff = diff.subs(VE(0,0)==0);
1131 diff.find(VE(
w0,
w1), ves);
1132 for(
auto ve : ves) {
1133 auto ve0 = abs(ve.op(0));
1134 if(ve0>1.5*ve.op(1)) {
1135 if(numeric(
"1.E10")*ve0<res_abs)
continue;
1136 if(numeric(
"1.E10")*ve0<
q2ex(
EpsAbs))
continue;
1147 auto res_tmp = res.subs(VE(
w1,
w2)==
w2);
1148 auto err = real_part(res_tmp);
1149 if(err < imag_part(res_tmp)) err = imag_part(res_tmp);
1150 if(smin<0 || err < min_err) {
1156 if(s>0 && min_err <
q2ex(
EpsAbs/cmax/stot)) {
1163 lstRE[current-1] = co * min_res;
1166 if(err > 100 * min_err)
break;
1168 if(smin == -2)
break;
1169 if(smin == -1)
throw Error(
"ReIntegrates: smin = -1, too small lambda (<1E-10)!");
1172 if((!err_break) && (ctryL >=
CTryL || ctryR>0))
break;
1173 log_lamax = log_lamin;
1175 if(!err_break) ctryL++;
1177 if(ctryR >=
CTryR || ctryL>0)
break;
1178 log_lamin = log_lamax;
1182 if(ctry >=
CTryM)
break;
1183 auto la1 = log_lamin + (smin-1) * (log_lamax-log_lamin) /
LambdaSplit;
1184 auto la2 = log_lamin + (smin+1) * (log_lamax-log_lamin) /
LambdaSplit;
1191 if(smin == -2)
continue;
1193 auto log_cla = (log_lamin + smin * (log_lamax-log_lamin) /
LambdaSplit);
1194 auto cla = powq(10.Q, log_cla);
1196 for(
int i=0; i<las.nops()-1; i++) {
1197 qlas[i] =
ex2q(las.op(i)) * cla;
1198 dlas[i] = (
dREAL)qlas[i];
1212 dREAL oo[las.nops()-1], ip[las.nops()-1];
1213 for(
int i=0; i<las.nops()-1; i++) ip[i] = oo[i] = (
dREAL)qlas[i];
1222 for(
int i=0; i<las.nops()-1; i++) {
1224 dlas[i] = (
dREAL)qlas[i];
1233 for(
int i=0; i<xsize; i++) {
1235 quadmath_snprintf(buffer,
sizeof buffer,
"%.6QG", qlas[i]);
1236 cout << buffer <<
" ";
1238 cout << endl <<
" ------------------------------" << endl;
1244 std::ofstream las_ofs;
1245 las_ofs.open(las_fn.str(), ios::out);
1247 for(
int i=0; i<las.nops()-1; i++) {
1249 las_ofs << la_tmp <<
" ";
1265 lstRE[current-1] =
NaN;
1267 lstRE[current-1] = co * res;
1275 for(
auto module : ex_modules) dlclose(module);
1276 dlclose(main_module);
1286 ostringstream garfn;
1288 if(pkey !=
"") garfn <<
"-" << pkey;
1289 garfn <<
".res.gar";
1292 ar.archive_ex(lstRE,
"relst");
1293 ar.archive_ex(19790923,
"c");
1294 ofstream out(garfn.str());