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 1085 : mycharinit(GEN C, long bit)
39 : {
40 : GEN L, LVC, LE, LGA;
41 1085 : long F = 0, i, j, lc = lg(C), prec;
42 :
43 1085 : bit += 64; prec = nbits2prec(bit);
44 1085 : L = cgetg(lc, t_VEC);
45 1085 : LE = cgetg(lc, t_VECSMALL);
46 1085 : LGA = cgetg(lc, t_VEC);
47 2205 : for (i = 1; i < lc; i++)
48 : {
49 1120 : GEN gv, ga, gm, ro, ldata = gel(C, i);
50 : long e;
51 1120 : if (is_linit(ldata)) ldata = linit_get_ldata(ldata);
52 1120 : gv = ldata_get_gammavec(ldata); e = itou(gel(gv, 1));
53 1120 : gm = ldata_get_conductor(ldata);
54 1120 : ro = ldata_get_rootno(ldata);
55 1120 : if (isintzero(ro)) ro = lfunrootno(ldata, bit);
56 1120 : ga = gmul(ro, gsqrt(gm, prec)); if (e) ga = mulcxI(ga);
57 1120 : gel(LGA, i) = ga;
58 1120 : LE[i] = e;
59 1120 : if (i == 1) F = itos(gm); /* constant */
60 1120 : gel(L, i) = lfunan(ldata, F, prec);
61 : }
62 1085 : 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 1078 : LVC = cgetg(F + 1, t_VEC);
71 4459 : for (j = 1; j <= F; j++)
72 : {
73 3381 : GEN v = cgetg(lc, t_VEC);
74 7049 : for (i = 1; i < lc; i++) gel(v, i) = gmael(L, i, j);
75 3381 : gel(LVC, j) = v;
76 : }
77 : }
78 1085 : 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 618472 : mycall(GEN VC, long n)
85 : {
86 618472 : long F = lg(VC) - 1;
87 618472 : GEN z = n <= F ? gel(VC, n) : gel(VC, ((n - 1) % F) + 1);
88 618472 : return gequal0(z)? NULL: z;
89 : }
90 :
91 187267 : static GEN get_chivec(GEN VCALL) { return gel(VCALL, 1); }
92 763801 : static long get_modulus(GEN VCALL) { return itos(gel(VCALL, 2)); }
93 185965 : static GEN get_signat(GEN VCALL) { return gel(VCALL, 3); }
94 21 : static GEN get_gauss(GEN VCALL) { return gel(VCALL, 4); }
95 184663 : 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 1085 : lfunlarge_char(GEN VCALL, GEN s, long bitprec)
144 : {
145 1085 : pari_sp av = avma;
146 : GEN sig, tau, z;
147 1085 : long funeq = 0, ts = typ(s), stau, flconj, q;
148 1085 : if (!is_real_t(ts) && ts != t_COMPLEX) pari_err_TYPE("lfunlarge_char", s);
149 1085 : sig = real_i(s); tau = imag_i(s);
150 1085 : if (gexpo(tau) < 1) pari_err_DOMAIN("lfun","im(s)", "<", gen_2, tau);
151 1085 : stau = gsigne(tau);
152 1085 : if (stau < 0) { tau = gneg(tau); VCALL = myinitconj(VCALL); }
153 1085 : if (gcmp(sig, ghalf) < 0) { funeq = 1; sig = gsubsg(1, sig); }
154 1085 : flconj = ((stau > 0 && funeq) || (stau < 0 && !funeq));
155 1085 : q = get_modulus(VCALL); bitprec += gexpo(stoi(q));
156 1085 : z = RZchi(VCALL, mkcomplex(sig, tau), nbits2prec(bitprec));
157 1085 : if (flconj) z = gconj(z);
158 1085 : 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 1085 : 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 5523 : static long m_n0(GEN sel) { return itos(gel(sel, 1)); }
207 576072 : static GEN m_r0(GEN sel) { return gel(sel, 2); }
208 1085 : static GEN m_al(GEN sel) { return gel(sel, 3); }
209 576072 : static GEN m_aleps(GEN sel) { return gel(sel, 4); }
210 4396 : static GEN m_h(GEN sel) { return gel(sel, 5); }
211 1113 : static GEN m_lin(GEN sel) { return gel(sel, 6); }
212 1113 : static long m_np(GEN sel) { return itou(gel(sel, 7)); }
213 :
214 : static GEN
215 3297 : phi_hat(GEN x, long prec)
216 : {
217 : GEN y;
218 3297 : if (gsigne(imag_i(x)) > 0)
219 1078 : y = gneg(gexpm1(gneg(gmul(PiI2(prec), x)), prec));
220 : else
221 2219 : y = gexpm1(gmul(PiI2(prec), x), prec);
222 3297 : return ginv(y);
223 : }
224 :
225 : static GEN
226 3241 : phi_hat_h0(GEN sel, long k, long prec)
227 : {
228 3241 : GEN t = gdiv(gsubsg(m_n0(sel) + k, m_r0(sel)), m_aleps(sel));
229 3241 : 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 612774 : mul_addsub(GEN A, GEN a, GEN b, GEN E)
235 : {
236 612774 : long i, l = lg(E);
237 612774 : GEN v = cgetg(l, t_VEC);
238 1308996 : for (i = 1; i < l; i++)
239 696222 : gel(v,i) = gmul(gel(A,i), E[i]? gsub(a, b): gadd(a, b));
240 612774 : return v;
241 : }
242 :
243 : static GEN
244 184663 : wd(GEN VCALL, GEN pmd, GEN x, long prec)
245 : {
246 184663 : GEN VC = get_chivec(VCALL), E = get_signat(VCALL), Z = get_chiZ(VCALL);
247 184663 : GEN ex, emx, xpmd = gmul(x, pmd), y = NULL;
248 184663 : long md = get_modulus(VCALL), N = 2*md, k;
249 184663 : ex = gexp(mulcxI(xpmd), prec); emx = ginv(ex);
250 797437 : for (k = 1; k <= (md-1) / 2; k++)
251 : {
252 612774 : GEN xc = mycall(VC, k);
253 612774 : if (xc)
254 : {
255 612774 : GEN p3, p2, p1 = gmul(xc, gel(Z, Fl_neg(Fl_sqr(k,N), N) + 1));
256 612774 : GEN a = gmul(ex, gel(Z, N - k + 1)), b = gmul(emx, gel(Z, k + 1));
257 612774 : GEN c = gmul(ex, gel(Z, k + 1)), d = gmul(emx, gel(Z, N - k + 1));
258 612774 : 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 17943 : p2 = mulcxI(gdiv(gadd(a,b), gsub(a,b))); /* cotan(xpmd - kpmd) */
266 17943 : p3 = mulcxI(gdiv(gadd(c,d), gsub(c,d))); /* cotan(xpmd + kpmd) */
267 : }
268 612774 : p1 = mul_addsub(p1, p2, p3, E);
269 612774 : y = y ? gadd(y, p1) : p1;
270 : }
271 : }
272 184663 : return mulcxmI(gdivgs(y, N));
273 : }
274 :
275 : static GEN
276 1085 : series_h0(long n0, GEN s, GEN VCALL, long fl, long prec)
277 : {
278 1085 : GEN C = get_modulus(VCALL) == 1? NULL: get_chivec(VCALL);
279 1085 : GEN R = pardirpowerssumfun(C, n0, gneg(s), fl, prec);
280 1085 : if (C) return R;
281 686 : if (fl) return mkvec2(mkvec(gel(R,1)), mkvec(gel(R,2)));
282 658 : return mkvec(R);
283 : }
284 :
285 : static GEN
286 1113 : series_residues_h0(GEN sel, GEN s, GEN VCALL, long prec)
287 : {
288 1113 : long n0 = m_n0(sel), np = m_np(sel), k;
289 1113 : GEN val = gen_0, VC = get_chivec(VCALL);
290 4424 : for (k = maxss(1 - np, 1 - n0); k <= 1 + np; k++)
291 : {
292 3311 : GEN nk = mycall(VC, n0 + k); /* n0 + k > 0 */
293 3311 : if (nk) val = gadd(val, gmul(gmul(phi_hat_h0(sel, k, prec), nk),
294 : gpow(stoi(n0 + k), gneg(s), prec)));
295 : }
296 1113 : return val;
297 : }
298 :
299 : static GEN
300 572831 : integrand_h0(GEN sel, GEN s, GEN VCALL, GEN x, long prec)
301 : {
302 572831 : pari_sp av = avma;
303 572831 : long md = get_modulus(VCALL);
304 572831 : GEN r0 = m_r0(sel), aleps = m_aleps(sel), zn, p1;
305 572831 : GEN pmd = divru(mppi(prec), md), ix = ginv(x);
306 572831 : zn = gadd(r0, gdivgs(gmul(aleps, gsub(x, ix)), 2));
307 572831 : p1 = gmul(expIxy(pmd, gsqr(zn), prec),
308 : gmul(gpow(zn, gneg(s), prec), gmul(aleps, gadd(x, ix))));
309 572831 : if (md == 1)
310 388168 : p1 = gdiv(mkvec(mulcxI(p1)), gmul2n(gsin(gmul(pmd, zn), prec), 2));
311 : else
312 184663 : p1 = gdivgs(gmul(p1, wd(VCALL, pmd, zn, prec)), -2);
313 572831 : return gerepileupto(av, p1);
314 : }
315 :
316 : static GEN
317 1113 : integral_h0(GEN sel, GEN s, GEN VCALL, long prec)
318 : {
319 1113 : GEN lin_grid = m_lin(sel), S = gen_0;
320 1113 : pari_sp av = avma;
321 1113 : long j, l = lg(lin_grid);
322 569604 : for (j = 1; j < l; j++)
323 : {
324 568491 : S = gadd(S, integrand_h0(sel, s, VCALL, gel(lin_grid, j), prec));
325 568491 : if ((j & 0xff) == 0) S = gerepileupto(av, S);
326 : }
327 1113 : return gerepileupto(av, gmul(m_h(sel), S));
328 : }
329 :
330 : /* a + log |x|, a t_REAL, low accuracy */
331 : static GEN
332 4508 : addrlogabs(GEN a, GEN x)
333 : {
334 4508 : long prec = DEFAULTPREC;
335 4508 : if (gequal0(x)) return real_m2n(64, prec); /* -oo */
336 4438 : switch(typ(x))
337 : {
338 4438 : 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 4340 : fun_q(void *E, GEN x)
348 : {
349 4340 : struct fun_q_t *S = (struct fun_q_t *)E;
350 4340 : GEN z = integrand_h0(S->sel,S->s,S->VCALL, gexp(x,DEFAULTPREC), DEFAULTPREC);
351 4340 : if (typ(z) == t_VEC) z = vecsum(z);
352 4340 : return addrlogabs(S->B, z);
353 : }
354 : static GEN
355 2254 : brent_q(void *E, GEN (*f)(void*,GEN), GEN q_low, GEN q_hi)
356 : {
357 2254 : 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 1127 : findq(void *E, GEN (*f)(void*,GEN), GEN lq, long B)
362 : {
363 1127 : GEN q_low, q_hi, q_right, q_left, q_est = gasinh(lq, LOWDEFAULTPREC);
364 1127 : q_low = gdivgs(gmulsg(4, q_est), 5);
365 1127 : q_hi = gdivgs(gmulsg(3, q_est), 2);
366 1127 : q_right = brent_q(E, f, q_low, q_hi); if (!q_right) q_right = q_est;
367 1127 : q_left = brent_q(E, f, gneg(q_low), gneg(q_hi)); if (!q_left) q_left = q_est;
368 1127 : return bitprecision0(gmax(q_right, q_left), B);
369 : }
370 :
371 : static GEN
372 1085 : set_q_value(GEN sel, GEN s, GEN VCALL, long prec)
373 : {
374 : struct fun_q_t E;
375 1085 : GEN al = m_al(sel), lq;
376 1085 : long md = get_modulus(VCALL), LD = DEFAULTPREC;
377 1085 : E.sel = sel; E.s = s; E.VCALL = VCALL, E.B = mulur(prec, mplog2(LD));
378 1085 : lq = gdiv(gsqrt(gdiv(gmulsg(md, E.B), Pi2n(1, LD)), LD), al);
379 1085 : return findq((void*)&E, &fun_q, lq, prec);
380 : }
381 :
382 : static GEN
383 1099 : setlin_grid_exp(GEN h, long m, long prec)
384 : {
385 1099 : GEN w, vex = gpowers(gexp(h, prec), (m - 1)/2);
386 : long i;
387 1099 : w = cgetg(m+1, t_VEC); gel(w, (m + 1)/2) = gen_1;
388 283108 : for (i = (m + 3)/2; i <= m; i++)
389 : {
390 282009 : GEN t1 = gel(vex, i - ((m - 1)/2));
391 282009 : gel(w, i) = t1; gel(w, (m + 1) - i) = ginv(t1);
392 : }
393 1099 : return w;
394 : }
395 :
396 : static long
397 1099 : get_m(GEN q, long prec)
398 : {
399 1099 : GEN t = divrr(mulur(4 * prec2nbits(prec), mplog2(prec)), sqrr(mppi(prec)));
400 1099 : return 2*itos(gfloor(mulrr(q, t))) + 1;
401 : }
402 :
403 : static GEN
404 1085 : RZinit(GEN s, GEN VCALL, GEN numpoles, long prec)
405 : {
406 : GEN sel, al, aleps, n0, r0, q, h;
407 1085 : long md = get_modulus(VCALL), m;
408 1085 : al = gcmpgs(gabs(imag_i(s), prec), 100) < 0 ? ginv(stoi(4)) : gen_1;
409 1085 : r0 = gsqrt(gdiv(gmulgs(s, md), PiI2(prec)), prec);
410 1085 : n0 = gfloor(gsub(real_i(r0), imag_i(r0)));
411 1085 : aleps = gmul(al, gexp(PiI2n(-2, prec), prec));
412 1085 : sel = mkvecn(7, n0, r0, al, aleps, NULL, NULL, numpoles);
413 1085 : q = set_q_value(sel, s, VCALL, prec);
414 1085 : m = get_m(q, prec);
415 1085 : gel(sel,5) = h = divru(q, (m - 1) >> 1);
416 1085 : gel(sel,6) = setlin_grid_exp(h, m, prec);
417 1085 : return sel;
418 : }
419 :
420 : static GEN
421 441 : xpquo_one(GEN s, GEN cs, GEN ga, long odd, long md, long prec)
422 : {
423 441 : GEN rho, a = odd? gen_1: gen_0, z = divsr(md, mppi(prec));
424 441 : rho = gmul(gdiv(gpow(gen_I(), gdivgs(gneg(a), 2), prec), gsqrt(ga, prec)),
425 : gpow(stoi(md), ginv(stoi(4)), prec));
426 441 : 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 1085 : xpquo(GEN s, GEN VCALL, long prec)
434 : {
435 1085 : long md = get_modulus(VCALL), n, lve, i;
436 1085 : GEN cd = NULL, z, pz, cs, VC = get_chivec(VCALL), ve, R;
437 1085 : if (!gequal0(s)) prec = nbits2prec(prec2nbits(prec) + maxss(gexpo(s), 0));
438 1085 : z = gexp(gdivgs(PiI2(prec), -md), prec);
439 1085 : if (md == 1)
440 686 : 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 399 : pz = gpowers(z, md - 1);
444 2786 : for (n = 1; n < md; n++)
445 : {
446 2387 : GEN xn = mycall(VC, n);
447 2387 : if (xn)
448 : {
449 2352 : GEN tmp = gmul(xn, gel(pz, n + 1));
450 2352 : cd = cd ? gadd(cd, tmp) : tmp;
451 : }
452 : }
453 399 : cs = gsubsg(1, gconj(s));
454 399 : ve = get_signat(VCALL); lve = lg(ve); R = cgetg(lve, t_VEC);
455 840 : for (i = 1; i < lve; i++)
456 441 : gel(R, i) = xpquo_one(s, cs, gel(cd, i), ve[i], md, prec);
457 399 : if (lve == 2) R = gel(R, 1);
458 399 : return R;
459 : }
460 :
461 : static GEN
462 1113 : total_value(GEN serh0, GEN sel, GEN s, GEN VCALL, long prec)
463 : {
464 1113 : return gadd(integral_h0(sel, s, VCALL, prec),
465 : gsub(serh0, series_residues_h0(sel, s, VCALL, prec)));
466 : }
467 : static GEN
468 1085 : dirichlet_ours(GEN s, GEN VCALL, long prec)
469 : {
470 1085 : int fl = !gequal(real_i(s), ghalf);
471 1085 : GEN sel = RZinit(s, VCALL, gen_1, prec);
472 1085 : GEN S1, S2, serh0 = series_h0(m_n0(sel), s, VCALL, fl, prec);
473 1085 : if (!fl)
474 1057 : S2 = S1 = total_value(serh0, sel, s, VCALL, prec);
475 : else
476 : {
477 28 : S1 = total_value(gel(serh0,1), sel, s, VCALL, prec);
478 28 : S2 = total_value(gel(serh0,2), sel, gsubsg(1, gconj(s)), VCALL, prec);
479 : }
480 1085 : return gadd(S1, vecmul(xpquo(s, VCALL, prec), gconj(S2)));
481 : }
482 :
483 : /* assume |Im(s)| > 2^-bitprec */
484 : static GEN
485 1085 : RZchi(GEN VCALL, GEN s, long prec)
486 : {
487 1085 : long prec2 = prec + EXTRAPREC64;
488 1085 : return gprec_wtrunc(dirichlet_ours(gprec_w(s, prec2), VCALL, prec2), prec);
489 : }
490 :
491 : /********************************************************************/
492 : /* Utility Functions */
493 : /********************************************************************/
494 : /* lam = 0, return L(s); else Lambda(s) */
495 : static GEN
496 1085 : lfuncharall(GEN VCALL, GEN s, long lam, long bitprec)
497 : {
498 1085 : GEN ve, P, Q, R, z = lfunlarge_char(VCALL, s, bitprec);
499 : long l, i, q, prec;
500 1085 : if (!lam) return z;
501 882 : ve = get_signat(VCALL); l = lg(ve);
502 882 : q = get_modulus(VCALL); prec = nbits2prec(bitprec);
503 882 : R = cgetg(l, t_VEC);
504 882 : Q = divur(q, mppi(prec));
505 882 : P = (q == 1 || zv_equal0(ve))? NULL: gsqrt(utoipos(q), prec);
506 1764 : for (i = 1; i < l; i++)
507 : {
508 882 : GEN se = gmul2n(gaddgs(s, ve[i]), -1), r;
509 882 : if (lam == 1)
510 : {
511 0 : r = gmul(gpow(Q, se, prec), ggamma(se, prec));
512 0 : if (P && ve[i]) r = gdiv(r, P);
513 : }
514 : else
515 : {
516 882 : r = gadd(gmul(se, glog(Q, prec)), glngamma(se, prec));
517 882 : if (P && ve[i]) r = gsub(r, glog(P, prec));
518 : }
519 882 : gel(R, i) = r;
520 : }
521 882 : return lam == 1 ? vecmul(R, z) : gadd(R, glog(z, prec));
522 : }
523 :
524 : static GEN
525 28 : lfunlargeall_from_chars(GEN v, GEN s, long lam, long bit)
526 : {
527 28 : long i, l = lg(v);
528 84 : for (i = 1; i < l; i++)
529 : {
530 56 : GEN w = mycharinit(gel(v, i), bit), L = lfuncharall(w, s, lam, bit);
531 56 : gel(v, i) = lam==-1 ? vecsum(L): vecprod(L);
532 : }
533 28 : return lam==-1 ? vecsum(v): vecprod(v);
534 : }
535 : static GEN
536 1057 : lfunlargeall(GEN ldata, GEN s, long lam, long bit)
537 : {
538 : GEN w, an;
539 1057 : if (lg(ldata) == 2)
540 : { /* HACK: ldata[1] a t_DESC_PRODUCT from lfunabelianrelinit / Q */
541 14 : GEN v = lfunprod_get_fact(linit_get_tech(gel(ldata,1)));
542 : long i, l;
543 14 : v = shallowcopy(gel(v,1)); l = lg(v);
544 42 : for (i = 1; i < l; i++) gel(v,i) = mkvec(gel(v,i));
545 14 : return lfunlargeall_from_chars(v, s, lam, bit);
546 : }
547 1043 : an = gel(ldata_get_an(ldata), 2);
548 1043 : switch(ldata_get_type(ldata))
549 : {
550 14 : case t_LFUN_NF:
551 : {
552 14 : GEN v = lfungetchars(nf_get_pol(an));
553 14 : return lfunlargeall_from_chars(v, s, lam, bit);
554 : }
555 7 : case t_LFUN_CHIGEN:
556 : {
557 7 : GEN chi = gmael(an, 2, 2);
558 7 : if (lg(chi) > 1 && is_vec_t(typ(gel(chi,1))))
559 : { /* multi char */
560 7 : w = mycharinit(mkcol(ldata), bit);
561 7 : return lfuncharall(w, s, lam, bit);
562 : }
563 : }
564 : default: /* single char */
565 1022 : w = mycharinit(mkcol(ldata), bit);
566 1022 : return gel(lfuncharall(w, s, lam, bit), 1);
567 : }
568 : }
569 :
570 : GEN
571 189 : lfunlarge(GEN CHI, GEN s, long bit)
572 189 : { return lfunlargeall(CHI, s, 0, bit); }
573 :
574 : GEN
575 0 : lfunlambdalarge(GEN CHI, GEN s, long bit)
576 0 : { return lfunlargeall(CHI, s, 1, bit); }
577 :
578 : GEN
579 868 : lfunloglambdalarge(GEN CHI, GEN s, long bit)
580 868 : { return lfunlargeall(CHI, s, -1, bit); }
581 :
582 : /********************************************************************/
583 : /* LERCH RS IMPLEMENTATION FROM SANDEEP TYAGI */
584 : /********************************************************************/
585 :
586 : static GEN
587 56 : double_exp_residue_pos_h(GEN selsm, long k, long ind, long prec)
588 : {
589 56 : long nk = itos(gel(selsm, 1)) + k;
590 56 : GEN r = gel(selsm, 2), ale = gel(selsm, 3), aor = gel(selsm, 4);
591 56 : GEN h = gel(selsm, 5), t = gen_0;
592 56 : switch(ind)
593 : {
594 28 : case 0: t = gaddsg(nk, aor); break;
595 0 : case 1: t = gneg(gaddsg(nk, aor)); break;
596 28 : case 2: t = gsubsg(nk, aor); break;
597 : }
598 56 : return gdiv(gasinh(gdiv(gsub(t, r), ale), prec), h);
599 : }
600 :
601 : static GEN
602 56 : phi_hat_h(GEN selsm, long m, long ind, long prec)
603 56 : { return phi_hat(double_exp_residue_pos_h(selsm, m, ind, prec), prec); }
604 :
605 : static long
606 56 : myex(GEN is)
607 56 : { return gequal0(is) ? 0 : maxss(0, 2 + gexpo(is)); }
608 :
609 : static GEN
610 56 : gaminus(GEN s, long prec)
611 : {
612 56 : GEN is = imag_i(s), tmp;
613 56 : long B = prec2nbits(prec);
614 56 : if (gcmpgs(is, -5*B) < 0) return gen_0;
615 56 : prec = nbits2prec(B + myex(is));
616 56 : tmp = gexp(gsub(glngamma(s, prec), gmul(PiI2n(-1, prec), s)), prec);
617 56 : return bitprecision0(tmp, B);
618 : }
619 :
620 : static GEN
621 28 : gaplus(GEN s, long prec)
622 : {
623 28 : GEN is = imag_i(s), tmp;
624 28 : long B = prec2nbits(prec);
625 28 : if (gcmpgs(is, 5*B) > 0) return gen_0;
626 0 : prec = nbits2prec(B + myex(is));
627 0 : tmp = gexp(gadd(glngamma(s, prec), gmul(PiI2n(-1, prec), s)), prec);
628 0 : return bitprecision0(tmp, B);
629 : }
630 :
631 : GEN
632 3514 : serh_worker(GEN k, GEN z, GEN a, GEN ns, GEN gprec)
633 : {
634 3514 : long prec = itou(gprec);
635 3514 : return gmul(gpow(z, k, prec), gpow(gadd(a, k), ns, prec));
636 : }
637 :
638 : static void
639 28 : set_arg(GEN worker, GEN z, GEN a, GEN ns, long prec)
640 28 : { gel(worker, 7) = mkvec4(z, a, ns, stoi(prec)); }
641 :
642 :
643 : static GEN
644 14 : series_h0l(GEN worker, long n0, GEN s, GEN a, GEN lam, long prec)
645 : {
646 14 : GEN z = typ(lam) == t_INT ? gen_1 : gexp(gmul(PiI2(prec), lam), prec);
647 14 : set_arg(worker, z, a, gneg(s), prec);
648 14 : return parsum(gen_0, utoi(n0), worker);
649 : }
650 :
651 : static GEN
652 14 : series_h1(GEN worker, long n1, GEN s, GEN a, GEN lam, long prec)
653 : {
654 14 : GEN mP, pre_factor, z, sn = gsubgs(s, 1);
655 14 : GEN ini = gequal0(lam) ? gen_1 : gen_0;
656 14 : pre_factor = gaplus(gneg(sn), prec);
657 14 : if (gequal0(pre_factor)) return gen_0;
658 0 : mP = gneg(PiI2(prec));
659 0 : pre_factor = gmul(gmul(pre_factor, gexp(gmul(mP, gmul(a, lam)), prec)),
660 : gpow(Pi2n(1, prec), sn, prec));
661 0 : z = typ(a) == t_INT ? gen_1 : gexp(gmul(mP, a), prec);
662 0 : set_arg(worker, z, lam, sn, prec);
663 0 : return gmul(pre_factor, parsum(ini, stoi(n1 - 1), worker));
664 : }
665 :
666 : static GEN
667 14 : series_h2(GEN worker, long n2, GEN s, GEN a, GEN lam, long prec)
668 : {
669 14 : GEN P, pre_factor, z, sn = gsubgs(s, 1);
670 14 : pre_factor = gaminus(gneg(sn), prec);
671 14 : if (gequal0(pre_factor)) return gen_0;
672 14 : P = PiI2(prec);
673 14 : pre_factor = gmul(gmul(pre_factor, gexp(gmul(gneg(P), gmul(a, lam)), prec)),
674 : gpow(Pi2n(1, prec), sn, prec));
675 14 : z = typ(a) == t_INT ? gen_1 : gexp(gmul(P, a), prec);
676 14 : set_arg(worker, z, gneg(lam), sn, prec);
677 14 : return gmul(pre_factor, parsum(gen_1, stoi(n2), worker));
678 : }
679 :
680 : static GEN
681 14 : series_residues_h0l(long numpoles, GEN selsm0, GEN s, GEN a, GEN lam, long prec)
682 : {
683 14 : GEN P, val = gen_0, ra = real_i(a);
684 14 : long n0 = m_n0(selsm0), k;
685 14 : P = PiI2(prec);
686 42 : for (k = -numpoles + 1; k <= numpoles; k++)
687 28 : if (gsigne(gaddsg(n0 + k, ra)) > 0)
688 28 : val = gadd(val, gmul(gmul(phi_hat_h(selsm0, k, 0, prec),
689 : gexp(gmul(P, gmulgs(lam, n0 + k)), prec)),
690 : gpow(gaddsg(n0 + k, a), gneg(s), prec)));
691 14 : return val;
692 : }
693 :
694 : static GEN
695 14 : series_residues_h1(long numpoles, GEN selsm1, GEN s, GEN a, GEN lam, long prec)
696 : {
697 14 : GEN mP, val = gen_0, rlam = real_i(lam), pre_factor, sn = gsubgs(s, 1);
698 14 : long n1 = m_n0(selsm1), k;
699 14 : pre_factor = gaplus(gneg(sn), prec);
700 14 : if (gequal0(pre_factor)) return gen_0;
701 0 : mP = gneg(PiI2(prec));
702 0 : pre_factor = gmul(gmul(pre_factor, gexp(gmul(mP, gmul(a, lam)), prec)),
703 : gpow(Pi2n(1, prec), sn, prec));
704 0 : for (k = -numpoles; k <= numpoles - 1; k++)
705 0 : if (gsigne(gaddsg(n1 + k, rlam)) > 0)
706 0 : val = gadd(val, gmul(gmul(phi_hat_h(selsm1, k, 1, prec),
707 : gexp(gmul(mP, gmulgs(a, n1 + k)), prec)),
708 : gpow(gaddsg(n1 + k, lam), sn, prec)));
709 0 : return gmul(pre_factor, val);
710 : }
711 :
712 : static GEN
713 14 : series_residues_h2(long numpoles, GEN selsm2, GEN s, GEN a, GEN lam, long prec)
714 : {
715 14 : GEN P, val = gen_0, rlam = real_i(lam), pre_factor, sn = gsubgs(s, 1);
716 14 : long n2 = m_n0(selsm2), k;
717 14 : pre_factor = gaminus(gneg(sn), prec);
718 14 : if (gequal0(pre_factor)) return gen_0;
719 14 : P = PiI2(prec);
720 14 : pre_factor = gmul(gmul(pre_factor, gexp(gmul(gneg(P), gmul(a, lam)), prec)),
721 : gpow(Pi2n(1, prec), sn, prec));
722 42 : for (k = -numpoles + 1; k <= numpoles; k++)
723 28 : if (gsigne(gsubsg(n2 + k, rlam)) > 0)
724 28 : val = gsub(val, gmul(gmul(phi_hat_h(selsm2, k, 2, prec),
725 : gexp(gmul(P, gmulgs(a, n2 + k)), prec)),
726 : gpow(gsubsg(n2 + k, lam), sn, prec)));
727 14 : return gmul(pre_factor, val);
728 : }
729 :
730 : static GEN
731 3430 : integrand_h0l(GEN selsm0, GEN s, GEN alam1, GEN x, long prec)
732 : {
733 3430 : GEN r0 = gel(selsm0, 2), ale = gel(selsm0, 3), a = gel(selsm0, 4);
734 3430 : GEN ix = ginv(x), zn = gadd(r0, gmul2n(gmul(ale, gsub(x, ix)), -1));
735 3430 : GEN P = PiI2n(0, prec), den, num;
736 3430 : den = gexpm1(gmul(P, gmul2n(gsub(zn,a), 1)), prec);
737 3430 : num = gexp(gmul(gmul(P, zn), gsub(alam1, zn)), prec);
738 3430 : num = gmul(gmul(gmul(num, ale), gmul2n(gadd(x, ix), -1)),
739 : gpow(zn, gneg(s), prec));
740 3430 : return gdiv(num, den);
741 : }
742 :
743 : static GEN
744 6860 : integrand_h12(GEN selsm1, GEN s, GEN alam1, GEN x, long prec)
745 : {
746 6860 : GEN r1 = gel(selsm1, 2), ale = gel(selsm1, 3), lam = gel(selsm1, 4);
747 6860 : GEN ix = ginv(x), zn = gadd(r1, gmul2n(gmul(ale, gsub(x, ix)), -1));
748 6860 : GEN P = PiI2n(0, prec), den, num, y;
749 6860 : den = gexpm1(gmul(P, gmul2n(gadd(zn,lam), 1)), prec);
750 6860 : num = gexp(gmul(gmul(P, zn), gadd(alam1, zn)), prec);
751 6860 : num = gmul(gmul(gmul(num, ale), gmul2n(gadd(x, ix), -1)),
752 : gpow(zn, gsubgs(s, 1), prec));
753 6860 : y = gdiv(num, den);
754 6860 : if (gcmp(garg(zn, prec), Pi2n(-2, prec)) > 0)
755 1722 : y = gmul(y, gexp(gmul(PiI2(prec), gsubsg(1, s)), prec));
756 6860 : return y;
757 : }
758 :
759 : static GEN
760 14 : integral_h0l(GEN lin_grid, GEN selsm0, GEN s, GEN a, GEN lam, long prec)
761 : {
762 14 : GEN A = gaddgs(gmul2n(gadd(a, lam),1), 1), S = gen_0;
763 14 : pari_sp av = avma;
764 14 : long j, l = lg(lin_grid);
765 :
766 3388 : for (j = 1; j < l; j++)
767 : {
768 3374 : S = gadd(S, integrand_h0l(selsm0, s, A, gel(lin_grid, j), prec));
769 3374 : if ((j & 0xff) == 0) S = gerepileupto(av, S);
770 : }
771 14 : S = gmul(m_h(selsm0), S);
772 14 : A = gmul(a, gaddsg(1, gadd(a, gmul2n(lam, 1))));
773 14 : return gmul(S, gexp(gneg(gmul(PiI2n(0, prec), A)), prec));
774 : }
775 :
776 : /* do not forget a minus sign for index 2 */
777 : static GEN
778 28 : integral_h12(GEN lin_grid, GEN selsm1, GEN s, GEN a, GEN lam, long prec)
779 : {
780 28 : GEN A, E, S = gen_0, ga = gaminus(gsubsg(1, s), prec);
781 28 : pari_sp av = avma;
782 28 : long j, l = lg(lin_grid);
783 :
784 28 : if (gequal0(ga)) return S;
785 28 : A = gaddgs(gmul2n(gadd(a,lam), 1), 1);
786 6776 : for (j = 1; j < l; j++)
787 : {
788 6748 : S = gadd(S, integrand_h12(selsm1, s, A, gel(lin_grid, j), prec));
789 6748 : if ((j & 0xff) == 0) S = gerepileupto(av, S);
790 : }
791 28 : if (gequal0(S)) return gen_0;
792 28 : S = gmul(m_h(selsm1), S);
793 28 : E = gexp(gmul(PiI2n(0, prec), gmul(lam, gaddgs(lam, 1))), prec);
794 28 : return gmul(gmul(gmul(S, ga), E), gpow(Pi2n(1, prec), gsubgs(s, 1), prec));
795 : }
796 :
797 : struct _fun_q0_t { GEN sel, s, alam1, B; };
798 : static GEN
799 56 : _fun_q0(void *E, GEN x)
800 : {
801 56 : struct _fun_q0_t *S = (struct _fun_q0_t*)E;
802 56 : GEN z = integrand_h0l(S->sel, S->s, S->alam1, x, DEFAULTPREC);
803 56 : return addrlogabs(S->B, z);
804 : }
805 : static GEN
806 112 : _fun_q12(void *E, GEN x)
807 : {
808 112 : struct _fun_q0_t *S = (struct _fun_q0_t*)E;
809 112 : GEN z = integrand_h12(S->sel, S->s, S->alam1, x, DEFAULTPREC);
810 112 : return addrlogabs(S->B, z);
811 : }
812 :
813 : static GEN
814 14 : RZLERinit(GEN s, GEN a, GEN lam, GEN al, GEN numpoles, long prec)
815 : {
816 : GEN eps, r0, r1, r2, h, lin_grid, q, q0, q1, q2, sel0, sel1, sel2, lq;
817 14 : GEN pinv = ginv(PiI2(prec)), c = gmul2n(gadd(a, lam), -1), n0, n1, n2, c2;
818 : long m;
819 : struct _fun_q0_t E;
820 :
821 14 : if (!al || gequal0(al))
822 0 : al = gcmpgs(gabs(imag_i(s), prec), 100) < 0 ? ginv(stoi(4)) : gen_1;
823 14 : c2 = gsub(gsqr(c), gmul(s, pinv));
824 14 : r0 = gadd(c, gsqrt(c2, prec));
825 14 : r1 = gsqrt(gadd(c2, pinv), prec);
826 14 : r2 = gsub(r1, c);
827 14 : r1 = gneg(gadd(r1, c));
828 14 : n0 = gfloor(gsub(gadd(real_i(r0), imag_i(r0)), a));
829 14 : n1 = gneg(gfloor(gadd(gsub(real_i(r1), imag_i(r1)), real_i(lam))));
830 14 : n2 = gfloor(gadd(gsub(real_i(r2), imag_i(r2)), real_i(lam)));
831 :
832 14 : E.s = s; E.alam1 = gaddgs(gmul2n(gadd(a, lam), 1), 1);
833 14 : E.B = mulur(prec, mplog2(prec));
834 14 : lq = gmul(al, sqrtr_abs(mulrr(divsr(prec, Pi2n(1, DEFAULTPREC)),
835 : mplog2(DEFAULTPREC))));
836 14 : eps = gexp(PiI2n(-2, prec), prec);
837 14 : E.sel = sel0 = mkvec5(n0, r0, gdiv(al, eps), a, gen_0);
838 14 : q0 = findq(&E, &_fun_q0, lq, prec);
839 :
840 14 : if (!gequal1(al)) lq = gdiv(lq, gsqr(al));
841 14 : E.sel = sel1 = mkvec5(n1, r1, gmul(al, eps), lam, gen_0);
842 14 : q1 = findq(&E, &_fun_q12, lq, prec);
843 14 : E.sel = sel2 = mkvec5(n2, r2, gmul(al, eps), lam, gen_0);
844 14 : q2 = findq(&E, &_fun_q12, lq, prec);
845 14 : q = vecmax(mkvec3(q0, q1, q2)); m = get_m(q, prec);
846 14 : gel(sel0, 5) = gel(sel1, 5) = gel(sel2, 5) = h = divru(q, (m-1) >> 1);
847 14 : lin_grid = setlin_grid_exp(h, m, prec);
848 14 : if (!numpoles) numpoles = gen_1;
849 14 : return mkvec5(sel0, sel1, sel2, lin_grid, numpoles);
850 : }
851 :
852 42 : static GEN add3(GEN x, GEN y, GEN z) { return gadd(x, gadd(y,z)); }
853 14 : static GEN addsub(GEN x, GEN y, GEN z) { return gadd(x, gsub(y,z)); }
854 :
855 : static GEN
856 14 : lerch_ours(GEN sel, GEN s, GEN a, GEN lam, long prec)
857 : {
858 14 : GEN selsm0 = gel(sel, 1), selsm1 = gel(sel, 2), selsm2 = gel(sel, 3);
859 14 : GEN lin_grid = gel(sel, 4), v0, v1, v2;
860 14 : long numpoles = itos(gel(sel, 5));
861 14 : GEN worker = snm_closure(is_entry("_serh_worker"),
862 : mkvec4(NULL, NULL, NULL, NULL));
863 14 : v0 = add3(series_h0l(worker, m_n0(selsm0), s, a, lam, prec),
864 : series_residues_h0l(numpoles, selsm0, s, a, lam, prec),
865 : integral_h0l(lin_grid, selsm0, s, a, lam, prec));
866 14 : v1 = add3(series_h1(worker, m_n0(selsm1), s, a, lam, prec),
867 : series_residues_h1(numpoles, selsm1, s, a, lam, prec),
868 : integral_h12(lin_grid, selsm1, s, a, lam, prec));
869 14 : v2 = addsub(series_h2(worker, m_n0(selsm2), s, a, lam, prec),
870 : series_residues_h2(numpoles, selsm2, s, a, lam, prec),
871 : integral_h12(lin_grid, selsm2, s, a, lam, prec));
872 14 : return add3(v0, v1, v2);
873 : }
874 :
875 : static GEN
876 0 : RZlerch_easy(GEN s, GEN a, GEN lam, long prec)
877 : {
878 0 : pari_sp av = avma;
879 : GEN z, y, N;
880 0 : long B = prec2nbits(prec), LD = LOWDEFAULTPREC;
881 0 : N = gdiv(gmulsg(B + 5, mplog2(LD)), gmul(Pi2n(1, LD), imag_i(lam)));
882 0 : if (gexpo(N) > 40) pari_err_IMPL("precision too large in lerchzeta");
883 0 : N = gceil(N); prec += EXTRAPREC64;
884 0 : z = typ(lam) == t_INT ? gen_1 : gexp(gmul(PiI2(prec), lam), prec);
885 0 : y = parsum(gen_0, N, snm_closure(is_entry("_serh_worker"),
886 : mkvec4(z, a, gneg(s), stoi(prec))));
887 0 : return gerepilecopy(av, gprec_wtrunc(y, prec));
888 : }
889 :
890 : static GEN
891 14 : mygfrac(GEN z)
892 0 : { return typ(z) == t_COMPLEX ? mkcomplex(gfrac(real_i(z)), imag_i(z))
893 14 : : gfrac(z); }
894 :
895 : static GEN
896 42 : lerchlarge(GEN s, GEN a, GEN lam, GEN al, GEN numpoles, long prec)
897 : {
898 42 : pari_sp av = avma;
899 42 : GEN val, sel, imlam = imag_i(lam);
900 : long prec2;
901 42 : switch(gsigne(imlam))
902 : {
903 0 : case -1: pari_err_IMPL("imag(lam) < 0");
904 0 : case 1: if (gexpo(imlam) >= -16) return RZlerch_easy(s, a, lam, prec);
905 : }
906 42 : if (gcmpgs(real_i(a), 1) < 0)
907 : {
908 14 : GEN P = gexp(gmul(PiI2(prec), lam), prec);
909 14 : GEN L = lerchlarge(s, gaddgs(a, 1), lam, al, numpoles, prec);
910 14 : return gerepileupto(av, gadd(gpow(a, gneg(s), prec), gmul(P, L)));
911 : }
912 28 : if (gcmpgs(real_i(a), 2) >= 0)
913 : {
914 0 : GEN L, P = gexp(gneg(gmul(PiI2(prec), lam)), prec);
915 0 : a = gsubgs(a, 1); L = lerchlarge(s, a, lam, al, numpoles, prec);
916 0 : return gerepileupto(av, gmul(P, gsub(L, gpow(a, gneg(s), prec))));
917 : }
918 28 : if (gsigne(imag_i(s)) > 0)
919 : {
920 : GEN L;
921 14 : lam = mygfrac(gneg(gconj(lam)));
922 14 : L = lerchlarge(gconj(s), a, lam, al, numpoles, prec);
923 14 : return gerepileupto(av, gconj(L));
924 : }
925 14 : prec2 = prec + EXTRAPREC64;
926 14 : a = gprec_w(a, prec2);
927 14 : s = gprec_w(s, prec2);
928 14 : lam = gprec_w(lam, prec2);
929 14 : sel = RZLERinit(s, a, lam, al, numpoles, prec2);
930 14 : val = lerch_ours(sel, s, a, lam, prec2);
931 14 : return gerepilecopy(av, gprec_wtrunc(val, prec));
932 : }
933 :
934 : GEN
935 7 : zetahurwitzlarge(GEN s, GEN a, long prec)
936 7 : { return lerchlarge(s, a, gen_0, gen_1, gen_1, prec); }
937 :
938 : GEN
939 7 : lerchzetalarge(GEN s, GEN a, GEN lam, long prec)
940 7 : { return lerchlarge(s, a, lam, gen_1, gen_1, prec); }
|