- // using Euler-MacLaurin summation
- if (n==2) {
- // Li_2. X_0 is special ...
- std::vector<cln::cl_N>::const_iterator it = Xn[0].begin();
- cln::cl_N u = -cln::log(cln::complex(cln::cl_float(1, prec), 0)-x);
- cln::cl_N factor = u;
- cln::cl_N res = u - u*u/4;
- cln::cl_N resbuf;
- for (int i=1; true; i++) {
- resbuf = res;
- factor = factor * u*u / (2*i * (2*i+1));
- res = res + (*it) * factor;
- it++; // should we check it? or rely on initsize? ...
- if (cln::zerop(res-resbuf))
- {
- break;
- }
- }
- return res;
- } else {
- // Li_3 and higher
- std::vector<cln::cl_N>::const_iterator it = Xn[n-2].begin();
- cln::cl_N u = -cln::log(cln::complex(cln::cl_float(1, prec), 0)-x);
- cln::cl_N factor = u;
- cln::cl_N res = u;
- cln::cl_N resbuf;
- for (int i=1; true; i++) {
- resbuf = res;
- factor = factor * u / (i+1);
- res = res + (*it) * factor;
- it++; // should we check it? or rely on initsize? ...
- if (cln::zerop(res-resbuf))
- {
- // should not be needed.
-// if (!cln::zerop(*it)) {
- break;
-// }
- }
- }
- return res;
- }
+
+// calculates Li(2,x) with EuMac
+static cln::cl_N Li2_series_EuMac(const cln::cl_N& x)
+{
+ std::vector<cln::cl_N>::const_iterator it = Xn[0].begin();
+ cln::cl_N u = -cln::log(1-x);
+ cln::cl_N factor = u;
+ cln::cl_N res = u - u*u/4;
+ cln::cl_N resbuf;
+ unsigned i = 1;
+ do {
+ resbuf = res;
+ factor = factor * u*u / (2*i * (2*i+1));
+ res = res + (*it) * factor;
+ it++; // should we check it? or rely on initsize? ...
+ i++;
+ } while (res != resbuf);
+ return res;
+}
+
+
+// calculates Li(n,x), n>2 without EuMac
+static cln::cl_N Lin_series(int n, const cln::cl_N& x)
+{
+ cln::cl_N factor = x;
+ cln::cl_N res = x;
+ cln::cl_N resbuf;
+ int i=2;
+ do {
+ resbuf = res;
+ factor = factor * x;
+ res = res + factor / cln::expt(cln::cl_I(i),n);
+ i++;
+ } while (res != resbuf);
+ return res;