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 - ZG.c (source / functions) Hit Total Coverage
Test: PARI/GP v2.10.0 lcov report (development 19825-b77c7f8) Lines: 44 79 55.7 %
Date: 2016-12-05 05:49:04 Functions: 8 14 57.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* Copyright (C) 2011  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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
      13             : 
      14             : #include "pari.h"
      15             : #include "paripriv.h"
      16             : 
      17             : static int
      18    11372375 : cmp_G(void *E, GEN x, GEN y) { (void)E; return cmp_universal(x,y); }
      19             : 
      20             : /* a ZG is either a t_INT or a t_VEC of pairs [g,e] representing
      21             :  * \sum e_i [g_i], e_i in Z, g_i in G. */
      22             : GEN
      23     1974497 : ZG_normalize(GEN x)
      24             : {
      25     1974497 :   if (typ(x) == t_INT) return x;
      26     1974497 :   return sort_factor(shallowcopy(x), NULL, &cmp_G);
      27             : }
      28             : GEN
      29     1392048 : ZG_add(GEN x, GEN y)
      30             : {
      31     1392048 :   if (typ(x) == t_INT)
      32             :   {
      33      793863 :     if (!signe(x)) return y;
      34           0 :     if (typ(y) == t_INT)
      35             :     {
      36           0 :       if (!signe(y)) return x;
      37           0 :       return addii(x,y);
      38             :     }
      39           0 :     x = to_famat_shallow(gen_1,x);
      40             :   }
      41      598185 :   else if (typ(y) == t_INT)
      42             :   {
      43           0 :     if (!signe(y)) return x;
      44           0 :     y = to_famat_shallow(gen_1,y);
      45             :   }
      46      598185 :   x = merge_factor(x, y, NULL, &cmp_G);
      47      598185 :   if (lg(gel(x,1)) == 1) return gen_0;
      48      543263 :   return x;
      49             : }
      50             : GEN
      51         553 : ZG_neg(GEN x)
      52             : {
      53         553 :   if (typ(x) == t_INT) return negi(x);
      54         553 :   return mkmat2(gel(x,1),ZC_neg(gel(x,2)));
      55             : }
      56             : GEN
      57           0 : ZG_sub(GEN x, GEN y) { return ZG_add(x, ZG_neg(y)); }
      58             : 
      59             : /* x * c.[1], x in Z[G] */
      60             : GEN
      61           0 : ZG_Z_mul(GEN x, GEN c)
      62             : {
      63           0 :   if (is_pm1(c)) return signe(c) > 0? x: ZG_neg(x);
      64           0 :   if (typ(x) == t_INT) return mulii(x,c);
      65           0 :   return mkmat2(gel(x,1), ZC_Z_mul(gel(x,2), c));
      66             : }
      67             : 
      68             : GEN
      69           0 : ZG_mul(GEN x, GEN y)
      70             : {
      71             :   pari_sp av;
      72             :   GEN z, XG, XE;
      73             :   long i, l;
      74           0 :   if (typ(x) == t_INT) return ZG_Z_mul(y, x);
      75           0 :   if (typ(y) == t_INT) return ZG_Z_mul(x, y);
      76           0 :   av = avma;
      77           0 :   XG = gel(x,1); XE = gel(x,2); l = lg(XG);
      78           0 :   z = ZG_Z_mul(G_ZG_mul(gel(XG,1), y), gel(XE,1));
      79           0 :   for (i = 2; i < l; i++)
      80             :   {
      81           0 :     z = ZG_add(z, ZG_Z_mul(G_ZG_mul(gel(XG,i), y), gel(XE,i)));
      82           0 :     if (gc_needed(av,3))
      83             :     {
      84           0 :       if(DEBUGMEM>1) pari_warn(warnmem,"ZG_mul, i = %ld/%ld",i,l-1);
      85           0 :       z = gerepilecopy(av, z);
      86             :     }
      87             :   }
      88           0 :   return z;
      89             : }
      90             : GEN
      91      117852 : ZGCs_add(GEN x, GEN y)
      92             : {
      93      117852 :   GEN xi = gel(x,1), xv = gel(x,2);
      94      117852 :   GEN yi = gel(y,1), yv = gel(y,2);
      95      117852 :   long i = 1, j = 1, k = 1, lx = lg(xi), ly = lg(yi), l = lx+ly-1;
      96      117852 :   GEN zi = cgetg(l, t_VECSMALL), zv = cgetg(l, t_VEC);
      97     1114974 :   while (i < lx && j < ly)
      98             :   {
      99      879270 :     if      (xi[i] < yi[j]) { zi[k] = xi[i]; gel(zv,k) = gel(xv,i); i++; }
     100      431193 :     else if (xi[i] > yi[j]) { zi[k] = yi[j]; gel(zv,k) = gel(yv,j); j++; }
     101      221074 :     else { zi[k] = xi[i]; gel(zv,k) = ZG_add(gel(xv,i),gel(yv,j)); i++; j++; }
     102      879270 :     k++;
     103             :   }
     104      117852 :   for(; i < lx; i++,k++) { zi[k] = xi[i]; gel(zv,k) = gel(xv,i); }
     105      117852 :   for(; j < ly; j++,k++) { zi[k] = yi[j]; gel(zv,k) = gel(yv,j); }
     106      117852 :   setlg(zi,k);
     107      117852 :   setlg(zv,k); return mkvec2(zi, zv);
     108             : }
     109             : GEN
     110      699594 : ZG_G_mul(GEN x, GEN y)
     111             : {
     112             :   long i, l;
     113             :   GEN z, X;
     114      699594 :   if (typ(x) == t_INT) return signe(x)? to_famat_shallow(y, x): gen_0;
     115      699594 :   X = gel(x,1);
     116      699594 :   z = cgetg_copy(X, &l);
     117      699594 :   for (i = 1; i < l; i++) gel(z,i) = gmul(gel(X,i), y);
     118      699594 :   return ZG_normalize( mkmat2(z, gel(x,2)) );
     119             : }
     120             : GEN
     121      532420 : G_ZG_mul(GEN x, GEN y)
     122             : {
     123             :   long i, l;
     124             :   GEN z, Y;
     125      532420 :   if (typ(y) == t_INT) return to_famat_shallow(x, y);
     126      532420 :   Y = gel(y,1);
     127      532420 :   z = cgetg_copy(Y, &l);
     128      532420 :   for (i = 1; i < l; i++) gel(z,i) = gmul(x, gel(Y,i));
     129      532420 :   return ZG_normalize( mkmat2(z, gel(y,2)) );
     130             : }
     131             : void
     132      152320 : ZGC_G_mul_inplace(GEN v, GEN x)
     133             : {
     134      152320 :   long i, l = lg(v);
     135      152320 :   for (i = 1; i < l; i++) gel(v,i) = ZG_G_mul(gel(v,i), x);
     136      152320 : }
     137             : GEN
     138           0 : ZGC_G_mul(GEN v, GEN x)
     139             : {
     140             :   long i, l;
     141           0 :   GEN w = cgetg_copy(v, &l);
     142           0 :   for (i = 1; i < l; i++) gel(w,i) = ZG_G_mul(gel(v,i), x);
     143           0 :   return w;
     144             : }
     145             : GEN
     146           0 : G_ZGC_mul(GEN x, GEN v)
     147             : {
     148             :   long i, l;
     149           0 :   GEN w = cgetg_copy(v, &l);
     150           0 :   for (i = 1; i < l; i++) gel(w,i) = G_ZG_mul(gel(v,i), x);
     151           0 :   return w;
     152             : }
     153             : GEN
     154           0 : ZGC_Z_mul(GEN v, GEN x)
     155             : {
     156             :   long i, l;
     157           0 :   GEN w = cgetg_copy(v, &l);
     158           0 :   for (i = 1; i < l; i++) gel(w,i) = ZG_Z_mul(gel(v,i), x);
     159           0 :   return w;
     160             : }

Generated by: LCOV version 1.11