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 - nflistQT.c (source / functions) Hit Total Coverage
Test: PARI/GP v2.18.0 lcov report (development 29806-4d001396c7) Lines: 164 169 97.0 %
Date: 2024-12-21 09:08:57 Functions: 12 12 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* Copyright (C) 2021  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             : static GEN
      18         798 : strtoint(char *s)
      19             : {
      20         798 :   long neg = (*s == '-');
      21             :   GEN n;
      22         798 :   if (!neg) return strtoi(s);
      23         532 :   n = strtoi(s+1); togglesign(n); return n;
      24             : }
      25             : /* export ? */
      26             : static GEN
      27          42 : mkZVn(long n, ...)
      28             : {
      29             :   va_list ap;
      30             :   GEN x;
      31             :   long i;
      32          42 :   va_start(ap,n);
      33          42 :   x = cgetg(n+1, t_VEC);
      34         840 :   for (i=1; i <= n; i++) gel(x,i) = strtoint(va_arg(ap, char*));
      35          42 :   va_end(ap); return x;
      36             : }
      37             : 
      38             : static GEN /* -t */
      39         105 : pol_mx(long v) { return deg1pol_shallow(gen_m1, gen_0, v); }
      40          42 : static GEN QT4(long k, long v)
      41          42 : { switch(k) {
      42          14 :   case 1: return mkpoln(5, gen_1, pol_x(v), stoi(-6), pol_mx(v), gen_1);
      43          14 :   case 2: return mkpoln(5, gen_1, gen_0, pol_x(v), gen_0, gen_1);
      44          14 :   case 3: return mkpoln(5, gen_1, pol_x(v), gen_0, pol_x(v), gen_1);
      45           0 :   default: return NULL; }}
      46          42 : static GEN QT5(long k, long v)
      47             : { GEN a3, a2, a1, a0;
      48          42 :   switch(k) {
      49          14 :   case 1:
      50          14 :   a3 = mkpoln(4, stoi(-2), stoi(-6), stoi(-10), stoi(-10)); setvarn(a3,v);
      51          14 :   a2 = mkpoln(5, gen_1, stoi(5), stoi(11), stoi(15), stoi(5)); setvarn(a2,v);
      52          14 :   a1 = mkpoln(4, gen_1, stoi(4), stoi(10), stoi(10)); setvarn(a1,v);
      53          14 :   return mkpoln(6, gen_1, pol_xn(2,v), a3, a2, a1, gen_1);
      54          14 :   case 2:
      55          14 :   a3 = deg1pol_shallow(gen_m1, stoi(-50), v);
      56          14 :   a1 = deg1pol_shallow(stoi(5), stoi(625), v);
      57          14 :   a0 = deg1pol_shallow(stoi(-3), gen_0, v);
      58          14 :   return mkpoln(6, gen_1, gen_0, a3, pol_mx(v), a1, a0);
      59          14 :   case 3:
      60          14 :   a2 = deg1pol_shallow(stoi(5), gen_0, v);
      61          14 :   a0 = deg2pol_shallow(gen_1, gen_m1, stoi(16), v);
      62          14 :   return mkpoln(6, gen_1, gen_0, stoi(10), a2, stoi(-15), a0);
      63           0 :   default: return NULL; }}
      64         196 : static GEN QT6(long k, long v)
      65             : { GEN a5, a4, a3, a2, a1, a0;
      66         196 :   switch(k) {
      67          14 :   case 1:
      68          14 :   a5 = deg1pol_shallow(gen_2, gen_0, v);
      69          14 :   a4 = deg1pol_shallow(stoi(-5), stoi(-15), v);
      70          14 :   a2 = deg1pol_shallow(stoi(5), gen_0, v);
      71          14 :   a1 = deg1pol_shallow(gen_m2, stoi(-6), v);
      72          14 :   return mkpoln(7, gen_1, a5, a4, stoi(20), a2, a1, gen_1);
      73          14 :   case 2:
      74          14 :   a0 = deg2pol_shallow(stoi(3), gen_0, stoi(4), v);
      75          14 :   return mkpoln(7, gen_1, gen_0, stoi(6), gen_0, stoi(9), gen_0, a0);
      76          14 :   case 3:
      77          14 :   return mkpoln(7, gen_1, gen_0, stoi(6), gen_0, stoi(9), gen_0, pol_mx(v));
      78          14 :   case 4:
      79          14 :   a2 = deg1pol_shallow(gen_1, stoi(-3), v);
      80          14 :   return mkpoln(7, gen_1, gen_0, pol_x(v), gen_0, a2, gen_0, gen_m1);
      81          14 :   case 5:
      82          14 :   a4 = deg1pol_shallow(gen_1, stoi(-6), v);
      83          14 :   a3 = deg1pol_shallow(gen_2, gen_m2, v);
      84          14 :   a2 = deg1pol_shallow(gen_1, stoi(9), v);
      85          14 :   return mkpoln(7, gen_1, gen_0, a4, a3, a2, stoi(6), gen_1);
      86          14 :   case 6:
      87          14 :   a2 = mkpoln(5,stoi(-12),gen_0,stoi(-36),gen_0,gen_0); setvarn(a2,v);
      88          14 :   a0 = mkpoln(7,stoi(16),gen_0,stoi(48),gen_0,gen_0,gen_0,gen_0); setvarn(a0,v);
      89          14 :   return mkpoln(7, gen_1, gen_0, gen_0, gen_0, a2, gen_0, a0);
      90          14 :   case 7: return mkpoln(7, gen_1,gen_0,gen_0,gen_0,pol_x(v),gen_0,gen_m1);
      91          14 :   case 8:
      92          14 :   a0 = deg2pol_shallow(stoi(3), gen_0, stoi(4), v);
      93          14 :   return mkpoln(7, gen_1,gen_0,stoi(-3),gen_0,gen_0,gen_0,a0);
      94          14 :   case 9:
      95          14 :   a4 = deg2pol_shallow(stoi(3), gen_0, stoi(-6), v);
      96          14 :   a3 = deg2pol_shallow(gen_m2, gen_0, stoi(4), v);
      97          14 :   return mkpoln(7, gen_1,gen_0,a4,a3,stoi(9),stoi(-12),stoi(4));
      98          14 :   case 10:
      99          14 :   a0 = deg2pol_shallow(gen_m1, gen_0, stoi(-1024), v);
     100          14 :   return mkpoln(7, gen_1,stoi(-12),stoi(36),gen_0,gen_0,gen_0,a0);
     101          14 :   case 11:
     102          14 :   a0 = deg1pol_shallow(gen_1, stoi(4), v);
     103          14 :   return mkpoln(7, gen_1,gen_0,stoi(-3),gen_0,gen_0,gen_0,a0);
     104          14 :   case 12:
     105          14 :   a5 = deg2pol_shallow(stoi(10), gen_0, stoi(-50), v);
     106          14 :   a4 = gtopoly(mkvecsmall5(55, 0,-550, 0, 1375), v);
     107          14 :   a3 = gtopoly(mkvecsmalln(7, 140L, 0L,-2100L, 0L, 10500L, 0L,-17500L), v);
     108          14 :   a2 = gtopoly(mkvecsmalln(9, 175L, 0L,-3500L, 0L, 26250L, 0L,-87500L, 0L, 109375L), v);
     109          14 :   a1 = gtopoly(mkvecsmalln(11, 106L, 0L,-1370L, 0L, 900L, 0L, 59500L, 0L,-308750L, 0L, 468750L), v);
     110          14 :   a0 = gtopoly(mkvecsmalln(13, 25L, 0L,-750L, 0L, 9375L, 0L,-62500L, 0L, 234375L, 0L,-468750L, 0L, 390625L), v);
     111          14 :   return mkpoln(7, gen_1,a5,a4,a3,a2,a1,a0);
     112          14 :   case 13:
     113          14 :   return mkpoln(7, gen_1,gen_m2,gen_1,gen_0,gen_0,gen_0,pol_mx(v));
     114          14 :   case 14:
     115          14 :   return mkpoln(7, gen_1,stoi(4),stoi(20),gen_0,gen_0,pol_mx(v),pol_x(v));
     116           0 :   default: return NULL; }}
     117          70 : static GEN QT7(long k, long v)
     118             : { GEN a6, a5, a4, a3, a2, a1, a0;
     119          70 :   switch(k) {
     120          14 :   case 1:
     121          14 :   a6 = gtopoly(mkvecsmall4(1, 2,-1, 13), v);
     122          14 :   a5 = gtopoly(mkvecsmalln(6, 3L,-3L, 9L, 24L,-21L, 54L), v);
     123          14 :   a4 = gtopoly(mkvecsmalln(8, 3L,-9L, 27L,-22L, 6L, 84L,-121L, 75L), v);
     124          14 :   a3 = gtopoly(mkvecsmalln(10, 1L,-6L, 22L,-57L, 82L,-70L,-87L, 140L,-225L,-2L), v);
     125          14 :   a2 = gtopoly(mkvecsmalln(11, -1L, 5L,-25L, 61L,-126L, 117L,-58L,-155L, 168L,-80L,-44L), v);
     126          14 :   a1 = gtopoly(mkvecsmalln(11, -1L, 8L,-30L, 75L,-102L, 89L, 34L,-56L, 113L, 42L,-17L), v);
     127          14 :   a0 = gtopoly(mkvecsmalln(10, 1L,-7L, 23L,-42L, 28L, 19L,-60L,-2L, 16L,-1L), v);
     128          14 :   return mkpoln(8, gen_1,a6,a5,a4,a3,a2,a1,a0);
     129          14 :   case 2:
     130          14 :   a5 = gtopoly(mkvecsmall4(-147,-735,-441,-21), v);
     131          14 :   a4 = gtopoly(mkvecsmall5(-686,-3920,-4508,-1568,-70), v);
     132          14 :   a3 = gtopoly(mkvecsmalln(7, 7203L, 67914L, 183505L, 107996L, 8085L,-1862L,-105L), v);
     133          14 :   a2 = gtopoly(mkvecsmalln(8, 67228L, 547428L, 1373372L, 1227940L, 416500L, 38220L,-588L,-84L), v);
     134          14 :   a1 = gtopoly(mkvecsmalln(10, -117649L,-1563051L,-6809236L,-10708460L,-4050830L, 788214L, 402780L, 37828L, 343L,-35L), v);
     135          14 :   a0 = gtopoly(mkvecsmalln(11, -1647086L,-16893436L,-56197806L,-69977488L,-44893212L,-13304872L,-624652L, 103152L, 11466L, 196L,-6L), v);
     136          14 :   return mkpoln(8, gen_1,gen_0,a5,a4,a3,a2,a1,a0);
     137          14 :   case 3:
     138          14 :   a5 = gtopoly(mkvecsmalln(7, -21L,0L,-1176L,147L,-20580L,3969L,-107163L), v);
     139          14 :   a4 = gtopoly(mkvecsmalln(10, -21L,49L,-1715L,4214L,-51107L,129850L,-653905L,1648458L,-3000564L,6751269L), v);
     140          14 :   a3 = gtopoly(mkvecsmalln(13, 91L,98L,9849L,8673L,427133L,291354L,9385460L,4618152L,108334149L,35173278L,608864445L,114771573L,1275989841L), v);
     141          14 :   a2 = gtopoly(mkZVn(16, "112","-49","14651","-10682","800513","-821730","23571744","-30983190","401636536","-628991685","3929562693","-6832117530","20190045015","-35916751080","40831674912","-68903451414]"), v);
     142          14 :   a1 = gtopoly(mkZVn(19, "-84","-98","-14896","-16709","-1127098","-1228626","-47347279","-51034970","-1201635330","-1316073164","-18735012261","-21705143929","-173551408569","-224605199322","-861876002232","-1329675932088","-1728966234555","-3376269119286","0"), v);
     143          14 :   a0 = gtopoly(mkZVn(22, "-97","-14","-19803","-903","-1765232","84609","-89982172","11950757","-2882068329","588528171","-59885187418","15296374002","-801314604769","222442927665","-6560078164731","1705024373220","-28577589326937","5543939564730","-38647180304208","4961048501808","74415727527120","25115308040403"), v);
     144          14 :   return mkpoln(8, gen_1,gen_0,a5,a4,a3,a2,a1,a0);
     145          14 :   case 4:
     146          14 :   a4 = deg2pol_shallow(stoi(-7), gen_0, stoi(98), v);
     147          14 :   a3 = deg1pol_shallow(stoi(28), stoi(441), v);
     148          14 :   a2 = gtopoly(mkvecsmall4(-35,-112,-196, 343), v);
     149          14 :   a1 = deg2pol_shallow(stoi(7), stoi(196), stoi(1372), v);
     150          14 :   a0 = gtopoly(mkvecsmalln(6, -1L,-30L,-259L,-588L,-1372L, 0L), v);
     151          14 :   return mkpoln(8, gen_1,stoi(7),stoi(42),a4,a3,a2,a1,a0);
     152          14 :   case 5:
     153          14 :   a3 = deg1pol_shallow(stoi(12), stoi(7203), v);
     154          14 :   a2 = deg1pol_shallow(stoi(-30), gen_0, v);
     155          14 :   a1 = deg1pol_shallow(stoi(28), stoi(-117649), v);
     156          14 :   a0 = deg1pol_shallow(stoi(-9), gen_0, v);
     157          14 :   return mkpoln(8, gen_1,gen_0,stoi(-147),pol_mx(v),a3,a2,a1,a0);
     158           0 :   default: return NULL; }}
     159             : 
     160             : static GEN
     161        4186 : nflistQTfile(long n, long t)
     162             : {
     163             :   pariFILE *F;
     164             :   GEN z;
     165        4186 :   char *f = stack_sprintf("%s/nflistdata/%ld/%ld/QT", pari_datadir, n, t);
     166        4186 :   F = pari_fopengz(f); if (!F) return NULL;
     167        4186 :   z = gp_read_stream(F->file); pari_fclose(F); return z;
     168             : }
     169             : 
     170             : static GEN
     171        4536 : nfmakeQT(long deg, long k, long v)
     172             : {
     173             :   long i, l;
     174             :   GEN P;
     175        4536 :   switch(deg) {
     176          42 :   case 4: P = QT4(k, v); break;
     177          42 :   case 5: P = QT5(k, v); break;
     178         196 :   case 6: P = QT6(k, v); break;
     179          70 :   case 7: P = QT7(k, v); break;
     180        4186 :   default: P = nflistQTfile(deg, k);
     181             :   }
     182        4536 :   if (!P)
     183           0 :     pari_err_IMPL(stack_sprintf("group %ldT%ld in nflist / Q(T)", deg,k));
     184        4536 :   if (deg <= 7) return P;
     185        4186 :   l = lg(P);
     186       58989 :   for (i = 1; i < l; i++)
     187             :   {
     188       54803 :     GEN p = gel(P,i);
     189       54803 :     if (typ(p) != t_INT) gel(P,i) = RgV_to_RgX(p, v);
     190             :   }
     191        4186 :   return RgV_to_RgX(P, 0);
     192             : }
     193             : 
     194             : static GEN
     195         168 : nfmakeAnQT(long n, long v)
     196             : {
     197         168 :   GEN A, P = vec_ei(n + 1, 1);
     198             :   long s;
     199         168 :   if (odd(n))
     200             :   {
     201          98 :     s = (n & 3L) == 1? 1: -1;
     202          98 :     A = sqru(n-2); setsigne(A, s);
     203          98 :     gel(P,2) = monomial(sqru(n), 1, v);
     204          98 :     gel(P,n) = s > 0? gen_1: gen_m1;
     205          98 :     gel(P,n+1) = monomial(A, 1, v);
     206             :   }
     207             :   else
     208             :   {
     209          70 :     s = (n & 3L)? -1 : 1;
     210          70 :     gel(P,2) = utoineg(n);
     211          70 :     gel(P,n+1) = deg2pol_shallow(stoi(s), gen_0, powuu(n-1,n-1), v);
     212             :   }
     213         168 :   return RgV_to_RgX_reverse(P, 0);
     214             : }
     215             : 
     216             : static GEN
     217         140 : nfmakeSnQT(long n, long v)
     218             : {
     219         140 :   GEN P = vec_ei(n + 1, 1);
     220         140 :   gel(P,n) = pol_x(v);
     221         140 :   gel(P,n+1) = gen_1; return RgV_to_RgX_reverse(P, 0);
     222             : }
     223             : 
     224             : GEN
     225        4893 : nflistQT(long n, long t, long v)
     226             : {
     227        4893 :   if (varncmp(0,v) >= 0)
     228           7 :     pari_err(e_MISC, "incorrect variable in nflist / Q(T)");
     229        4886 :   if (n == 1) return pol_x(0);
     230        4865 :   if (n == 2) return deg2pol_shallow(gen_1, pol_mx(v), gen_1, 0);
     231        4844 :   if (t == -1) return nfmakeSnQT(n, v);
     232        4704 :   if (t == -2) return nfmakeAnQT(n, v);
     233        4536 :   return nfmakeQT(n, t, v);
     234             : }

Generated by: LCOV version 1.16