Line data Source code
1 : /* Copyright (C) 2000 The PARI group.
2 :
3 : This file is part of the PARI/GP package.
4 :
5 : PARI/GP is free software; you can redistribute it and/or modify it under the
6 : terms of the GNU General Public License as published by the Free Software
7 : Foundation. It is distributed in the hope that it will be useful, but WITHOUT
8 : ANY WARRANTY WHATSOEVER.
9 :
10 : Check the License for details. You should have received a copy of it, along
11 : with the package; see the file 'COPYING'. If not, write to the Free Software
12 : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
13 :
14 : #include "pari.h"
15 : #include "paripriv.h"
16 :
17 : /*****************************************************************/
18 : /* Program to compute L(chi,s) */
19 : /* for Im(s) large, chi primitive Dirichlet character */
20 : /* In the present branch, only Tyagi's method is used */
21 : /*****************************************************************/
22 : /* In addition, C can also be a polynomial defining an abelian
23 : * extension of Q. */
24 :
25 : /*****************************************************************/
26 : /* Character programs */
27 : /*****************************************************************/
28 : /* A character, always assumed primitive can be given in the following formats:
29 : * - omitted or 0: special to zetaRS,
30 : * - a t_INT: assumed to be a discriminant,
31 : * - a t_INTMOD: a conrey character,
32 : * - a pair [G,chi] or [bnr,chi],
33 : * - [C1,C2,...]~ where the Ci are characters as above with same moduli. */
34 :
35 : /* Given a list of linit/ldata for chars of same conductor F, return
36 : * [Vecan, F, Parities, Gaussums] */
37 : static GEN
38 1127 : mycharinit(GEN C, long bit)
39 : {
40 : GEN L, LVC, LE, LGA;
41 1127 : long F = 0, i, j, lc = lg(C), prec;
42 :
43 1127 : bit += 64; prec = nbits2prec(bit);
44 1127 : L = cgetg(lc, t_VEC);
45 1127 : LE = cgetg(lc, t_VECSMALL);
46 1127 : LGA = cgetg(lc, t_VEC);
47 2289 : for (i = 1; i < lc; i++)
48 : {
49 1162 : GEN gv, ga, gm, ro, ldata = gel(C, i);
50 : long e;
51 1162 : if (is_linit(ldata)) ldata = linit_get_ldata(ldata);
52 1162 : gv = ldata_get_gammavec(ldata); e = itou(gel(gv, 1));
53 1162 : gm = ldata_get_conductor(ldata);
54 1162 : ro = ldata_get_rootno(ldata);
55 1162 : if (isintzero(ro)) ro = lfunrootno(ldata, bit);
56 1162 : ga = gmul(ro, gsqrt(gm, prec)); if (e) ga = mulcxI(ga);
57 1162 : gel(LGA, i) = ga;
58 1162 : LE[i] = e;
59 1162 : if (i == 1) F = itos(gm); /* constant */
60 1162 : gel(L, i) = lfunan(ldata, F, prec);
61 : }
62 1127 : if (lc == 2 && is_vec_t(typ(gmael(L,1,1))))
63 : { /* multichar */
64 7 : LGA = gel(LGA,1); lc = lg(LGA);
65 7 : LVC = gel(L,1);
66 7 : LE = const_vecsmall(lc-1, LE[1]); /* FIXME: can handle mixed values */
67 : }
68 : else
69 : {
70 1120 : LVC = cgetg(F + 1, t_VEC);
71 4627 : for (j = 1; j <= F; j++)
72 : {
73 3507 : GEN v = cgetg(lc, t_VEC);
74 7301 : for (i = 1; i < lc; i++) gel(v, i) = gmael(L, i, j);
75 3507 : gel(LVC, j) = v;
76 : }
77 : }
78 1127 : return mkvec5(LVC, stoi(F), LE, LGA, grootsof1(2*F, prec));
79 : }
80 :
81 : /* n >= 1 and #VC = F, the conductor of the character or multicharacter X.
82 : * VC contains [X(1),X(2),...X(F)] */
83 : static GEN
84 636923 : mycall(GEN VC, long n)
85 : {
86 636923 : long F = lg(VC) - 1;
87 636923 : GEN z = n <= F ? gel(VC, n) : gel(VC, ((n - 1) % F) + 1);
88 636923 : return gequal0(z)? NULL: z;
89 : }
90 :
91 205578 : static GEN get_chivec(GEN VCALL) { return gel(VCALL, 1); }
92 805484 : static long get_modulus(GEN VCALL) { return itos(gel(VCALL, 2)); }
93 204871 : static GEN get_signat(GEN VCALL) { return gel(VCALL, 3); }
94 21 : static GEN get_gauss(GEN VCALL) { return gel(VCALL, 4); }
95 203968 : static GEN get_chiZ(GEN VCALL) { return gel(VCALL, 5); }
96 :
97 : /* (-1)^A[i] * conj(B[i]) */
98 : static GEN
99 7 : gnegconj(GEN A, GEN B)
100 : {
101 7 : long i, l = lg(A);
102 7 : GEN W = cgetg(l, t_VEC);
103 14 : for (i = 1; i < l; i++)
104 7 : { GEN b = gconj(gel(B,i)); gel(W,i) = A[i]? gneg(b): b; }
105 7 : return W;
106 : }
107 : /* g(conj(CHI)) */
108 : static GEN
109 7 : gaussconj(GEN VCALL)
110 7 : { return gnegconj(get_signat(VCALL), get_gauss(VCALL)); }
111 :
112 : static GEN
113 7 : myinitconj(GEN VCALL)
114 : {
115 7 : GEN CONJ = shallowcopy(VCALL);
116 7 : gel(CONJ, 1) = gconj(get_chivec(VCALL));
117 7 : gel(CONJ, 4) = gaussconj(VCALL); return CONJ;
118 : }
119 :
120 : /********************************************************************/
121 : /* Driver Program */
122 : /********************************************************************/
123 :
124 : /* assume |Im(s)| >> 1, in particular s is not a negative integer */
125 : static GEN
126 14 : applyfuneq(GEN gau, GEN s, GEN z, long odd, long q, long bitprec)
127 : {
128 : GEN t, S;
129 : long prec;
130 14 : if (!gequal0(s)) bitprec += maxss(gexpo(s), 0);
131 14 : prec = nbits2prec(bitprec);
132 14 : if (odd) gau = mulcxmI(gau);
133 14 : S = gmul(Pi2n(-1, prec), gsubgs(s, odd));
134 14 : t = ginv(gmul2n(gmul(gcos(S, prec), ggamma(s, prec)), 1));
135 14 : t = gmul(gpow(gdivgs(Pi2n(1, prec), q), s, prec), t);
136 14 : return gmul(gmul(gau, t), z);
137 : }
138 :
139 : static GEN RZchi(GEN VCALL, GEN s, long prec);
140 :
141 : /* VCALL already initialized */
142 : static GEN
143 1127 : lfunlarge_char(GEN VCALL, GEN s, long bitprec)
144 : {
145 1127 : pari_sp av = avma;
146 : GEN sig, tau, z;
147 1127 : long funeq = 0, ts = typ(s), stau, flconj, q;
148 1127 : if (!is_real_t(ts) && ts != t_COMPLEX) pari_err_TYPE("lfunlarge_char", s);
149 1127 : sig = real_i(s); tau = imag_i(s);
150 1127 : if (gexpo(tau) < 1) pari_err_DOMAIN("lfun","im(s)", "<", gen_2, tau);
151 1127 : stau = gsigne(tau);
152 1127 : if (stau < 0) { tau = gneg(tau); VCALL = myinitconj(VCALL); }
153 1127 : if (gcmp(sig, ghalf) < 0) { funeq = 1; sig = gsubsg(1, sig); }
154 1127 : flconj = ((stau > 0 && funeq) || (stau < 0 && !funeq));
155 1127 : q = get_modulus(VCALL); bitprec += gexpo(stoi(q));
156 1127 : z = RZchi(VCALL, mkcomplex(sig, tau), nbits2prec(bitprec));
157 1127 : if (flconj) z = gconj(z);
158 1127 : if (funeq)
159 : {
160 14 : GEN odd = get_signat(VCALL), gau = get_gauss(VCALL), Vz;
161 14 : long lC = lg(gau), j;
162 14 : Vz = cgetg(lC, t_VEC);
163 28 : for (j = 1; j < lC; j++)
164 14 : gel(Vz,j) = applyfuneq(gel(gau,j), s, gel(z,j), odd[j], q, bitprec);
165 14 : z = Vz;
166 : }
167 1127 : return gerepilecopy(av, z);
168 : }
169 :
170 : static GEN
171 14 : lfungetchars(GEN pol)
172 : {
173 14 : GEN L, F, v, bnf = Buchall(pol_x(1), 0, LOWDEFAULTPREC);
174 : GEN w, condall, bnr;
175 : long i, l, lc;
176 14 : condall = rnfconductor(bnf, pol); bnr = gel(condall, 2);
177 14 : L = bnrchar(bnr, gel(condall, 3), NULL); lc = lg(L);
178 14 : F = cgetg(lc, t_VEC);
179 77 : for (i = 1; i < lc; i++)
180 : {
181 63 : GEN chi = gel(L, i), cond = bnrconductor_raw(bnr, chi);
182 63 : gel(F, i) = gcoeff(gel(cond,1), 1, 1);
183 : }
184 14 : w = vec_equiv(F); l = lg(w); v = cgetg(l, t_COL);
185 42 : for (i = 1; i < l; i++)
186 : {
187 28 : GEN wi = gel(w, i), vi;
188 28 : long j, li = lg(wi);
189 28 : gel(v,i) = vi = cgetg(li, t_VEC);
190 28 : if (li == 2 && equali1(gel(F, wi[1]))) /* common conductor is 1 */
191 14 : gel(vi,1) = lfunmisc_to_ldata_shallow(gen_1);
192 : else
193 : {
194 63 : for (j = 1; j < li; j++)
195 49 : gel(vi,j) = lfunmisc_to_ldata_shallow(mkvec2(bnr, gel(L, wi[j])));
196 : }
197 : }
198 14 : return v;
199 : }
200 :
201 : /********************************************************************/
202 : /* NEW RS IMPLEMENTATION FROM SANDEEP TYAGI */
203 : /********************************************************************/
204 : /* See arXiv:2203.02509v2 */
205 :
206 5775 : static long m_n0(GEN sel) { return itos(gel(sel, 1)); }
207 599514 : static GEN m_r0(GEN sel) { return gel(sel, 2); }
208 1127 : static GEN m_al(GEN sel) { return gel(sel, 3); }
209 599514 : static GEN m_aleps(GEN sel) { return gel(sel, 4); }
210 4606 : static GEN m_h(GEN sel) { return gel(sel, 5); }
211 1176 : static GEN m_lin(GEN sel) { return gel(sel, 6); }
212 1176 : static long m_np(GEN sel) { return itou(gel(sel, 7)); }
213 :
214 : static GEN
215 3444 : phi_hat(GEN x, long prec)
216 : {
217 : GEN y;
218 3444 : if (gsigne(imag_i(x)) > 0)
219 1141 : y = gneg(gexpm1(gneg(gmul(PiI2(prec), x)), prec));
220 : else
221 2303 : y = gexpm1(gmul(PiI2(prec), x), prec);
222 3444 : return ginv(y);
223 : }
224 :
225 : static GEN
226 3388 : phi_hat_h0(GEN sel, long k, long prec)
227 : {
228 3388 : GEN t = gdiv(gsubsg(m_n0(sel) + k, m_r0(sel)), m_aleps(sel));
229 3388 : return phi_hat(gdiv(gasinh(t, prec), m_h(sel)), prec);
230 : }
231 :
232 : /* v[i] = A[i] * (a + (-1)^E[i] b) */
233 : static GEN
234 630952 : mul_addsub(GEN A, GEN a, GEN b, GEN E)
235 : {
236 630952 : long i, l = lg(E);
237 630952 : GEN v = cgetg(l, t_VEC);
238 1345352 : for (i = 1; i < l; i++)
239 714400 : gel(v,i) = gmul(gel(A,i), E[i]? gsub(a, b): gadd(a, b));
240 630952 : return v;
241 : }
242 :
243 : static GEN
244 202841 : wd(GEN VCALL, GEN pmd, GEN x, long prec)
245 : {
246 202841 : GEN VC = get_chivec(VCALL), E = get_signat(VCALL), Z = get_chiZ(VCALL);
247 202841 : GEN ex, emx, xpmd = gmul(x, pmd), y = NULL;
248 202841 : long md = get_modulus(VCALL), N = 2*md, k;
249 202841 : ex = gexp(mulcxI(xpmd), prec); emx = ginv(ex);
250 833793 : for (k = 1; k <= (md-1) / 2; k++)
251 : {
252 630952 : GEN xc = mycall(VC, k);
253 630952 : if (xc)
254 : {
255 630952 : GEN p3, p2, p1 = gmul(xc, gel(Z, Fl_neg(Fl_sqr(k,N), N) + 1));
256 630952 : GEN a = gmul(ex, gel(Z, N - k + 1)), b = gmul(emx, gel(Z, k + 1));
257 630952 : GEN c = gmul(ex, gel(Z, k + 1)), d = gmul(emx, gel(Z, N - k + 1));
258 630952 : if (odd(md))
259 : {
260 594831 : p2 = ginv(mulcxmI(gmul2n(gsub(a,b), -1))); /* 1 / sin(xpmd - kpmd) */
261 594831 : p3 = ginv(mulcxmI(gmul2n(gsub(c,d), -1))); /* 1 / sin(xpmd + kpmd) */
262 : }
263 : else
264 : {
265 36121 : p2 = mulcxI(gdiv(gadd(a,b), gsub(a,b))); /* cotan(xpmd - kpmd) */
266 36121 : p3 = mulcxI(gdiv(gadd(c,d), gsub(c,d))); /* cotan(xpmd + kpmd) */
267 : }
268 630952 : p1 = mul_addsub(p1, p2, p3, E);
269 630952 : y = y ? gadd(y, p1) : p1;
270 : }
271 : }
272 202841 : return mulcxmI(gdivgs(y, N));
273 : }
274 :
275 : static GEN
276 1127 : series_h0(long n0, GEN s, GEN VCALL, long fl, long prec)
277 : {
278 1127 : GEN C = get_modulus(VCALL) == 1? NULL: get_chivec(VCALL);
279 1127 : GEN R = pardirpowerssumfun(C, n0, gneg(s), fl, prec);
280 1127 : if (C) return R;
281 700 : if (fl) return mkvec2(mkvec(gel(R,1)), mkvec(gel(R,2)));
282 665 : return mkvec(R);
283 : }
284 :
285 : static GEN
286 1176 : series_residues_h0(GEN sel, GEN s, GEN VCALL, long prec)
287 : {
288 1176 : long n0 = m_n0(sel), np = m_np(sel), k;
289 1176 : GEN val = gen_0, VC = get_chivec(VCALL);
290 4676 : for (k = maxss(1 - np, 1 - n0); k <= 1 + np; k++)
291 : {
292 3500 : GEN nk = mycall(VC, n0 + k); /* n0 + k > 0 */
293 3500 : if (nk) val = gadd(val, gmul(gmul(phi_hat_h0(sel, k, prec), nk),
294 : gpow(stoi(n0 + k), gneg(s), prec)));
295 : }
296 1176 : return val;
297 : }
298 :
299 : static GEN
300 596126 : integrand_h0(GEN sel, GEN s, GEN VCALL, GEN x, long prec)
301 : {
302 596126 : pari_sp av = avma;
303 596126 : long md = get_modulus(VCALL);
304 596126 : GEN r0 = m_r0(sel), aleps = m_aleps(sel), zn, p1;
305 596126 : GEN pmd = divru(mppi(prec), md), ix = ginv(x);
306 596126 : zn = gadd(r0, gdivgs(gmul(aleps, gsub(x, ix)), 2));
307 596126 : p1 = gmul(expIxy(pmd, gsqr(zn), prec),
308 : gmul(gpow(zn, gneg(s), prec), gmul(aleps, gadd(x, ix))));
309 596126 : if (md == 1)
310 393285 : p1 = gdiv(mkvec(mulcxI(p1)), gmul2n(gsin(gmul(pmd, zn), prec), 2));
311 : else
312 202841 : p1 = gdivgs(gmul(p1, wd(VCALL, pmd, zn, prec)), -2);
313 596126 : return gerepileupto(av, p1);
314 : }
315 :
316 : static GEN
317 1176 : integral_h0(GEN sel, GEN s, GEN VCALL, long prec)
318 : {
319 1176 : GEN lin_grid = m_lin(sel), S = gen_0;
320 1176 : pari_sp av = avma;
321 1176 : long j, l = lg(lin_grid);
322 592794 : for (j = 1; j < l; j++)
323 : {
324 591618 : S = gadd(S, integrand_h0(sel, s, VCALL, gel(lin_grid, j), prec));
325 591618 : if ((j & 0xff) == 0) S = gerepileupto(av, S);
326 : }
327 1176 : return gerepileupto(av, gmul(m_h(sel), S));
328 : }
329 :
330 : /* a + log |x|, a t_REAL, low accuracy */
331 : static GEN
332 4676 : addrlogabs(GEN a, GEN x)
333 : {
334 4676 : long prec = DEFAULTPREC;
335 4676 : if (gequal0(x)) return real_m2n(64, prec); /* -oo */
336 4550 : switch(typ(x))
337 : {
338 4550 : case t_COMPLEX: return gmul2n(glog(cxnorm(x), prec), -1);
339 0 : case t_REAL: break;
340 0 : default: x = gtofp(x, prec);
341 : }
342 0 : return addrr(a, logr_abs(x));
343 : }
344 :
345 : struct fun_q_t { GEN sel, s, VCALL, B; };
346 : static GEN
347 4508 : fun_q(void *E, GEN x)
348 : {
349 4508 : struct fun_q_t *S = (struct fun_q_t *)E;
350 4508 : GEN z = integrand_h0(S->sel,S->s,S->VCALL, gexp(x,DEFAULTPREC), DEFAULTPREC);
351 4508 : if (typ(z) == t_VEC) z = vecsum(z);
352 4508 : return addrlogabs(S->B, z);
353 : }
354 : static GEN
355 2338 : brent_q(void *E, GEN (*f)(void*,GEN), GEN q_low, GEN q_hi)
356 : {
357 2338 : if (gsigne(f(E, q_low)) * gsigne(f(E, q_hi)) >= 0) return NULL;
358 0 : return zbrent(E, f, q_low, q_hi, LOWDEFAULTPREC);
359 : }
360 : static GEN
361 1169 : findq(void *E, GEN (*f)(void*,GEN), GEN lq, long prec)
362 : {
363 1169 : GEN q_low, q_hi, q_right, q_left, q_est = gasinh(lq, LOWDEFAULTPREC);
364 1169 : q_low = gdivgs(gmulsg(4, q_est), 5);
365 1169 : q_hi = gdivgs(gmulsg(3, q_est), 2);
366 1169 : q_right = brent_q(E, f, q_low, q_hi); if (!q_right) q_right = q_est;
367 1169 : q_left = brent_q(E, f, gneg(q_low), gneg(q_hi)); if (!q_left) q_left = q_est;
368 1169 : return gprec_w(gmax(q_right, q_left), prec);
369 : }
370 :
371 : static GEN
372 1127 : set_q_value(GEN sel, GEN s, GEN VCALL, long prec)
373 : {
374 : struct fun_q_t E;
375 1127 : GEN al = m_al(sel), lq;
376 1127 : long md = get_modulus(VCALL), LD = DEFAULTPREC;
377 1127 : E.sel = sel; E.s = s; E.VCALL = VCALL, E.B = mulur(prec, mplog2(LD));
378 1127 : lq = gdiv(gsqrt(gdiv(gmulsg(md, E.B), Pi2n(1, LD)), LD), al);
379 1127 : return findq((void*)&E, &fun_q, lq, prec);
380 : }
381 :
382 : static GEN
383 1141 : setlin_grid_exp(GEN h, long m, long prec)
384 : {
385 1141 : GEN w, vex = gpowers(gexp(h, prec), (m - 1)/2);
386 : long i;
387 1141 : w = cgetg(m+1, t_VEC); gel(w, (m + 1)/2) = gen_1;
388 290838 : for (i = (m + 3)/2; i <= m; i++)
389 : {
390 289697 : GEN t1 = gel(vex, i - ((m - 1)/2));
391 289697 : gel(w, i) = t1; gel(w, (m + 1) - i) = ginv(t1);
392 : }
393 1141 : return w;
394 : }
395 :
396 : static long
397 1141 : get_m(GEN q, long prec)
398 : {
399 1141 : GEN t = divrr(mulur(4 * prec, mplog2(prec)), sqrr(mppi(prec)));
400 1141 : return 2*itos(gfloor(mulrr(q, t))) + 1;
401 : }
402 :
403 : static GEN
404 1127 : RZinit(GEN s, GEN VCALL, GEN numpoles, long prec)
405 : {
406 : GEN sel, al, aleps, n0, r0, q, h;
407 1127 : long md = get_modulus(VCALL), m;
408 1127 : al = gcmpgs(gabs(imag_i(s), prec), 100) < 0 ? ginv(stoi(4)) : gen_1;
409 1127 : r0 = gsqrt(gdiv(gmulgs(s, md), PiI2(prec)), prec);
410 1127 : n0 = gfloor(gsub(real_i(r0), imag_i(r0)));
411 1127 : aleps = gmul(al, gexp(PiI2n(-2, prec), prec));
412 1127 : sel = mkvecn(7, n0, r0, al, aleps, NULL, NULL, numpoles);
413 1127 : q = set_q_value(sel, s, VCALL, prec);
414 1127 : m = get_m(q, prec);
415 1127 : gel(sel,5) = h = divru(q, (m - 1) >> 1);
416 1127 : gel(sel,6) = setlin_grid_exp(h, m, prec);
417 1127 : return sel;
418 : }
419 :
420 : static GEN
421 469 : xpquo_one(GEN s, GEN cs, GEN ga, long odd, long md, long prec)
422 : {
423 469 : GEN rho, a = odd? gen_1: gen_0, z = divsr(md, mppi(prec));
424 469 : rho = gmul(gdiv(gpow(gen_I(), gdivgs(gneg(a), 2), prec), gsqrt(ga, prec)),
425 : gpow(stoi(md), ginv(stoi(4)), prec));
426 469 : return gmul(gdiv(gconj(gmul(rho, gpow(z, gdivgs(cs, 2), prec))),
427 : gmul(rho, gpow(z, gdivgs(s, 2), prec))),
428 : gexp(gsub(gconj(glngamma(gdivgs(gadd(cs, a), 2), prec)),
429 : glngamma(gdivgs(gadd(s, a), 2), prec)), prec));
430 : }
431 :
432 : static GEN
433 1127 : xpquo(GEN s, GEN VCALL, long prec)
434 : {
435 1127 : GEN ve = get_signat(VCALL), VC = get_chivec(VCALL), Z = get_chiZ(VCALL);
436 1127 : GEN R, cs, cd = NULL;
437 1127 : long md = get_modulus(VCALL), lve = lg(ve), n, i;
438 1127 : if (!gequal0(s)) prec = nbits2prec(prec + maxss(gexpo(s), 0));
439 1127 : if (md == 1)
440 700 : return gmul(gpow(mppi(prec), gsub(s, ghalf), prec),
441 : gexp(gsub(glngamma(gdivgs(gsubsg(1, s), 2), prec),
442 : glngamma(gdivgs(s, 2), prec)), prec));
443 2898 : for (n = 1; n < md; n++)
444 : {
445 2471 : GEN xn = mycall(VC, n);
446 2471 : if (xn)
447 : {
448 2408 : xn = gmul(xn, gel(Z, 2*(md - n) + 1));
449 2408 : cd = cd ? gadd(cd, xn) : xn;
450 : }
451 : }
452 427 : cs = gsubsg(1, gconj(s)); R = cgetg(lve, t_VEC);
453 896 : for (i = 1; i < lve; i++)
454 469 : gel(R, i) = xpquo_one(s, cs, gel(cd, i), ve[i], md, prec);
455 427 : if (lve == 2) R = gel(R, 1);
456 427 : return R;
457 : }
458 :
459 : static GEN
460 1176 : total_value(GEN serh0, GEN sel, GEN s, GEN VCALL, long prec)
461 : {
462 1176 : return gadd(integral_h0(sel, s, VCALL, prec),
463 : gsub(serh0, series_residues_h0(sel, s, VCALL, prec)));
464 : }
465 : static GEN
466 1127 : dirichlet_ours(GEN s, GEN VCALL, long prec)
467 : {
468 1127 : int fl = !gequal(real_i(s), ghalf);
469 1127 : GEN sel = RZinit(s, VCALL, gen_1, prec);
470 1127 : GEN S1, S2, serh0 = series_h0(m_n0(sel), s, VCALL, fl, prec);
471 1127 : if (!fl)
472 1078 : S2 = S1 = total_value(serh0, sel, s, VCALL, prec);
473 : else
474 : {
475 49 : S1 = total_value(gel(serh0,1), sel, s, VCALL, prec);
476 49 : S2 = total_value(gconj(gel(serh0,2)), sel, gsubsg(1, gconj(s)), VCALL, prec);
477 : }
478 1127 : return gadd(S1, vecmul(xpquo(s, VCALL, prec), gconj(S2)));
479 : }
480 :
481 : /* assume |Im(s)| > 2^-bitprec */
482 : static GEN
483 1127 : RZchi(GEN VCALL, GEN s, long prec)
484 : {
485 1127 : long prec2 = prec + EXTRAPREC64;
486 1127 : return gprec_wtrunc(dirichlet_ours(gprec_w(s, prec2), VCALL, prec2), prec);
487 : }
488 :
489 : /********************************************************************/
490 : /* Utility Functions */
491 : /********************************************************************/
492 : /* lam = 0, return L(s); else Lambda(s) */
493 : static GEN
494 1127 : lfuncharall(GEN VCALL, GEN s, long lam, long bitprec)
495 : {
496 1127 : GEN ve, P, Q, R, z = lfunlarge_char(VCALL, s, bitprec);
497 : long l, i, q, prec;
498 1127 : if (!lam) return z;
499 882 : ve = get_signat(VCALL); l = lg(ve);
500 882 : q = get_modulus(VCALL); prec = nbits2prec(bitprec);
501 882 : R = cgetg(l, t_VEC);
502 882 : Q = divur(q, mppi(prec));
503 882 : P = (q == 1 || zv_equal0(ve))? NULL: gsqrt(utoipos(q), prec);
504 1764 : for (i = 1; i < l; i++)
505 : {
506 882 : GEN se = gmul2n(gaddgs(s, ve[i]), -1), r;
507 882 : if (lam == 1)
508 : {
509 0 : r = gmul(gpow(Q, se, prec), ggamma(se, prec));
510 0 : if (P && ve[i]) r = gdiv(r, P);
511 : }
512 : else
513 : {
514 882 : r = gadd(gmul(se, glog(Q, prec)), glngamma(se, prec));
515 882 : if (P && ve[i]) r = gsub(r, glog(P, prec));
516 : }
517 882 : gel(R, i) = r;
518 : }
519 882 : return lam == 1 ? vecmul(R, z) : gadd(R, glog(z, prec));
520 : }
521 :
522 : static GEN
523 28 : lfunlargeall_from_chars(GEN v, GEN s, long lam, long bit)
524 : {
525 28 : long i, l = lg(v);
526 84 : for (i = 1; i < l; i++)
527 : {
528 56 : GEN w = mycharinit(gel(v, i), bit), L = lfuncharall(w, s, lam, bit);
529 56 : gel(v, i) = lam==-1 ? vecsum(L): vecprod(L);
530 : }
531 28 : return lam==-1 ? vecsum(v): vecprod(v);
532 : }
533 : static GEN
534 1099 : lfunlargeall(GEN ldata, GEN s, long lam, long bit)
535 : {
536 : GEN w, an;
537 1099 : if (lg(ldata) == 2)
538 : { /* HACK: ldata[1] a t_DESC_PRODUCT from lfunabelianrelinit / Q */
539 14 : GEN v = lfunprod_get_fact(linit_get_tech(gel(ldata,1)));
540 : long i, l;
541 14 : v = shallowcopy(gel(v,1)); l = lg(v);
542 42 : for (i = 1; i < l; i++) gel(v,i) = mkvec(gel(v,i));
543 14 : return lfunlargeall_from_chars(v, s, lam, bit);
544 : }
545 1085 : an = gel(ldata_get_an(ldata), 2);
546 1085 : switch(ldata_get_type(ldata))
547 : {
548 14 : case t_LFUN_NF:
549 : {
550 14 : GEN v = lfungetchars(nf_get_pol(an));
551 14 : return lfunlargeall_from_chars(v, s, lam, bit);
552 : }
553 7 : case t_LFUN_CHIGEN:
554 : {
555 7 : GEN chi = gmael(an, 2, 2);
556 7 : if (lg(chi) > 1 && is_vec_t(typ(gel(chi,1))))
557 : { /* multi char */
558 7 : w = mycharinit(mkcol(ldata), bit);
559 7 : return lfuncharall(w, s, lam, bit);
560 : }
561 : }
562 : default: /* single char */
563 1064 : w = mycharinit(mkcol(ldata), bit);
564 1064 : return gel(lfuncharall(w, s, lam, bit), 1);
565 : }
566 : }
567 :
568 : GEN
569 231 : lfunlarge(GEN CHI, GEN s, long bit)
570 231 : { return lfunlargeall(CHI, s, 0, bit); }
571 :
572 : GEN
573 0 : lfunlambdalarge(GEN CHI, GEN s, long bit)
574 0 : { return lfunlargeall(CHI, s, 1, bit); }
575 :
576 : GEN
577 868 : lfunloglambdalarge(GEN CHI, GEN s, long bit)
578 868 : { return lfunlargeall(CHI, s, -1, bit); }
579 :
580 : /********************************************************************/
581 : /* LERCH RS IMPLEMENTATION FROM SANDEEP TYAGI */
582 : /********************************************************************/
583 :
584 : static GEN
585 56 : double_exp_residue_pos_h(GEN selsm, long k, long ind, long prec)
586 : {
587 56 : long nk = itos(gel(selsm, 1)) + k;
588 56 : GEN r = gel(selsm, 2), ale = gel(selsm, 3), aor = gel(selsm, 4);
589 56 : GEN h = gel(selsm, 5), t = gen_0;
590 56 : switch(ind)
591 : {
592 28 : case 0: t = gaddsg(nk, aor); break;
593 0 : case 1: t = gneg(gaddsg(nk, aor)); break;
594 28 : case 2: t = gsubsg(nk, aor); break;
595 : }
596 56 : return gdiv(gasinh(gdiv(gsub(t, r), ale), prec), h);
597 : }
598 :
599 : static GEN
600 56 : phi_hat_h(GEN selsm, long m, long ind, long prec)
601 56 : { return phi_hat(double_exp_residue_pos_h(selsm, m, ind, prec), prec); }
602 :
603 : static long
604 56 : myex(GEN is) { return gequal0(is) ? 0 : maxss(0, 2 + gexpo(is)); }
605 : static GEN
606 56 : gaminus(GEN s, long prec)
607 : {
608 56 : GEN is = imag_i(s), tmp;
609 : long prec2;
610 56 : if (gcmpgs(is, -5*prec) < 0) return gen_0;
611 56 : prec2 = nbits2prec(prec + myex(is));
612 56 : tmp = gexp(gsub(glngamma(s, prec2), gmul(PiI2n(-1, prec2), s)), prec2);
613 56 : return gprec_w(tmp, prec);
614 : }
615 : static GEN
616 28 : gaplus(GEN s, long prec)
617 : {
618 28 : GEN is = imag_i(s), tmp;
619 : long prec2;
620 28 : if (gcmpgs(is, 5*prec) > 0) return gen_0;
621 0 : prec2 = nbits2prec(prec + myex(is));
622 0 : tmp = gexp(gadd(glngamma(s, prec2), gmul(PiI2n(-1, prec2), s)), prec2);
623 0 : return gprec_w(tmp, prec);
624 : }
625 :
626 : GEN
627 3514 : serh_worker(GEN k, GEN z, GEN a, GEN ns, GEN gprec)
628 : {
629 3514 : long prec = itou(gprec);
630 3514 : return gmul(gpow(z, k, prec), gpow(gadd(a, k), ns, prec));
631 : }
632 :
633 : static void
634 28 : set_arg(GEN worker, GEN z, GEN a, GEN ns, long prec)
635 28 : { gel(worker, 7) = mkvec4(z, a, ns, utoi(prec)); }
636 :
637 :
638 : static GEN
639 14 : series_h0l(GEN worker, long n0, GEN s, GEN a, GEN lam, long prec)
640 : {
641 14 : GEN z = typ(lam) == t_INT ? gen_1 : gexp(gmul(PiI2(prec), lam), prec);
642 14 : set_arg(worker, z, a, gneg(s), prec);
643 14 : return parsum(gen_0, utoi(n0), worker);
644 : }
645 :
646 : static GEN
647 14 : series_h1(GEN worker, long n1, GEN s, GEN a, GEN lam, long prec)
648 : {
649 14 : GEN mP, pre_factor, z, sn = gsubgs(s, 1);
650 14 : GEN ini = gequal0(lam) ? gen_1 : gen_0;
651 14 : pre_factor = gaplus(gneg(sn), prec);
652 14 : if (gequal0(pre_factor)) return gen_0;
653 0 : mP = gneg(PiI2(prec));
654 0 : pre_factor = gmul(gmul(pre_factor, gexp(gmul(mP, gmul(a, lam)), prec)),
655 : gpow(Pi2n(1, prec), sn, prec));
656 0 : z = typ(a) == t_INT ? gen_1 : gexp(gmul(mP, a), prec);
657 0 : set_arg(worker, z, lam, sn, prec);
658 0 : return gmul(pre_factor, parsum(ini, stoi(n1 - 1), worker));
659 : }
660 :
661 : static GEN
662 14 : series_h2(GEN worker, long n2, GEN s, GEN a, GEN lam, long prec)
663 : {
664 14 : GEN P, pre_factor, z, sn = gsubgs(s, 1);
665 14 : pre_factor = gaminus(gneg(sn), prec);
666 14 : if (gequal0(pre_factor)) return gen_0;
667 14 : P = PiI2(prec);
668 14 : pre_factor = gmul(gmul(pre_factor, gexp(gmul(gneg(P), gmul(a, lam)), prec)),
669 : gpow(Pi2n(1, prec), sn, prec));
670 14 : z = typ(a) == t_INT ? gen_1 : gexp(gmul(P, a), prec);
671 14 : set_arg(worker, z, gneg(lam), sn, prec);
672 14 : return gmul(pre_factor, parsum(gen_1, stoi(n2), worker));
673 : }
674 :
675 : static GEN
676 14 : series_residues_h0l(long numpoles, GEN selsm0, GEN s, GEN a, GEN lam, long prec)
677 : {
678 14 : GEN P, val = gen_0, ra = real_i(a);
679 14 : long n0 = m_n0(selsm0), k;
680 14 : P = PiI2(prec);
681 42 : for (k = -numpoles + 1; k <= numpoles; k++)
682 28 : if (gsigne(gaddsg(n0 + k, ra)) > 0)
683 28 : val = gadd(val, gmul(gmul(phi_hat_h(selsm0, k, 0, prec),
684 : gexp(gmul(P, gmulgs(lam, n0 + k)), prec)),
685 : gpow(gaddsg(n0 + k, a), gneg(s), prec)));
686 14 : return val;
687 : }
688 :
689 : static GEN
690 14 : series_residues_h1(long numpoles, GEN selsm1, GEN s, GEN a, GEN lam, long prec)
691 : {
692 14 : GEN mP, val = gen_0, rlam = real_i(lam), pre_factor, sn = gsubgs(s, 1);
693 14 : long n1 = m_n0(selsm1), k;
694 14 : pre_factor = gaplus(gneg(sn), prec);
695 14 : if (gequal0(pre_factor)) return gen_0;
696 0 : mP = gneg(PiI2(prec));
697 0 : pre_factor = gmul(gmul(pre_factor, gexp(gmul(mP, gmul(a, lam)), prec)),
698 : gpow(Pi2n(1, prec), sn, prec));
699 0 : for (k = -numpoles; k <= numpoles - 1; k++)
700 0 : if (gsigne(gaddsg(n1 + k, rlam)) > 0)
701 0 : val = gadd(val, gmul(gmul(phi_hat_h(selsm1, k, 1, prec),
702 : gexp(gmul(mP, gmulgs(a, n1 + k)), prec)),
703 : gpow(gaddsg(n1 + k, lam), sn, prec)));
704 0 : return gmul(pre_factor, val);
705 : }
706 :
707 : static GEN
708 14 : series_residues_h2(long numpoles, GEN selsm2, GEN s, GEN a, GEN lam, long prec)
709 : {
710 14 : GEN P, val = gen_0, rlam = real_i(lam), pre_factor, sn = gsubgs(s, 1);
711 14 : long n2 = m_n0(selsm2), k;
712 14 : pre_factor = gaminus(gneg(sn), prec);
713 14 : if (gequal0(pre_factor)) return gen_0;
714 14 : P = PiI2(prec);
715 14 : pre_factor = gmul(gmul(pre_factor, gexp(gmul(gneg(P), gmul(a, lam)), prec)),
716 : gpow(Pi2n(1, prec), sn, prec));
717 42 : for (k = -numpoles + 1; k <= numpoles; k++)
718 28 : if (gsigne(gsubsg(n2 + k, rlam)) > 0)
719 28 : val = gsub(val, gmul(gmul(phi_hat_h(selsm2, k, 2, prec),
720 : gexp(gmul(P, gmulgs(a, n2 + k)), prec)),
721 : gpow(gsubsg(n2 + k, lam), sn, prec)));
722 14 : return gmul(pre_factor, val);
723 : }
724 :
725 : static GEN
726 3430 : integrand_h0l(GEN selsm0, GEN s, GEN alam1, GEN x, long prec)
727 : {
728 3430 : GEN r0 = gel(selsm0, 2), ale = gel(selsm0, 3), a = gel(selsm0, 4);
729 3430 : GEN ix = ginv(x), zn = gadd(r0, gmul2n(gmul(ale, gsub(x, ix)), -1));
730 3430 : GEN P = PiI2n(0, prec), den, num;
731 3430 : den = gexpm1(gmul(P, gmul2n(gsub(zn,a), 1)), prec);
732 3430 : num = gexp(gmul(gmul(P, zn), gsub(alam1, zn)), prec);
733 3430 : num = gmul(gmul(gmul(num, ale), gmul2n(gadd(x, ix), -1)),
734 : gpow(zn, gneg(s), prec));
735 3430 : return gdiv(num, den);
736 : }
737 :
738 : static GEN
739 6860 : integrand_h12(GEN selsm1, GEN s, GEN alam1, GEN x, long prec)
740 : {
741 6860 : GEN r1 = gel(selsm1, 2), ale = gel(selsm1, 3), lam = gel(selsm1, 4);
742 6860 : GEN ix = ginv(x), zn = gadd(r1, gmul2n(gmul(ale, gsub(x, ix)), -1));
743 6860 : GEN P = PiI2n(0, prec), den, num, y;
744 6860 : den = gexpm1(gmul(P, gmul2n(gadd(zn,lam), 1)), prec);
745 6860 : num = gexp(gmul(gmul(P, zn), gadd(alam1, zn)), prec);
746 6860 : num = gmul(gmul(gmul(num, ale), gmul2n(gadd(x, ix), -1)),
747 : gpow(zn, gsubgs(s, 1), prec));
748 6860 : y = gdiv(num, den);
749 6860 : if (gcmp(garg(zn, prec), Pi2n(-2, prec)) > 0)
750 1722 : y = gmul(y, gexp(gmul(PiI2(prec), gsubsg(1, s)), prec));
751 6860 : return y;
752 : }
753 :
754 : static GEN
755 14 : integral_h0l(GEN lin_grid, GEN selsm0, GEN s, GEN a, GEN lam, long prec)
756 : {
757 14 : GEN A = gaddgs(gmul2n(gadd(a, lam),1), 1), S = gen_0;
758 14 : pari_sp av = avma;
759 14 : long j, l = lg(lin_grid);
760 :
761 3388 : for (j = 1; j < l; j++)
762 : {
763 3374 : S = gadd(S, integrand_h0l(selsm0, s, A, gel(lin_grid, j), prec));
764 3374 : if ((j & 0xff) == 0) S = gerepileupto(av, S);
765 : }
766 14 : S = gmul(m_h(selsm0), S);
767 14 : A = gmul(a, gaddsg(1, gadd(a, gmul2n(lam, 1))));
768 14 : return gmul(S, gexp(gneg(gmul(PiI2n(0, prec), A)), prec));
769 : }
770 :
771 : /* do not forget a minus sign for index 2 */
772 : static GEN
773 28 : integral_h12(GEN lin_grid, GEN selsm1, GEN s, GEN a, GEN lam, long prec)
774 : {
775 28 : GEN A, E, S = gen_0, ga = gaminus(gsubsg(1, s), prec);
776 28 : pari_sp av = avma;
777 28 : long j, l = lg(lin_grid);
778 :
779 28 : if (gequal0(ga)) return S;
780 28 : A = gaddgs(gmul2n(gadd(a,lam), 1), 1);
781 6776 : for (j = 1; j < l; j++)
782 : {
783 6748 : S = gadd(S, integrand_h12(selsm1, s, A, gel(lin_grid, j), prec));
784 6748 : if ((j & 0xff) == 0) S = gerepileupto(av, S);
785 : }
786 28 : if (gequal0(S)) return gen_0;
787 28 : S = gmul(m_h(selsm1), S);
788 28 : E = gexp(gmul(PiI2n(0, prec), gmul(lam, gaddgs(lam, 1))), prec);
789 28 : return gmul(gmul(gmul(S, ga), E), gpow(Pi2n(1, prec), gsubgs(s, 1), prec));
790 : }
791 :
792 : struct _fun_q0_t { GEN sel, s, alam1, B; };
793 : static GEN
794 56 : _fun_q0(void *E, GEN x)
795 : {
796 56 : struct _fun_q0_t *S = (struct _fun_q0_t*)E;
797 56 : GEN z = integrand_h0l(S->sel, S->s, S->alam1, x, DEFAULTPREC);
798 56 : return addrlogabs(S->B, z);
799 : }
800 : static GEN
801 112 : _fun_q12(void *E, GEN x)
802 : {
803 112 : struct _fun_q0_t *S = (struct _fun_q0_t*)E;
804 112 : GEN z = integrand_h12(S->sel, S->s, S->alam1, x, DEFAULTPREC);
805 112 : return addrlogabs(S->B, z);
806 : }
807 :
808 : static GEN
809 14 : RZLERinit(GEN s, GEN a, GEN lam, GEN al, GEN numpoles, long prec)
810 : {
811 : GEN eps, r0, r1, r2, h, lin_grid, q, q0, q1, q2, sel0, sel1, sel2, lq;
812 14 : GEN pinv = ginv(PiI2(prec)), c = gmul2n(gadd(a, lam), -1), n0, n1, n2, c2;
813 : long m;
814 : struct _fun_q0_t E;
815 :
816 14 : if (!al || gequal0(al))
817 0 : al = gcmpgs(gabs(imag_i(s), prec), 100) < 0 ? ginv(stoi(4)) : gen_1;
818 14 : c2 = gsub(gsqr(c), gmul(s, pinv));
819 14 : r0 = gadd(c, gsqrt(c2, prec));
820 14 : r1 = gsqrt(gadd(c2, pinv), prec);
821 14 : r2 = gsub(r1, c);
822 14 : r1 = gneg(gadd(r1, c));
823 14 : n0 = gfloor(gsub(gadd(real_i(r0), imag_i(r0)), a));
824 14 : n1 = gneg(gfloor(gadd(gsub(real_i(r1), imag_i(r1)), real_i(lam))));
825 14 : n2 = gfloor(gadd(gsub(real_i(r2), imag_i(r2)), real_i(lam)));
826 :
827 14 : E.s = s; E.alam1 = gaddgs(gmul2n(gadd(a, lam), 1), 1);
828 14 : E.B = mulur(prec, mplog2(prec));
829 14 : lq = gmul(al, sqrtr_abs(mulrr(divsr(prec, Pi2n(1, DEFAULTPREC)),
830 : mplog2(DEFAULTPREC))));
831 14 : eps = gexp(PiI2n(-2, prec), prec);
832 14 : E.sel = sel0 = mkvec5(n0, r0, gdiv(al, eps), a, gen_0);
833 14 : q0 = findq(&E, &_fun_q0, lq, prec);
834 :
835 14 : if (!gequal1(al)) lq = gdiv(lq, gsqr(al));
836 14 : E.sel = sel1 = mkvec5(n1, r1, gmul(al, eps), lam, gen_0);
837 14 : q1 = findq(&E, &_fun_q12, lq, prec);
838 14 : E.sel = sel2 = mkvec5(n2, r2, gmul(al, eps), lam, gen_0);
839 14 : q2 = findq(&E, &_fun_q12, lq, prec);
840 14 : q = vecmax(mkvec3(q0, q1, q2)); m = get_m(q, prec);
841 14 : gel(sel0, 5) = gel(sel1, 5) = gel(sel2, 5) = h = divru(q, (m-1) >> 1);
842 14 : lin_grid = setlin_grid_exp(h, m, prec);
843 14 : if (!numpoles) numpoles = gen_1;
844 14 : return mkvec5(sel0, sel1, sel2, lin_grid, numpoles);
845 : }
846 :
847 42 : static GEN add3(GEN x, GEN y, GEN z) { return gadd(x, gadd(y,z)); }
848 14 : static GEN addsub(GEN x, GEN y, GEN z) { return gadd(x, gsub(y,z)); }
849 :
850 : static GEN
851 14 : lerch_ours(GEN sel, GEN s, GEN a, GEN lam, long prec)
852 : {
853 14 : GEN selsm0 = gel(sel, 1), selsm1 = gel(sel, 2), selsm2 = gel(sel, 3);
854 14 : GEN lin_grid = gel(sel, 4), v0, v1, v2;
855 14 : long numpoles = itos(gel(sel, 5));
856 14 : GEN worker = snm_closure(is_entry("_serh_worker"),
857 : mkvec4(NULL, NULL, NULL, NULL));
858 14 : v0 = add3(series_h0l(worker, m_n0(selsm0), s, a, lam, prec),
859 : series_residues_h0l(numpoles, selsm0, s, a, lam, prec),
860 : integral_h0l(lin_grid, selsm0, s, a, lam, prec));
861 14 : v1 = add3(series_h1(worker, m_n0(selsm1), s, a, lam, prec),
862 : series_residues_h1(numpoles, selsm1, s, a, lam, prec),
863 : integral_h12(lin_grid, selsm1, s, a, lam, prec));
864 14 : v2 = addsub(series_h2(worker, m_n0(selsm2), s, a, lam, prec),
865 : series_residues_h2(numpoles, selsm2, s, a, lam, prec),
866 : integral_h12(lin_grid, selsm2, s, a, lam, prec));
867 14 : return add3(v0, v1, v2);
868 : }
869 :
870 : static GEN
871 0 : RZlerch_easy(GEN s, GEN a, GEN lam, long prec)
872 : {
873 0 : pari_sp av = avma;
874 : GEN z, y, N;
875 0 : N = gdiv(gmulsg(prec + 5, mplog2(LOWDEFAULTPREC)),
876 : gmul(Pi2n(1, LOWDEFAULTPREC), imag_i(lam)));
877 0 : if (gexpo(N) > 40) pari_err_IMPL("precision too large in lerchzeta");
878 0 : N = gceil(N); prec += EXTRAPREC64;
879 0 : z = typ(lam) == t_INT ? gen_1 : gexp(gmul(PiI2(prec), lam), prec);
880 0 : y = parsum(gen_0, N, snm_closure(is_entry("_serh_worker"),
881 : mkvec4(z, a, gneg(s), stoi(prec))));
882 0 : return gerepilecopy(av, gprec_wtrunc(y, prec));
883 : }
884 :
885 : static GEN
886 14 : mygfrac(GEN z)
887 0 : { return typ(z) == t_COMPLEX ? mkcomplex(gfrac(real_i(z)), imag_i(z))
888 14 : : gfrac(z); }
889 :
890 : static GEN
891 42 : lerchlarge(GEN s, GEN a, GEN lam, GEN al, GEN numpoles, long prec)
892 : {
893 42 : pari_sp av = avma;
894 42 : GEN val, sel, imlam = imag_i(lam);
895 : long prec2;
896 42 : switch(gsigne(imlam))
897 : {
898 0 : case -1: pari_err_IMPL("imag(lam) < 0");
899 0 : case 1: if (gexpo(imlam) >= -16) return RZlerch_easy(s, a, lam, prec);
900 : }
901 42 : if (gcmpgs(real_i(a), 1) < 0)
902 : {
903 14 : GEN P = gexp(gmul(PiI2(prec), lam), prec);
904 14 : GEN L = lerchlarge(s, gaddgs(a, 1), lam, al, numpoles, prec);
905 14 : return gerepileupto(av, gadd(gpow(a, gneg(s), prec), gmul(P, L)));
906 : }
907 28 : if (gcmpgs(real_i(a), 2) >= 0)
908 : {
909 0 : GEN L, P = gexp(gneg(gmul(PiI2(prec), lam)), prec);
910 0 : a = gsubgs(a, 1); L = lerchlarge(s, a, lam, al, numpoles, prec);
911 0 : return gerepileupto(av, gmul(P, gsub(L, gpow(a, gneg(s), prec))));
912 : }
913 28 : if (gsigne(imag_i(s)) > 0)
914 : {
915 : GEN L;
916 14 : lam = mygfrac(gneg(gconj(lam)));
917 14 : L = lerchlarge(gconj(s), a, lam, al, numpoles, prec);
918 14 : return gerepileupto(av, gconj(L));
919 : }
920 14 : prec2 = prec + EXTRAPREC64;
921 14 : a = gprec_w(a, prec2);
922 14 : s = gprec_w(s, prec2);
923 14 : lam = gprec_w(lam, prec2);
924 14 : sel = RZLERinit(s, a, lam, al, numpoles, prec2);
925 14 : val = lerch_ours(sel, s, a, lam, prec2);
926 14 : return gerepilecopy(av, gprec_wtrunc(val, prec));
927 : }
928 :
929 : GEN
930 7 : zetahurwitzlarge(GEN s, GEN a, long prec)
931 7 : { return lerchlarge(s, a, gen_0, gen_1, gen_1, prec); }
932 :
933 : GEN
934 7 : lerchzetalarge(GEN s, GEN a, GEN lam, long prec)
935 7 : { return lerchlarge(s, a, lam, gen_1, gen_1, prec); }
|