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 - modules - ellfromeqn.c (source / functions) Hit Total Coverage
Test: PARI/GP v2.10.0 lcov report (development 21348-d75f58f) Lines: 63 67 94.0 %
Date: 2017-11-20 06:21:05 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* Copyright (C) 2015  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             : /* This file is a C version by Bill Allombert of a GP script by
      18             :    Fernando Rodriguez-Villegas */
      19             : 
      20             : /* ---------------  GP code  --------------------------------------- */
      21             : /* http://www.ma.utexas.edu/users/villegas/cnt/jacobians.gp */
      22             : /* */
      23             : /* Description: Compute long Weierstrass equation for genus 1 curve */
      24             : /* given by a plane curve */
      25             : /* */
      26             : /* Original Author:     Fernando Rodriguez-Villegas  */
      27             : /*                      villegas@math.utexas.edu */
      28             : /*                      University of Texas at Austin */
      29             : /* */
      30             : /* Created:             Tue Jun  7 2005 */
      31             : /* */
      32             : /*----------------------------------------------------------------- */
      33             : 
      34             : /* The mathematic behind this is described in
      35             : On the Jacobians of plane cubics,
      36             : Artin, Michael and Rodriguez-Villegas, Fernando and Tate, John,
      37             : Advances in Mathematics, 198, 2005, 1, 366--382
      38             : DOI: 10.1016/j.aim.2005.06.004
      39             : URL: http://dx.doi.org/10.1016/j.aim.2005.06.004
      40             : PDF: http://www.sciencedirect.com/science/article/pii/S0001870805001775
      41             : */
      42             : 
      43             : /* Input: coefficients of a cubic  */
      44             : /*t0*y^3+(s1+s0*x)*y^2 +(r2+r1*x+r0*x^2)*y+(q3+q2*x+q1*x^2+q0*x^3)=0*/
      45             : 
      46             : static GEN
      47          77 : jac_cubic(GEN t0, GEN s0, GEN s1, GEN r0, GEN r1, GEN r2, GEN q0, GEN q1, GEN q2, GEN q3)
      48             : {
      49          77 :   GEN p1 = cgetg(6, t_VEC);
      50          77 :   gel(p1, 1) = gcopy(r1);
      51          77 :   gel(p1, 2) = gneg(gadd(gadd(gmul(s0, q2), gmul(s1, q1)), gmul(r0, r2)));
      52          77 :   gel(p1, 3) = gadd(gmul(gsub(gmul(gmulsg(9, t0), q0), gmul(s0, r0)), q3), gadd(gmul(gsub(gmul(gneg(t0), q1), gmul(s1, r0)), q2), gsub(gmul(gmul(gneg(s0), r2), q1), gmul(gmul(s1, r2), q0))));
      53          77 :   gel(p1, 4) = gadd(gmul(gadd(gmul(gadd(gmul(gmulsg(-3, t0), r0), gsqr(s0)), q1), gadd(gmul(gmul(gmulsg(-3, s1), s0), q0), gmul(s1, gsqr(r0)))), q3), gadd(gadd(gmul(gmul(t0, r0), gsqr(q2)), gmul(gadd(gmul(gmul(s1, s0), q1), gadd(gmul(gadd(gmul(gmulsg(-3, t0), r2), gsqr(s1)), q0), gmul(gmul(s0, r0), r2))), q2)), gadd(gadd(gmul(gmul(t0, r2), gsqr(q1)), gmul(gmul(gmul(s1, r0), r2), q1)), gmul(gmul(s0, gsqr(r2)), q0))));
      54          77 :   gel(p1, 5) = gadd(gadd(gmul(gsub(gadd(gmul(gmulsg(-27, gsqr(t0)), gsqr(q0)), gmul(gsub(gmul(gmul(gmulsg(9, t0), s0), r0), gpowgs(s0, 3)), q0)), gmul(t0, gpowgs(r0, 3))), gsqr(q3)), gmul(gadd(gmul(gadd(gmul(gsub(gmul(gmulsg(9, gsqr(t0)), q0), gmul(gmul(t0, s0), r0)), q1), gadd(gmul(gadd(gmul(gmul(gmulsg(-3, t0), s0), r1), gadd(gmul(gmul(gmulsg(3, t0), s1), r0), gmul(gmulsg(2, s1), gsqr(s0)))), q0), gsub(gmul(gmul(t0, gsqr(r0)), r1), gmul(gmul(s1, s0), gsqr(r0))))), q2), gadd(gadd(gadd(gmul(gneg(gsqr(t0)), gpowgs(q1, 3)), gmul(gadd(gmul(gmul(t0, s0), r1), gsub(gmul(gmul(gmulsg(2, t0), s1), r0), gmul(s1, gsqr(s0)))), gsqr(q1))), gmul(gadd(gmul(gadd(gmul(gmul(gmulsg(3, t0), s0), r2), gadd(gmul(gmul(gmulsg(-3, t0), s1), r1), gmul(gmulsg(2, gsqr(s1)), s0))), q0), gadd(gmul(gsub(gmul(gmulsg(2, t0), gsqr(r0)), gmul(gsqr(s0), r0)), r2), gsub(gadd(gmul(gmul(gneg(t0), r0), gsqr(r1)), gmul(gmul(gmul(s1, s0), r0), r1)), gmul(gsqr(s1), gsqr(r0))))), q1)), gadd(gmul(gsub(gmul(gmul(gmulsg(9, t0), s1), r2), gpowgs(s1, 3)), gsqr(q0)), gmul(gadd(gmul(gsub(gmul(gadd(gmul(gmulsg(-3, t0), r0), gsqr(s0)), r1), gmul(gmul(s1, s0), r0)), r2), gadd(gsub(gmul(t0, gpowgs(r1, 3)), gmul(gmul(s1, s0), gsqr(r1))), gmul(gmul(gsqr(s1), r0), r1))), q0)))), q3)), gadd(gadd(gadd(gmul(gmul(gneg(gsqr(t0)), q0), gpowgs(q2, 3)), gmul(gadd(gmul(gmul(gmul(gneg(t0), s1), r0), q1), gsub(gmul(gadd(gmul(gmul(gmulsg(2, t0), s0), r2), gsub(gmul(gmul(t0, s1), r1), gmul(gsqr(s1), s0))), q0), gmul(gmul(t0, gsqr(r0)), r2))), gsqr(q2))), gmul(gadd(gadd(gmul(gmul(gmul(gneg(t0), s0), r2), gsqr(q1)), gmul(gadd(gmul(gmul(gmul(gneg(t0), s1), r2), q0), gmul(gsub(gmul(gmul(t0, r0), r1), gmul(gmul(s1, s0), r0)), r2)), q1)), gmul(gadd(gmul(gsub(gmul(gmulsg(2, t0), r0), gsqr(s0)), gsqr(r2)), gmul(gsub(gadd(gmul(gneg(t0), gsqr(r1)), gmul(gmul(s1, s0), r1)), gmul(gsqr(s1), r0)), r2)), q0)), q2)), gsub(gadd(gmul(gmul(gmul(gneg(t0), r0), gsqr(r2)), gsqr(q1)), gmul(gmul(gmul(gsub(gmul(t0, r1), gmul(s1, s0)), gsqr(r2)), q0), q1)), gmul(gmul(t0, gpowgs(r2, 3)), gsqr(q0)))));
      55          77 :   return p1;
      56             : }
      57             : 
      58             : /* Input: coefficients of an equation */
      59             : /* t0*y^2+(s0*x^2+s1*x+s2)*y+(r0*x^4+r1*x^3+r2*x^2+r3*x+r4)=0 */
      60             : 
      61             : static GEN
      62          21 : jac_quart(GEN t0, GEN s0, GEN s1, GEN s2, GEN r0, GEN r1, GEN r2, GEN r3, GEN r4)
      63             : {
      64          21 :   GEN p1 = cgetg(6, t_VEC);
      65          21 :   gel(p1, 1) = gcopy(s1);
      66          21 :   gel(p1, 2) = gsub(gmul(gneg(t0), r2), gmul(s0, s2));
      67          21 :   gel(p1, 3) = gsub(gmul(gmul(gneg(t0), s2), r1), gmul(gmul(t0, s0), r3));
      68          21 :   gel(p1, 4) = gadd(gadd(gadd(gmul(gneg(gsub(gmul(gmulsg(4, gsqr(t0)), r4), gmul(t0, gsqr(s2)))), r0), gmul(gmul(gsqr(t0), r1), r3)), gmul(gmul(gmul(t0, s0), s2), r2)), gmul(gmul(t0, gsqr(s0)), r4));
      69          21 :   gel(p1, 5) = gsub(gsub(gsub(gmul(gneg(gadd(gsub(gadd(gmul(gneg(gsub(gmul(gmulsg(4, gpowgs(t0, 3)), r4), gmul(gsqr(t0), gsqr(s2)))), r2), gmul(gpowgs(t0, 3), gsqr(r3))), gmul(gmul(gmul(gsqr(t0), s1), s2), r3)), gmul(gmul(gsqr(t0), gsqr(s1)), r4))), r0), gmul(gmul(gpowgs(t0, 3), gsqr(r1)), r4)), gmul(gsub(gmul(gmul(gmul(gsqr(t0), s0), s2), r3), gmul(gmul(gmul(gsqr(t0), s0), s1), r4)), r1)), gmul(gmul(gmul(gsqr(t0), gsqr(s0)), r2), r4));
      70          21 :   return p1;
      71             : }
      72             : 
      73             : /* Input: coefficients of an equation */
      74             : /* (t0*x^2+t1*x+t2)*y^2+(r0*x^2+r1*x+r2)*y+(s0*x^2+s1*x+s2)=0 */
      75             : 
      76             : static GEN
      77           7 : jac_biquadr(GEN t0, GEN t1, GEN t2, GEN r0, GEN r1, GEN r2,
      78             :                                     GEN s0, GEN s1, GEN s2)
      79             : {
      80           7 :   GEN p1 = cgetg(6, t_VEC);
      81           7 :   gel(p1, 1) = gcopy(r1);
      82           7 :   gel(p1, 2) = gneg(gadd(gadd(gadd(gmul(s2, t0), gmul(t2, s0)), gmul(t1, s1)), gmul(r2, r0)));
      83           7 :   gel(p1, 3) = gadd(gmul(gmul(gneg(r2), s1), t0), gadd(gmul(gmul(gneg(t1), r2), s0), gsub(gmul(gmul(gneg(t2), r0), s1), gmul(gmul(t1, r0), s2))));
      84           7 :   gel(p1, 4) = gadd(gmul(gadd(gmul(gadd(gmul(gmulsg(-4, t2), s2), gsqr(r2)), s0), gadd(gadd(gmul(t2, gsqr(s1)), gmul(gmul(t1, s2), s1)), gmul(gmul(r2, r0), s2))), t0), gadd(gmul(gadd(gmul(gmul(t2, t1), s1), gadd(gmul(gsqr(t1), s2), gmul(gmul(t2, r2), r0))), s0), gadd(gmul(gmul(gmul(t1, r2), r0), s1), gmul(gmul(t2, gsqr(r0)), s2))));
      85           7 :   gel(p1, 5) = gadd(gadd(gmul(gsub(gmul(gsub(gmul(gmulsg(4, t2), gsqr(s2)), gmul(gsqr(r2), s2)), s0), gmul(gmul(t2, s2), gsqr(s1))), gsqr(t0)), gmul(gadd(gadd(gmul(gsub(gmul(gmulsg(4, gsqr(t2)), s2), gmul(t2, gsqr(r2))), gsqr(s0)), gmul(gadd(gadd(gmul(gneg(gsqr(t2)), gsqr(s1)), gmul(gsub(gmul(gmul(t2, r2), r1), gmul(t1, gsqr(r2))), s1)), gadd(gmul(gneg(gsqr(t1)), gsqr(s2)), gmul(gadd(gmul(gneg(t2), gsqr(r1)), gmul(gmul(t1, r2), r1)), s2))), s0)), gsub(gadd(gmul(gmul(gmul(gneg(t2), r2), r0), gsqr(s1)), gmul(gmul(gmul(gsub(gmul(t2, r1), gmul(t1, r2)), r0), s2), s1)), gmul(gmul(t2, gsqr(r0)), gsqr(s2)))), t0)), gsub(gadd(gmul(gmul(gmul(gneg(t2), gsqr(t1)), s2), gsqr(s0)), gmul(gadd(gmul(gmul(gmul(gmul(gneg(t2), t1), r2), r0), s1), gmul(gadd(gmul(gneg(gsqr(t2)), gsqr(r0)), gmul(gsub(gmul(gmul(t2, t1), r1), gmul(gsqr(t1), r2)), r0)), s2)), s0)), gmul(gmul(gmul(gmul(t2, t1), gsqr(r0)), s2), s1)));
      86           7 :   return p1;
      87             : }
      88             : 
      89             : 
      90             : INLINE long
      91         315 : dg(GEN P, long v)
      92             : {
      93         315 :   if (typ(P)!=t_POL || varn(P)!=v || !signe(P))
      94         266 :     return -1;
      95          49 :   return degpol(P);
      96             : }
      97             : 
      98             : INLINE GEN
      99        1442 : co(GEN P, long i, long v)
     100             : {
     101        1442 :   if (typ(P)!=t_POL || varn(P)!=v)
     102         490 :     return i==0 ? P: gen_0;
     103         952 :   if (i>degpol(P)) return gen_0;
     104         882 :   return gel(P, i+2);
     105             : }
     106             : 
     107             : GEN
     108         105 : ellfromeqn(GEN P)
     109             : {
     110         105 :   pari_sp av = avma;
     111             :   long vx, vy, dx, dy, dm;
     112         105 :   GEN r = gen_0;
     113         105 :   if (typ(P)!=t_POL) pari_err_TYPE("ellfromeqn",P);
     114         105 :   vx = varn(P); vy = gvar2(P);
     115         105 :   if (vy==NO_VARIABLE) pari_err_TYPE("ellfromeqn",P);
     116         105 :   dx = poldegree(P, vx);
     117         105 :   dy = poldegree(P, vy);
     118         105 :   dm = maxss(dx, dy);
     119         105 :   if (dm == 2)
     120             :   {
     121           7 :     GEN p_0 = co(P, 0, vx), p_1 = co(P, 1, vx), p_2 = co(P, 2, vx);
     122           7 :     r = jac_biquadr(co(p_2, 2, vy), co(p_2, 1, vy), co(p_2, 0, vy),
     123             :                     co(p_1, 2, vy), co(p_1, 1, vy), co(p_1, 0, vy),
     124             :                     co(p_0, 2, vy), co(p_0, 1, vy), co(p_0, 0, vy));
     125             :   }
     126          98 :   else if (dm == 3)
     127             :   {
     128          77 :     GEN p_0 = co(P, 0, vx), p_1 = co(P, 1, vx),
     129          77 :         p_2 = co(P, 2, vx), p_3 = co(P, 3, vx);
     130          77 :     if (dg(p_3, vy) > 0 || dg(p_2, vy) > 1 || dg(p_1, vy) > 2)
     131           0 :       r = gen_0; /* genus > 1 */
     132             :     else
     133          77 :       r = jac_cubic( co(p_3, 0, vy),
     134             :         co(p_2, 1, vy), co(p_2, 0, vy),
     135             :         co(p_1, 2, vy), co(p_1, 1, vy), co(p_1, 0, vy),
     136             :         co(p_0, 3, vy), co(p_0, 2, vy), co(p_0, 1, vy), co(p_0, 0, vy));
     137             :   }
     138          21 :   else if (dm == 4 && dx == 2)
     139           7 :   {
     140           7 :     GEN p_0 = co(P, 0, vx), p_1 = co(P, 1, vx), p_2 = co(P, 2, vx);
     141           7 :     if (dg(p_2, vy) > 0 || dg(p_1, vy) > 2)
     142           0 :       r = gen_0; /* genus > 1 */
     143             :     else
     144           7 :       r = jac_quart( co(p_2, 0, vy),
     145             :         co(p_1, 2, vy), co(p_1, 1, vy), co(p_1, 0, vy),
     146             :         co(p_0, 4, vy), co(p_0, 3, vy), co(p_0, 2, vy), co(p_0, 1, vy),
     147             :                                                         co(p_0, 0, vy));
     148             :   }
     149          14 :   else if (dm == 4 && dx == 4)
     150             :   {
     151          14 :     GEN p_0 = co(P, 0, vx), p_1 = co(P, 1, vx), p_2 = co(P, 2, vx),
     152          14 :         p_3 = co(P, 3, vx), p_4 = co(P, 4, vx);
     153          14 :     if (dg(p_4, vy) > 0 || dg(p_3, vy) > 0
     154          14 :      || dg(p_2, vy) > 1 || dg(p_1, vy) > 1 || dg(p_0, vy) > 2)
     155           0 :       r = gen_0; /* genus > 1 */
     156             :     else
     157          14 :       r = jac_quart(co(p_0, 2, vy),
     158             :                     co(p_2, 1, vy), co(p_1, 1, vy), co(p_0, 1, vy),
     159             :                     co(p_4, 0, vy), co(p_3, 0, vy), co(p_2, 0, vy),
     160             :                                     co(p_1, 0, vy), co(p_0, 0, vy));
     161             :   }
     162         105 :   if (r==gen_0)
     163           0 :     pari_err_DOMAIN("ellfromeqn", "genus", "!=", gen_1,P);
     164         105 :   return gerepileupto(av, r);
     165             : }

Generated by: LCOV version 1.11