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 - FpV.c (source / functions) Hit Total Coverage
Test: PARI/GP v2.10.0 lcov report (development 20443-183d202) Lines: 646 846 76.4 %
Date: 2017-03-27 05:17:48 Functions: 93 119 78.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* Copyright (C) 2000  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             : /********************************************************************/
      18             : /**                                                                **/
      19             : /**                           REDUCTION                            **/
      20             : /**                                                                **/
      21             : /********************************************************************/
      22             : /* z in Z^n, return lift(Col(z) * Mod(1,p)) */
      23             : GEN
      24     6081819 : FpC_red(GEN z, GEN p)
      25             : {
      26     6081819 :   long i,l = lg(z);
      27     6081819 :   GEN x = cgetg(l, t_COL);
      28     6081819 :   for (i=1; i<l; i++) gel(x,i) = modii(gel(z,i),p);
      29     6081819 :   return x;
      30             : }
      31             : 
      32             : /* z in Z^n, return lift(Vec(z) * Mod(1,p)) */
      33             : GEN
      34      144295 : FpV_red(GEN z, GEN p)
      35             : {
      36      144295 :   long i,l = lg(z);
      37      144295 :   GEN x = cgetg(l, t_VEC);
      38      144295 :   for (i=1; i<l; i++) gel(x,i) = modii(gel(z,i),p);
      39      144295 :   return x;
      40             : }
      41             : GEN
      42      327830 : FpC_center(GEN z, GEN p, GEN pov2)
      43             : {
      44      327830 :   long i,l = lg(z);
      45      327830 :   GEN x = cgetg(l, t_COL);
      46      327830 :   for (i=1; i<l; i++) gel(x,i) = Fp_center(gel(z,i),p, pov2);
      47      327830 :   return x;
      48             : }
      49             : 
      50             : /* assume 0 <= u < p and ps2 = p>>1 */
      51             : INLINE void
      52          20 : Fp_center_inplace(GEN u, GEN p, GEN ps2)
      53          20 : { if (abscmpii(u,ps2) > 0) subiiz(u,p,u); }
      54             : 
      55             : void
      56          10 : FpC_center_inplace(GEN z, GEN p, GEN ps2)
      57             : {
      58          10 :   long i,l = lg(z);
      59          30 :   for (i=1; i<l; i++)
      60          20 :     Fp_center_inplace(gel(z,i), p, ps2);
      61          10 : }
      62             : 
      63             : GEN
      64       79780 : Flv_center(GEN z, ulong p, ulong ps2)
      65             : {
      66       79780 :   long i, l = lg(z);
      67       79780 :   GEN x = cgetg(l,t_VECSMALL);
      68       79780 :   for (i=1; i<l; i++) x[i] = Fl_center(z[i],p,ps2);
      69       79780 :   return x;
      70             : }
      71             : 
      72             : /* z in Mat m,n(Z), return lift(z * Mod(1,p)) */
      73             : GEN
      74     1241881 : FpM_red(GEN z, GEN p)
      75             : {
      76     1241881 :   long i, l = lg(z);
      77     1241881 :   GEN x = cgetg(l,t_MAT);
      78     1241881 :   for (i=1; i<l; i++) gel(x,i) = FpC_red(gel(z,i), p);
      79     1241881 :   return x;
      80             : }
      81             : GEN
      82       35575 : FpM_center(GEN z, GEN p, GEN pov2)
      83             : {
      84       35575 :   long i, l = lg(z);
      85       35575 :   GEN x = cgetg(l,t_MAT);
      86       35575 :   for (i=1; i<l; i++) gel(x,i) = FpC_center(gel(z,i), p, pov2);
      87       35575 :   return x;
      88             : }
      89             : 
      90             : void
      91          10 : FpM_center_inplace(GEN z, GEN p, GEN pov2)
      92             : {
      93          10 :   long i, l = lg(z);
      94          10 :   for (i=1; i<l; i++) FpC_center_inplace(gel(z,i), p, pov2);
      95          10 : }
      96             : GEN
      97        5640 : Flm_center(GEN z, ulong p, ulong ps2)
      98             : {
      99        5640 :   long i, l = lg(z);
     100        5640 :   GEN x = cgetg(l,t_MAT);
     101        5640 :   for (i=1; i<l; i++) gel(x,i) = Flv_center(gel(z,i),p,ps2);
     102        5640 :   return x;
     103             : }
     104             : 
     105             : GEN
     106           0 : random_FpV(long d, GEN p)
     107             : {
     108             :   long i;
     109           0 :   GEN y = cgetg(d+1,t_VEC);
     110           0 :   for (i=1; i<=d; i++) gel(y,i) = randomi(p);
     111           0 :   return y;
     112             : }
     113             : 
     114             : GEN
     115          20 : random_FpC(long d, GEN p)
     116             : {
     117             :   long i;
     118          20 :   GEN y = cgetg(d+1,t_COL);
     119          20 :   for (i=1; i<=d; i++) gel(y,i) = randomi(p);
     120          20 :   return y;
     121             : }
     122             : 
     123             : GEN
     124        2115 : random_Flv(long n, ulong p)
     125             : {
     126        2115 :   GEN y = cgetg(n+1, t_VECSMALL);
     127             :   long i;
     128        2115 :   for (i=1; i<=n; i++) uel(y,i) = random_Fl(p);
     129        2115 :   return y;
     130             : }
     131             : 
     132             : /********************************************************************/
     133             : /**                                                                **/
     134             : /**                           ADD, SUB                             **/
     135             : /**                                                                **/
     136             : /********************************************************************/
     137             : GEN
     138      280410 : FpC_add(GEN x, GEN y, GEN p)
     139             : {
     140      280410 :   long i, lx = lg(x);
     141      280410 :   GEN z = cgetg(lx, t_COL);
     142      280410 :   for (i = 1; i < lx; i++) gel(z, i) = Fp_add(gel(x, i), gel(y, i), p);
     143      280410 :   return z;
     144             : }
     145             : GEN
     146           0 : FpV_add(GEN x, GEN y, GEN p)
     147             : {
     148           0 :   long i, lx = lg(x);
     149           0 :   GEN z = cgetg(lx, t_VEC);
     150           0 :   for (i = 1; i < lx; i++) gel(z, i) = Fp_add(gel(x, i), gel(y, i), p);
     151           0 :   return z;
     152             : }
     153             : GEN
     154           0 : FpM_add(GEN x, GEN y, GEN p)
     155             : {
     156           0 :   long lx = lg(x), j;
     157             :   GEN z;
     158           0 :   if (lx == 1) return cgetg(1, t_MAT);
     159           0 :   z = cgetg(lx, t_MAT);
     160           0 :   for (j = 1; j < lx; j++) gel(z,j) = FpC_add(gel(x,j), gel(y,j), p);
     161           0 :   return z;
     162             : }
     163             : 
     164             : GEN
     165      679910 : Flv_add(GEN x, GEN y, ulong p)
     166             : {
     167      679910 :   long i, l = lg(x);
     168      679910 :   GEN z = cgetg(l, t_VECSMALL);
     169      679910 :   if (p==2)
     170       32365 :     for (i = 1; i < l; i++) z[i] = x[i]^y[i];
     171             :   else
     172      647545 :     for (i = 1; i < l; i++) z[i] = Fl_add(x[i], y[i], p);
     173      679910 :   return z;
     174             : }
     175             : 
     176             : void
     177      114740 : Flv_add_inplace(GEN x, GEN y, ulong p)
     178             : {
     179      114740 :   long i, l = lg(x);
     180      114740 :   if (p==2)
     181      113240 :     for (i = 1; i < l; i++) x[i] ^= y[i];
     182             :   else
     183        1500 :     for (i = 1; i < l; i++) x[i] = Fl_add(x[i], y[i], p);
     184      114740 : }
     185             : 
     186             : ulong
     187        2730 : Flv_sum(GEN x, ulong p)
     188             : {
     189        2730 :   long i, l = lg(x);
     190        2730 :   ulong s = 0;
     191        2730 :   if (p==2)
     192        2730 :     for (i = 1; i < l; i++) s ^= x[i];
     193             :   else
     194           0 :     for (i = 1; i < l; i++) s = Fl_add(s, x[i], p);
     195        2730 :   return s;
     196             : }
     197             : 
     198             : GEN
     199      239875 : FpC_sub(GEN x, GEN y, GEN p)
     200             : {
     201      239875 :   long i, lx = lg(x);
     202      239875 :   GEN z = cgetg(lx, t_COL);
     203      239875 :   for (i = 1; i < lx; i++) gel(z, i) = Fp_sub(gel(x, i), gel(y, i), p);
     204      239875 :   return z;
     205             : }
     206             : GEN
     207           0 : FpV_sub(GEN x, GEN y, GEN p)
     208             : {
     209           0 :   long i, lx = lg(x);
     210           0 :   GEN z = cgetg(lx, t_VEC);
     211           0 :   for (i = 1; i < lx; i++) gel(z, i) = Fp_sub(gel(x, i), gel(y, i), p);
     212           0 :   return z;
     213             : }
     214             : 
     215             : GEN
     216           0 : FpM_sub(GEN x, GEN y, GEN p)
     217             : {
     218           0 :   long i, l = lg(x);
     219           0 :   GEN z = cgetg(l, t_MAT);
     220           0 :   for (i = 1; i < l; i++) gel(z, i) = FpC_sub(gel(x, i), gel(y, i), p);
     221           0 :   return z;
     222             : }
     223             : 
     224             : GEN
     225    44214605 : Flv_sub(GEN x, GEN y, ulong p)
     226             : {
     227    44214605 :   long i, l = lg(x);
     228    44214605 :   GEN z = cgetg(l, t_VECSMALL);
     229    44214605 :   for (i = 1; i < l; i++) z[i] = Fl_sub(x[i], y[i], p);
     230    44214605 :   return z;
     231             : }
     232             : 
     233             : void
     234           0 : Flv_sub_inplace(GEN x, GEN y, ulong p)
     235             : {
     236           0 :   long i, l = lg(x);
     237           0 :   for (i = 1; i < l; i++) x[i] = Fl_sub(x[i], y[i], p);
     238           0 : }
     239             : 
     240             : GEN
     241        5630 : Flm_Fl_add(GEN x, ulong y, ulong p)
     242             : {
     243        5630 :   long l = lg(x), i, j;
     244        5630 :   GEN z = cgetg(l,t_MAT);
     245             : 
     246        5630 :   if (l==1) return z;
     247        5630 :   if (l != lgcols(x)) pari_err_OP( "+", x, utoi(y));
     248       23115 :   for (i=1; i<l; i++)
     249             :   {
     250       17485 :     GEN zi = cgetg(l,t_VECSMALL), xi = gel(x,i);
     251       17485 :     gel(z,i) = zi;
     252       17485 :     for (j=1; j<l; j++) zi[j] = xi[j];
     253       17485 :     zi[i] = Fl_add(zi[i], y, p);
     254             :   }
     255        5630 :   return z;
     256             : }
     257             : 
     258             : GEN
     259       10400 : Flm_add(GEN x, GEN y, ulong p)
     260             : {
     261       10400 :   long i, l = lg(x);
     262       10400 :   GEN z = cgetg(l,t_MAT);
     263       10400 :   for (i = 1; i < l; i++) gel(z,i) = Flv_add(gel(x,i),gel(y,i),p);
     264       10400 :   return z;
     265             : }
     266             : 
     267             : GEN
     268     4421155 : Flm_sub(GEN x, GEN y, ulong p)
     269             : {
     270     4421155 :   long i, l = lg(x);
     271     4421155 :   GEN z = cgetg(l, t_MAT);
     272     4421155 :   for (i = 1; i < l; i++) gel(z, i) = Flv_sub(gel(x, i), gel(y, i), p);
     273     4421155 :   return z;
     274             : }
     275             : 
     276             : /********************************************************************/
     277             : /**                                                                **/
     278             : /**                           MULTIPLICATION                       **/
     279             : /**                                                                **/
     280             : /********************************************************************/
     281             : GEN
     282      751515 : FpC_Fp_mul(GEN x, GEN y, GEN p)
     283             : {
     284      751515 :   long i, l = lg(x);
     285      751515 :   GEN z = cgetg(l, t_COL);
     286      751515 :   for (i=1;i<l;i++) gel(z,i) = Fp_mul(gel(x,i),y,p);
     287      751515 :   return z;
     288             : }
     289             : GEN
     290      549280 : Flv_Fl_mul(GEN x, ulong y, ulong p)
     291             : {
     292      549280 :   long i, l = lg(x);
     293      549280 :   GEN z = cgetg(l, t_VECSMALL);
     294      549280 :   for (i=1;i<l;i++) z[i] = Fl_mul(x[i], y, p);
     295      549280 :   return z;
     296             : }
     297             : GEN
     298        2035 : Flv_Fl_div(GEN x, ulong y, ulong p)
     299             : {
     300        2035 :   return Flv_Fl_mul(x, Fl_inv(y, p), p);
     301             : }
     302             : void
     303           0 : Flv_Fl_div_inplace(GEN x, ulong y, ulong p)
     304             : {
     305           0 :   Flv_Fl_mul_inplace(x, Fl_inv(y, p), p);
     306           0 : }
     307             : GEN
     308        1055 : FpM_Fp_mul(GEN X, GEN c, GEN p) {
     309        1055 :   long i, j, h, l = lg(X);
     310        1055 :   GEN A = cgetg(l, t_MAT);
     311        1055 :   if (l == 1) return A;
     312        1055 :   h = lgcols(X);
     313       11845 :   for (j=1; j<l; j++)
     314             :   {
     315       10790 :     GEN a = cgetg(h, t_COL), x = gel(X, j);
     316       10790 :     for (i = 1; i < h; i++) gel(a,i) = Fp_mul(gel(x,i), c, p);
     317       10790 :     gel(A,j) = a;
     318             :   }
     319        1055 :   return A;
     320             : }
     321             : 
     322             : /* x *= y */
     323             : void
     324     1111366 : Flv_Fl_mul_part_inplace(GEN x, ulong y, ulong p, long l)
     325             : {
     326             :   long i;
     327     1111366 :   for (i=1;i<=l;i++) x[i] = Fl_mul(x[i], y, p);
     328     1111366 : }
     329             : void
     330           0 : Flv_Fl_mul_inplace(GEN x, ulong y, ulong p)
     331           0 : { Flv_Fl_mul_part_inplace(x, y, p, lg(x)-1); }
     332             : 
     333             : /* set y *= x */
     334             : void
     335       17870 : Flm_Fl_mul_inplace(GEN y, ulong x, ulong p)
     336             : {
     337       17870 :   long i, j, m, l = lg(y);
     338       35740 :   if (l == 1) return;
     339       17870 :   m = lgcols(y);
     340       17870 :   if (HIGHWORD(x | p))
     341      172540 :     for(j=1; j<l; j++)
     342      154670 :       for(i=1; i<m; i++) ucoeff(y,i,j) = Fl_mul(ucoeff(y,i,j), x, p);
     343             :   else
     344           0 :     for(j=1; j<l; j++)
     345           0 :       for(i=1; i<m; i++) ucoeff(y,i,j) = (ucoeff(y,i,j) * x) % p;
     346             : }
     347             : 
     348             : /* return x * y */
     349             : GEN
     350     3965430 : Flm_Fl_mul(GEN y, ulong x, ulong p)
     351             : {
     352     3965430 :   long i, j, m, l = lg(y);
     353     3965430 :   GEN z = cgetg(l, t_MAT);
     354     3965430 :   if (l == 1) return z;
     355     3965430 :   m = lgcols(y);
     356     3965430 :   if (HIGHWORD(x | p))
     357    21830710 :     for(j=1; j<l; j++) {
     358    19630420 :       GEN c = cgetg(m, t_VECSMALL); gel(z,j) = c;
     359    19630420 :       for(i=1; i<m; i++) c[i] = Fl_mul(ucoeff(y,i,j), x, p);
     360             :     }
     361             :   else
     362    13071330 :     for(j=1; j<l; j++) {
     363    11306190 :       GEN c = cgetg(m, t_VECSMALL); gel(z,j) = c;
     364    11306190 :       for(i=1; i<m; i++) c[i] = (ucoeff(y,i,j) * x) % p;
     365             :     }
     366     3965430 :   return z;
     367             : }
     368             : 
     369             : GEN
     370      863855 : Flv_neg(GEN v, ulong p)
     371             : {
     372      863855 :   long i, m = lg(v);
     373      863855 :   GEN c = cgetg(m, t_VECSMALL);
     374      863855 :   for(i=1; i<m; i++) uel(c,i) = Fl_neg(uel(v,i), p);
     375      863855 :   return c;
     376             : }
     377             : 
     378             : void
     379        2435 : Flv_neg_inplace(GEN v, ulong p)
     380             : {
     381             :   long i;
     382      108595 :   for (i = 1; i < lg(v); ++i)
     383      106160 :     v[i] = Fl_neg(v[i], p);
     384        2435 : }
     385             : 
     386             : GEN
     387       74230 : Flm_neg(GEN y, ulong p)
     388             : {
     389       74230 :   long j, l = lg(y);
     390       74230 :   GEN z = cgetg(l, t_MAT);
     391      924705 :   for(j=1; j<l; j++)
     392      850475 :     gel(z,j) = Flv_neg(gel(y,j), p);
     393       74230 :   return z;
     394             : }
     395             : 
     396             : /* x[i,]*y. Assume lx > 1 and 0 < i < lgcols(x) */
     397             : static GEN
     398    11219565 : ZMrow_ZC_mul_i(GEN x, GEN y, long lx, long i)
     399             : {
     400    11219565 :   GEN c = mulii(gcoeff(x,i,1), gel(y,1));
     401             :   long k;
     402   227234930 :   for (k = 2; k < lx; k++)
     403             :   {
     404   216015365 :     GEN t = mulii(gcoeff(x,i,k), gel(y,k));
     405   216015365 :     if (signe(t)) c = addii(c, t);
     406             :   }
     407    11219565 :   return c;
     408             : }
     409             : 
     410             : static long
     411    15453945 : zmrow_zc_mul(GEN x, GEN y, long lx, long i)
     412             : {
     413             :   long k;
     414    15453945 :   long c = coeff(x,i,1) * y[1];
     415   206591140 :   for (k = 2; k < lx; k++)
     416   191137195 :     c += coeff(x,i,k) * y[k];
     417    15453945 :   return c;
     418             : }
     419             : 
     420             : GEN
     421     1180875 : zm_zc_mul(GEN x, GEN y)
     422             : {
     423     1180875 :   long lx = lg(x), l, i;
     424             :   GEN z;
     425     1180875 :   if (lx == 1) return cgetg(1, t_VECSMALL);
     426     1180875 :   l = lg(gel(x,1));
     427     1180875 :   z = cgetg(l,t_VECSMALL);
     428     1180875 :   for (i=1; i<l; i++) z[i] = zmrow_zc_mul(x, y, lx, i);
     429     1180875 :   return z;
     430             : }
     431             : 
     432             : GEN
     433         180 : zm_mul(GEN x, GEN y)
     434             : {
     435         180 :   long i,j,lx=lg(x), ly=lg(y);
     436             :   GEN z;
     437         180 :   if (ly==1) return cgetg(1,t_MAT);
     438         180 :   z = cgetg(ly,t_MAT);
     439         180 :   if (lx==1)
     440             :   {
     441           0 :     for (i=1; i<ly; i++) gel(z,i) = cgetg(1,t_VECSMALL);
     442           0 :     return z;
     443             :   }
     444        1520 :   for (j=1; j<ly; j++)
     445        1340 :     gel(z,j) = zm_zc_mul(x, gel(y,j));
     446         180 :   return z;
     447             : }
     448             : 
     449             : static ulong
     450   210708710 : Flmrow_Flc_mul_SMALL(GEN x, GEN y, ulong p, long lx, long i)
     451             : {
     452   210708710 :   ulong c = ucoeff(x,i,1) * uel(y,1);
     453             :   long k;
     454  5141513900 :   for (k = 2; k < lx; k++) {
     455  4930805190 :     c += ucoeff(x,i,k) * uel(y,k);
     456  4930805190 :     if (c & HIGHBIT) c %= p;
     457             :   }
     458   210708710 :   return c % p;
     459             : }
     460             : 
     461             : static ulong
     462    72936405 : Flmrow_Flc_mul_i(GEN x, GEN y, ulong p, ulong pi, long lx, long i)
     463             : {
     464             :   ulong l0, l1, v1, h0, h1;
     465    72936405 :   long k = 1;
     466             :   LOCAL_OVERFLOW;
     467             :   LOCAL_HIREMAINDER;
     468    72936405 :   l1 = mulll(ucoeff(x,i,k), uel(y,k)); h1 = hiremainder; v1 = 0;
     469   823839010 :   while (++k < lx) {
     470   677966200 :     l0 = mulll(ucoeff(x,i,k), uel(y,k)); h0 = hiremainder;
     471   677966200 :     l1 = addll(l0, l1); h1 = addllx(h0, h1); v1 += overflow;
     472             :   }
     473    72936405 :   if (v1 == 0) return remll_pre(h1, l1, p, pi);
     474     2744535 :   else return remlll_pre(v1, h1, l1, p, pi);
     475             : }
     476             : 
     477             : static GEN
     478      102905 : Flm_Flc_mul_i_2(GEN x, GEN y, long lx, long l)
     479             : {
     480             :   long i,j;
     481      102905 :   GEN z = NULL;
     482             : 
     483     2684125 :   for (j=1; j<lx; j++)
     484             :   {
     485     2581220 :     if (!y[j]) continue;
     486      195850 :     if (!z) z = Flv_copy(gel(x,j));
     487      120110 :     else for (i = 1; i < l; i++) z[i] ^= coeff(x,i,j);
     488             :   }
     489      102905 :   if (!z) z = zero_zv(l-1);
     490      102905 :   return z;
     491             : }
     492             : 
     493             : static GEN
     494      716650 : FpM_FpC_mul_i(GEN x, GEN y, long lx, long l, GEN p)
     495             : {
     496      716650 :   GEN z = cgetg(l,t_COL);
     497             :   long i;
     498    11648310 :   for (i = 1; i < l; i++)
     499             :   {
     500    10931660 :     pari_sp av = avma;
     501    10931660 :     GEN c = ZMrow_ZC_mul_i(x, y, lx, i);
     502    10931660 :     gel(z,i) = gerepileuptoint(av, modii(c,p));
     503             :   }
     504      716650 :   return z;
     505             : }
     506             : 
     507             : static void
     508    20768495 : __Flm_Flc_mul_i_SMALL(GEN z, GEN x, GEN y, long lx, long l, ulong p)
     509             : {
     510             :   long i;
     511    20768495 :   for (i = 1; i < l; i++) z[i] = Flmrow_Flc_mul_SMALL(x, y, p, lx, i);
     512    20768495 : }
     513             : static GEN
     514    18352370 : Flm_Flc_mul_i_SMALL(GEN x, GEN y, long lx, long l, ulong p)
     515             : {
     516    18352370 :   GEN z = cgetg(l,t_VECSMALL);
     517    18352370 :   __Flm_Flc_mul_i_SMALL(z, x, y, lx, l, p);
     518    18352370 :   return z;
     519             : }
     520             : 
     521             : static void
     522    14588645 : __Flm_Flc_mul_i(GEN z, GEN x, GEN y, long lx, long l, ulong p, ulong pi)
     523             : {
     524             :   long i;
     525    14588645 :   for (i = 1; i < l; i++) z[i] = Flmrow_Flc_mul_i(x, y, p, pi, lx, i);
     526    14588645 : }
     527             : static GEN
     528    12315755 : Flm_Flc_mul_i(GEN x, GEN y, long lx, long l, ulong p, ulong pi)
     529             : {
     530    12315755 :   GEN z = cgetg(l,t_VECSMALL);
     531    12315755 :   __Flm_Flc_mul_i(z, x, y, lx, l, p, pi);
     532    12315755 :   return z;
     533             : }
     534             : 
     535             : INLINE GEN
     536      134235 : F2m_F2c_mul_i(GEN x, GEN y, long lx, long l)
     537             : {
     538             :   long j;
     539      134235 :   GEN z = NULL;
     540             : 
     541     1820345 :   for (j=1; j<lx; j++)
     542             :   {
     543     1686110 :     if (!F2v_coeff(y,j)) continue;
     544      378610 :     if (!z) z = vecsmall_copy(gel(x,j));
     545      256075 :     else F2v_add_inplace(z,gel(x,j));
     546             :   }
     547      134235 :   if (!z) z = zero_F2v(l);
     548      134235 :   return z;
     549             : }
     550             : 
     551             : GEN
     552      255540 : FpM_mul(GEN x, GEN y, GEN p)
     553             : {
     554      255540 :   long j, l, lx=lg(x), ly=lg(y);
     555             :   GEN z;
     556      255540 :   if (ly==1) return cgetg(1,t_MAT);
     557      255540 :   if (lx==1) return zeromat(0, ly-1);
     558      255540 :   if (lgefint(p) == 3)
     559             :   {
     560      255135 :     pari_sp av = avma;
     561      255135 :     ulong pp = uel(p,2);
     562      255135 :     if (pp == 2)
     563             :     {
     564       30860 :       x = ZM_to_F2m(x);
     565       30860 :       y = ZM_to_F2m(y);
     566       30860 :       z = F2m_to_ZM(F2m_mul(x,y));
     567             :     }
     568             :     else
     569             :     {
     570      224275 :       x = ZM_to_Flm(x, pp);
     571      224275 :       y = ZM_to_Flm(y, pp);
     572      224275 :       z = Flm_to_ZM(Flm_mul(x,y, pp));
     573             :     }
     574      255135 :     return gerepileupto(av, z);
     575             :   }
     576         405 :   l = lgcols(x); z = cgetg(ly,t_MAT);
     577         405 :   for (j=1; j<ly; j++) gel(z,j) = FpM_FpC_mul_i(x, gel(y,j), lx, l, p);
     578         405 :   return z;
     579             : }
     580             : GEN
     581     3338105 : Flm_mul(GEN x, GEN y, ulong p)
     582             : {
     583     3338105 :   long i,j,l,lx=lg(x), ly=lg(y);
     584             :   GEN z;
     585     3338105 :   if (ly==1) return cgetg(1,t_MAT);
     586     3338105 :   z = cgetg(ly,t_MAT);
     587     3338105 :   if (lx==1)
     588             :   {
     589           0 :     for (i=1; i<ly; i++) gel(z,i) = cgetg(1,t_VECSMALL);
     590           0 :     return z;
     591             :   }
     592     3338105 :   l = lgcols(x);
     593     3338105 :   if (SMALL_ULONG(p)) {
     594    19787555 :     for (j=1; j<ly; j++)
     595    18176370 :       gel(z,j) = Flm_Flc_mul_i_SMALL(x, gel(y,j), lx, l, p);
     596             :   } else {
     597     1726920 :     ulong pi = get_Fl_red(p);
     598    14042675 :     for (j=1; j<ly; j++)
     599    12315755 :       gel(z,j) = Flm_Flc_mul_i(x, gel(y,j), lx, l, p, pi);
     600             :   }
     601     3338105 :   return z;
     602             : }
     603             : GEN
     604       30895 : F2m_mul(GEN x, GEN y)
     605             : {
     606       30895 :   long i,j,l,lx=lg(x), ly=lg(y);
     607             :   GEN z;
     608       30895 :   if (ly==1) return cgetg(1,t_MAT);
     609       30895 :   z = cgetg(ly,t_MAT);
     610       30895 :   if (lx==1)
     611             :   {
     612           0 :     for (i=1; i<ly; i++) gel(z,i) = mkvecsmall(0);
     613           0 :     return z;
     614             :   }
     615       30895 :   l = coeff(x,1,1);
     616       30895 :   for (j=1; j<ly; j++) gel(z,j) = F2m_F2c_mul_i(x, gel(y,j), lx, l);
     617       30895 :   return z;
     618             : }
     619             : 
     620             : static GEN
     621       10155 : _Flm_mul(void *p , GEN x, GEN y)
     622       10155 : { return Flm_mul(x,y,*(ulong*)p); }
     623             : static GEN
     624       30250 : _Flm_sqr(void *p, GEN x)
     625       30250 : { return Flm_mul(x,x,*(ulong*)p); }
     626             : GEN
     627       14030 : Flm_powu(GEN x, ulong n, ulong p)
     628             : {
     629       14030 :   pari_sp av = avma;
     630       14030 :   if (!n) return matid(lg(x)-1);
     631       14030 :   return gerepileupto(av, gen_powu(x, n, (void*)&p, &_Flm_sqr, &_Flm_mul));
     632             : }
     633             : static GEN
     634           0 : _F2m_mul(void *data, GEN x, GEN y)
     635           0 : { (void) data; return F2m_mul(x,y); }
     636             : static GEN
     637           0 : _F2m_sqr(void *data, GEN x)
     638           0 : { (void) data; return F2m_mul(x,x); }
     639             : GEN
     640           0 : F2m_powu(GEN x, ulong n)
     641             : {
     642           0 :   pari_sp av = avma;
     643           0 :   if (!n) return matid(lg(x)-1);
     644           0 :   return gerepileupto(av, gen_powu(x, n,NULL, &_F2m_sqr, &_F2m_mul));
     645             : }
     646             : static GEN
     647           0 : _FpM_mul(void *p , GEN x, GEN y)
     648           0 : { return FpM_mul(x,y,(GEN)p); }
     649             : static GEN
     650           0 : _FpM_sqr(void *p, GEN x)
     651           0 : { return FpM_mul(x,x,(GEN)p); }
     652             : GEN
     653           0 : FpM_powu(GEN x, ulong n, GEN p)
     654             : {
     655           0 :   pari_sp av = avma;
     656           0 :   if (!n) return matid(lg(x)-1);
     657           0 :   if (lgefint(p) == 3)
     658             :   {
     659           0 :     pari_sp av = avma;
     660           0 :     ulong pp = uel(p,2);
     661             :     GEN z;
     662           0 :     if (pp == 2)
     663           0 :       z = F2m_to_ZM(F2m_powu(ZM_to_F2m(x),n));
     664             :     else
     665           0 :       z = Flm_to_ZM(Flm_powu(ZM_to_Flm(x, pp), n, pp));
     666           0 :     return gerepileupto(av, z);
     667             :   }
     668           0 :   return gerepileupto(av, gen_powu(x, n, (void*)p, &_FpM_sqr, &_FpM_mul));
     669             : }
     670             : 
     671             : /*Multiple a column vector by a line vector to make a matrix*/
     672             : GEN
     673         985 : FpC_FpV_mul(GEN x, GEN y, GEN p)
     674             : {
     675         985 :   long i,j, lx=lg(x), ly=lg(y);
     676             :   GEN z;
     677         985 :   if (ly==1) return cgetg(1,t_MAT);
     678         985 :   z = cgetg(ly,t_MAT);
     679       18750 :   for (j=1; j < ly; j++)
     680             :   {
     681       17765 :     gel(z,j) = cgetg(lx,t_COL);
     682       17765 :     for (i=1; i<lx; i++) gcoeff(z,i,j) = Fp_mul(gel(x,i),gel(y,j), p);
     683             :   }
     684         985 :   return z;
     685             : }
     686             : 
     687             : /* Multiply a line vector by a column and return a scalar (t_INT) */
     688             : GEN
     689      522799 : FpV_dotproduct(GEN x, GEN y, GEN p)
     690             : {
     691      522799 :   long i, lx = lg(x);
     692             :   pari_sp av;
     693             :   GEN c;
     694      522799 :   if (lx == 1) return gen_0;
     695      522769 :   av = avma; c = mulii(gel(x,1),gel(y,1));
     696      522769 :   for (i=2; i<lx; i++) c = addii(c, mulii(gel(x,i),gel(y,i)));
     697      522769 :   return gerepileuptoint(av, modii(c,p));
     698             : }
     699             : GEN
     700           0 : FpV_dotsquare(GEN x, GEN p)
     701             : {
     702           0 :   long i, lx = lg(x);
     703             :   pari_sp av;
     704             :   GEN c;
     705           0 :   if (lx == 1) return gen_0;
     706           0 :   av = avma; c = sqri(gel(x,1));
     707           0 :   for (i=2; i<lx; i++) c = addii(c, sqri(gel(x,i)));
     708           0 :   return gerepileuptoint(av, modii(c,p));
     709             : }
     710             : 
     711             : INLINE ulong
     712      573150 : Flv_dotproductspec_SMALL(GEN x, GEN y, ulong p, long lx)
     713             : {
     714      573150 :   ulong c = uel(x,0) * uel(y,0);
     715             :   long k;
     716     8734825 :   for (k = 1; k < lx; k++) {
     717     8161675 :     c += uel(x,k) * uel(y,k);
     718     8161675 :     if (c & HIGHBIT) c %= p;
     719             :   }
     720      573150 :   return c % p;
     721             : }
     722             : 
     723             : INLINE ulong
     724         360 : Flv_dotproductspec_i(GEN x, GEN y, ulong p, ulong pi, long lx)
     725             : {
     726             :   ulong l0, l1, v1, h0, h1;
     727         360 :   long i = 0;
     728             :   LOCAL_OVERFLOW;
     729             :   LOCAL_HIREMAINDER;
     730         360 :   l1 = mulll(uel(x,i), uel(y,i)); h1 = hiremainder; v1 = 0;
     731       10200 :   while (++i < lx) {
     732        9480 :     l0 = mulll(uel(x,i), uel(y,i)); h0 = hiremainder;
     733        9480 :     l1 = addll(l0, l1); h1 = addllx(h0, h1); v1 += overflow;
     734             :   }
     735         360 :   if (v1 == 0) return remll_pre(h1, l1, p, pi);
     736           0 :   else return remlll_pre(v1, h1, l1, p, pi);
     737             : }
     738             : 
     739             : ulong
     740      266685 : Flv_dotproduct(GEN x, GEN y, ulong p)
     741             : {
     742      266685 :   long lx = lg(x)-1;
     743      266685 :   if (lx == 1) return 0;
     744      266685 :   if (SMALL_ULONG(p))
     745      266685 :     return Flv_dotproductspec_SMALL(x+1, y+1, p, lx);
     746             :   else
     747           0 :     return Flv_dotproductspec_i(x+1, y+1, p, get_Fl_red(p), lx);
     748             : }
     749             : 
     750             : ulong
     751       31700 : Flv_dotproduct_pre(GEN x, GEN y, ulong p, ulong pi)
     752             : {
     753       31700 :   long lx = lg(x)-1;
     754       31700 :   if (lx == 1) return 0;
     755       31700 :   if (SMALL_ULONG(p))
     756       31400 :     return Flv_dotproductspec_SMALL(x+1, y+1, p, lx);
     757             :   else
     758         300 :     return Flv_dotproductspec_i(x+1, y+1, p, pi, lx);
     759             : }
     760             : 
     761             : ulong
     762      281470 : Flx_dotproduct(GEN x, GEN y, ulong p)
     763             : {
     764      281470 :   long lx = minss(lgpol(x), lgpol(y));
     765      281470 :   if (lx == 0) return 0;
     766      275125 :   if (SMALL_ULONG(p))
     767      275065 :     return Flv_dotproductspec_SMALL(x+2, y+2, p, lx);
     768             :   else
     769          60 :     return Flv_dotproductspec_i(x+2, y+2, p, get_Fl_red(p), lx);
     770             : }
     771             : 
     772             : ulong
     773           0 : F2v_dotproduct(GEN x, GEN y)
     774             : {
     775           0 :   long i, lx = lg(x);
     776             :   ulong c;
     777           0 :   if (lx == 2) return 0;
     778           0 :   c = uel(x,2) & uel(y,2);
     779           0 :   for (i=3; i<lx; i++) c ^= uel(x,i) & uel(y,i);
     780             : #ifdef LONG_IS_64BIT
     781           0 :   c ^= c >> 32;
     782             : #endif
     783           0 :   c ^= c >> 16;
     784           0 :   c ^= c >>  8;
     785           0 :   c ^= c >>  4;
     786           0 :   c ^= c >>  2;
     787           0 :   c ^= c >>  1;
     788           0 :   return c & 1;
     789             : }
     790             : 
     791             : GEN
     792      713415 : FpM_FpC_mul(GEN x, GEN y, GEN p)
     793             : {
     794      713415 :   long lx = lg(x);
     795      713415 :   return lx==1? cgetg(1,t_COL): FpM_FpC_mul_i(x, y, lx, lgcols(x), p);
     796             : }
     797             : GEN
     798      278905 : Flm_Flc_mul(GEN x, GEN y, ulong p)
     799             : {
     800      278905 :   long l, lx = lg(x);
     801      278905 :   if (lx==1) return cgetg(1,t_VECSMALL);
     802      278905 :   l = lgcols(x);
     803      278905 :   if (p==2)
     804      102905 :     return Flm_Flc_mul_i_2(x, y, lx, l);
     805      176000 :   else if (SMALL_ULONG(p))
     806      176000 :     return Flm_Flc_mul_i_SMALL(x, y, lx, l, p);
     807             :   else
     808           0 :     return Flm_Flc_mul_i(x, y, lx, l, p, get_Fl_red(p));
     809             : }
     810             : 
     811             : GEN
     812        3440 : Flm_Flc_mul_pre(GEN x, GEN y, ulong p, ulong pi)
     813             : {
     814        3440 :   long l, lx = lg(x);
     815             :   GEN z;
     816        3440 :   if (lx==1) return cgetg(1,t_VECSMALL);
     817        3440 :   l = lgcols(x);
     818        3440 :   z = cgetg(l, t_VECSMALL);
     819        3440 :   if (SMALL_ULONG(p))
     820        3440 :     __Flm_Flc_mul_i_SMALL(z, x, y, lx, l, p);
     821             :   else
     822           0 :     __Flm_Flc_mul_i(z, x, y, lx, l, p, pi);
     823        3440 :   return z;
     824             : }
     825             : 
     826             : GEN
     827     4685575 : Flm_Flc_mul_pre_Flx(GEN x, GEN y, ulong p, ulong pi, long sv)
     828             : {
     829     4685575 :   long l, lx = lg(x);
     830             :   GEN z;
     831     4685575 :   if (lx==1) return pol0_Flx(sv);
     832     4685575 :   l = lgcols(x);
     833     4685575 :   z = cgetg(l + 1, t_VECSMALL); z[1] = sv;
     834     4685575 :   if (SMALL_ULONG(p))
     835     2412685 :     __Flm_Flc_mul_i_SMALL(z + 1, x, y, lx, l, p);
     836             :   else
     837     2272890 :     __Flm_Flc_mul_i(z + 1, x, y, lx, l, p, pi);
     838     4685575 :   return Flx_normalize(z, l + 1);
     839             : }
     840             : 
     841             : GEN
     842           0 : F2m_F2c_mul(GEN x, GEN y)
     843             : {
     844           0 :   long l, lx = lg(x);
     845           0 :   if (lx==1) return cgetg(1,t_VECSMALL);
     846           0 :   l = coeff(x,1,1);
     847           0 :   return F2m_F2c_mul_i(x, y, lx, l);
     848             : }
     849             : /* RgV_to_RgX(FpM_FpC_mul(x,y,p), v), p != NULL, memory clean */
     850             : GEN
     851       80820 : FpM_FpC_mul_FpX(GEN x, GEN y, GEN p, long v)
     852             : {
     853       80820 :   long i, l, lx = lg(x);
     854             :   GEN z;
     855       80820 :   if (lx==1) return pol_0(v);
     856       80820 :   l = lgcols(x);
     857       80820 :   z = new_chunk(l+1);
     858      134855 :   for (i=l-1; i; i--)
     859             :   {
     860      124640 :     pari_sp av = avma;
     861      124640 :     GEN p1 = ZMrow_ZC_mul_i(x,y,lx,i);
     862      124640 :     p1 = modii(p1, p);
     863      124640 :     if (signe(p1))
     864             :     {
     865       70605 :       if (i != l-1) stackdummy((pari_sp)(z + l+1), (pari_sp)(z + i+2));
     866       70605 :       gel(z,i+1) = gerepileuptoint(av, p1);
     867       70605 :       break;
     868             :     }
     869       54035 :     avma = av;
     870             :   }
     871       80820 :   if (!i) { avma = (pari_sp)(z + l+1); return pol_0(v); }
     872       70605 :   z[0] = evaltyp(t_POL) | evallg(i+2);
     873       70605 :   z[1] = evalsigne(1) | evalvarn(v);
     874      233870 :   for (; i; i--)
     875             :   {
     876      163265 :     pari_sp av = avma;
     877      163265 :     GEN p1 = ZMrow_ZC_mul_i(x,y,lx,i);
     878      163265 :     gel(z,i+1) = gerepileuptoint(av, modii(p1,p));
     879             :   }
     880       70605 :   return z;
     881             : }
     882             : 
     883             : /********************************************************************/
     884             : /**                                                                **/
     885             : /**                           TRANSPOSITION                        **/
     886             : /**                                                                **/
     887             : /********************************************************************/
     888             : 
     889             : /* == zm_transpose */
     890             : GEN
     891      164095 : Flm_transpose(GEN x)
     892             : {
     893      164095 :   long i, dx, lx = lg(x);
     894             :   GEN y;
     895      164095 :   if (lx == 1) return cgetg(1,t_MAT);
     896      164095 :   dx = lgcols(x); y = cgetg(dx,t_MAT);
     897      164095 :   for (i=1; i<dx; i++) gel(y,i) = Flm_row(x,i);
     898      164095 :   return y;
     899             : }
     900             : 
     901             : /********************************************************************/
     902             : /**                                                                **/
     903             : /**                           SCALAR MATRICES                      **/
     904             : /**                                                                **/
     905             : /********************************************************************/
     906             : 
     907             : GEN
     908         400 : gen_matid(long n, void *E, const struct bb_field *S)
     909             : {
     910         400 :   GEN y = cgetg(n+1,t_MAT), _0, _1;
     911             :   long i;
     912         400 :   if (n < 0) pari_err_DOMAIN("gen_matid", "dimension","<",gen_0,stoi(n));
     913         400 :   _0 = S->s(E,0);
     914         400 :   _1 = S->s(E,1);
     915        7160 :   for (i=1; i<=n; i++)
     916             :   {
     917        6760 :     GEN z = const_col(n, _0); gel(z,i) = _1;
     918        6760 :     gel(y, i) = z;
     919             :   }
     920         400 :   return y;
     921             : }
     922             : 
     923             : GEN
     924        6605 : matid_F2m(long n)
     925             : {
     926        6605 :   GEN y = cgetg(n+1,t_MAT);
     927             :   long i;
     928        6605 :   if (n < 0) pari_err_DOMAIN("matid_F2m", "dimension","<",gen_0,stoi(n));
     929        6605 :   for (i=1; i<=n; i++) { gel(y,i) = zero_F2v(n); F2v_set(gel(y,i),i); }
     930        6605 :   return y;
     931             : }
     932             : 
     933             : GEN
     934          25 : matid_F2xqM(long n, GEN T)
     935             : {
     936             :   void *E;
     937          25 :   const struct bb_field *S = get_F2xq_field(&E, T);
     938          25 :   return gen_matid(n, E, S);
     939             : }
     940             : GEN
     941         375 : matid_FlxqM(long n, GEN T, ulong p)
     942             : {
     943             :   void *E;
     944         375 :   const struct bb_field *S = get_Flxq_field(&E, T, p);
     945         375 :   return gen_matid(n, E, S);
     946             : }
     947             : 
     948             : GEN
     949      562630 : matid_Flm(long n)
     950             : {
     951      562630 :   GEN y = cgetg(n+1,t_MAT);
     952             :   long i;
     953      562630 :   if (n < 0) pari_err_DOMAIN("matid_Flm", "dimension","<",gen_0,stoi(n));
     954      562630 :   for (i=1; i<=n; i++) { gel(y,i) = zero_zv(n); ucoeff(y, i,i) = 1; }
     955      562630 :   return y;
     956             : }
     957             : 
     958             : GEN
     959          30 : scalar_Flm(long s, long n)
     960             : {
     961             :   long i;
     962          30 :   GEN y = cgetg(n+1,t_MAT);
     963          30 :   for (i=1; i<=n; i++) { gel(y,i) = zero_Flv(n); coeff(y, i,i) = s; }
     964          30 :   return y;
     965             : }
     966             : 
     967             : /********************************************************************/
     968             : /**                                                                **/
     969             : /**                           CONVERSIONS                          **/
     970             : /**                                                                **/
     971             : /********************************************************************/
     972             : GEN
     973    13495090 : ZV_to_Flv(GEN x, ulong p)
     974             : {
     975    13495090 :   long i, n = lg(x);
     976    13495090 :   GEN y = cgetg(n,t_VECSMALL);
     977    13495090 :   for (i=1; i<n; i++) y[i] = umodiu(gel(x,i), p);
     978    13495090 :   return y;
     979             : }
     980             : GEN
     981     2260760 : ZM_to_Flm(GEN x, ulong p)
     982             : {
     983     2260760 :   long j,n = lg(x);
     984     2260760 :   GEN y = cgetg(n,t_MAT);
     985     2260760 :   if (n == 1) return y;
     986     2260635 :   for (j=1; j<n; j++) gel(y,j) = ZV_to_Flv(gel(x,j), p);
     987     2260635 :   return y;
     988             : }
     989             : GEN
     990         980 : ZMV_to_FlmV(GEN z, ulong m)
     991             : {
     992         980 :   long i, l = lg(z);
     993         980 :   GEN x = cgetg(l,t_VEC);
     994         980 :   for (i=1; i<l; i++) gel(x,i) = ZM_to_Flm(gel(z,i), m);
     995         980 :   return x;
     996             : }
     997             : 
     998             : /*                          TO INTMOD                        */
     999             : static GEN
    1000      907350 : to_intmod(GEN x, GEN p) { retmkintmod(modii(x, p), p); }
    1001             : static GEN
    1002       19430 : Fl_to_intmod(ulong x, GEN p) { retmkintmod(utoi(x), p); }
    1003             : 
    1004             : GEN
    1005      197695 : Fp_to_mod(GEN z, GEN p)
    1006             : {
    1007      197695 :   retmkintmod(modii(z, p), icopy(p));
    1008             : }
    1009             : 
    1010             : /* z in Z[X], return z * Mod(1,p), normalized*/
    1011             : GEN
    1012       38250 : FpX_to_mod(GEN z, GEN p)
    1013             : {
    1014       38250 :   long i,l = lg(z);
    1015       38250 :   GEN x = cgetg(l,t_POL);
    1016       38250 :   if (l >2) p = icopy(p);
    1017       38250 :   for (i=2; i<l; i++) gel(x,i) = to_intmod(gel(z,i), p);
    1018       38250 :   x[1] = z[1]; return normalizepol_lg(x,l);
    1019             : }
    1020             : 
    1021             : /* z in Z^n, return z * Mod(1,p), normalized*/
    1022             : GEN
    1023        3050 : FpV_to_mod(GEN z, GEN p)
    1024             : {
    1025        3050 :   long i,l = lg(z);
    1026        3050 :   GEN x = cgetg(l, t_VEC);
    1027        3050 :   if (l == 1) return x;
    1028        3050 :   p = icopy(p);
    1029        3050 :   for (i=1; i<l; i++) gel(x,i) = to_intmod(gel(z,i), p);
    1030        3050 :   return x;
    1031             : }
    1032             : /* z in Z^n, return z * Mod(1,p), normalized*/
    1033             : GEN
    1034          45 : FpC_to_mod(GEN z, GEN p)
    1035             : {
    1036          45 :   long i, l = lg(z);
    1037          45 :   GEN x = cgetg(l, t_COL);
    1038          45 :   if (l == 1) return x;
    1039          45 :   p = icopy(p);
    1040          45 :   for (i=1; i<l; i++) gel(x,i) = to_intmod(gel(z,i), p);
    1041          45 :   return x;
    1042             : }
    1043             : /* z in Mat m,n(Z), return z * Mod(1,p), normalized*/
    1044             : GEN
    1045          70 : FpM_to_mod(GEN z, GEN p)
    1046             : {
    1047          70 :   long i, j, m, l = lg(z);
    1048          70 :   GEN  x = cgetg(l,t_MAT), y, zi;
    1049          70 :   if (l == 1) return x;
    1050          65 :   m = lgcols(z);
    1051          65 :   p = icopy(p);
    1052         560 :   for (i=1; i<l; i++)
    1053             :   {
    1054         495 :     gel(x,i) = cgetg(m,t_COL);
    1055         495 :     y = gel(x,i); zi= gel(z,i);
    1056         495 :     for (j=1; j<m; j++) gel(y,j) = to_intmod(gel(zi,j), p);
    1057             :   }
    1058          65 :   return x;
    1059             : }
    1060             : GEN
    1061          20 : Flc_to_mod(GEN z, ulong pp)
    1062             : {
    1063          20 :   long i, l = lg(z);
    1064          20 :   GEN p, x = cgetg(l, t_COL);
    1065          20 :   if (l == 1) return x;
    1066          20 :   p = utoipos(pp);
    1067          20 :   for (i=1; i<l; i++) gel(x,i) = Fl_to_intmod(z[i], p);
    1068          20 :   return x;
    1069             : }
    1070             : GEN
    1071         190 : Flm_to_mod(GEN z, ulong pp)
    1072             : {
    1073         190 :   long i, j, m, l = lg(z);
    1074         190 :   GEN p, x = cgetg(l,t_MAT), y, zi;
    1075         190 :   if (l == 1) return x;
    1076         170 :   m = lgcols(z);
    1077         170 :   p = utoipos(pp);
    1078        1405 :   for (i=1; i<l; i++)
    1079             :   {
    1080        1235 :     gel(x,i) = cgetg(m,t_COL);
    1081        1235 :     y = gel(x,i); zi= gel(z,i);
    1082        1235 :     for (j=1; j<m; j++) gel(y,j) = Fl_to_intmod(zi[j], p);
    1083             :   }
    1084         170 :   return x;
    1085             : }
    1086             : 
    1087             : GEN
    1088        1300 : FpVV_to_mod(GEN z, GEN p)
    1089             : {
    1090        1300 :   long i, j, m, l = lg(z);
    1091        1300 :   GEN  x = cgetg(l,t_VEC), y, zi;
    1092        1300 :   if (l == 1) return x;
    1093        1245 :   m = lgcols(z);
    1094        1245 :   p = icopy(p);
    1095        2605 :   for (i=1; i<l; i++)
    1096             :   {
    1097        1360 :     gel(x,i) = cgetg(m,t_VEC);
    1098        1360 :     y = gel(x,i); zi= gel(z,i);
    1099        1360 :     for (j=1; j<m; j++) gel(y,j) = to_intmod(gel(zi,j), p);
    1100             :   }
    1101        1245 :   return x;
    1102             : }
    1103             : 
    1104             : /* z in Z^n, return z * Mod(1,p), normalized*/
    1105             : GEN
    1106           5 : FpXQC_to_mod(GEN z, GEN T, GEN p)
    1107             : {
    1108           5 :   long i,l = lg(z);
    1109           5 :   GEN x = cgetg(l, t_COL); T = FpX_to_mod(T, p);
    1110          15 :   for (i=1; i<l; i++)
    1111          10 :     gel(x,i) = mkpolmod(FpX_to_mod(gel(z,i), p), T);
    1112           5 :   return x;
    1113             : }
    1114             : 
    1115             : /********************************************************************/
    1116             : /*                                                                  */
    1117             : /*                     Blackbox linear algebra                      */
    1118             : /*                                                                  */
    1119             : /********************************************************************/
    1120             : 
    1121             : /* A sparse column (zCs) v is a t_COL with two components C and E which are
    1122             :  * t_VECSMALL of the same length, representing sum_i E[i]*e_{C[i]}, where
    1123             :  * (e_j) is the canonical basis.
    1124             :  * A sparse matrix (zMs) is a t_VEC of zCs */
    1125             : 
    1126             : /* FpCs and FpMs are identical but E[i] is interpreted as a _signed_ C long
    1127             :  * integer representing an element of Fp. This is important since p can be
    1128             :  * large and p+E[i] would not fit in a C long.  */
    1129             : 
    1130             : /* RgCs and RgMs are similar, except that the type of the component is
    1131             :  * unspecified. Functions handling RgCs/RgMs must be independent of the type
    1132             :  * of E. */
    1133             : 
    1134             : /* Most functions take an argument nbrow which is the number of lines of the
    1135             :  * column/matrix, which cannot be derived from the data. */
    1136             : 
    1137             : GEN
    1138           0 : zCs_to_ZC(GEN R, long nbrow)
    1139             : {
    1140           0 :   GEN C = gel(R,1), E = gel(R,2), c = zerocol(nbrow);
    1141           0 :   long j, l = lg(C);
    1142           0 :   for (j = 1; j < l; ++j) gel(c, C[j]) = stoi(E[j]);
    1143           0 :   return c;
    1144             : }
    1145             : 
    1146             : GEN
    1147           0 : zMs_to_ZM(GEN M, long nbrow)
    1148             : {
    1149           0 :   long i, l = lg(M);
    1150           0 :   GEN m = cgetg(l, t_MAT);
    1151           0 :   for (i = 1; i < l; ++i) gel(m,i) = zCs_to_ZC(gel(M,i), nbrow);
    1152           0 :   return m;
    1153             : }
    1154             : 
    1155             : /* Solve equation f(X) = B (mod p) where B is a FpV, and f is an endomorphism.
    1156             :  * Return either a solution as a t_COL, or a kernel vector as a t_VEC. */
    1157             : GEN
    1158          85 : gen_FpM_Wiedemann(void *E, GEN (*f)(void*, GEN), GEN B, GEN p)
    1159             : {
    1160          85 :   pari_sp ltop = avma;
    1161          85 :   long col = 0, n = lg(B)-1, m = 2*n+1;
    1162          85 :   if (ZV_equal0(B)) return zerocol(n);
    1163         170 :   while (++col <= n)
    1164             :   {
    1165          85 :     pari_sp btop = avma, av;
    1166             :     long i, lQ;
    1167          85 :     GEN V, Q, M, W = B;
    1168          85 :     GEN b = cgetg(m+2, t_POL);
    1169          85 :     b[1] = evalsigne(1)|evalvarn(0);
    1170          85 :     gel(b, 2) = gel(W, col);
    1171       36585 :     for (i = 3; i<m+2; i++)
    1172       36500 :       gel(b, i) = cgeti(lgefint(p));
    1173          85 :     av = avma;
    1174       36585 :     for (i = 3; i<m+2; i++)
    1175             :     {
    1176       36500 :       W = f(E, W);
    1177       36500 :       affii(gel(W, col),gel(b, i));
    1178       36500 :       if (gc_needed(av,1))
    1179             :       {
    1180        1360 :         if (DEBUGMEM>1) pari_warn(warnmem,"Wiedemann: first loop, %ld",i);
    1181        1360 :         W = gerepileupto(av, W);
    1182             :       }
    1183             :     }
    1184          85 :     b = FpX_renormalize(b, m+2);
    1185          85 :     if (lgpol(b)==0) {avma = btop; continue; }
    1186          85 :     M = FpX_halfgcd(b, pol_xn(m, 0), p);
    1187          85 :     Q = FpX_neg(FpX_normalize(gcoeff(M, 2, 1),p),p);
    1188          85 :     W = B; lQ =lg(Q);
    1189          85 :     if (DEBUGLEVEL) err_printf("Wiedemann: deg. minpoly: %ld\n",lQ-3);
    1190          85 :     V = FpC_Fp_mul(W, gel(Q, lQ-2), p);
    1191          85 :     av = avma;
    1192       17900 :     for (i = lQ-3; i > 1; i--)
    1193             :     {
    1194       17815 :       W = f(E, W);
    1195       17815 :       V = ZC_lincomb(gen_1, gel(Q,i), V, W);
    1196       17815 :       if (gc_needed(av,1))
    1197             :       {
    1198        1127 :         if (DEBUGMEM>1) pari_warn(warnmem,"Wiedemann: second loop, %ld",i);
    1199        1127 :         gerepileall(av, 2, &V, &W);
    1200             :       }
    1201             :     }
    1202          85 :     V = FpC_red(V, p);
    1203          85 :     W = FpC_sub(f(E,V), B, p);
    1204         170 :     if (ZV_equal0(W)) return gerepilecopy(ltop, V);
    1205           0 :     av = avma;
    1206           0 :     for (i = 1; i <= n; ++i)
    1207             :     {
    1208           0 :       V = W;
    1209           0 :       W = f(E, V);
    1210           0 :       if (ZV_equal0(W))
    1211           0 :         return gerepilecopy(ltop, shallowtrans(V));
    1212           0 :       gerepileall(av, 2, &V, &W);
    1213             :     }
    1214           0 :     avma = btop;
    1215             :   }
    1216           0 :   return NULL;
    1217             : }
    1218             : 
    1219             : GEN
    1220           0 : zMs_ZC_mul(GEN M, GEN B)
    1221             : {
    1222             :   long i, j;
    1223           0 :   long n = lg(B)-1;
    1224           0 :   GEN V = zerocol(n);
    1225           0 :   for (i = 1; i <= n; ++i)
    1226           0 :     if (signe(gel(B, i)))
    1227             :     {
    1228           0 :       GEN R = gel(M, i), C = gel(R, 1), E = gel(R, 2);
    1229           0 :       long l = lg(C);
    1230           0 :       for (j = 1; j < l; ++j)
    1231             :       {
    1232           0 :         long k = C[j];
    1233           0 :         switch(E[j])
    1234             :         {
    1235             :         case 1:
    1236           0 :           gel(V, k) = gel(V,k)==gen_0 ? gel(B,i) : addii(gel(V, k), gel(B,i));
    1237           0 :           break;
    1238             :         case -1:
    1239           0 :           gel(V, k) = gel(V,k)==gen_0 ? negi(gel(B,i)) : subii(gel(V, k), gel(B,i));
    1240           0 :           break;
    1241             :         default:
    1242           0 :           gel(V, k) = gel(V,k)==gen_0 ? mulis(gel(B, i), E[j]) : addii(gel(V, k), mulis(gel(B, i), E[j]));
    1243           0 :           break;
    1244             :         }
    1245             :       }
    1246             :     }
    1247           0 :   return V;
    1248             : }
    1249             : 
    1250             : GEN
    1251           0 : FpMs_FpC_mul(GEN M, GEN B, GEN p) { return FpC_red(zMs_ZC_mul(M, B), p); }
    1252             : 
    1253             : GEN
    1254       54485 : ZV_zMs_mul(GEN B, GEN M)
    1255             : {
    1256             :   long i, j;
    1257       54485 :   long m = lg(M)-1;
    1258       54485 :   GEN V = cgetg(m+1,t_VEC);
    1259    28985010 :   for (i = 1; i <= m; ++i)
    1260             :   {
    1261    28930525 :     GEN R = gel(M, i), C = gel(R, 1), E = gel(R, 2);
    1262    28930525 :     long l = lg(C);
    1263    28930525 :     GEN z = mulis(gel(B, C[1]), E[1]);
    1264   243171760 :     for (j = 2; j < l; ++j)
    1265             :     {
    1266   214241235 :       long k = C[j];
    1267   214241235 :       switch(E[j])
    1268             :       {
    1269             :       case 1:
    1270   145698330 :         z = addii(z, gel(B,k));
    1271   145698330 :         break;
    1272             :       case -1:
    1273    58400170 :         z = subii(z, gel(B,k));
    1274    58400170 :         break;
    1275             :       default:
    1276    10142735 :         z = addii(z, mulis(gel(B,k), E[j]));
    1277    10142735 :         break;
    1278             :       }
    1279             :     }
    1280    28930525 :     gel(V,i) = z;
    1281             :   }
    1282       54485 :   return V;
    1283             : }
    1284             : 
    1285             : GEN
    1286          85 : FpV_FpMs_mul(GEN B, GEN M, GEN p) { return FpV_red(ZV_zMs_mul(B, M), p); }
    1287             : 
    1288             : GEN
    1289      304375 : ZlM_gauss(GEN a, GEN b, ulong p, long e, GEN C)
    1290             : {
    1291      304375 :   pari_sp av = avma, av2;
    1292      304375 :   GEN xi, xb, pi = gen_1, P;
    1293             :   long i;
    1294      304375 :   if (!C) {
    1295           0 :     C = Flm_inv(ZM_to_Flm(a, p), p);
    1296           0 :     if (!C) pari_err_INV("ZlM_gauss", a);
    1297             :   }
    1298      304375 :   P = utoipos(p);
    1299      304375 :   av2 = avma;
    1300      304375 :   xi = Flm_mul(C, ZM_to_Flm(b, p), p);
    1301      304375 :   xb = Flm_to_ZM(xi);
    1302      659575 :   for (i = 2; i <= e; i++)
    1303             :   {
    1304      355200 :     pi = muliu(pi, p); /* = p^(i-1) */
    1305      355200 :     b = ZM_Z_divexact(ZM_sub(b, ZM_nm_mul(a, xi)), P);
    1306      355200 :     if (gc_needed(av,2))
    1307             :     {
    1308          20 :       if(DEBUGMEM>1) pari_warn(warnmem,"ZlM_gauss. i=%ld",i);
    1309          20 :       gerepileall(av2,3, &pi,&b,&xb);
    1310             :     }
    1311      355200 :     xi = Flm_mul(C, ZM_to_Flm(b, p), p);
    1312      355200 :     xb = ZM_add(xb, nm_Z_mul(xi, pi));
    1313             :   }
    1314      304375 :   return gerepileupto(av, xb);
    1315             : }
    1316             : 
    1317             : struct wrapper_modp_s {
    1318             :   GEN (*f)(void*, GEN);
    1319             :   void *E;
    1320             :   GEN p;
    1321             : };
    1322             : 
    1323             : /* compute f(x) mod p */
    1324             : static GEN
    1325       54400 : wrap_relcomb_modp(void *E, GEN x)
    1326             : {
    1327       54400 :   struct wrapper_modp_s *W = (struct wrapper_modp_s*)E;
    1328       54400 :   return FpC_red(W->f(W->E, x), W->p);
    1329             : }
    1330             : static GEN
    1331           0 : wrap_relcomb(void*E, GEN x) { return zMs_ZC_mul((GEN)E, x); }
    1332             : 
    1333             : static GEN
    1334       54400 : wrap_relker(void*E, GEN x) { return ZV_zMs_mul(x, (GEN)E); }
    1335             : 
    1336             : /* Solve f(X) = B (mod p^e); blackbox version of ZlM_gauss */
    1337             : GEN
    1338           0 : gen_ZpM_Dixon(void *E, GEN (*f)(void*, GEN), GEN B, GEN p, long e)
    1339             : {
    1340             :   struct wrapper_modp_s W;
    1341           0 :   pari_sp av = avma;
    1342           0 :   GEN xb, xi, pi = gen_1;
    1343             :   long i;
    1344           0 :   W.E = E;
    1345           0 :   W.f = f;
    1346           0 :   W.p = p;
    1347           0 :   xi = gen_FpM_Wiedemann((void*)&W, wrap_relcomb_modp, FpC_red(B, p), p); /* f^(-1) B */
    1348           0 :   if (!xi || e == 1 || typ(xi) == t_VEC) return xi;
    1349           0 :   xb = xi;
    1350           0 :   for (i = 2; i <= e; i++)
    1351             :   {
    1352           0 :     pi = mulii(pi, p); /* = p^(i-1) */
    1353           0 :     B = ZC_Z_divexact(ZC_sub(B, f(E, xi)), p);
    1354           0 :     if (gc_needed(av,2))
    1355             :     {
    1356           0 :       if(DEBUGMEM>1) pari_warn(warnmem,"gen_ZpM_Dixon. i=%ld",i);
    1357           0 :       gerepileall(av,3, &pi,&B,&xb);
    1358             :     }
    1359           0 :     xi = gen_FpM_Wiedemann((void*)&W, wrap_relcomb_modp, FpC_red(B, p), p);
    1360           0 :     if (!xi) return NULL;
    1361           0 :     if (typ(xi) == t_VEC) return gerepileupto(av, xi);
    1362           0 :     xb = ZC_add(xb, ZC_Z_mul(xi, pi));
    1363             :   }
    1364           0 :   return gerepileupto(av, xb);
    1365             : }
    1366             : 
    1367             : static GEN
    1368       18250 : vecprow(GEN A, GEN prow)
    1369             : {
    1370       18250 :   return mkvec2(vecsmallpermute(prow,gel(A,1)), gel(A,2));
    1371             : }
    1372             : 
    1373             : /* Solve the equation MX = A. Return either a solution as a t_COL,
    1374             :  * or the index of a column which is linearly dependent from the others as a
    1375             :  * t_VECSMALL with a single component. */
    1376             : GEN
    1377           0 : ZpMs_ZpCs_solve(GEN M, GEN A, long nbrow, GEN p, long e)
    1378             : {
    1379           0 :   pari_sp av = avma;
    1380             :   GEN pcol, prow;
    1381           0 :   long nbi=lg(M)-1, lR;
    1382             :   long i, n;
    1383             :   GEN Mp, Ap, Rp;
    1384             :   pari_timer ti;
    1385           0 :   if (DEBUGLEVEL) timer_start(&ti);
    1386           0 :   RgMs_structelim(M, nbrow, gel(A, 1), &pcol, &prow);
    1387           0 :   if (!pcol) { avma = av; return NULL; }
    1388           0 :   if (DEBUGLEVEL)
    1389           0 :     timer_printf(&ti,"structured elimination (%ld -> %ld)",nbi,lg(pcol)-1);
    1390           0 :   n = lg(pcol)-1;
    1391           0 :   Mp = cgetg(n+1, t_MAT);
    1392           0 :   for(i=1; i<=n; i++)
    1393           0 :     gel(Mp, i) = vecprow(gel(M,pcol[i]), prow);
    1394           0 :   Ap = zCs_to_ZC(vecprow(A, prow), n);
    1395           0 :   if (DEBUGLEVEL) timer_start(&ti);
    1396           0 :   Rp = gen_ZpM_Dixon((void*)Mp,wrap_relcomb, Ap, p, e);
    1397           0 :   if (DEBUGLEVEL) timer_printf(&ti,"linear algebra");
    1398           0 :   if (!Rp) { avma = av; return NULL; }
    1399           0 :   lR = lg(Rp)-1;
    1400           0 :   if (typ(Rp) == t_COL)
    1401             :   {
    1402           0 :     GEN R = zerocol(nbi+1);
    1403           0 :     for (i=1; i<=lR; i++)
    1404           0 :        gel(R,pcol[i]) = gel(Rp,i);
    1405           0 :     return gerepilecopy(av, R);
    1406             :   }
    1407           0 :   for (i = 1; i <= lR; ++i)
    1408           0 :     if (signe(gel(Rp, i)))
    1409           0 :       return gerepileuptoleaf(av, mkvecsmall(pcol[i]));
    1410             :   return NULL; /* LCOV_EXCL_LINE */
    1411             : }
    1412             : 
    1413             : GEN
    1414           0 : FpMs_FpCs_solve(GEN M, GEN A, long nbrow, GEN p)
    1415             : {
    1416           0 :   return ZpMs_ZpCs_solve(M, A, nbrow, p, 1);
    1417             : }
    1418             : 
    1419             : GEN
    1420           0 : FpMs_FpCs_solve_safe(GEN M, GEN A, long nbrow, GEN p)
    1421             : {
    1422             :   GEN res;
    1423           0 :   pari_CATCH(e_INV)
    1424             :   {
    1425           0 :     GEN E = pari_err_last();
    1426           0 :     GEN x = err_get_compo(E,2);
    1427           0 :     if (typ(x) != t_INTMOD) pari_err(0,E);
    1428           0 :     if (DEBUGLEVEL)
    1429           0 :       pari_warn(warner,"FpMs_FpCs_solve_safe, impossible inverse %Ps", x);
    1430           0 :     res = NULL;
    1431             :   } pari_TRY {
    1432           0 :     res = ZpMs_ZpCs_solve(M, A, nbrow, p, 1);
    1433           0 :   } pari_ENDCATCH
    1434           0 :   return res;
    1435             : }
    1436             : 
    1437             : static GEN
    1438          85 : FpMs_structelim_back(GEN M, GEN V, GEN prow, GEN p)
    1439             : {
    1440          85 :   long i, j, oldf = 0, f = 0;
    1441          85 :   long lrow = lg(prow), lM = lg(M);
    1442          85 :   GEN W = const_vecsmall(lM-1,1);
    1443          85 :   GEN R = cgetg(lrow, t_VEC);
    1444      157645 :   for (i=1; i<lrow; i++)
    1445      157560 :     gel(R,i) = prow[i]==0 ? NULL: gel(V,prow[i]);
    1446             :   do
    1447             :   {
    1448         275 :     oldf = f;
    1449      297815 :     for(i=1; i<lM; i++)
    1450      297540 :       if (W[i])
    1451             :       {
    1452      100890 :         GEN C = gel(M,i), F = gel(C,1), E = gel(C,2);
    1453      100890 :         long c=0, cj=0, lF = lg(F);
    1454      882700 :         for(j=1; j<lF; j++)
    1455      781810 :           if (!gel(R,F[j]))
    1456       58440 :           { c++; cj=j; }
    1457      100890 :         if (c>=2) continue;
    1458       87215 :         if (c==1)
    1459             :         {
    1460       28165 :           pari_sp av = avma;
    1461       28165 :           GEN s = gen_0;
    1462      245355 :           for(j=1; j<lF; j++)
    1463      217190 :             if (j!=cj) s = Fp_add(s, mulis(gel(R,F[j]), E[j]), p);
    1464       28165 :           gel(R,F[cj]) = gerepileupto(av, Fp_div(Fp_neg(s, p), stoi(E[cj]), p));
    1465       28165 :           f++;
    1466             :         }
    1467       87215 :         W[i]=0;
    1468             :       }
    1469         275 :   } while(oldf!=f);
    1470      157645 :   for (i=1; i<lrow; i++)
    1471      157560 :     if (!gel(R,i)) gel(R,i) = gen_0;
    1472          85 :   return R;
    1473             : }
    1474             : 
    1475             : /* Return a linear form Y such that YM is essentially 0 */
    1476             : GEN
    1477          85 : FpMs_leftkernel_elt_col(GEN M, long nbcol, long nbrow, GEN p)
    1478             : {
    1479          85 :   pari_sp av = avma, av2;
    1480             :   GEN pcol, prow;
    1481             :   long i, n;
    1482             :   GEN Mp, B, MB, R, Rp;
    1483             :   pari_timer ti;
    1484             :   struct wrapper_modp_s W;
    1485          85 :   if (DEBUGLEVEL) timer_start(&ti);
    1486          85 :   RgMs_structelim_col(M, nbcol, nbrow, cgetg(1,t_VECSMALL), &pcol, &prow);
    1487          85 :   if (!pcol) { avma = av; return NULL; }
    1488          85 :   if (DEBUGLEVEL)
    1489           0 :     timer_printf(&ti,"structured elimination (%ld -> %ld)",nbcol,lg(pcol)-1);
    1490          85 :   n = lg(pcol)-1;
    1491          85 :   Mp = cgetg(n+1, t_MAT);
    1492       18335 :   for(i=1; i<=n; i++)
    1493       18250 :     gel(Mp, i) = vecprow(gel(M,pcol[i]), prow);
    1494          85 :   W.E = (void*) Mp;
    1495          85 :   W.f = wrap_relker;
    1496          85 :   W.p = p;
    1497          85 :   av2 = avma;
    1498             :   for(;;)
    1499             :   {
    1500          85 :     avma = av2;
    1501          85 :     B = cgetg(n+1,t_VEC);
    1502       18335 :     for(i=1; i<=n; i++)
    1503       18250 :       gel(B,i) = randomi(p);
    1504          85 :     MB = FpV_FpMs_mul(B, Mp, p);
    1505          85 :     if (DEBUGLEVEL) timer_start(&ti);
    1506          85 :     pari_CATCH(e_INV)
    1507             :     {
    1508           0 :       GEN E = pari_err_last();
    1509           0 :       GEN x = err_get_compo(E,2);
    1510           0 :       if (typ(x) != t_INTMOD) pari_err(0,E);
    1511           0 :       if (DEBUGLEVEL)
    1512           0 :         pari_warn(warner,"FpMs_leftkernel_elt, impossible inverse %Ps", x);
    1513           0 :       Rp = NULL;
    1514             :     } pari_TRY {
    1515          85 :       Rp = gen_FpM_Wiedemann((void*)&W, wrap_relcomb_modp, MB, p);
    1516          85 :     } pari_ENDCATCH
    1517          85 :     if (!Rp) continue;
    1518          85 :     if (typ(Rp)==t_COL)
    1519             :     {
    1520          85 :       Rp = FpC_sub(Rp,B,p);
    1521          85 :       if (ZV_equal0(Rp)) continue;
    1522             :     }
    1523          85 :     R = FpMs_structelim_back(M, Rp, prow, p);
    1524          85 :     if (DEBUGLEVEL) timer_printf(&ti,"Wiedemann left kernel");
    1525          85 :     return gerepilecopy(av, R);
    1526           0 :   }
    1527             : }
    1528             : 
    1529             : GEN
    1530          25 : FpMs_leftkernel_elt(GEN M, long nbrow, GEN p)
    1531             : {
    1532          25 :   return FpMs_leftkernel_elt_col(M, lg(M)-1, nbrow, p);
    1533             : }

Generated by: LCOV version 1.11