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-bordeaux1.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 - ellpadicL.c (source / functions) Hit Total Coverage
Test: PARI/GP v2.8.0 lcov report (development 16741-1378b1c) Lines: 62 94 66.0 %
Date: 2014-08-17 Functions: 5 8 62.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 26 68 38.2 %

           Branch data     Line data    Source code
       1                 :            : /* $Id$
       2                 :            : 
       3                 :            : Copyright (C) 2011  The PARI group.
       4                 :            : 
       5                 :            : This file is part of the PARI/GP package.
       6                 :            : 
       7                 :            : PARI/GP is free software; you can redistribute it and/or modify it under the
       8                 :            : terms of the GNU General Public License as published by the Free Software
       9                 :            : Foundation. It is distributed in the hope that it will be useful, but WITHOUT
      10                 :            : ANY WARRANTY WHATSOEVER.
      11                 :            : 
      12                 :            : Check the License for details. You should have received a copy of it, along
      13                 :            : with the package; see the file 'COPYING'. If not, write to the Free Software
      14                 :            : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
      15                 :            : 
      16                 :            : #include "pari.h"
      17                 :            : #include "paripriv.h"
      18                 :            : 
      19                 :            : /** Batch p-adic logarithms **/
      20                 :            : 
      21                 :            : /* a/b mod q */
      22                 :            : static GEN
      23                 :          0 : divmodulo(GEN a, ulong b, ulong p, GEN q)
      24                 :            : {
      25                 :          0 :   long v = u_lvalrem(b, p, &b);
      26         [ #  # ]:          0 :   if (v) a = divis(a, upowuu(p,v));
      27                 :            :   /* a/b is now a p-integer */
      28                 :          0 :   return Fp_div(a, utoipos(b), q);
      29                 :            : }
      30                 :            : 
      31                 :            : /* to compute log_p(a) mod q = p^n, p < 2^31 */
      32                 :            : static GEN
      33                 :          0 : initQplog(long p, GEN q, long n)
      34                 :            : {
      35                 :            :   long i, nn, nt;
      36                 :            :   GEN a, C;
      37         [ #  # ]:          0 :   for(nn = n, nt = n + 1; nn >= p; nn /= p) nt++;
      38         [ #  # ]:          0 :   if (p == 2)
      39         [ #  # ]:          0 :     while(3 * (nt - 1) > u_lval(nt-1, p) + n) nt--;
      40                 :            :   else
      41         [ #  # ]:          0 :     while(nt > u_lval(nt-1, p) + n) nt--;
      42                 :            : 
      43                 :          0 :   C = cgetg(nt, t_VEC);
      44                 :            :   /* [ (-1)^k-1 p^k / (k*(p-1)) ] k=1..nt
      45                 :            :    * [ (-1)^k-1 2^3k / (2*k) ]    k=1..nt if p = 2*/
      46         [ #  # ]:          0 :   for(i = 1, a = utoipos(p); i < nt; i++, a = mulis(a, -p))
      47         [ #  # ]:          0 :     gel(C,i) = divmodulo(a, i * (p==2? 2: p-1), p, q);
      48                 :          0 :   return C;
      49                 :            : }
      50                 :            : 
      51                 :            : /* compute log_p(a), 'a' a p-unit, C = initQplog(p,q,n), q = p^n */
      52                 :            : static GEN
      53                 :          0 : logp(GEN C, GEN a, ulong p, GEN q)
      54                 :            : {
      55                 :          0 :   long i, nt = lg(C);
      56                 :          0 :   ulong av = avma;
      57                 :            :   GEN b, res;
      58                 :            : 
      59         [ #  # ]:          0 :   if (p == 2)
      60                 :          0 :     b = Fp_sqr(modii(a,q), q);
      61                 :            :   else
      62                 :          0 :     b = Fp_powu(a, p-1, q);
      63                 :            :   /* now b = 1 mod p, compute (b-1) / p = euclidean quotient */
      64                 :          0 :   b = divis(b, p);
      65                 :          0 :   res = Fp_mul(b, gel(C,nt-1), q);
      66         [ #  # ]:          0 :   for(i = nt-2; i > 0; i--)
      67                 :          0 :     res = Fp_mul(addii(res, gel(C,i)), b, q);
      68                 :          0 :   return gerepileuptoint(av, res);
      69                 :            : }
      70                 :            : 
      71                 :            : /** p-adic L function **/
      72                 :            : 
      73                 :            : /* E an ellsym struct. D > 0. Assume |D p^m| < MAX_ULONG, m > 0 */
      74                 :            : static GEN
      75                 :         35 : loopLpn(GEN E, ulong D, ulong p, long m, long R, GEN q)
      76                 :            : {
      77                 :            :   pari_sp av, lim;
      78                 :            :   ulong a;
      79                 :         35 :   GEN q1 = diviuexact(q,p);
      80                 :         35 :   GEN Dq1= mului(D,q1), Dq = muliu(Dq1,p);
      81                 :         35 :   GEN u = gen_0, u1 = gen_0, nc = icopy(gen_1);
      82                 :         35 :   GEN c = mkfrac(nc, Dq), c1 = mkfrac(nc, Dq1);
      83         [ -  + ]:         35 :   GEN C = R? initQplog(p, q, m): NULL;
      84                 :         35 :   ulong A = itou(shifti(Dq,-1));
      85                 :            : 
      86                 :         35 :   av = avma; lim = stack_lim(av,2);
      87         [ +  + ]:    1050645 :   for (a = 1; a <= A; a++)
      88                 :            :   {
      89                 :            :     GEN logpR, x,x1;
      90                 :            :     long s;
      91 [ +  + ][ -  + ]:    1050610 :     if (a % p == 0 || !(s = krouu(D,a))) continue;
      92                 :     684390 :     nc[2] = (long)a;
      93                 :     684390 :     x = Q_xpm(E, c); /* xpm(a / Dq) */
      94                 :     684390 :     x1= Q_xpm(E, c1);/* xpm(a / D(q/p)) */
      95 [ +  + ][ +  + ]:     684390 :     if (!signe(x) && !signe(x1)) continue;
      96         [ -  + ]:     653790 :     if (R)
      97                 :            :     {
      98                 :          0 :       logpR = logp(C, nc, p, q);
      99         [ #  # ]:          0 :       if (R != 1) logpR = Fp_powu(logpR, R, q);
     100                 :          0 :       x = mulii(x, logpR);
     101                 :          0 :       x1= mulii(x1,logpR);
     102                 :            :     }
     103         [ -  + ]:     653790 :     if (s < 0) { u = subii(u, x); u1= subii(u1,x1); }
     104                 :     653790 :     else       { u = addii(u, x); u1= addii(u1,x1); }
     105         [ -  + ]:     653790 :     if (low_stack(lim, stack_lim(av,2)))
     106                 :            :     {
     107         [ #  # ]:          0 :       if (DEBUGMEM>1) pari_warn(warnmem,"loopLp: a = %ld / %ld",a,A);
     108                 :          0 :       gerepileall(av, 2, &u,&u1);
     109                 :            :     }
     110                 :            :   }
     111                 :         35 :   return mkvec2(u,u1);
     112                 :            : }
     113                 :            : 
     114                 :            : /* p | ap, return unit root of x^2 - ap*x + p, accuracy p^n */
     115                 :            : static GEN
     116                 :          5 : unit_eigenvalue(GEN ap, GEN p, long n)
     117                 :            : {
     118                 :          5 :   GEN sqrtD, D = subii(sqri(ap), shifti(p,2));
     119         [ -  + ]:          5 :   if (equaliu(p,2)) n++;
     120                 :          5 :   sqrtD = Zp_sqrtlift(D, ap, p, n); /* congruent to ap mod p */
     121                 :          5 :   return gmul2n(gadd(ap, cvtop(sqrtD,p,n)), -1);
     122                 :            : }
     123                 :            : 
     124                 :            : /* FIXME : delete and export !!! */
     125                 :            : static GEN
     126                 :         35 : ellsym_get_ell(GEN E) { return gel(E,3); }
     127                 :            : static GEN
     128                 :         35 : ellsym_get_scale(GEN E) { return gel(E,4); }
     129                 :            : 
     130                 :            : /* TODO: C corresponds to Teichmuller, currently allways NULL */
     131                 :            : GEN
     132                 :         35 : ellpadicL(GEN e, GEN pp, long n, long r, GEN DD, GEN C)
     133                 :            : {
     134                 :         35 :   pari_sp av = avma;
     135                 :            :   GEN E, ap, scale, L;
     136                 :            :   ulong p, D;
     137                 :            : 
     138                 :         35 :   E = ellsym(e, 1);
     139                 :         35 :   e = ellsym_get_ell(E);
     140 [ -  + ][ #  # ]:         35 :   if (DD && !Z_isfundamental(DD))
     141                 :          0 :     pari_err_DOMAIN("ellpadicL", "isfundamental(D)", "=", gen_0, DD);
     142 [ -  + ][ #  # ]:         35 :   if (DD && signe(DD) <= 0) pari_err_DOMAIN("ellpadicL", "D", "<=", gen_0, DD);
     143         [ -  + ]:         35 :   if (typ(pp) != t_INT)
     144         [ #  # ]:          0 :   if (typ(pp) != t_INT) pari_err_TYPE("ellpadicL",pp);
     145         [ -  + ]:         35 :   if (cmpis(pp,2) < 0) pari_err_PRIME("ellpadicL",pp);
     146         [ -  + ]:         35 :   if (n <= 0) pari_err_DOMAIN("ellpadicL","precision","<=",gen_0,stoi(n));
     147         [ -  + ]:         35 :   if (r < 0) pari_err_DOMAIN("ellpadicL","r","<",gen_0,stoi(r));
     148                 :         35 :   p = itou(pp);
     149         [ -  + ]:         35 :   D = DD? itou(DD): 1;
     150                 :            : 
     151                 :         35 :   scale = ellsym_get_scale(E);
     152                 :         35 :   n -= Q_pval(scale, pp);
     153                 :         35 :   scale = cvtop(scale, pp, n);
     154                 :            : 
     155                 :         35 :   ap = ellap(e,pp);
     156         [ +  + ]:         35 :   if (umodiu(ap,p))
     157                 :            :   { /* ordinary */
     158                 :          5 :     long N = n+1;
     159                 :          5 :     GEN pn = powuu(p, N);
     160                 :          5 :     GEN u,v, uv = loopLpn(E, D, p, N, r, pn); /* correct mod p^n */
     161                 :          5 :     GEN al = ginv( unit_eigenvalue(ap, pp, n) );
     162                 :          5 :     al = gel(al,4); /* lift to Z */
     163                 :          5 :     u = modii(gel(uv,1), pn);
     164                 :          5 :     v = modii(gel(uv,2), pn);
     165                 :          5 :     L = Fp_sub(u, Fp_mul(al,v,pn), pn);
     166                 :          5 :     L = Fp_mul(L, Fp_powu(al, N, pn), pn);
     167         [ -  + ]:          5 :     if (!signe(L)) L = zeropadic_shallow(pp, n);
     168                 :            :   }
     169                 :            :   else
     170                 :            :   { /* supersingular */
     171                 :         30 :     GEN _0 = zeropadic_shallow(pp, n);
     172         [ +  + ]:         30 :     long N = signe(ap)? 2*n+3: 2*n+1;
     173                 :         30 :     GEN uv = loopLpn(E, D, p, N, r, powiu(pp,N)), u = gel(uv,1), v = gel(uv,2);
     174                 :         30 :     GEN M = mkmat2(mkcol2(gen_0, gen_m1), gdivgs(mkcol2(gen_1,ap),p));
     175                 :         30 :     L = RgV_RgM_mul(mkvec2(u,gdivgs(v,-p)), gpowgs(M,N));
     176                 :         30 :     u = gadd(gel(L,1), _0);
     177                 :         30 :     v = gadd(gel(L,2), _0);
     178                 :         30 :     L = mkvec2(u,v);
     179                 :            :   }
     180                 :         35 :   return gerepileupto(av, gmul(L, gmul2n(scale,1)));
     181                 :            : }

Generated by: LCOV version 1.9