Code coverage tests

This page documents the degree to which the PARI/GP source code is tested by our public test suite, distributed with the source distribution in directory src/test/. This is measured by the gcov utility; we then process gcov output using the lcov frond-end.

We test a few variants depending on Configure flags on the pari.math.u-bordeaux.fr machine (x86_64 architecture), and agregate them in the final report:

The target is to exceed 90% coverage for all mathematical modules (given that branches depending on DEBUGLEVEL or DEBUGMEM are not covered). This script is run to produce the results below.

LCOV - code coverage report
Current view: top level - basemath - bnflog.c (source / functions) Hit Total Coverage
Test: PARI/GP v2.12.1 lcov report (development 24988-2584e74448) Lines: 274 280 97.9 %
Date: 2020-01-26 05:57:03 Functions: 26 26 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* Copyright (C) 2016  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             : /*                  LOGARITHMIC CLASS GROUP                        */
      18             : /*******************************************************************/
      19             : /* min(v, v(Log_p Norm_{F_\p/Q_p}(x))) */
      20             : static long
      21         280 : vlognorm(GEN nf, GEN T, GEN x, GEN p, long v)
      22             : {
      23         280 :   GEN a = nf_to_scalar_or_alg(nf, x);
      24         280 :   GEN N = RgXQ_norm(a, T);
      25         280 :   if (typ(N) != t_PADIC) N = cvtop(N, p, v);
      26         280 :   return minss(v, valp( Qp_log(N) ));
      27             : }
      28             : /* K number field, pr a maximal ideal, let K_pr be the attached local
      29             :  * field, K_pr = Q_p[X] / (T), T irreducible. Return \tilde{e}(K_pr/Q_p) */
      30             : static long
      31         546 : etilde(GEN nf, GEN pr, GEN T)
      32             : {
      33         546 :   GEN gp = pr_get_p(pr);
      34         546 :   ulong e = pr_get_e(pr);
      35             :   long v, voo, vmin, p, k;
      36             : 
      37         546 :   if (!u_pval(e, gp))
      38             :   {
      39         448 :     v = u_pval(pr_get_f(pr), gp);
      40         448 :     return itou( mului(e, powiu(gp, v)) );
      41             :   }
      42          98 :   nf = checknf(nf);
      43          98 :   p = itou(gp);
      44          98 :   k = e / (p-1) + 1;
      45             :   /* log Norm_{F_P/Q_p} (1 + P^k) = Tr(P^k) = p^[(k + v(Diff))/ e] Z_p */
      46          98 :   voo = (k + idealval(nf, nf_get_diff(nf), pr)) / e;
      47          98 :   vmin = vlognorm(nf, T, pr_get_gen(pr), gp, voo);
      48          98 :   if (k > 1)
      49             :   {
      50          98 :     GEN U = idealprincipalunits(nf, pr, k);
      51          98 :     GEN gen = abgrp_get_gen(U), cyc = abgrp_get_cyc(U);
      52          98 :     long i, l = lg(cyc);
      53         280 :     for (i = 1; i < l; i++)
      54             :     {
      55         182 :       if (voo - Z_lval(gel(cyc,i), p) >= vmin) break;
      56         182 :       vmin = vlognorm(nf, T, gel(gen,i), gp, vmin);
      57             :     }
      58             :   }
      59          98 :   v = u_lval(degpol(T), p) + (p == 2UL? 2 : 1) - vmin;
      60          98 :   (void)u_lvalrem(e, p, &e);
      61          98 :   return e * upowuu(p,v);
      62             : }
      63             : static long
      64         483 : ftilde_from_e(GEN pr, long e) { return pr_get_e(pr) * pr_get_f(pr) / e; }
      65             : static long
      66         483 : ftilde(GEN K, GEN pr, GEN T) { return ftilde_from_e(pr, etilde(K,pr, T)); }
      67             : 
      68             : static long
      69         553 : get_ZpX_index(GEN K, GEN pr, GEN T)
      70             : {
      71             :   GEN p, pi;
      72         553 :   long j, l = lg(T);
      73         553 :   if (l == 2) return 1;
      74         434 :   p = pr_get_p(pr); pi = nf_to_scalar_or_alg(K, pr_get_gen(pr));
      75        1323 :   for (j = 1; j < l; j++)
      76             :   {
      77        1323 :     GEN t = gel(T,j);
      78        1323 :     if (t && gvaluation(RgXQ_norm(pi, t), p)) return j;
      79             :   }
      80           0 :   return 0;
      81             : }
      82             : 
      83             : /* Given a number field K and a prime p, return
      84             :  * S = places of K above p [primedec]
      85             :  * R = corresponding p-adic factors of K.pol (mod p^k), in the same order */
      86             : static GEN
      87         238 : padicfact(GEN K, GEN S, long k)
      88             : {
      89         238 :     GEN R, p = pr_get_p(gel(S,1));
      90         238 :   GEN T = gel(factorpadic(nf_get_pol(K), p, k), 1);
      91             :   long l, i;
      92         238 :   S = idealprimedec(K, p);
      93         238 :   R = cgetg_copy(S, &l);
      94         770 :   for (i = 1; i < l; i++)
      95             :   {
      96         532 :     long j = get_ZpX_index(K, gel(S,i), T);
      97         532 :     gel(R,i) = gel(T,j);
      98         532 :     gel(T,j) = NULL;
      99             :   }
     100         238 :   return R;
     101             : }
     102             : 
     103             : /* K a bnf, compute Cl'(K) = ell-Sylow of Cl(K) / (places above ell).
     104             :  * Return [D, u, R0, U0, ordS]
     105             :  * - D: cyclic factors for Cl'(K)
     106             :  * - u: generators of cyclic factors (all coprime to ell)
     107             :  * - R0: subgroup isprincipal(<S>) (divides K.cyc)
     108             :  * - U0: generators of R0 are of the form S . U0
     109             :  * - ordS[i] = order of S[i] in CL(K)  */
     110             : static GEN
     111         175 : CL_prime(GEN K, GEN ell, GEN Sell)
     112             : {
     113         175 :   GEN g, ordS, R0, U0, U, D, u, cyc = bnf_get_cyc(K);
     114         175 :   long i, l, lD, lS = lg(Sell);
     115             : 
     116         175 :   g = leafcopy(bnf_get_gen(K));
     117         175 :   l = lg(g);
     118         511 :   for (i = 1; i < l; i++)
     119             :   {
     120         336 :     GEN A = gel(g,i), a = gcoeff(A,1,1);
     121         336 :     long v = Z_pvalrem(a, ell, &a);
     122         336 :     if (v) gel(g,i) = hnfmodid(A, a); /* make coprime to ell */
     123             :   }
     124         175 :   R0 = cgetg(lS, t_MAT);
     125         175 :   ordS = cgetg(lS, t_VEC);
     126         637 :   for (i = 1; i < lS; i++)
     127             :   {
     128         462 :     gel(R0,i) = isprincipal(K, gel(Sell,i));
     129         462 :     gel(ordS,i) = charorder(cyc, gel(R0,i)); /* order of Sell[i] */
     130             :   }
     131         175 :   R0 = shallowconcat(R0, diagonal_shallow(cyc));
     132             :   /* R0 = subgroup generated by S in Cl(K) [ divides diagonal(K.cyc) ]*/
     133         175 :   R0 = ZM_hnfall(R0, &U0, 2); /* [S | cyc] * U0 = R0 in HNF */
     134         175 :   D = ZM_snfall(R0, &U,NULL);
     135         175 :   D = RgM_diagonal_shallow(D);
     136         175 :   lD = lg(D);
     137         175 :   u = ZM_inv(U, NULL); settyp(u, t_VEC);
     138         175 :   for (i = 1; i < lD; i++) gel(u,i) = idealfactorback(K,g,gel(u,i),1);
     139         175 :   setlg(U0, l);
     140         175 :   U0 = rowslice(U0,1,lS-1); /* restrict to 'S' part */
     141         175 :   return mkvec5(D, u, R0, U0, ordS);
     142             : }
     143             : 
     144             : static GEN
     145         196 : ell1(GEN ell) { return equaliu(ell,2)? utoipos(5): addiu(ell,1); }
     146             : 
     147             : /* log N_{F_P/Q_p}(x) */
     148             : static GEN
     149      165367 : vtilde_i(GEN K, GEN x, GEN T, GEN ell, long prec)
     150             : {
     151             :   GEN N, cx;
     152      165367 :   if (typ(x) != t_POL) x = nf_to_scalar_or_alg(K, x);
     153      165367 :   if (typ(x) != t_POL) { cx = x; N = NULL; }
     154             :   else
     155             :   {
     156      157562 :     x = Q_primitive_part(x,&cx);
     157      157562 :     N = resultant(RgX_rem(x,T), T);
     158      157562 :     N = cvtop(N,ell,prec);
     159             :   }
     160      165367 :   if (cx)
     161             :   {
     162      165318 :     (void)Q_pvalrem(cx, ell, &cx);
     163      165318 :     if (!isint1(cx))
     164             :     {
     165      164083 :       cx = gpowgs(cvtop(cx,ell,prec), degpol(T));
     166      164083 :       N = N? gmul(N, cx): cx;
     167             :     }
     168             :   }
     169      165367 :   return N? Qp_log(N): gen_0;
     170             : }
     171             : static GEN
     172        3178 : vecvtilde_i(GEN K, GEN x, GEN T, GEN ell, long prec)
     173        3178 : { pari_APPLY_same(vtilde_i(K, gel(x,i), T, ell, prec)); }
     174             : static GEN
     175        4214 : vtilde(GEN K, GEN x, GEN T, GEN deg, GEN ell, long prec)
     176             : {
     177             :   pari_sp av;
     178             :   GEN v, G, E;
     179        4214 :   if (typ(x) != t_MAT) return gdiv(vtilde_i(K,x,T,ell,prec), deg);
     180        3178 :   G = gel(x,1);
     181        3178 :   E = gel(x,2); av = avma; v = vecvtilde_i(K,G,T,ell,prec);
     182        3178 :   return gerepileupto(av, gdiv(RgV_dotproduct(E, v), deg));
     183             : }
     184             : 
     185             : /* v[i] = deg S[i] mod p^prec */
     186             : static GEN
     187         175 : get_vdegS(GEN Ftilde, GEN ell, long prec)
     188             : {
     189         175 :   long i, l = lg(Ftilde);
     190         175 :   GEN v = cgetg(l, t_VEC), degell = Qp_log( cvtop(ell1(ell), ell, prec) );
     191         175 :   for (i = 1; i < l; i++) gel(v,i) = gmulsg(Ftilde[i], degell);
     192         175 :   return v;
     193             : }
     194             : /* K a bnf. Compute kernel \tilde{Cl}_K(ell); return cyclic factors.
     195             :  * Set *pM to (vtilde_S[i](US[j]))_{i,j} */
     196             : static GEN
     197         175 : CL_tilde(GEN K, GEN US, GEN ell, GEN T, long imin, GEN vdegS,
     198             :          GEN *pM, long prec)
     199             : {
     200         175 :   long i, j, k, lD, l = lg(T), lU = lg(US);
     201             :   GEN D, M, ellk;
     202             : 
     203             :   /* p = P^e: \tilde{Cl}(l) = (1) */
     204         175 :   if (l == 2) { *pM = cgetg(1, t_MAT); return cgetg(1, t_VEC); }
     205         133 :   M = cgetg(lU, t_MAT);
     206         805 :   for (j = 1; j < lU; j++)
     207             :   {
     208         672 :     GEN c = cgetg(l, t_COL), a = gel(US,j);
     209        3892 :     for (i = 1; i < l; i++)
     210        3220 :       gel(c,i) = vtilde(K, a, gel(T,i), gel(vdegS,i), ell, prec);
     211         672 :     gel(M,j) = c;
     212             :   }
     213         133 :   k = padicprec(M, ell); ellk = powiu(ell, k);
     214         133 :   *pM = M = gmod(M, ellk);
     215         133 :   M = ZM_hnfmodid(rowsplice(M, imin), ellk);
     216         133 :   D = matsnf0(M, 4); lD = lg(D);
     217         133 :   if (lD > 1 && Z_pval(gel(D,1), ell) >= k) return NULL;
     218         133 :   return D;
     219             : }
     220             : 
     221             : /* [L:K] = ell^k; return 1 if L/K is locally cyclotomic at ell, 0 otherwise */
     222             : long
     223          35 : rnfislocalcyclo(GEN rnf)
     224             : {
     225          35 :   pari_sp av = avma;
     226             :   GEN K, L, S, SK, TK, SLs, SL2, TL, ell;
     227             :   ulong ll;
     228             :   long i, j, k, lk, lSK;
     229          35 :   checkrnf(rnf);
     230          35 :   lk = rnf_get_degree(rnf);
     231          35 :   if (lk == 1) return 1;
     232          28 :   k = uisprimepower(lk, &ll);
     233          28 :   if (!k) pari_err_IMPL("rnfislocalcyclo for non-l-extensions");
     234          21 :   ell = utoi(ll);
     235          21 :   K = rnf_get_nf(rnf);
     236          21 :   L = rnf_build_nfabs(rnf, nf_get_prec(K));
     237          21 :   S = rnfidealprimedec(rnf, ell);
     238          21 :   SK  = gel(S,1);
     239          21 :   SLs = gel(S,2);
     240          21 :   SL2 = shallowconcat1(SLs);
     241          21 :   TK = padicfact(K, SK, 100); lSK = lg(SK);
     242          21 :   TL = padicfact(L, SL2, 100);
     243          35 :   for (i = 1; i < lSK; i++)
     244             :   {
     245          21 :     long eK = etilde(K, gel(SK,i), gel(TK,i));
     246          21 :     GEN SL = gel(SLs,i);
     247          21 :     long lSL = lg(SL);
     248          35 :     for (j = 1; j < lSL; j++)
     249             :     {
     250          21 :       long iS = gen_search(SL2, gel(SL,j), 0, (void*)&cmp_prime_over_p,
     251             :                 &cmp_nodata);
     252          21 :       long eL = etilde(L, gel(SL,j), gel(TL,iS));
     253          21 :       if (dvdui(eL/eK, ell)) return gc_long(av,0);
     254             :     }
     255             :   };
     256          14 :   return gc_long(av,1);
     257             : }
     258             : 
     259             : #if 0
     260             : /* Return 1 if L/Q is locally cyclotomic at ell */
     261             : static int
     262             : islocalcycloQ(GEN L, GEN ell)
     263             : {
     264             :   GEN SL = idealprimedec(L,ell), TL;
     265             :   long i, lSL = lg(SL);
     266             :   TL = padicfact(L,  SL, 100);
     267             :   for (i = 1; i < lSL; i++)
     268             :   {
     269             :     long eL = etilde(L, gel(SL,i), gel(TL,i));
     270             :     if (dvdui(eL,ell)) return 0;
     271             :   }
     272             :   return 1;
     273             : }
     274             : #endif
     275             : 
     276             : /* true nf, pr a prid */
     277             : static long
     278          91 : nfislocalpower_i(GEN nf, GEN pr, GEN a, GEN n)
     279             : {
     280             :   long v, e, t;
     281             :   GEN p, G, L;
     282          91 :   a = nf_to_scalar_or_basis(nf,a);
     283          91 :   if (!signe(n)) return isint1(a);
     284          77 :   v = nfvalrem(nf, a, pr, &a); if (!dvdsi(v, n)) return 0;
     285          63 :   p = pr_get_p(pr);
     286          63 :   v = Z_pvalrem(n, p, &n);
     287          63 :   if (!equali1(n))
     288             :   {
     289          21 :     GEN T, modpr = zk_to_Fq_init(nf, &pr, &T, &p);
     290          21 :     GEN ap = nf_to_Fq(nf, a, modpr);
     291          21 :     if (!Fq_ispower(ap, n, T, p)) return 0;
     292             :   }
     293          56 :   if (!v) return 1;
     294          56 :   e = pr_get_e(pr);
     295          56 :   if (v == 1) /* optimal formula */
     296          42 :     t = itos( divii(mului(e,p), subiu(p,1)) ) + 1;
     297             :   else /* straight Hensel */
     298          14 :     t = 2 * e * v + 1;
     299          56 :   G = Idealstarprk(nf, pr, t, nf_INIT);
     300          56 :   L = ideallog(nf, a, G);
     301          56 :   return (ZV_equal0(L) || ZV_pval(L, p) >= v);
     302             : }
     303             : long
     304         105 : nfislocalpower(GEN nf, GEN pr, GEN a, GEN n)
     305             : {
     306         105 :   pari_sp av = avma;
     307         105 :   if (typ(n) != t_INT) pari_err_TYPE("nfislocalpower",n);
     308         105 :   nf = checknf(nf); checkprid(pr);
     309          91 :   return gc_long(av, nfislocalpower_i(nf, pr, a, n));
     310             : }
     311             : 
     312             : /* v_ell(  exponent(D) ) */
     313             : static long
     314         350 : ellexpo(GEN D, GEN ell) { return lg(D) == 1? 0: Z_pval(gel(D,1), ell); }
     315             : 
     316             : static GEN
     317         161 : ellsylow(GEN cyc, GEN ell)
     318             : {
     319             :   long i, l;
     320         161 :   GEN d = cgetg_copy(cyc, &l);
     321         343 :   for (i = 1; i < l; i++)
     322             :   {
     323         266 :     GEN c = gel(cyc,i), a;
     324         266 :     if (!Z_pvalrem(c, ell, &a)) break;
     325         182 :     gel(d,i) = diviiexact(c, a);
     326             :   }
     327         161 :   setlg(d, i); return d;
     328             : }
     329             : 
     330             : static long
     331        9281 : vnorm_x(GEN nf, GEN x, GEN ell)
     332             : {
     333        9281 :   x = nf_to_scalar_or_alg(nf,x);
     334        9281 :   if (typ(x) != t_POL) return 0;
     335        8681 :   x = Q_primpart(x);
     336        8681 :   return Q_pval(nfnorm(nf,x), ell);
     337             : }
     338             : static long
     339         462 : vtilde_prec_x(GEN nf, GEN x, GEN ell)
     340             : {
     341             :   long i, l, v;
     342             :   GEN G;
     343         462 :   if (typ(x) != t_MAT) return vnorm_x(nf,x,ell);
     344         462 :   G = gel(x,1); l = lg(G); v = 0;
     345         462 :   for (i = 1; i < l; i++) v = maxss(v, vnorm_x(nf,gel(G,i),ell));
     346         462 :   return v;
     347             : }
     348             : /* upper bound for \delta(vec): estimate loss of accuracy when evaluating
     349             :  * \tilde{v} on the vec[i] */
     350             : static long
     351         175 : vtilde_prec(GEN nf, GEN vec, GEN ell)
     352             : {
     353         175 :   long v0 = 0, i, l = lg(vec);
     354         637 :   for (i = 1; i < l; i++)
     355         462 :     v0 = maxss(v0, vtilde_prec_x(nf, gel(vec,i), ell));
     356         175 :   return 3 + v0 + z_pval(nf_get_degree(nf), ell);
     357             : }
     358             : static GEN
     359         175 : get_Ftilde(GEN nf, GEN S, GEN T, GEN ell, long *pimin)
     360             : {
     361         175 :   long j, lS = lg(S), vmin = lS;
     362         175 :   GEN Ftilde = cgetg(lS, t_VECSMALL);
     363         175 :   *pimin = 1;
     364         637 :   for (j = 1; j < lS; j++)
     365             :   {
     366         462 :     long f = ftilde(nf, gel(S,j), gel(T,j)), v = z_pval(f, ell);
     367         462 :     Ftilde[j] = f; if (v < vmin) { vmin = v; *pimin = j; }
     368             :   }
     369         175 :   return Ftilde;
     370             : }
     371             : static GEN
     372         175 : bnflog_i(GEN bnf, GEN ell)
     373             : {
     374             :   long prec0, prec;
     375             :   GEN nf, US, vdegS, S, T, M, CLp, CLt, Ftilde, vtG, ellk;
     376             :   GEN D, Ap, cycAp, fu;
     377             :   long imin, i, j, lvAp;
     378             : 
     379         175 :   checkbnf(bnf);
     380         175 :   nf = checknf(bnf);
     381         175 :   S = idealprimedec(nf, ell);
     382         175 :   US = sunits_mod_units(bnf, S);
     383         175 :   prec0 = maxss(30, vtilde_prec(nf, US, ell));
     384         175 :   if (!(fu = bnf_build_cheapfu(bnf)) && !(fu = bnf_compactfu(bnf)))
     385           0 :     bnf_build_units(bnf);
     386         175 :   US = shallowconcat(fu, US);
     387         175 :   settyp(US, t_COL);
     388         175 :   T = padicfact(nf, S, prec0);
     389         175 :   Ftilde = get_Ftilde(nf, S, T, ell, &imin);
     390         175 :   CLp = CL_prime(bnf, ell, S);
     391         175 :   cycAp = gel(CLp,1);
     392         175 :   Ap = gel(CLp,2);
     393             :   for(;;)
     394             :   {
     395         175 :     vdegS = get_vdegS(Ftilde, ell, prec0);
     396         175 :     CLt = CL_tilde(nf, US, ell, T, imin, vdegS, &vtG, prec0);
     397         175 :     if (CLt) break;
     398           0 :     prec0 <<= 1;
     399           0 :     T = padicfact(nf, S, prec0);
     400             :   }
     401         175 :   prec = ellexpo(cycAp, ell) + ellexpo(CLt,ell) + 1;
     402         175 :   if (prec == 1) return mkvec3(cgetg(1,t_VEC), cgetg(1,t_VEC), cgetg(1,t_VEC));
     403             : 
     404         161 :   ellk = powiu(ell, prec);
     405         161 :   lvAp = lg(Ap);
     406         161 :   if (lvAp > 1)
     407             :   {
     408         154 :     long lS = lg(S);
     409         154 :     GEN Kcyc = bnf_get_cyc(bnf);
     410         154 :     GEN C = zeromatcopy(lvAp-1, lS-1);
     411         154 :     GEN Rell = gel(CLp,3), Uell = gel(CLp,4), ordS = gel(CLp,5);
     412         476 :     for (i = 1; i < lvAp; i++)
     413             :     {
     414         322 :       GEN a, b, bi, A = gel(Ap,i), d = gel(cycAp,i);
     415         322 :       bi = isprincipal(bnf, A);
     416         322 :       a = vecmodii(ZC_Z_mul(bi,d), Kcyc);
     417             :       /* a in subgroup generated by S = Rell; hence b integral */
     418         322 :       b = hnf_invimage(Rell, a);
     419         322 :       b = vecmodii(ZM_ZC_mul(Uell, ZC_neg(b)), ordS);
     420         322 :       A = mkvec2(A, trivial_fact());
     421         322 :       A = idealpowred(nf, A, d);
     422             :       /* find a principal representative of A_i^cycA_i up to elements of S */
     423         322 :       a = isprincipalfact(bnf,gel(A,1),S,b,nf_GENMAT|nf_FORCE);
     424         322 :       if (!gequal0(gel(a,1))) pari_err_BUG("bnflog");
     425         322 :       a = famat_mul_shallow(gel(A,2), gel(a,2)); /* principal part */
     426         322 :       if (lg(a) == 1) continue;
     427        1316 :       for (j = 1; j < lS; j++)
     428         994 :         gcoeff(C,i,j) = vtilde(nf, a, gel(T,j), gel(vdegS,j), ell, prec0);
     429             :     }
     430         154 :     C = gmod(gneg(C),ellk);
     431         154 :     C = shallowtrans(C);
     432         154 :     M = mkmat2(mkcol2(diagonal_shallow(cycAp), C), mkcol2(gen_0, vtG));
     433         154 :     M = shallowmatconcat(M); /* relation matrix */
     434             :   }
     435             :   else
     436           7 :     M = vtG;
     437         161 :   M = ZM_hnfmodid(M, ellk);
     438         161 :   D = matsnf0(M, 4);
     439         161 :   if (lg(D) == 1 || !dvdii(gel(D,1), ellk))
     440           0 :     pari_err_BUG("bnflog [missing Z_l component]");
     441         161 :   D = vecslice(D,2,lg(D)-1);
     442         161 :   return mkvec3(D, CLt, ellsylow(cycAp, ell));
     443             : }
     444             : GEN
     445         175 : bnflog(GEN bnf, GEN ell)
     446             : {
     447         175 :   pari_sp av = avma;
     448         175 :   return gerepilecopy(av, bnflog_i(bnf, ell));
     449             : }
     450             : 
     451             : GEN
     452          42 : bnflogef(GEN nf, GEN pr)
     453             : {
     454          42 :   pari_sp av = avma;
     455             :   long e, f, ef;
     456             :   GEN p;
     457          42 :   checkprid(pr); p = pr_get_p(pr);
     458          42 :   nf = checknf(nf);
     459          42 :   e = pr_get_e(pr);
     460          42 :   f = pr_get_f(pr); ef = e*f;
     461          42 :   if (u_pval(ef, p))
     462             :   {
     463          21 :     GEN T = gel(factorpadic(nf_get_pol(nf), p, 100), 1);
     464          21 :     long j = get_ZpX_index(nf, pr, T);
     465          21 :     e = etilde(nf, pr, gel(T,j));
     466          21 :     f = ef / e;
     467             :   }
     468          42 :   set_avma(av); return mkvec2s(e,f);
     469             : }
     470             : 
     471             : GEN
     472          21 : bnflogdegree(GEN nf, GEN A, GEN ell)
     473             : {
     474          21 :   pari_sp av = avma;
     475             :   GEN AZ, A0Z, NA0;
     476             :   long vAZ;
     477             : 
     478          21 :   if (typ(ell) != t_INT) pari_err_TYPE("bnflogdegree", ell);
     479          21 :   nf = checknf(nf);
     480          21 :   A = idealhnf(nf, A);
     481          21 :   AZ = gcoeff(A,1,1);
     482          21 :   vAZ = Z_pvalrem(AZ, ell, &A0Z);
     483          21 :   if (is_pm1(A0Z))
     484           0 :     NA0 = gen_1;
     485             :   else
     486          21 :     (void)Z_pvalrem(idealnorm(nf,A), ell, &NA0);
     487          21 :   if (vAZ)
     488             :   {
     489          21 :     GEN Aell = ZM_hnfmodid(A, powiu(ell,vAZ));
     490          21 :     GEN S = idealprimedec(nf, ell), T;
     491          21 :     long l, i, s = 0;
     492          21 :     T = padicfact(nf, S, 100);
     493          21 :     l = lg(S);
     494          49 :     for (i = 1; i < l; i++)
     495             :     {
     496          28 :       GEN P = gel(S,i);
     497          28 :       long v = idealval(nf, Aell, P);
     498          28 :       if (v) s += v * ftilde(nf, P, gel(T,i));
     499             :     }
     500          21 :     if (s) NA0 = gmul(NA0, gpowgs(ell1(ell), s));
     501             :   }
     502          21 :   return gerepileupto(av, NA0);
     503             : }

Generated by: LCOV version 1.13