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 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.10.0 lcov report (development 21348-d75f58f) Lines: 275 281 97.9 %
Date: 2017-11-20 06:21:05 Functions: 24 24 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         553 :   GEN pi = nf_to_scalar_or_alg(K, pr_get_gen(pr));
      72         553 :   GEN p = pr_get_p(pr);
      73         553 :   long j, l = lg(T);
      74        1442 :   for (j = 1; j < l; j++)
      75             :   {
      76        1442 :     GEN t = gel(T,j);
      77        1442 :     if (!t) continue;
      78         861 :     if (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         315 : ell1(GEN ell) { return equaliu(ell,2)? utoipos(5): addiu(ell,1); }
     146             : 
     147             : /* log N_{F_P/Q_p}(x) / deg_F P */
     148             : static GEN
     149        7616 : vtilde_i(GEN K, GEN x, GEN T, GEN deg, GEN ell, long prec)
     150             : {
     151             :   GEN L, N, cx;
     152        7616 :   if (typ(x) != t_POL) x = nf_to_scalar_or_alg(K, x);
     153        7616 :   x = Q_primitive_part(x,&cx);
     154        7616 :   N = RgXQ_norm(x, T);
     155        7616 :   L = Qp_log(cvtop(N,ell,prec));
     156        7616 :   if (cx)
     157             :   {
     158        7567 :     Q_pvalrem(cx, ell, &cx);
     159        7567 :     if (!isint1(cx))
     160        7189 :       L = gadd(L, gmulsg(degpol(T), Qp_log(cvtop(cx,ell,prec))));
     161             :   }
     162        7616 :   return gdiv(L, deg);
     163             : }
     164             : static GEN
     165        3836 : vtilde(GEN K, GEN x, GEN T, GEN deg, GEN ell, long prec)
     166             : {
     167             :   GEN G, E, vG;
     168             :   long i, l;
     169        3836 :   if (typ(x) != t_MAT) return vtilde_i(K,x,T,deg,ell,prec);
     170        2800 :   G = gel(x,1); vG = cgetg_copy(G, &l);
     171        2800 :   E = gel(x,2);
     172        2800 :   for (i = 1; i < l; i++) gel(vG, i) = vtilde_i(K, gel(G,i),T,deg,ell,prec);
     173        2800 :   return RgV_dotproduct(E, vG);
     174             : }
     175             : 
     176             : /* v[i] = deg S[i] mod p^prec */
     177             : static GEN
     178         294 : get_vdegS(GEN Ftilde, GEN ell, long prec)
     179             : {
     180         294 :   long i, l = lg(Ftilde);
     181         294 :   GEN v = cgetg(l, t_VEC), degell = Qp_log( cvtop(ell1(ell), ell, prec) );
     182         294 :   for (i = 1; i < l; i++) gel(v,i) = gmulsg(Ftilde[i], degell);
     183         294 :   return v;
     184             : }
     185             : /* K a bnf. Compute kernel \tilde{Cl}_K(ell); return cyclic factors.
     186             :  * Set *pM to (vtilde_S[i](US[j]))_{i,j} */
     187             : static GEN
     188         175 : CL_tilde(GEN K, GEN US, GEN ell, GEN T, GEN Ftilde, GEN *pM, long prec)
     189             : {
     190             :   GEN D, M, ellk, vdegS;
     191         175 :   long i, j, imin, vmin, k, lD, l = lg(T), lU = lg(US);
     192             : 
     193         175 :   *pM = cgetg(1, t_MAT);
     194         175 :   if (l == 2) return cgetg(1, t_VEC); /* p = P^e: \tilde{Cl}(l) = (1) */
     195         133 :   vdegS = get_vdegS(Ftilde, ell, prec);
     196         133 :   imin = 1; vmin = l; /* upper bound */
     197         553 :   for (i = 1; i < l; i++)
     198             :   {
     199         420 :     long v = z_pval(Ftilde[i], ell);
     200         420 :     if (v < vmin) { vmin = v; imin = i; }
     201             :   }
     202         133 :   M = cgetg(lU, t_MAT);
     203         805 :   for (j = 1; j < lU; j++)
     204             :   {
     205         672 :     GEN c = cgetg(l, t_COL), a = gel(US,j);
     206        3892 :     for (i = 1; i < l; i++)
     207        3220 :       gel(c,i) = vtilde(K, a, gel(T,i), gel(vdegS,i), ell, prec);
     208         672 :     gel(M,j) = c;
     209             :   }
     210         133 :   k = padicprec(M, ell); ellk = powiu(ell, k);
     211         133 :   *pM = M = gmod(M, ellk);
     212         133 :   M = rowsplice(M, imin);
     213         133 :   l--;
     214         133 :   if (l == 1) return cgetg(1, t_VEC);
     215         133 :   M = ZM_hnfmodid(M, 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)) { avma = av; return 0; }
     254             :     }
     255             :   };
     256          14 :   avma = av; return 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             :   long r;
     308         105 :   if (typ(n) != t_INT) pari_err_TYPE("nfislocalpower",n);
     309         105 :   nf = checknf(nf);
     310         105 :   checkprid(pr);
     311          91 :   r = nfislocalpower_i(nf, pr, a, n);
     312          91 :   avma = av; return r;
     313             : }
     314             : 
     315             : /* v_ell(  exponent(D) ) */
     316             : static long
     317         350 : ellexpo(GEN D, GEN ell) { return lg(D) == 1? 0: Z_pval(gel(D,1), ell); }
     318             : 
     319             : static GEN
     320         161 : ellsylow(GEN cyc, GEN ell)
     321             : {
     322             :   long i, l;
     323         161 :   GEN d = cgetg_copy(cyc, &l);
     324         343 :   for (i = 1; i < l; i++)
     325             :   {
     326         266 :     GEN c = gel(cyc,i), a;
     327         266 :     if (!Z_pvalrem(c, ell, &a)) break;
     328         182 :     gel(d,i) = diviiexact(c, a);
     329             :   }
     330         161 :   setlg(d, i); return d;
     331             : }
     332             : 
     333             : static long
     334         889 : vnorm_x(GEN nf, GEN x, GEN ell)
     335             : {
     336         889 :   x = nf_to_scalar_or_alg(nf,x);
     337         889 :   if (typ(x) != t_POL) return 0;
     338         833 :   x = Q_primpart(x);
     339         833 :   return Q_pval(nfnorm(nf,x), ell);
     340             : }
     341             : static long
     342         462 : vtilde_prec_x(GEN nf, GEN x, GEN ell)
     343             : {
     344             :   long i, l, v;
     345             :   GEN G;
     346         462 :   if (typ(x) != t_MAT) return vnorm_x(nf,x,ell);
     347         462 :   G = gel(x,1); l = lg(G); v = 0;
     348         462 :   for (i = 1; i < l; i++) v = maxss(v, vnorm_x(nf,gel(G,i),ell));
     349         462 :   return v;
     350             : }
     351             : /* upper bound for \delta(vec): estimate loss of accuracy when evaluating
     352             :  * \tilde{v} on the vec[i] */
     353             : static long
     354         175 : vtilde_prec(GEN nf, GEN vec, GEN ell)
     355             : {
     356         175 :   long v0 = 0, i, l = lg(vec);
     357         637 :   for (i = 1; i < l; i++)
     358         462 :     v0 = maxss(v0, vtilde_prec_x(nf, gel(vec,i), ell));
     359         175 :   return 3 + v0 + z_pval(nf_get_degree(nf), ell);
     360             : }
     361             : 
     362             : static GEN
     363         175 : bnflog_i(GEN bnf, GEN ell)
     364             : {
     365             :   long prec0, prec;
     366             :   GEN nf, US, vdegS, S, T, M, CLp, CLt, Ftilde, vtG, ellk;
     367             :   GEN D, Ap, cycAp, bnfS;
     368             :   long i, j, lS, lvAp;
     369             : 
     370         175 :   checkbnf(bnf);
     371         175 :   nf = checknf(bnf);
     372         175 :   S = idealprimedec(nf, ell);
     373         175 :   bnfS = bnfsunit0(bnf, S, nf_GENMAT, LOWDEFAULTPREC); /* S-units */
     374         175 :   US = leafcopy(gel(bnfS,1));
     375         175 :   prec0 = maxss(30, vtilde_prec(nf, US, ell));
     376         175 :   US = shallowconcat(bnf_get_fu(bnf), US);
     377         175 :   settyp(US, t_COL);
     378         175 :   T = padicfact(nf, S, prec0);
     379         175 :   lS = lg(S); Ftilde = cgetg(lS, t_VECSMALL);
     380         175 :   for (j = 1; j < lS; j++) Ftilde[j] = ftilde(nf, gel(S,j), gel(T,j));
     381         175 :   CLp = CL_prime(bnf, ell, S);
     382         175 :   cycAp = gel(CLp,1);
     383         175 :   Ap = gel(CLp,2);
     384             :   for(;;)
     385             :   {
     386         175 :     CLt = CL_tilde(nf, US, ell, T, Ftilde, &vtG, prec0);
     387         175 :     if (CLt) break;
     388           0 :     prec0 <<= 1;
     389           0 :     T = padicfact(nf, S, prec0);
     390           0 :   }
     391         175 :   prec = ellexpo(cycAp, ell) + ellexpo(CLt,ell) + 1;
     392         175 :   if (prec == 1) return mkvec3(cgetg(1,t_VEC), cgetg(1,t_VEC), cgetg(1,t_VEC));
     393             : 
     394         161 :   vdegS = get_vdegS(Ftilde, ell, prec0);
     395         161 :   ellk = powiu(ell, prec);
     396         161 :   lvAp = lg(Ap);
     397         161 :   if (lvAp > 1)
     398             :   {
     399         154 :     GEN Kcyc = bnf_get_cyc(bnf);
     400         154 :     GEN C = zeromatcopy(lvAp-1, lS-1);
     401         154 :     GEN Rell = gel(CLp,3), Uell = gel(CLp,4), ordS = gel(CLp,5);
     402         476 :     for (i = 1; i < lvAp; i++)
     403             :     {
     404         322 :       GEN a, b, bi, A = gel(Ap,i), d = gel(cycAp,i);
     405         322 :       bi = isprincipal(bnf, A);
     406         322 :       a = vecmodii(ZC_Z_mul(bi,d), Kcyc);
     407             :       /* a in subgroup generated by S = Rell; hence b integral */
     408         322 :       b = hnf_invimage(Rell, a);
     409         322 :       b = vecmodii(ZM_ZC_mul(Uell, ZC_neg(b)), ordS);
     410         322 :       A = mkvec2(A, cgetg(1,t_MAT));
     411         322 :       A = idealpowred(nf, A, d);
     412             :       /* find a principal representative of A_i^cycA_i up to elements of S */
     413         322 :       a = isprincipalfact(bnf,gel(A,1),S,b,nf_GENMAT|nf_FORCE);
     414         322 :       if (!gequal0(gel(a,1))) pari_err_BUG("bnflog");
     415         322 :       a = famat_mul_shallow(gel(A,2), gel(a,2)); /* principal part */
     416         322 :       if (lg(a) == 1) continue;
     417         889 :       for (j = 1; j < lS; j++)
     418         616 :         gcoeff(C,i,j) = vtilde(nf, a, gel(T,j), gel(vdegS,j), ell, prec0);
     419             :     }
     420         154 :     C = gmod(gneg(C),ellk);
     421         154 :     C = shallowtrans(C);
     422         154 :     M = mkmat2(mkcol2(diagonal_shallow(cycAp), C), mkcol2(gen_0, vtG));
     423         154 :     M = shallowmatconcat(M); /* relation matrix */
     424             :   }
     425             :   else
     426           7 :     M = vtG;
     427         161 :   M = ZM_hnfmodid(M, ellk);
     428         161 :   D = matsnf0(M, 4);
     429         161 :   if (lg(D) == 1 || !dvdii(gel(D,1), ellk))
     430           0 :     pari_err_BUG("bnflog [missing Z_l component]");
     431         161 :   D = vecslice(D,2,lg(D)-1);
     432         161 :   return mkvec3(D, CLt, ellsylow(cycAp, ell));
     433             : }
     434             : GEN
     435         175 : bnflog(GEN bnf, GEN ell)
     436             : {
     437         175 :   pari_sp av = avma;
     438         175 :   return gerepilecopy(av, bnflog_i(bnf, ell));
     439             : }
     440             : 
     441             : GEN
     442          42 : bnflogef(GEN nf, GEN pr)
     443             : {
     444          42 :   pari_sp av = avma;
     445             :   long e, f, ef;
     446             :   GEN p;
     447          42 :   checkprid(pr); p = pr_get_p(pr);
     448          42 :   nf = checknf(nf);
     449          42 :   e = pr_get_e(pr);
     450          42 :   f = pr_get_f(pr); ef = e*f;
     451          42 :   if (u_pval(ef, p))
     452             :   {
     453          21 :     GEN T = gel(factorpadic(nf_get_pol(nf), p, 100), 1);
     454          21 :     long j = get_ZpX_index(nf, pr, T);
     455          21 :     e = etilde(nf, pr, gel(T,j));
     456          21 :     f = ef / e;
     457             :   }
     458          42 :   avma = av; return mkvec2s(e,f);
     459             : }
     460             : 
     461             : GEN
     462          21 : bnflogdegree(GEN nf, GEN A, GEN ell)
     463             : {
     464          21 :   pari_sp av = avma;
     465             :   GEN AZ, A0Z, NA0;
     466             :   long vAZ;
     467             : 
     468          21 :   if (typ(ell) != t_INT) pari_err_TYPE("bnflogdegree", ell);
     469          21 :   nf = checknf(nf);
     470          21 :   A = idealhnf(nf, A);
     471          21 :   AZ = gcoeff(A,1,1);
     472          21 :   vAZ = Z_pvalrem(AZ, ell, &A0Z);
     473          21 :   if (is_pm1(A0Z))
     474           0 :     NA0 = gen_1;
     475             :   else
     476          21 :     (void)Z_pvalrem(idealnorm(nf,A), ell, &NA0);
     477          21 :   if (vAZ)
     478             :   {
     479          21 :     GEN Aell = ZM_hnfmodid(A, powiu(ell,vAZ));
     480          21 :     GEN S = idealprimedec(nf, ell), T;
     481          21 :     long l, i, s = 0;
     482          21 :     T = padicfact(nf, S, 100);
     483          21 :     l = lg(S);
     484          49 :     for (i = 1; i < l; i++)
     485             :     {
     486          28 :       GEN P = gel(S,i);
     487          28 :       long v = idealval(nf, Aell, P);
     488          28 :       if (v) s += v * ftilde(nf, P, gel(T,i));
     489             :     }
     490          21 :     if (s) NA0 = gmul(NA0, gpowgs(ell1(ell), s));
     491             :   }
     492          21 :   return gerepileupto(av, NA0);
     493             : }

Generated by: LCOV version 1.11