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 - headers - pariinl.h (source / functions) Hit Total Coverage
Test: PARI/GP v2.10.0 lcov report (development 20296-0a10b35) Lines: 1218 1389 87.7 %
Date: 2017-02-26 05:50:47 Functions: 520 592 87.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* Copyright (C) 2000-2010  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             : /*******************************************************************/
      15             : /*                                                                 */
      16             : /*                          CONSTRUCTORS                           */
      17             : /*                                                                 */
      18             : /*******************************************************************/
      19             : #define retmkfrac(x,y)\
      20             :   do { GEN _v = cgetg(3, t_FRAC);\
      21             :        gel(_v,1) = (x);\
      22             :        gel(_v,2) = (y); return _v; } while(0)
      23             : #define retmkrfrac(x,y)\
      24             :   do { GEN _v = cgetg(3, t_RFRAC);\
      25             :        gel(_v,1) = (x);\
      26             :        gel(_v,2) = (y); return _v; } while(0)
      27             : #define retmkintmod(x,y)\
      28             :   do { GEN _v = cgetg(3, t_INTMOD);\
      29             :        gel(_v,1) = (y);\
      30             :        gel(_v,2) = (x); return _v; } while(0)
      31             : #define retmkcomplex(x,y)\
      32             :   do { GEN _v = cgetg(3, t_COMPLEX);\
      33             :        gel(_v,1) = (x);\
      34             :        gel(_v,2) = (y); return _v; } while(0)
      35             : #define retmkpolmod(x,y)\
      36             :   do { GEN _v = cgetg(3, t_POLMOD);\
      37             :        gel(_v,1) = (y);\
      38             :        gel(_v,2) = (x); return _v; } while(0)
      39             : #define retmkvec(x)\
      40             :   do { GEN _v = cgetg(2, t_VEC);\
      41             :        gel(_v,1) = (x); return _v; } while(0)
      42             : #define retmkvec2(x,y)\
      43             :   do { GEN _v = cgetg(3, t_VEC);\
      44             :        gel(_v,1) = (x);\
      45             :        gel(_v,2) = (y); return _v; } while(0)
      46             : #define retmkvec3(x,y,z)\
      47             :   do { GEN _v = cgetg(4, t_VEC);\
      48             :        gel(_v,1) = (x);\
      49             :        gel(_v,2) = (y);\
      50             :        gel(_v,3) = (z); return _v; } while(0)
      51             : #define retmkqfi(x,y,z)\
      52             :   do { GEN _v = cgetg(4, t_QFI);\
      53             :        gel(_v,1) = (x);\
      54             :        gel(_v,2) = (y);\
      55             :        gel(_v,3) = (z); return _v; } while(0)
      56             : #define retmkqfr(x,y,z,d)\
      57             :   do { GEN _v = cgetg(5, t_QFR);\
      58             :        gel(_v,1) = (x);\
      59             :        gel(_v,2) = (y);\
      60             :        gel(_v,3) = (z);\
      61             :        gel(_v,4) = (d); return _v; } while(0)
      62             : #define retmkquad(x,y,z)\
      63             :   do { GEN _v = cgetg(4, t_QUAD);\
      64             :        gel(_v,1) = (x);\
      65             :        gel(_v,2) = (y);\
      66             :        gel(_v,3) = (z); return _v; } while(0)
      67             : #define retmkvec4(x,y,z,t)\
      68             :   do { GEN _v = cgetg(5, t_VEC);\
      69             :        gel(_v,1) = (x);\
      70             :        gel(_v,2) = (y);\
      71             :        gel(_v,3) = (z);\
      72             :        gel(_v,4) = (t); return _v; } while(0)
      73             : #define retmkvec5(x,y,z,t,u)\
      74             :   do { GEN _v = cgetg(6, t_VEC);\
      75             :        gel(_v,1) = (x);\
      76             :        gel(_v,2) = (y);\
      77             :        gel(_v,3) = (z);\
      78             :        gel(_v,4) = (t);\
      79             :        gel(_v,5) = (u); return _v; } while(0)
      80             : #define retmkcol(x)\
      81             :   do { GEN _v = cgetg(2, t_COL);\
      82             :        gel(_v,1) = (x); return _v; } while(0)
      83             : #define retmkcol2(x,y)\
      84             :   do { GEN _v = cgetg(3, t_COL);\
      85             :        gel(_v,1) = (x);\
      86             :        gel(_v,2) = (y); return _v; } while(0)
      87             : #define retmkcol3(x,y,z)\
      88             :   do { GEN _v = cgetg(4, t_COL);\
      89             :        gel(_v,1) = (x);\
      90             :        gel(_v,2) = (y);\
      91             :        gel(_v,3) = (z); return _v; } while(0)
      92             : #define retmkcol4(x,y,z,t)\
      93             :   do { GEN _v = cgetg(5, t_COL);\
      94             :        gel(_v,1) = (x);\
      95             :        gel(_v,2) = (y);\
      96             :        gel(_v,3) = (z);\
      97             :        gel(_v,4) = (t); return _v; } while(0)
      98             : #define retmkcol5(x,y,z,t,u)\
      99             :   do { GEN _v = cgetg(6, t_COL);\
     100             :        gel(_v,1) = (x);\
     101             :        gel(_v,2) = (y);\
     102             :        gel(_v,3) = (z);\
     103             :        gel(_v,4) = (t);\
     104             :        gel(_v,5) = (u); return _v; } while(0)
     105             : #define retmkcol6(x,y,z,t,u,v)\
     106             :   do { GEN _v = cgetg(7, t_COL);\
     107             :        gel(_v,1) = (x);\
     108             :        gel(_v,2) = (y);\
     109             :        gel(_v,3) = (z);\
     110             :        gel(_v,4) = (t);\
     111             :        gel(_v,5) = (u);\
     112             :        gel(_v,6) = (v); return _v; } while(0)
     113             : #define retmkmat(x)\
     114             :   do { GEN _v = cgetg(2, t_MAT);\
     115             :        gel(_v,1) = (x); return _v; } while(0)
     116             : #define retmkmat2(x,y)\
     117             :   do { GEN _v = cgetg(3, t_MAT);\
     118             :        gel(_v,1) = (x);\
     119             :        gel(_v,2) = (y); return _v; } while(0)
     120             : #define retmkmat3(x,y,z)\
     121             :   do { GEN _v = cgetg(4, t_MAT);\
     122             :        gel(_v,1) = (x);\
     123             :        gel(_v,2) = (y);\
     124             :        gel(_v,3) = (z); return _v; } while(0)
     125             : #define retmkmat4(x,y,z,t)\
     126             :   do { GEN _v = cgetg(5, t_MAT);\
     127             :        gel(_v,1) = (x);\
     128             :        gel(_v,2) = (y);\
     129             :        gel(_v,3) = (z);\
     130             :        gel(_v,4) = (t); return _v; } while(0)
     131             : #define retmkmat5(x,y,z,t,u)\
     132             :   do { GEN _v = cgetg(6, t_MAT);\
     133             :        gel(_v,1) = (x);\
     134             :        gel(_v,2) = (y);\
     135             :        gel(_v,3) = (z);\
     136             :        gel(_v,4) = (t);\
     137             :        gel(_v,5) = (u); return _v; } while(0)
     138             : 
     139             : INLINE GEN
     140      332311 : mkintmod(GEN x, GEN y) { retmkintmod(x,y); }
     141             : INLINE GEN
     142        3780 : mkintmodu(ulong x, ulong y) {
     143        3780 :   GEN v = cgetg(3,t_INTMOD);
     144        3780 :   gel(v,1) = utoipos(y);
     145        3780 :   gel(v,2) = utoi(x); return v;
     146             : }
     147             : INLINE GEN
     148      287508 : mkpolmod(GEN x, GEN y) { retmkpolmod(x,y); }
     149             : INLINE GEN
     150     1847498 : mkfrac(GEN x, GEN y) { retmkfrac(x,y); }
     151             : INLINE GEN
     152     2874391 : mkfraccopy(GEN x, GEN y) { retmkfrac(icopy(x), icopy(y)); }
     153             : INLINE GEN
     154        5019 : mkrfrac(GEN x, GEN y) { GEN v = cgetg(3, t_RFRAC);
     155        5019 :   gel(v,1) = x; gel(v,2) = y; return v; }
     156             : INLINE GEN
     157          14 : mkrfraccopy(GEN x, GEN y) { GEN v = cgetg(3, t_RFRAC);
     158          14 :   gel(v,1) = gcopy(x); gel(v,2) = gcopy(y); return v; }
     159             : INLINE GEN
     160     2861806 : mkcomplex(GEN x, GEN y) { retmkcomplex(x,y); }
     161             : INLINE GEN
     162      424680 : gen_I(void) { return mkcomplex(gen_0, gen_1); }
     163             : INLINE GEN
     164      204133 : cgetc(long l) { retmkcomplex(cgetr(l), cgetr(l)); }
     165             : INLINE GEN
     166          42 : mkquad(GEN n, GEN x, GEN y) { GEN v = cgetg(4, t_QUAD);
     167          42 :   gel(v,1) = n; gel(v,2) = x; gel(v,3) = y; return v; }
     168             : /* vecsmall */
     169             : INLINE GEN
     170    49514137 : mkvecsmall(long x) { GEN v = cgetg(2, t_VECSMALL); v[1] = x; return v; }
     171             : INLINE GEN
     172   110072469 : mkvecsmall2(long x,long y) { GEN v = cgetg(3, t_VECSMALL);
     173   110066468 :   v[1]=x; v[2]=y; return v; }
     174             : INLINE GEN
     175    61678832 : mkvecsmall3(long x,long y,long z) { GEN v = cgetg(4, t_VECSMALL);
     176    61676449 :   v[1]=x; v[2]=y; v[3]=z; return v; }
     177             : INLINE GEN
     178     9290756 : mkvecsmall4(long x,long y,long z,long t) { GEN v = cgetg(5, t_VECSMALL);
     179     9280103 :   v[1]=x; v[2]=y; v[3]=z; v[4]=t; return v; }
     180             : INLINE GEN
     181      435710 : mkvecsmall5(long x,long y,long z,long t,long u) { GEN v = cgetg(6, t_VECSMALL);
     182      435710 :   v[1]=x; v[2]=y; v[3]=z; v[4]=t; v[5]=u; return v; }
     183             : 
     184             : INLINE GEN
     185      158123 : mkqfi(GEN x, GEN y, GEN z) { retmkqfi(x,y,z); }
     186             : /* vec */
     187             : INLINE GEN
     188     3131486 : mkvec(GEN x) { retmkvec(x); }
     189             : INLINE GEN
     190    22551344 : mkvec2(GEN x, GEN y) { retmkvec2(x,y); }
     191             : INLINE GEN
     192    51920493 : mkvec3(GEN x, GEN y, GEN z) { retmkvec3(x,y,z); }
     193             : INLINE GEN
     194     7338508 : mkvec4(GEN x, GEN y, GEN z, GEN t) { retmkvec4(x,y,z,t); }
     195             : INLINE GEN
     196    11754869 : mkvec5(GEN x, GEN y, GEN z, GEN t, GEN u) { retmkvec5(x,y,z,t,u); }
     197             : INLINE GEN
     198           7 : mkvecs(long x) { retmkvec(stoi(x)); }
     199             : INLINE GEN
     200       12054 : mkvec2s(long x, long y) { retmkvec2(stoi(x),stoi(y)); }
     201             : INLINE GEN
     202      492702 : mkvec3s(long x, long y, long z) { retmkvec3(stoi(x),stoi(y),stoi(z)); }
     203             : INLINE GEN
     204           0 : mkvec4s(long x, long y, long z, long t) { retmkvec4(stoi(x),stoi(y),stoi(z),stoi(t)); }
     205             : INLINE GEN
     206       33355 : mkveccopy(GEN x) { GEN v = cgetg(2, t_VEC); gel(v,1) = gcopy(x); return v; }
     207             : INLINE GEN
     208      184930 : mkvec2copy(GEN x, GEN y) {
     209      184930 :   GEN v = cgetg(3,t_VEC); gel(v,1) = gcopy(x); gel(v,2) = gcopy(y); return v; }
     210             : /* col */
     211             : INLINE GEN
     212     2083515 : mkcol(GEN x) { retmkcol(x); }
     213             : INLINE GEN
     214    14740539 : mkcol2(GEN x, GEN y) { retmkcol2(x,y); }
     215             : INLINE GEN
     216       41615 : mkcol3(GEN x, GEN y, GEN z) { retmkcol3(x,y,z); }
     217             : INLINE GEN
     218           0 : mkcol4(GEN x, GEN y, GEN z, GEN t) { retmkcol4(x,y,z,t); }
     219             : INLINE GEN
     220           0 : mkcol5(GEN x, GEN y, GEN z, GEN t, GEN u) { retmkcol5(x,y,z,t,u); }
     221             : INLINE GEN
     222         764 : mkcol6(GEN x, GEN y, GEN z, GEN t, GEN u, GEN v) { retmkcol6(x,y,z,t,u,v); }
     223             : INLINE GEN
     224         728 : mkcols(long x) { retmkcol(stoi(x)); }
     225             : INLINE GEN
     226     1181376 : mkcol2s(long x, long y) { retmkcol2(stoi(x),stoi(y)); }
     227             : INLINE GEN
     228           0 : mkcol3s(long x, long y, long z) { retmkcol3(stoi(x),stoi(y),stoi(z)); }
     229             : INLINE GEN
     230           0 : mkcol4s(long x, long y, long z, long t) { retmkcol4(stoi(x),stoi(y),stoi(z),stoi(t)); }
     231             : INLINE GEN
     232       22255 : mkcolcopy(GEN x) { GEN v = cgetg(2, t_COL); gel(v,1) = gcopy(x); return v; }
     233             : /* mat */
     234             : INLINE GEN
     235      693581 : mkmat(GEN x) { retmkmat(x); }
     236             : INLINE GEN
     237    15699705 : mkmat2(GEN x, GEN y) { retmkmat2(x,y); }
     238             : INLINE GEN
     239        2352 : mkmat3(GEN x, GEN y, GEN z) { retmkmat3(x,y,z); }
     240             : INLINE GEN
     241           0 : mkmat4(GEN x, GEN y, GEN z, GEN t) { retmkmat4(x,y,z,t); }
     242             : INLINE GEN
     243           0 : mkmat5(GEN x, GEN y, GEN z, GEN t, GEN u) { retmkmat5(x,y,z,t,u); }
     244             : INLINE GEN
     245        7229 : mkmatcopy(GEN x) { GEN v = cgetg(2, t_MAT); gel(v,1) = gcopy(x); return v; }
     246             : INLINE GEN
     247           0 : mkerr(long x) { GEN v = cgetg(2, t_ERROR); v[1] = x; return v; }
     248             : INLINE GEN
     249       14149 : mkoo(void) { GEN v = cgetg(2, t_INFINITY); gel(v,1) = gen_1; return v; }
     250             : INLINE GEN
     251        7874 : mkmoo(void) { GEN v = cgetg(2, t_INFINITY); gel(v,1) = gen_m1; return v; }
     252             : INLINE long
     253       29090 : inf_get_sign(GEN x) { return signe(gel(x,1)); }
     254             : /* pol */
     255             : INLINE GEN
     256      685669 : pol_x(long v) {
     257      685669 :   GEN p = cgetg(4, t_POL);
     258      685669 :   p[1] = evalsigne(1)|evalvarn(v);
     259      685669 :   gel(p,2) = gen_0;
     260      685669 :   gel(p,3) = gen_1; return p;
     261             : }
     262             : /* x^n, assume n >= 0 */
     263             : INLINE GEN
     264     2510730 : pol_xn(long n, long v) {
     265     2510730 :   long i, a = n+2;
     266     2510730 :   GEN p = cgetg(a+1, t_POL);
     267     2510730 :   p[1] = evalsigne(1)|evalvarn(v);
     268     2510730 :   for (i = 2; i < a; i++) gel(p,i) = gen_0;
     269     2510730 :   gel(p,a) = gen_1; return p;
     270             : }
     271             : /* x^n, no assumption on n */
     272             : INLINE GEN
     273         133 : pol_xnall(long n, long v)
     274             : {
     275         133 :   if (n < 0) retmkrfrac(gen_1, pol_xn(-n,v));
     276          42 :   return pol_xn(n, v);
     277             : }
     278             : INLINE GEN
     279     1189763 : pol_1(long v) {
     280     1189763 :   GEN p = cgetg(3, t_POL);
     281     1189763 :   p[1] = evalsigne(1)|evalvarn(v);
     282     1189763 :   gel(p,2) = gen_1; return p;
     283             : }
     284             : INLINE GEN
     285    13780153 : pol_0(long v)
     286             : {
     287    13780153 :   GEN x = cgetg(2,t_POL);
     288    13780153 :   x[1] = evalvarn(v); return x;
     289             : }
     290             : #define retconst_vec(n,x)\
     291             :   do { long _i, _n = (n);\
     292             :        GEN _v = cgetg(_n+1, t_VEC), _x = (x);\
     293             :        for (_i = 1; _i <= _n; _i++) gel(_v,_i) = _x;\
     294             :        return _v; } while(0)
     295             : INLINE GEN
     296     9133712 : const_vec(long n, GEN x) { retconst_vec(n, x); }
     297             : #define retconst_col(n,x)\
     298             :   do { long _i, _n = (n);\
     299             :        GEN _v = cgetg(_n+1, t_COL), _x = (x);\
     300             :        for (_i = 1; _i <= _n; _i++) gel(_v,_i) = _x;\
     301             :        return _v; } while(0)
     302             : INLINE GEN
     303       32252 : const_col(long n, GEN x) { retconst_col(n, x); }
     304             : INLINE GEN
     305     4963236 : const_vecsmall(long n, long c)
     306             : {
     307             :   long i;
     308     4963236 :   GEN V = cgetg(n+1,t_VECSMALL);
     309     4963236 :   for(i=1;i<=n;i++) V[i] = c;
     310     4963236 :   return V;
     311             : }
     312             : 
     313             : /***   ZERO   ***/
     314             : /* O(p^e) */
     315             : INLINE GEN
     316      300979 : zeropadic(GEN p, long e)
     317             : {
     318      300979 :   GEN y = cgetg(5,t_PADIC);
     319      300979 :   gel(y,4) = gen_0;
     320      300979 :   gel(y,3) = gen_1;
     321      300979 :   gel(y,2) = icopy(p);
     322      300979 :   y[1] = evalvalp(e) | _evalprecp(0);
     323      300979 :   return y;
     324             : }
     325             : INLINE GEN
     326         504 : zeropadic_shallow(GEN p, long e)
     327             : {
     328         504 :   GEN y = cgetg(5,t_PADIC);
     329         504 :   gel(y,4) = gen_0;
     330         504 :   gel(y,3) = gen_1;
     331         504 :   gel(y,2) = p;
     332         504 :   y[1] = evalvalp(e) | _evalprecp(0);
     333         504 :   return y;
     334             : }
     335             : /* O(pol_x(v)^e) */
     336             : INLINE GEN
     337       14091 : zeroser(long v, long e)
     338             : {
     339       14091 :   GEN x = cgetg(2, t_SER);
     340       14091 :   x[1] = evalvalp(e) | evalvarn(v); return x;
     341             : }
     342             : INLINE int
     343     4025218 : ser_isexactzero(GEN x)
     344             : {
     345     4025218 :   if (!signe(x)) switch(lg(x))
     346             :   {
     347       12614 :     case 2: return 1;
     348         812 :     case 3: return isexactzero(gel(x,2));
     349             :   }
     350     4011792 :   return 0;
     351             : }
     352             : /* 0 * pol_x(v) */
     353             : INLINE GEN
     354     5109309 : zeropol(long v) { return pol_0(v); }
     355             : /* vector(n) */
     356             : INLINE GEN
     357    21767305 : zerocol(long n)
     358             : {
     359    21767305 :   GEN y = cgetg(n+1,t_COL);
     360    21767305 :   long i; for (i=1; i<=n; i++) gel(y,i) = gen_0;
     361    21767305 :   return y;
     362             : }
     363             : /* vectorv(n) */
     364             : INLINE GEN
     365     7785926 : zerovec(long n)
     366             : {
     367     7785926 :   GEN y = cgetg(n+1,t_VEC);
     368     7785928 :   long i; for (i=1; i<=n; i++) gel(y,i) = gen_0;
     369     7785928 :   return y;
     370             : }
     371             : /* matrix(m, n) */
     372             : INLINE GEN
     373        4725 : zeromat(long m, long n)
     374             : {
     375        4725 :   GEN y = cgetg(n+1,t_MAT);
     376        4725 :   GEN v = zerocol(m);
     377        4725 :   long i; for (i=1; i<=n; i++) gel(y,i) = v;
     378        4725 :   return y;
     379             : }
     380             : /* = zero_zx, sv is a evalvarn()*/
     381             : INLINE GEN
     382      784780 : zero_Flx(long sv) { return pol0_Flx(sv); }
     383             : INLINE GEN
     384    29337412 : zero_Flv(long n)
     385             : {
     386    29337412 :   GEN y = cgetg(n+1,t_VECSMALL);
     387    29337732 :   long i; for (i=1; i<=n; i++) y[i] = 0;
     388    29337732 :   return y;
     389             : }
     390             : /* matrix(m, n) */
     391             : INLINE GEN
     392         287 : zero_Flm(long m, long n)
     393             : {
     394         287 :   GEN y = cgetg(n+1,t_MAT);
     395         287 :   GEN v = zero_Flv(m);
     396         287 :   long i; for (i=1; i<=n; i++) gel(y,i) = v;
     397         287 :   return y;
     398             : }
     399             : /* matrix(m, n) */
     400             : INLINE GEN
     401       74577 : zero_Flm_copy(long m, long n)
     402             : {
     403       74577 :   GEN y = cgetg(n+1,t_MAT);
     404       74575 :   long i; for (i=1; i<=n; i++) gel(y,i) = zero_Flv(m);
     405       74579 :   return y;
     406             : }
     407             : 
     408             : INLINE GEN
     409      746753 : zero_F2v(long m)
     410             : {
     411      746753 :   long l = nbits2nlong(m);
     412      746753 :   GEN v  = zero_Flv(l+1);
     413      746753 :   v[1] = m;
     414      746753 :   return v;
     415             : }
     416             : 
     417             : INLINE GEN
     418           0 : zero_F2m(long m, long n)
     419             : {
     420             :   long i;
     421           0 :   GEN M = cgetg(n+1, t_MAT);
     422           0 :   GEN v = zero_F2v(m);
     423           0 :   for (i = 1; i <= n; i++)
     424           0 :     gel(M,i) = v;
     425           0 :   return M;
     426             : }
     427             : 
     428             : 
     429             : INLINE GEN
     430      269987 : zero_F2m_copy(long m, long n)
     431             : {
     432             :   long i;
     433      269987 :   GEN M = cgetg(n+1, t_MAT);
     434      767767 :   for (i = 1; i <= n; i++)
     435      497780 :     gel(M,i)= zero_F2v(m);
     436      269987 :   return M;
     437             : }
     438             : 
     439             : /* matrix(m, n) */
     440             : INLINE GEN
     441     1919516 : zeromatcopy(long m, long n)
     442             : {
     443     1919516 :   GEN y = cgetg(n+1,t_MAT);
     444     1919516 :   long i; for (i=1; i<=n; i++) gel(y,i) = zerocol(m);
     445     1919516 :   return y;
     446             : }
     447             : 
     448             : INLINE GEN
     449       15771 : zerovec_block(long len)
     450             : {
     451             :   long i;
     452       15771 :   GEN blk = cgetg_block(len + 1, t_VEC);
     453      520443 :   for (i = 1; i <= len; ++i)
     454      504672 :     gel(blk, i) = gen_0;
     455       15771 :   return blk;
     456             : }
     457             : 
     458             : /* i-th vector in the standard basis */
     459             : INLINE GEN
     460     1295851 : col_ei(long n, long i) { GEN e = zerocol(n); gel(e,i) = gen_1; return e; }
     461             : INLINE GEN
     462      304249 : vec_ei(long n, long i) { GEN e = zerovec(n); gel(e,i) = gen_1; return e; }
     463             : INLINE GEN
     464           7 : F2v_ei(long n, long i) { GEN e = zero_F2v(n); F2v_set(e,i); return e; }
     465             : INLINE GEN
     466       40345 : vecsmall_ei(long n, long i) { GEN e = zero_zv(n); e[i] = 1; return e; }
     467             : INLINE GEN
     468     2788191 : Rg_col_ei(GEN x, long n, long i) { GEN e = zerocol(n); gel(e,i) = x; return e; }
     469             : 
     470             : INLINE GEN
     471     2273278 : shallowcopy(GEN x)
     472     2273278 : { return typ(x) == t_MAT ? RgM_shallowcopy(x): leafcopy(x); }
     473             : 
     474             : /* routines for naive growarrays */
     475             : INLINE GEN
     476    11519111 : vectrunc_init(long l)
     477             : {
     478    11519111 :   GEN z = new_chunk(l);
     479    11519493 :   z[0] = evaltyp(t_VEC) | _evallg(1); return z;
     480             : }
     481             : INLINE void
     482    42966327 : vectrunc_append(GEN x, GEN t)
     483    42966327 : { long l = lg(x); gel(x,l) = t; setlg(x, l+1); }
     484             : INLINE void
     485           0 : vectrunc_append_batch(GEN x, GEN y)
     486             : {
     487           0 :   long i, l = lg(x), ly = lg(y);
     488           0 :   GEN z = x + l-1;
     489           0 :   for (i = 1; i < ly; i++) gel(z,i) = gel(y,i);
     490           0 :   setlg(x, l+ly-1);
     491           0 : }
     492             : INLINE GEN
     493     1399532 : vecsmalltrunc_init(long l)
     494             : {
     495     1399532 :   GEN z = new_chunk(l);
     496     1399532 :   z[0] = evaltyp(t_VECSMALL) | _evallg(1); return z;
     497             : }
     498             : INLINE void
     499     2864052 : vecsmalltrunc_append(GEN x, long t)
     500     2864052 : { long l = lg(x); x[l] = t; setlg(x, l+1); }
     501             : 
     502             : /*******************************************************************/
     503             : /*                                                                 */
     504             : /*                        VEC / COL / VECSMALL                     */
     505             : /*                                                                 */
     506             : /*******************************************************************/
     507             : /* shallow*/
     508             : INLINE GEN
     509           0 : vec_shorten(GEN v, long n)
     510             : {
     511             :   long i;
     512           0 :   GEN V = cgetg(n+1,t_VEC);
     513           0 :   for(i=1;i<=n;i++) gel(V,i) = gel(v,i);
     514           0 :   return V;
     515             : }
     516             : /* shallow*/
     517             : INLINE GEN
     518       10577 : vec_lengthen(GEN v, long n)
     519             : {
     520             :   long i;
     521       10577 :   long l=lg(v);
     522       10577 :   GEN V = cgetg(n+1,t_VEC);
     523       10577 :   for(i=1;i<l;i++) gel(V,i) = gel(v,i);
     524       10577 :   return V;
     525             : }
     526             : /* shallow*/
     527             : INLINE GEN
     528       56308 : vec_append(GEN V, GEN s)
     529             : {
     530       56308 :   long i, l2 = lg(V);
     531       56308 :   GEN res = cgetg(l2+1, typ(V));
     532       56308 :   for (i = 1; i < l2; ++i) gel(res, i) = gel(V,i);
     533       56308 :   gel(res,l2) = s; return res;
     534             : }
     535             : /* shallow*/
     536             : INLINE GEN
     537           0 : vec_setconst(GEN v, GEN x)
     538             : {
     539           0 :   long i, l = lg(v);
     540           0 :   for (i = 1; i < l; i++) gel(v,i) = x;
     541           0 :   return v;
     542             : }
     543             : INLINE GEN
     544      129828 : vecsmall_shorten(GEN v, long n)
     545             : {
     546             :   long i;
     547      129828 :   GEN V = cgetg(n+1,t_VECSMALL);
     548      129831 :   for(i=1;i<=n;i++) V[i] = v[i];
     549      129831 :   return V;
     550             : }
     551             : INLINE GEN
     552          21 : vecsmall_lengthen(GEN v, long n)
     553             : {
     554          21 :   long i, l = lg(v);
     555          21 :   GEN V = cgetg(n+1,t_VECSMALL);
     556          21 :   for(i=1;i<l;i++) V[i] = v[i];
     557          21 :   return V;
     558             : }
     559             : 
     560             : INLINE GEN
     561      232860 : vec_to_vecsmall(GEN z)
     562             : {
     563      232860 :   long i, l = lg(z);
     564      232860 :   GEN x = cgetg(l, t_VECSMALL);
     565      232860 :   for (i=1; i<l; i++) x[i] = itos(gel(z,i));
     566      232860 :   return x;
     567             : }
     568             : INLINE GEN
     569       21357 : vecsmall_to_vec(GEN z)
     570             : {
     571       21357 :   long i, l = lg(z);
     572       21357 :   GEN x = cgetg(l,t_VEC);
     573       21357 :   for (i=1; i<l; i++) gel(x,i) = stoi(z[i]);
     574       21357 :   return x;
     575             : }
     576             : INLINE GEN
     577         896 : vecsmall_to_vec_inplace(GEN z)
     578             : {
     579         896 :   long i, l = lg(z);
     580         896 :   for (i=1; i<l; i++) gel(z,i) = stoi(z[i]);
     581         896 :   settyp(z, t_VEC); return z;
     582             : }
     583             : INLINE GEN
     584     1269844 : vecsmall_to_col(GEN z)
     585             : {
     586     1269844 :   long i, l = lg(z);
     587     1269844 :   GEN x = cgetg(l,t_COL);
     588     1269844 :   for (i=1; i<l; i++) gel(x,i) = stoi(z[i]);
     589     1269844 :   return x;
     590             : }
     591             : 
     592             : INLINE int
     593     8165890 : vecsmall_lexcmp(GEN x, GEN y)
     594             : {
     595             :   long lx,ly,l,i;
     596     8165890 :   lx = lg(x);
     597     8165890 :   ly = lg(y); l = minss(lx,ly);
     598    51102501 :   for (i=1; i<l; i++)
     599    49430490 :     if (x[i] != y[i]) return x[i]<y[i]? -1: 1;
     600     1672011 :   if (lx == ly) return 0;
     601          14 :   return (lx < ly)? -1 : 1;
     602             : }
     603             : 
     604             : INLINE int
     605    47066978 : vecsmall_prefixcmp(GEN x, GEN y)
     606             : {
     607    47066978 :   long i, lx = lg(x), ly = lg(y), l = minss(lx,ly);
     608   148811348 :   for (i=1; i<l; i++)
     609   134951817 :     if (x[i] != y[i]) return x[i]<y[i]? -1: 1;
     610    13859531 :   return 0;
     611             : }
     612             : 
     613             : /*Can be used on t_VEC, but coeffs not gcopy-ed*/
     614             : INLINE GEN
     615        1491 : vecsmall_prepend(GEN V, long s)
     616             : {
     617        1491 :   long i, l2 = lg(V);
     618        1491 :   GEN res = cgetg(l2+1, typ(V));
     619        1491 :   res[1] = s;
     620        1491 :   for (i = 2; i <= l2; ++i) res[i] = V[i - 1];
     621        1491 :   return res;
     622             : }
     623             : 
     624             : INLINE GEN
     625      371706 : vecsmall_append(GEN V, long s)
     626             : {
     627      371706 :   long i, l2 = lg(V);
     628      371706 :   GEN res = cgetg(l2+1, t_VECSMALL);
     629      371706 :   for (i = 1; i < l2; ++i) res[i] = V[i];
     630      371706 :   res[l2] = s; return res;
     631             : }
     632             : 
     633             : INLINE GEN
     634      243324 : vecsmall_concat(GEN u, GEN v)
     635             : {
     636      243324 :   long i, l1 = lg(u)-1, l2 = lg(v)-1;
     637      243324 :   GEN res = cgetg(l1+l2+1, t_VECSMALL);
     638      243325 :   for (i = 1; i <= l1; ++i) res[i]    = u[i];
     639      243325 :   for (i = 1; i <= l2; ++i) res[i+l1] = v[i];
     640      243325 :   return res;
     641             : }
     642             : 
     643             : /* return the number of indices where u and v are equal */
     644             : INLINE long
     645           0 : vecsmall_coincidence(GEN u, GEN v)
     646             : {
     647           0 :   long i, s = 0, l = minss(lg(u),lg(v));
     648           0 :   for(i=1; i<l; i++)
     649           0 :     if(u[i] == v[i]) s++;
     650           0 :   return s;
     651             : }
     652             : 
     653             : /* returns the first index i<=n such that x=v[i] if it exists, 0 otherwise */
     654             : INLINE long
     655           0 : vecsmall_isin(GEN v, long x)
     656             : {
     657           0 :   long i, l = lg(v);
     658           0 :   for (i = 1; i < l; i++)
     659           0 :     if (v[i] == x) return i;
     660           0 :   return 0;
     661             : }
     662             : 
     663             : INLINE long
     664          84 : vecsmall_pack(GEN V, long base, long mod)
     665             : {
     666          84 :   long i, s = 0;
     667          84 :   for(i=1; i<lg(V); i++) s = (base*s + V[i]) % mod;
     668          84 :   return s;
     669             : }
     670             : 
     671             : INLINE long
     672          14 : vecsmall_indexmax(GEN x)
     673             : {
     674          14 :   long i, i0 = 1, t = x[1], lx = lg(x);
     675          56 :   for (i=2; i<lx; i++)
     676          42 :     if (x[i] > t) t = x[i0=i];
     677          14 :   return i0;
     678             : }
     679             : 
     680             : INLINE long
     681       40555 : vecsmall_max(GEN x)
     682             : {
     683       40555 :   long i, t = x[1], lx = lg(x);
     684       73564 :   for (i=2; i<lx; i++)
     685       33009 :     if (x[i] > t) t = x[i];
     686       40555 :   return t;
     687             : }
     688             : 
     689             : INLINE long
     690          14 : vecsmall_indexmin(GEN x)
     691             : {
     692          14 :   long i, i0 = 1, t = x[1], lx =lg(x);
     693          56 :   for (i=2; i<lx; i++)
     694          42 :     if (x[i] < t) t = x[i0=i];
     695          14 :   return i0;
     696             : }
     697             : 
     698             : INLINE long
     699           0 : vecsmall_min(GEN x)
     700             : {
     701           0 :   long i, t = x[1], lx =lg(x);
     702           0 :   for (i=2; i<lx; i++)
     703           0 :     if (x[i] < t) t = x[i];
     704           0 :   return t;
     705             : }
     706             : 
     707             : INLINE int
     708     2012226 : ZV_isscalar(GEN x)
     709             : {
     710     2012226 :   long l = lg(x);
     711     7456329 :   while (--l > 1)
     712     5082852 :     if (signe(gel(x, l))) return 0;
     713      361251 :   return 1;
     714             : }
     715             : INLINE int
     716     6122014 : QV_isscalar(GEN x)
     717             : {
     718     6122014 :   long lx = lg(x),i;
     719     7156440 :   for (i=2; i<lx; i++)
     720     6630881 :     if (!isintzero(gel(x, i))) return 0;
     721      525559 :   return 1;
     722             : }
     723             : INLINE int
     724        3696 : RgV_isscalar(GEN x)
     725             : {
     726        3696 :   long lx = lg(x),i;
     727        7064 :   for (i=2; i<lx; i++)
     728        6132 :     if (!gequal0(gel(x, i))) return 0;
     729         932 :   return 1;
     730             : }
     731             : INLINE int
     732           0 : RgX_isscalar(GEN x)
     733             : {
     734             :   long i;
     735           0 :   for (i=lg(x)-1; i>2; i--)
     736           0 :     if (!gequal0(gel(x, i))) return 0;
     737           0 :   return 1;
     738             : }
     739             : INLINE long
     740     3980956 : RgX_equal_var(GEN x, GEN y) { return varn(x) == varn(y) && RgX_equal(x,y); }
     741             : 
     742             : INLINE int
     743        2577 : RgX_is_rational(GEN x)
     744             : {
     745             :   long i;
     746       16821 :   for (i = lg(x)-1; i > 1; i--)
     747       15623 :     if (!is_rational_t(typ(gel(x,i)))) return 0;
     748        1198 :   return 1;
     749             : }
     750             : INLINE int
     751    55807005 : RgX_is_ZX(GEN x)
     752             : {
     753             :   long i;
     754   247675397 :   for (i = lg(x)-1; i > 1; i--)
     755   197107450 :     if (typ(gel(x,i)) != t_INT) return 0;
     756    50567947 :   return 1;
     757             : }
     758             : INLINE int
     759      161269 : RgX_is_QX(GEN x)
     760             : {
     761      161269 :   long k = lg(x)-1;
     762      631204 :   for ( ; k>1; k--)
     763      470789 :     if (!is_rational_t(typ(gel(x,k)))) return 0;
     764      160415 :   return 1;
     765             : }
     766             : INLINE int
     767    15529137 : RgX_is_monomial(GEN x)
     768             : {
     769             :   long i;
     770    15529137 :   if (!signe(x)) return 0;
     771    25668660 :   for (i=lg(x)-2; i>1; i--)
     772    17736474 :     if (!isexactzero(gel(x,i))) return 0;
     773     7932186 :   return 1;
     774             : }
     775             : INLINE int
     776     2496324 : RgV_is_ZV(GEN x)
     777             : {
     778             :   long i;
     779     8847503 :   for (i = lg(x)-1; i > 0; i--)
     780     6351900 :     if (typ(gel(x,i)) != t_INT) return 0;
     781     2495603 :   return 1;
     782             : }
     783             : INLINE int
     784         147 : RgV_is_QV(GEN x)
     785             : {
     786             :   long i;
     787         413 :   for (i = lg(x)-1; i > 0; i--)
     788         280 :     if (!is_rational_t(typ(gel(x,i)))) return 0;
     789         133 :   return 1;
     790             : }
     791             : 
     792             : /********************************************************************/
     793             : /**                                                                **/
     794             : /**            Dynamic arrays implementation                       **/
     795             : /**                                                                **/
     796             : /********************************************************************/
     797             : INLINE void **
     798   330888665 : pari_stack_base(pari_stack *s) { return s->data; }
     799             : 
     800             : INLINE void
     801      897150 : pari_stack_init(pari_stack *s, size_t size, void **data)
     802             : {
     803      897150 :   s->data = data;
     804      897150 :   *data = NULL;
     805      897150 :   s->n = 0;
     806      897150 :   s->alloc = 0;
     807      897150 :   s->size = size;
     808      897150 : }
     809             : 
     810             : INLINE void
     811   330007419 : pari_stack_alloc(pari_stack *s, long nb)
     812             : {
     813   330007419 :   void **sdat = pari_stack_base(s);
     814   330144619 :   long alloc = s->alloc;
     815   660290076 :   if (s->n+nb <= alloc) return;
     816      309391 :   if (!alloc)
     817      262418 :     alloc = nb;
     818             :   else
     819             :   {
     820       46973 :     while (s->n+nb > alloc) alloc <<= 1;
     821             :   }
     822      309391 :   *sdat = pari_realloc(*sdat,alloc*s->size);
     823      310229 :   s->alloc = alloc;
     824             : }
     825             : 
     826             : INLINE long
     827   276527616 : pari_stack_new(pari_stack *s) { pari_stack_alloc(s, 1); return s->n++; }
     828             : 
     829             : INLINE void
     830      778883 : pari_stack_delete(pari_stack *s)
     831             : {
     832      778883 :   void **sdat = pari_stack_base(s);
     833      778515 :   if (*sdat) pari_free(*sdat);
     834      778854 : }
     835             : 
     836             : INLINE void
     837        5831 : pari_stack_pushp(pari_stack *s, void *u)
     838             : {
     839        5831 :   long n = pari_stack_new(s);
     840        5831 :   void **sdat =(void**) *pari_stack_base(s);
     841        5831 :   sdat[n] = u;
     842        5831 : }
     843             : 
     844             : /*******************************************************************/
     845             : /*                                                                 */
     846             : /*                            EXTRACT                              */
     847             : /*                                                                 */
     848             : /*******************************************************************/
     849             : INLINE GEN
     850     3766383 : vecslice(GEN A, long y1, long y2)
     851             : {
     852     3766383 :   long i,lB = y2 - y1 + 2;
     853     3766383 :   GEN B = cgetg(lB, typ(A));
     854     3766383 :   for (i=1; i<lB; i++) B[i] = A[y1-1+i];
     855     3766383 :   return B;
     856             : }
     857             : INLINE GEN
     858      140628 : vecslicepermute(GEN A, GEN p, long y1, long y2)
     859             : {
     860      140628 :   long i,lB = y2 - y1 + 2;
     861      140628 :   GEN B = cgetg(lB, typ(A));
     862      140628 :   for (i=1; i<lB; i++) B[i] = A[p[y1-1+i]];
     863      140628 :   return B;
     864             : }
     865             : /* rowslice(rowpermute(A,p), x1, x2) */
     866             : INLINE GEN
     867       35210 : rowslicepermute(GEN A, GEN p, long x1, long x2)
     868             : {
     869       35210 :   long i, lB = lg(A);
     870       35210 :   GEN B = cgetg(lB, typ(A));
     871       35210 :   for (i=1; i<lB; i++) gel(B,i) = vecslicepermute(gel(A,i),p,x1,x2);
     872       35210 :   return B;
     873             : }
     874             : INLINE GEN
     875      239363 : rowslice(GEN A, long x1, long x2)
     876             : {
     877      239363 :   long i, lB = lg(A);
     878      239363 :   GEN B = cgetg(lB, typ(A));
     879      239363 :   for (i=1; i<lB; i++) gel(B,i) = vecslice(gel(A,i),x1,x2);
     880      239363 :   return B;
     881             : }
     882             : 
     883             : INLINE GEN
     884      114555 : matslice(GEN A, long x1, long x2, long y1, long y2)
     885             : {
     886      114555 :   return rowslice(vecslice(A, y1, y2), x1, x2);
     887             : }
     888             : 
     889             : /* shallow, remove coeff of index j */
     890             : INLINE GEN
     891         133 : rowsplice(GEN a, long j)
     892             : {
     893             :   long i, l;
     894         133 :   GEN b = cgetg_copy(a,&l);
     895         133 :   for (i = 1; i < l; i++) gel(b,i) = vecsplice(gel(a,i), j);
     896         133 :   return b;
     897             : }
     898             : /* shallow, remove coeff of index j */
     899             : INLINE GEN
     900        8365 : vecsplice(GEN a, long j)
     901             : {
     902        8365 :   long i, k, l = lg(a);
     903             :   GEN b;
     904        8365 :   if (l == 1) pari_err(e_MISC, "incorrect component in vecsplice");
     905        8365 :   b = cgetg(l-1, typ(a));
     906       46830 :   for (i = k = 1; i < l; i++)
     907       38465 :     if (i != j) gel(b, k++) = gel(a,i);
     908        8365 :   return b;
     909             : }
     910             : /* shallow */
     911             : INLINE GEN
     912         756 : RgM_minor(GEN a, long i, long j)
     913             : {
     914         756 :   GEN b = vecsplice(a, j);
     915         756 :   long k, l = lg(b);
     916         756 :   for (k = 1; k < l; k++) gel(b,k) = vecsplice(gel(b,k), i);
     917         756 :   return b;
     918             : }
     919             : 
     920             : /* A[x0,] */
     921             : INLINE GEN
     922      169578 : row(GEN A, long x0)
     923             : {
     924      169578 :   long i, lB = lg(A);
     925      169578 :   GEN B  = cgetg(lB, t_VEC);
     926      169578 :   for (i=1; i<lB; i++) gel(B, i) = gcoeff(A, x0, i);
     927      169578 :   return B;
     928             : }
     929             : INLINE GEN
     930       25686 : Flm_row(GEN A, long x0)
     931             : {
     932       25686 :   long i, lB = lg(A);
     933       25686 :   GEN B  = cgetg(lB, t_VECSMALL);
     934       25685 :   for (i=1; i<lB; i++) B[i] = coeff(A, x0, i);
     935       25685 :   return B;
     936             : }
     937             : /* A[x0,] */
     938             : INLINE GEN
     939          56 : rowcopy(GEN A, long x0)
     940             : {
     941          56 :   long i, lB = lg(A);
     942          56 :   GEN B  = cgetg(lB, t_VEC);
     943          56 :   for (i=1; i<lB; i++) gel(B, i) = gcopy(gcoeff(A, x0, i));
     944          56 :   return B;
     945             : }
     946             : /* A[x0, x1..x2] */
     947             : INLINE GEN
     948        2177 : row_i(GEN A, long x0, long x1, long x2)
     949             : {
     950        2177 :   long i, lB = x2 - x1 + 2;
     951        2177 :   GEN B  = cgetg(lB, t_VEC);
     952        2177 :   for (i=x1; i<=x2; i++) gel(B, i) = gcoeff(A, x0, i);
     953        2177 :   return B;
     954             : }
     955             : 
     956             : INLINE GEN
     957     4744860 : vecreverse(GEN A)
     958             : {
     959             :   long i, l;
     960     4744860 :   GEN B = cgetg_copy(A, &l);
     961     4744860 :   for (i=1; i<l; i++) gel(B, i) = gel(A, l-i);
     962     4744860 :   return B;
     963             : }
     964             : 
     965             : INLINE GEN
     966         252 : vecsmall_reverse(GEN A)
     967             : {
     968             :   long i, l;
     969         252 :   GEN B = cgetg_copy(A, &l);
     970         252 :   for (i=1; i<l; i++) B[i] = A[l-i];
     971         252 :   return B;
     972             : }
     973             : 
     974             : INLINE void
     975         232 : vecreverse_inplace(GEN y)
     976             : {
     977         232 :   long ly = lg(y), lim = ly>>1, i;
     978         640 :   for (i = 1; i <= lim; i++)
     979             :   {
     980         408 :     GEN z = gel(y,i);
     981         408 :     gel(y,i)    = gel(y,ly-i);
     982         408 :     gel(y,ly-i) = z;
     983             :   }
     984         232 : }
     985             : 
     986             : INLINE GEN
     987    20075046 : vecsmallpermute(GEN A, GEN p) { return perm_mul(A, p); }
     988             : 
     989             : INLINE GEN
     990     4357125 : vecpermute(GEN A, GEN p)
     991             : {
     992     4357125 :   long i,lB = lg(p);
     993     4357125 :   GEN B = cgetg(lB, typ(A));
     994     4357125 :   for (i=1; i<lB; i++) gel(B, i) = gel(A, p[i]);
     995     4357125 :   return B;
     996             : }
     997             : INLINE GEN
     998       86549 : rowpermute(GEN A, GEN p)
     999             : {
    1000       86549 :   long i, lB = lg(A);
    1001       86549 :   GEN B = cgetg(lB, typ(A));
    1002     1404544 :   for (i=1; i<lB; i++)
    1003     2594109 :     gel(B, i) = typ(gel(A,i)) == t_VECSMALL ? vecsmallpermute(gel(A, i), p):
    1004     1276114 :                                                     vecpermute(gel(A, i), p);
    1005       86549 :   return B;
    1006             : }
    1007             : /*******************************************************************/
    1008             : /*                                                                 */
    1009             : /*                          PERMUTATIONS                           */
    1010             : /*                                                                 */
    1011             : /*******************************************************************/
    1012             : /* identity permutation */
    1013             : INLINE GEN
    1014       74216 : identity_perm(long n)
    1015             : {
    1016       74216 :   GEN perm = cgetg(n+1, t_VECSMALL);
    1017             :   long i;
    1018       74216 :   for (i = 1; i <= n; i++) perm[i] = i;
    1019       74216 :   return perm;
    1020             : }
    1021             : 
    1022             : /* assume d <= n */
    1023             : INLINE GEN
    1024           0 : cyclic_perm(long n, long d)
    1025             : {
    1026           0 :   GEN perm = cgetg(n+1, t_VECSMALL);
    1027             :   long i;
    1028           0 :   for (i = 1; i <= n-d; i++) perm[i] = i+d;
    1029           0 :   for (     ; i <= n;   i++) perm[i] = i-n+d;
    1030           0 :   return perm;
    1031             : }
    1032             : 
    1033             : /* Multiply (compose) two permutations */
    1034             : INLINE GEN
    1035    21353127 : perm_mul(GEN s, GEN t)
    1036             : {
    1037             :   GEN u;
    1038    21353127 :   long i, l = lg(t);
    1039    21353127 :   u = cgetg(l, t_VECSMALL);
    1040    21353127 :   for (i = 1; i < l; i++) u[i] = s[ t[i] ];
    1041    21353127 :   return u;
    1042             : }
    1043             : /* Compute the inverse (reciprocal) of a permutation. */
    1044             : INLINE GEN
    1045        6356 : perm_inv(GEN x)
    1046             : {
    1047             :   long i, lx;
    1048        6356 :   GEN y = cgetg_copy(x, &lx);
    1049        6356 :   for (i=1; i<lx; i++) y[ x[i] ] = i;
    1050        6356 :   return y;
    1051             : }
    1052             : /* Return s*t*s^-1 */
    1053             : INLINE GEN
    1054      204981 : perm_conj(GEN s, GEN t)
    1055             : {
    1056             :   long i, l;
    1057      204981 :   GEN v = cgetg_copy(s, &l);
    1058      204981 :   for (i = 1; i < l; i++) v[ s[i] ] = s[ t[i] ];
    1059      204981 :   return v;
    1060             : }
    1061             : 
    1062             : /*********************************************************************/
    1063             : /*                       MALLOC/FREE WRAPPERS                        */
    1064             : /*********************************************************************/
    1065             : #define BLOCK_SIGALRM_START          \
    1066             : {                                    \
    1067             :   int block=PARI_SIGINT_block;       \
    1068             :   PARI_SIGINT_block = 2;             \
    1069             :   MT_SIGINT_BLOCK(block);
    1070             : 
    1071             : #define BLOCK_SIGINT_START           \
    1072             : {                                    \
    1073             :   int block=PARI_SIGINT_block;       \
    1074             :   PARI_SIGINT_block = 1;             \
    1075             :   MT_SIGINT_BLOCK(block);
    1076             : 
    1077             : #define BLOCK_SIGINT_END             \
    1078             :   PARI_SIGINT_block = block;         \
    1079             :   MT_SIGINT_UNBLOCK(block);          \
    1080             :   if (!block && PARI_SIGINT_pending) \
    1081             :   {                                  \
    1082             :     int sig = PARI_SIGINT_pending;   \
    1083             :     PARI_SIGINT_pending = 0;         \
    1084             :     raise(sig);                      \
    1085             :   }                                  \
    1086             : }
    1087             : 
    1088             : INLINE void
    1089    46043354 : pari_free(void *pointer)
    1090             : {
    1091    46043354 :   BLOCK_SIGINT_START;
    1092    46044383 :   free(pointer);
    1093    46044383 :   BLOCK_SIGINT_END;
    1094    46044111 : }
    1095             : INLINE void*
    1096   183544569 : pari_malloc(size_t size)
    1097             : {
    1098   183544569 :   if (size)
    1099             :   {
    1100             :     char *tmp;
    1101   183544569 :     BLOCK_SIGINT_START;
    1102   183546277 :     tmp = (char*)malloc(size);
    1103   183546277 :     BLOCK_SIGINT_END;
    1104   183546215 :     if (!tmp) pari_err(e_MEM);
    1105   183546215 :     return tmp;
    1106             :   }
    1107           0 :   if (DEBUGMEM) pari_warn(warner,"mallocing NULL object");
    1108           0 :   return NULL;
    1109             : }
    1110             : INLINE void*
    1111      314980 : pari_realloc(void *pointer, size_t size)
    1112             : {
    1113             :   char *tmp;
    1114             : 
    1115      314980 :   BLOCK_SIGINT_START;
    1116      316184 :   if (!pointer) tmp = (char *) malloc(size);
    1117       50445 :   else tmp = (char *) realloc(pointer,size);
    1118      316184 :   BLOCK_SIGINT_END;
    1119      315753 :   if (!tmp) pari_err(e_MEM);
    1120      315753 :   return tmp;
    1121             : }
    1122             : INLINE void*
    1123       30343 : pari_calloc(size_t size)
    1124             : {
    1125       30343 :   void *t = pari_malloc(size);
    1126       30343 :   memset(t, 0, size); return t;
    1127             : }
    1128             : INLINE GEN
    1129        3905 : cgetalloc(long t, size_t l)
    1130             : {
    1131        3905 :   GEN x = (GEN)pari_malloc(l * sizeof(long));
    1132        3905 :   x[0] = evaltyp(t) | evallg(l); return x;
    1133             : }
    1134             : 
    1135             : /*******************************************************************/
    1136             : /*                                                                 */
    1137             : /*                       GARBAGE COLLECTION                        */
    1138             : /*                                                                 */
    1139             : /*******************************************************************/
    1140             : /* copy integer x as if we had avma = av */
    1141             : INLINE GEN
    1142  3664795764 : icopy_avma(GEN x, pari_sp av)
    1143             : {
    1144  3664795764 :   long i = lgefint(x), lx = i;
    1145  3664795764 :   GEN y = ((GEN)av) - i;
    1146  3664795764 :   while (--i > 0) y[i] = x[i];
    1147  3664795764 :   y[0] = evaltyp(t_INT)|evallg(lx);
    1148  3664705404 :   return y;
    1149             : }
    1150             : /* copy leaf x as if we had avma = av */
    1151             : INLINE GEN
    1152    93675757 : leafcopy_avma(GEN x, pari_sp av)
    1153             : {
    1154    93675757 :   long i = lg(x);
    1155    93675757 :   GEN y = ((GEN)av) - i;
    1156    93675757 :   while (--i > 0) y[i] = x[i];
    1157    93675757 :   y[0] = x[0] & (~CLONEBIT);
    1158    93675757 :   return y;
    1159             : }
    1160             : INLINE GEN
    1161   513663888 : gerepileuptoleaf(pari_sp av, GEN x)
    1162             : {
    1163             :   long lx;
    1164             :   GEN q;
    1165             : 
    1166   513663888 :   if (!isonstack(x) || (GEN)av<=x) { avma = av; return x; }
    1167   514631490 :   lx = lg(x);
    1168   514631490 :   q = ((GEN)av) - lx;
    1169   514631490 :   avma = (pari_sp)q;
    1170   514631490 :   while (--lx >= 0) q[lx] = x[lx];
    1171   514631490 :   return q;
    1172             : }
    1173             : INLINE GEN
    1174   923008761 : gerepileuptoint(pari_sp av, GEN x)
    1175             : {
    1176   923008761 :   if (!isonstack(x) || (GEN)av<=x) { avma = av; return x; }
    1177   799218757 :   avma = (pari_sp)icopy_avma(x, av);
    1178   799529579 :   return (GEN)avma;
    1179             : }
    1180             : INLINE GEN
    1181   633467129 : gerepileupto(pari_sp av, GEN x)
    1182             : {
    1183   633467129 :   if (!isonstack(x) || (GEN)av<=x) { avma = av; return x; }
    1184   564538008 :   switch(typ(x))
    1185             :   { /* non-default = !is_recursive_t(tq) */
    1186   170500266 :     case t_INT: return gerepileuptoint(av, x);
    1187             :     case t_REAL:
    1188             :     case t_STR:
    1189   110018004 :     case t_VECSMALL: return gerepileuptoleaf(av,x);
    1190             :     default:
    1191             :       /* NB: x+i --> ((long)x) + i*sizeof(long) */
    1192   284019738 :       return gerepile(av, (pari_sp) (x+lg(x)), x);
    1193             :   }
    1194             : }
    1195             : 
    1196             : /* gerepileupto(av, gcopy(x)) */
    1197             : INLINE GEN
    1198    33510173 : gerepilecopy(pari_sp av, GEN x)
    1199             : {
    1200    33510173 :   if (is_recursive_t(typ(x)))
    1201             :   {
    1202    27399407 :     GENbin *p = copy_bin(x);
    1203    27399411 :     avma = av; return bin_copy(p);
    1204             :   }
    1205             :   else
    1206             :   {
    1207     6113449 :     avma = av;
    1208     6113449 :     if (x < (GEN)av) {
    1209     4865414 :       if (x < (GEN)pari_mainstack->bot) new_chunk(lg(x));
    1210     4865414 :       x = leafcopy_avma(x, av);
    1211     4871838 :       avma = (pari_sp)x;
    1212             :     } else
    1213     1248035 :       x = leafcopy(x);
    1214     6122391 :     return x;
    1215             :   }
    1216             : }
    1217             : 
    1218             : /* Takes an array of pointers to GENs, of length n. Copies all
    1219             :  * objects to contiguous locations and cleans up the stack between
    1220             :  * av and avma. */
    1221             : INLINE void
    1222       64813 : gerepilemany(pari_sp av, GEN* gptr[], int n)
    1223             : {
    1224             :   int i;
    1225       64813 :   for (i=0; i<n; i++) *gptr[i] = (GEN)copy_bin(*gptr[i]);
    1226       64813 :   avma = av;
    1227       64813 :   for (i=0; i<n; i++) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1228       64813 : }
    1229             : 
    1230             : INLINE void
    1231     4916617 : gerepileall(pari_sp av, int n, ...)
    1232             : {
    1233             :   int i;
    1234     4916617 :   va_list a; va_start(a, n);
    1235     4916617 :   if (n < 10)
    1236             :   {
    1237             :     GEN *gptr[10];
    1238    15078560 :     for (i=0; i<n; i++)
    1239    10161933 :     { gptr[i] = va_arg(a,GEN*); *gptr[i] = (GEN)copy_bin(*gptr[i]); }
    1240     4916627 :     avma = av;
    1241     4916627 :     for (--i; i>=0; i--) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1242             : 
    1243             :   }
    1244             :   else
    1245             :   {
    1246           0 :     GEN **gptr = (GEN**)  pari_malloc(n*sizeof(GEN*));
    1247           0 :     for (i=0; i<n; i++)
    1248           0 :     { gptr[i] = va_arg(a,GEN*); *gptr[i] = (GEN)copy_bin(*gptr[i]); }
    1249           0 :     avma = av;
    1250           0 :     for (--i; i>=0; i--) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1251           0 :     pari_free(gptr);
    1252             :   }
    1253     4916631 :   va_end(a);
    1254     4916631 : }
    1255             : 
    1256             : INLINE void
    1257           8 : gerepilecoeffs(pari_sp av, GEN x, int n)
    1258             : {
    1259             :   int i;
    1260           8 :   for (i=0; i<n; i++) gel(x,i) = (GEN)copy_bin(gel(x,i));
    1261           8 :   avma = av;
    1262           8 :   for (i=0; i<n; i++) gel(x,i) = bin_copy((GENbin*)x[i]);
    1263           8 : }
    1264             : 
    1265             : /* p from copy_bin. Copy p->x back to stack, then destroy p */
    1266             : INLINE GEN
    1267    37735112 : bin_copy(GENbin *p)
    1268             : {
    1269             :   GEN x, y, base;
    1270             :   long dx, len;
    1271             : 
    1272    37735112 :   x   = p->x; if (!x) { pari_free(p); return gen_0; }
    1273    37732528 :   len = p->len;
    1274    37732528 :   base= p->base; dx = x - base;
    1275    37732528 :   y = (GEN)memcpy((void*)new_chunk(len), (void*)GENbinbase(p), len*sizeof(long));
    1276    37732515 :   y += dx;
    1277    37732515 :   p->rebase(y, ((ulong)y-(ulong)x));
    1278    37732526 :   pari_free(p); return y;
    1279             : }
    1280             : 
    1281             : INLINE GEN
    1282    75467690 : GENbinbase(GENbin *p) { return (GEN)(p + 1); }
    1283             : 
    1284             : INLINE void
    1285    26909243 : cgiv(GEN x)
    1286             : {
    1287    26909243 :   pari_sp av = (pari_sp)(x+lg(x));
    1288    26909243 :   if (isonstack((GEN)av)) avma = av;
    1289    26909144 : }
    1290             : 
    1291             : INLINE void
    1292     1174530 : killblock(GEN x) { gunclone(x); }
    1293             : 
    1294             : INLINE int
    1295    16915868 : is_universal_constant(GEN x) { return (x >= gen_0 && x <= ghalf); }
    1296             : 
    1297             : /*******************************************************************/
    1298             : /*                                                                 */
    1299             : /*                    CONVERSION / ASSIGNMENT                      */
    1300             : /*                                                                 */
    1301             : /*******************************************************************/
    1302             : /* z is a type which may be a t_COMPLEX component (not a t_QUAD) */
    1303             : INLINE GEN
    1304     2144176 : cxcompotor(GEN z, long prec)
    1305             : {
    1306     2144176 :   switch(typ(z))
    1307             :   {
    1308     1089288 :     case t_INT:  return itor(z, prec);
    1309      134120 :     case t_FRAC: return fractor(z, prec);
    1310      920768 :     case t_REAL: return rtor(z, prec);
    1311           0 :     default: pari_err_TYPE("cxcompotor",z);
    1312             :              return NULL; /* LCOV_EXCL_LINE */
    1313             :   }
    1314             : }
    1315             : INLINE GEN
    1316     1070333 : cxtofp(GEN x, long prec)
    1317     1070333 : { retmkcomplex(cxcompotor(gel(x,1),prec), cxcompotor(gel(x,2),prec)); }
    1318             : 
    1319             : INLINE double
    1320    21241368 : gtodouble(GEN x)
    1321             : {
    1322    21241368 :   if (typ(x)!=t_REAL) {
    1323     4060866 :     pari_sp av = avma;
    1324     4060866 :     x = gtofp(x, DEFAULTPREC);
    1325     4060866 :     if (typ(x)!=t_REAL) pari_err_TYPE("gtodouble [t_REAL expected]", x);
    1326     4060866 :     avma = av;
    1327             :   }
    1328    21241368 :   return rtodbl(x);
    1329             : }
    1330             : INLINE long
    1331    66520432 : gtos(GEN x) {
    1332    66520432 :   if (typ(x) != t_INT) pari_err_TYPE("gtos [integer expected]",x);
    1333    66520425 :   return itos(x);
    1334             : }
    1335             : 
    1336             : INLINE ulong
    1337       83025 : gtou(GEN x) {
    1338       83025 :   if (typ(x) != t_INT || signe(x)<0)
    1339           0 :     pari_err_TYPE("gtou [integer >=0 expected]",x);
    1340       83253 :   return itou(x);
    1341             : }
    1342             : 
    1343             : INLINE GEN
    1344     1823953 : absfrac(GEN x)
    1345             : {
    1346     1823953 :   GEN y = cgetg(3, t_FRAC);
    1347     1823953 :   gel(y,1) = absi(gel(x,1));
    1348     1823953 :   gel(y,2) = icopy(gel(x,2)); return y;
    1349             : }
    1350             : INLINE GEN
    1351       10909 : absfrac_shallow(GEN x)
    1352       10909 : { return signe(gel(x,1))>0? x: mkfrac(negi(gel(x,1)), gel(x,2)); }
    1353             : INLINE GEN
    1354      550942 : Q_abs(GEN x) { return (typ(x) == t_INT)? absi(x): absfrac(x); }
    1355             : INLINE GEN
    1356       31799 : Q_abs_shallow(GEN x)
    1357       31799 : { return (typ(x) == t_INT)? absi_shallow(x): absfrac_shallow(x); }
    1358             : INLINE GEN
    1359         322 : R_abs_shallow(GEN x)
    1360         322 : { return (typ(x) == t_FRAC)? absfrac_shallow(x): mpabs_shallow(x); }
    1361             : INLINE GEN
    1362           0 : R_abs(GEN x)
    1363           0 : { return (typ(x) == t_FRAC)? absfrac(x): mpabs(x); }
    1364             : 
    1365             : /* Force z to be of type real/complex with floating point components */
    1366             : INLINE GEN
    1367    17620488 : gtofp(GEN z, long prec)
    1368             : {
    1369    17620488 :   switch(typ(z))
    1370             :   {
    1371     8003017 :     case t_INT:  return itor(z, prec);
    1372     4601635 :     case t_FRAC: return fractor(z, prec);
    1373     4128620 :     case t_REAL: return rtor(z, prec);
    1374             :     case t_COMPLEX: {
    1375      887216 :       GEN a = gel(z,1), b = gel(z,2);
    1376      887216 :       if (isintzero(b)) return cxcompotor(a, prec);
    1377      885501 :       if (isintzero(a)) {
    1378        1683 :         GEN y = cgetg(3, t_COMPLEX);
    1379        1683 :         b = cxcompotor(b, prec);
    1380        1683 :         gel(y,1) = real_0_bit(expo(b) - prec2nbits(prec));
    1381        1683 :         gel(y,2) = b; return y;
    1382             :       }
    1383      883818 :       return cxtofp(z, prec);
    1384             :     }
    1385           0 :     case t_QUAD: return quadtofp(z, prec);
    1386           0 :     default: pari_err_TYPE("gtofp",z);
    1387             :              return NULL; /* LCOV_EXCL_LINE */
    1388             :   }
    1389             : }
    1390             : /* Force z to be of type real / int */
    1391             : INLINE GEN
    1392       22400 : gtomp(GEN z, long prec)
    1393             : {
    1394       22400 :   switch(typ(z))
    1395             :   {
    1396          14 :     case t_INT:  return z;
    1397       22386 :     case t_FRAC: return fractor(z, prec);
    1398           0 :     case t_REAL: return rtor(z, prec);
    1399           0 :     case t_QUAD: z = quadtofp(z, prec);
    1400           0 :                  if (typ(z) == t_REAL) return z;
    1401           0 :     default: pari_err_TYPE("gtomp",z);
    1402             :              return NULL; /* LCOV_EXCL_LINE */
    1403             :   }
    1404             : }
    1405             : 
    1406             : INLINE GEN
    1407      484722 : RgX_gtofp(GEN x, long prec)
    1408             : {
    1409             :   long l;
    1410      484722 :   GEN y = cgetg_copy(x, &l);
    1411      484722 :   while (--l > 1) gel(y,l) = gtofp(gel(x,l), prec);
    1412      484722 :   y[1] = x[1]; return y;
    1413             : }
    1414             : INLINE GEN
    1415      264807 : RgC_gtofp(GEN x, long prec)
    1416             : {
    1417      264807 :   long l = lg(x);
    1418      264807 :   GEN y = cgetg(l, t_COL);
    1419      264807 :   while (--l > 0) gel(y,l) = gtofp(gel(x,l), prec);
    1420      264807 :   return y;
    1421             : }
    1422             : INLINE GEN
    1423          42 : RgV_gtofp(GEN x, long prec)
    1424             : {
    1425          42 :   long l = lg(x);
    1426          42 :   GEN y = cgetg(l, t_VEC);
    1427          42 :   while (--l > 0) gel(y,l) = gtofp(gel(x,l), prec);
    1428          42 :   return y;
    1429             : }
    1430             : INLINE GEN
    1431       18838 : RgM_gtofp(GEN x, long prec)
    1432             : {
    1433             :   long l;
    1434       18838 :   GEN y = cgetg_copy(x, &l);
    1435       18838 :   while (--l > 0) gel(y,l) = RgC_gtofp(gel(x,l), prec);
    1436       18838 :   return y;
    1437             : }
    1438             : INLINE GEN
    1439         560 : RgC_gtomp(GEN x, long prec)
    1440             : {
    1441         560 :   long l = lg(x);
    1442         560 :   GEN y = cgetg(l, t_COL);
    1443         560 :   while (--l > 0) gel(y,l) = gtomp(gel(x,l), prec);
    1444         560 :   return y;
    1445             : }
    1446             : INLINE GEN
    1447          14 : RgM_gtomp(GEN x, long prec)
    1448             : {
    1449             :   long l;
    1450          14 :   GEN y = cgetg_copy(x, &l);
    1451          14 :   while (--l > 0) gel(y,l) = RgC_gtomp(gel(x,l), prec);
    1452          14 :   return y;
    1453             : }
    1454             : 
    1455             : INLINE GEN
    1456        7232 : RgX_fpnorml2(GEN x, long prec)
    1457             : {
    1458        7232 :   pari_sp av = avma;
    1459        7232 :   return gerepileupto(av, gnorml2(RgX_gtofp(x, prec)));
    1460             : }
    1461             : INLINE GEN
    1462      132630 : RgC_fpnorml2(GEN x, long prec)
    1463             : {
    1464      132630 :   pari_sp av = avma;
    1465      132630 :   return gerepileupto(av, gnorml2(RgC_gtofp(x, prec)));
    1466             : }
    1467             : INLINE GEN
    1468        1563 : RgM_fpnorml2(GEN x, long prec)
    1469             : {
    1470        1563 :   pari_sp av = avma;
    1471        1563 :   return gerepileupto(av, gnorml2(RgM_gtofp(x, prec)));
    1472             : }
    1473             : 
    1474             : /* y a t_REAL */
    1475             : INLINE void
    1476      180482 : affgr(GEN x, GEN y)
    1477             : {
    1478             :   pari_sp av;
    1479      180482 :   switch(typ(x)) {
    1480         260 :     case t_INT:  affir(x,y); break;
    1481      180222 :     case t_REAL: affrr(x,y); break;
    1482           0 :     case t_FRAC: rdiviiz(gel(x,1),gel(x,2), y); break;
    1483           0 :     case t_QUAD: av = avma; affgr(quadtofp(x,realprec(y)), y); avma = av; break;
    1484           0 :     default: pari_err_TYPE2("=",x,y);
    1485             :   }
    1486      180482 : }
    1487             : 
    1488             : INLINE GEN
    1489      186595 : affc_fixlg(GEN x, GEN res)
    1490             : {
    1491      186595 :   if (typ(x) == t_COMPLEX)
    1492             :   {
    1493      175616 :     affrr_fixlg(gel(x,1), gel(res,1));
    1494      175616 :     affrr_fixlg(gel(x,2), gel(res,2));
    1495             :   }
    1496             :   else
    1497             :   {
    1498       10979 :     avma = (pari_sp)(res+3);
    1499       10979 :     res = cgetr(realprec(gel(res,1)));
    1500       10979 :     affrr_fixlg(x, res);
    1501             :   }
    1502      186595 :   return res;
    1503             : }
    1504             : 
    1505             : INLINE GEN
    1506           0 : trunc_safe(GEN x) { long e; return gcvtoi(x,&e); }
    1507             : 
    1508             : /*******************************************************************/
    1509             : /*                                                                 */
    1510             : /*                          LENGTH CONVERSIONS                     */
    1511             : /*                                                                 */
    1512             : /*******************************************************************/
    1513             : INLINE long
    1514       23049 : ndec2nlong(long x) { return 1 + (long)((x)*(LOG2_10/BITS_IN_LONG)); }
    1515             : INLINE long
    1516       22587 : ndec2prec(long x) { return 2 + ndec2nlong(x); }
    1517             : INLINE long
    1518         462 : ndec2nbits(long x) { return ndec2nlong(x) << TWOPOTBITS_IN_LONG; }
    1519             : /* Fast implementation of ceil(x / (8*sizeof(long))); typecast to (ulong)
    1520             :  * to avoid overflow. Faster than 1 + ((x-1)>>TWOPOTBITS_IN_LONG)) :
    1521             :  *   addl, shrl instead of subl, sarl, addl */
    1522             : INLINE long
    1523     1005773 : nbits2nlong(long x) {
    1524     1005773 :   return (long)(((ulong)x+BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1525             : }
    1526             : 
    1527             : INLINE long
    1528   240317725 : nbits2extraprec(long x) {
    1529   240317725 :   return (long)(((ulong)x+BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1530             : }
    1531             : 
    1532             : /* Fast implementation of 2 + nbits2nlong(x) */
    1533             : INLINE long
    1534    74955407 : nbits2prec(long x) {
    1535    74955407 :   return (long)(((ulong)x+3*BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1536             : }
    1537             : INLINE long
    1538     3311278 : nbits2lg(long x) {
    1539     3311278 :   return (long)(((ulong)x+3*BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1540             : }
    1541             : /* ceil(x / sizeof(long)) */
    1542             : INLINE long
    1543     6925940 : nchar2nlong(long x) {
    1544     6925940 :   return (long)(((ulong)x+sizeof(long)-1) >> (TWOPOTBITS_IN_LONG-3L));
    1545             : }
    1546             : INLINE long
    1547  1180057089 : prec2nbits(long x) { return (x-2) * BITS_IN_LONG; }
    1548             : INLINE double
    1549      453973 : bit_accuracy_mul(long x, double y) { return (x-2) * (BITS_IN_LONG*y); }
    1550             : INLINE double
    1551      229912 : prec2nbits_mul(long x, double y) { return (x-2) * (BITS_IN_LONG*y); }
    1552             : INLINE long
    1553    23756005 : bit_prec(GEN x) { return prec2nbits(realprec(x)); }
    1554             : INLINE long
    1555  1100928867 : bit_accuracy(long x) { return prec2nbits(x); }
    1556             : INLINE long
    1557       12134 : prec2ndec(long x) { return (long)prec2nbits_mul(x, LOG10_2); }
    1558             : INLINE long
    1559         179 : nbits2ndec(long x) { return (long)(x * LOG10_2); }
    1560             : INLINE long
    1561        1650 : precdbl(long x) {return (x - 1) << 1;}
    1562             : INLINE long
    1563  2875702669 : divsBIL(long n) { return n >> TWOPOTBITS_IN_LONG; }
    1564             : INLINE long
    1565  2811243474 : remsBIL(long n) { return n & (BITS_IN_LONG-1); }
    1566             : 
    1567             : /*********************************************************************/
    1568             : /**                                                                 **/
    1569             : /**                      OPERATIONS MODULO m                        **/
    1570             : /**                                                                 **/
    1571             : /*********************************************************************/
    1572             : /* Assume m > 0, more efficient if 0 <= a, b < m */
    1573             : 
    1574             : INLINE GEN
    1575     1723303 : Fp_red(GEN a, GEN m) { return modii(a, m); }
    1576             : INLINE GEN
    1577    60110796 : Fp_add(GEN a, GEN b, GEN m)
    1578             : {
    1579    60110796 :   pari_sp av=avma;
    1580    60110796 :   GEN p = addii(a,b);
    1581    60092157 :   long s = signe(p);
    1582    60092157 :   if (!s) return p; /* = gen_0 */
    1583    49444895 :   if (s > 0) /* general case */
    1584             :   {
    1585    49222784 :     GEN t = subii(p, m);
    1586    49237165 :     s = signe(t);
    1587    49237165 :     if (!s) { avma = av; return gen_0; }
    1588    43778305 :     if (s < 0) { avma = (pari_sp)p; return p; }
    1589    17044905 :     if (cmpii(t, m) < 0) return gerepileuptoint(av, t); /* general case ! */
    1590     1123357 :     p = remii(t, m);
    1591             :   }
    1592             :   else
    1593      222111 :     p = modii(p, m);
    1594     1345468 :   return gerepileuptoint(av, p);
    1595             : }
    1596             : INLINE GEN
    1597    45944557 : Fp_sub(GEN a, GEN b, GEN m)
    1598             : {
    1599    45944557 :   pari_sp av=avma;
    1600    45944557 :   GEN p = subii(a,b);
    1601    46021088 :   long s = signe(p);
    1602    46021088 :   if (!s) return p; /* = gen_0 */
    1603    38399604 :   if (s > 0)
    1604             :   {
    1605    18694386 :     if (cmpii(p, m) < 0) return p; /* general case ! */
    1606      742259 :     p = remii(p, m);
    1607             :   }
    1608             :   else
    1609             :   {
    1610    19705218 :     GEN t = addii(p, m);
    1611    19697002 :     if (!s) { avma = av; return gen_0; }
    1612    19697002 :     if (s > 0) return gerepileuptoint(av, t); /* general case ! */
    1613    19697002 :     p = modii(t, m);
    1614             :   }
    1615    20429086 :   return gerepileuptoint(av, p);
    1616             : }
    1617             : INLINE GEN
    1618    10717621 : Fp_neg(GEN b, GEN m)
    1619             : {
    1620    10717621 :   pari_sp av = avma;
    1621    10717621 :   long s = signe(b);
    1622             :   GEN p;
    1623    10717621 :   if (!s) return gen_0;
    1624     7385892 :   if (s > 0)
    1625             :   {
    1626     7204526 :     p = subii(m, b);
    1627     7204297 :     if (signe(p) >= 0) return p; /* general case ! */
    1628       74635 :     p = modii(p, m);
    1629             :   } else
    1630      181366 :     p = remii(negi(b), m);
    1631      256001 :   return gerepileuptoint(av, p);
    1632             : }
    1633             : 
    1634             : INLINE GEN
    1635       19786 : Fp_halve(GEN a, GEN p)
    1636             : {
    1637       19786 :   if (mpodd(a)) a = addii(a,p);
    1638       19786 :   return shifti(a,-1);
    1639             : }
    1640             : 
    1641             : /* assume 0 <= u < p and ps2 = p>>1 */
    1642             : INLINE GEN
    1643     5070776 : Fp_center(GEN u, GEN p, GEN ps2)
    1644     5070776 : { return abscmpii(u,ps2)<=0? icopy(u): subii(u,p); }
    1645             : 
    1646             : /* x + y*z mod p */
    1647             : INLINE GEN
    1648     1507863 : Fp_addmul(GEN x, GEN y, GEN z, GEN p)
    1649             : {
    1650             :   pari_sp av;
    1651     1507863 :   if (!signe(y) || !signe(z)) return Fp_red(x, p);
    1652     1507590 :   if (!signe(x)) return Fp_mul(z,y, p);
    1653     1215767 :   av = avma;
    1654     1215767 :   return gerepileuptoint(av, modii(addii(x, mulii(y,z)), p));
    1655             : }
    1656             : 
    1657             : INLINE GEN
    1658    48013170 : Fp_mul(GEN a, GEN b, GEN m)
    1659             : {
    1660    48013170 :   pari_sp av=avma;
    1661             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1662    48013170 :   (void)new_chunk(lg(a)+lg(b)+(lg(m)<<1));
    1663    48014182 :   p = mulii(a,b);
    1664    48012851 :   avma = av; return modii(p,m);
    1665             : }
    1666             : INLINE GEN
    1667     6996462 : Fp_sqr(GEN a, GEN m)
    1668             : {
    1669     6996462 :   pari_sp av=avma;
    1670             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1671     6996462 :   (void)new_chunk((lg(a)+lg(m))<<1);
    1672     7028390 :   p = sqri(a);
    1673     7055216 :   avma = av; return modii(p,m);
    1674             : }
    1675             : INLINE GEN
    1676    44045887 : Fp_mulu(GEN a, ulong b, GEN m)
    1677             : {
    1678    44045887 :   long l = lgefint(m);
    1679    44045887 :   if (l == 3)
    1680             :   {
    1681    31322886 :     ulong mm = m[2];
    1682    31322886 :     return utoi( Fl_mul(umodiu(a, mm), b, mm) );
    1683             :   } else {
    1684    12723001 :     pari_sp av = avma;
    1685             :     GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1686    12723001 :     (void)new_chunk(lg(a)+1+(l<<1));
    1687    12735308 :     p = muliu(a,b);
    1688    12490641 :     avma = av; return modii(p,m);
    1689             :   }
    1690             : }
    1691             : INLINE GEN
    1692           0 : Fp_muls(GEN a, long b, GEN m)
    1693             : {
    1694           0 :   long l = lgefint(m);
    1695           0 :   if (l == 3)
    1696             :   {
    1697           0 :     ulong mm = m[2];
    1698           0 :     if (b < 0)
    1699             :     {
    1700           0 :       ulong t = Fl_mul(umodiu(a, mm), -b, mm);
    1701           0 :       return t? utoipos(mm - t): gen_0;
    1702             :     }
    1703             :     else
    1704           0 :       return utoi( Fl_mul(umodiu(a, mm), b, mm) );
    1705             :   } else {
    1706           0 :     pari_sp av = avma;
    1707             :     GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1708           0 :     (void)new_chunk(lg(a)+1+(l<<1));
    1709           0 :     p = mulis(a,b);
    1710           0 :     avma = av; return modii(p,m);
    1711             :   }
    1712             : }
    1713             : 
    1714             : INLINE GEN
    1715     7601073 : Fp_inv(GEN a, GEN m)
    1716             : {
    1717             :   GEN res;
    1718     7601073 :   if (! invmod(a,m,&res)) pari_err_INV("Fp_inv", mkintmod(res,m));
    1719     7588988 :   return res;
    1720             : }
    1721             : INLINE GEN
    1722      290489 : Fp_invsafe(GEN a, GEN m)
    1723             : {
    1724             :   GEN res;
    1725      290489 :   if (! invmod(a,m,&res)) return NULL;
    1726      290489 :   return res;
    1727             : }
    1728             : INLINE GEN
    1729     4617971 : Fp_div(GEN a, GEN b, GEN m)
    1730             : {
    1731     4617971 :   pari_sp av=avma;
    1732             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1733     4617971 :   (void)new_chunk(lg(a)+(lg(m)<<1));
    1734     4625662 :   p = mulii(a, Fp_inv(b,m));
    1735     4630171 :   avma = av; return modii(p,m);
    1736             : }
    1737             : 
    1738             : INLINE GEN
    1739      665925 : Flx_mulu(GEN x, ulong a, ulong p) { return Flx_Fl_mul(x,a%p,p); }
    1740             : 
    1741             : /*******************************************************************/
    1742             : /*                                                                 */
    1743             : /*                        ADDMULII / SUBMULII                      */
    1744             : /*                                                                 */
    1745             : /*******************************************************************/
    1746             : /* x - y*z */
    1747             : INLINE GEN
    1748    13414807 : submulii(GEN x, GEN y, GEN z)
    1749             : {
    1750    13414807 :   long lx = lgefint(x), ly, lz;
    1751             :   pari_sp av;
    1752             :   GEN t;
    1753    13414807 :   if (lx == 2) { t = mulii(z,y); togglesign(t); return t; }
    1754    11609358 :   ly = lgefint(y);
    1755    11609358 :   if (ly == 2) return icopy(x);
    1756    10615111 :   lz = lgefint(z);
    1757    10615111 :   av = avma; (void)new_chunk(lx+ly+lz); /* HACK */
    1758    10615111 :   t = mulii(z, y);
    1759    10615111 :   avma = av; return subii(x,t);
    1760             : }
    1761             : /* y*z - x */
    1762             : INLINE GEN
    1763     2249139 : mulsubii(GEN y, GEN z, GEN x)
    1764             : {
    1765     2249139 :   long lx = lgefint(x), ly, lz;
    1766             :   pari_sp av;
    1767             :   GEN t;
    1768     2249139 :   if (lx == 2) return mulii(z,y);
    1769     1398904 :   ly = lgefint(y);
    1770     1398904 :   if (ly == 2) return negi(x);
    1771     1348235 :   lz = lgefint(z);
    1772     1348235 :   av = avma; (void)new_chunk(lx+ly+lz); /* HACK */
    1773     1348235 :   t = mulii(z, y);
    1774     1348235 :   avma = av; return subii(t,x);
    1775             : }
    1776             : 
    1777             : /* x - u*y */
    1778             : INLINE GEN
    1779        7000 : submuliu(GEN x, GEN y, ulong u)
    1780             : {
    1781             :   pari_sp av;
    1782        7000 :   long ly = lgefint(y);
    1783        7000 :   if (ly == 2) return icopy(x);
    1784        7000 :   av = avma;
    1785        7000 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1786        7000 :   y = mului(u,y);
    1787        7000 :   avma = av; return subii(x, y);
    1788             : }
    1789             : /* x + u*y */
    1790             : INLINE GEN
    1791        7000 : addmuliu(GEN x, GEN y, ulong u)
    1792             : {
    1793             :   pari_sp av;
    1794        7000 :   long ly = lgefint(y);
    1795        7000 :   if (ly == 2) return icopy(x);
    1796        7000 :   av = avma;
    1797        7000 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1798        7000 :   y = mului(u,y);
    1799        7000 :   avma = av; return addii(x, y);
    1800             : }
    1801             : /* x - u*y */
    1802             : INLINE GEN
    1803   110361828 : submuliu_inplace(GEN x, GEN y, ulong u)
    1804             : {
    1805             :   pari_sp av;
    1806   110361828 :   long ly = lgefint(y);
    1807   110361828 :   if (ly == 2) return x;
    1808    88449687 :   av = avma;
    1809    88449687 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1810    88449687 :   y = mului(u,y);
    1811    88449687 :   avma = av; return subii(x, y);
    1812             : }
    1813             : /* x + u*y */
    1814             : INLINE GEN
    1815   109014313 : addmuliu_inplace(GEN x, GEN y, ulong u)
    1816             : {
    1817             :   pari_sp av;
    1818   109014313 :   long ly = lgefint(y);
    1819   109014313 :   if (ly == 2) return x;
    1820    88092795 :   av = avma;
    1821    88092795 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1822    88092795 :   y = mului(u,y);
    1823    88092795 :   avma = av; return addii(x, y);
    1824             : }
    1825             : /* ux + vy */
    1826             : INLINE GEN
    1827    26127860 : lincombii(GEN u, GEN v, GEN x, GEN y)
    1828             : {
    1829    26127860 :   long lx = lgefint(x), ly;
    1830             :   GEN p1, p2;
    1831             :   pari_sp av;
    1832    26127860 :   if (lx == 2) return mulii(v,y);
    1833    15932025 :   ly = lgefint(y);
    1834    15932025 :   if (ly == 2) return mulii(u,x);
    1835    14753594 :   av = avma; (void)new_chunk(lx+ly+lgefint(u)+lgefint(v)); /* HACK */
    1836    14753594 :   p1 = mulii(u,x);
    1837    14753594 :   p2 = mulii(v,y);
    1838    14753594 :   avma = av; return addii(p1,p2);
    1839             : }
    1840             : 
    1841             : /*******************************************************************/
    1842             : /*                                                                 */
    1843             : /*                          GEN SUBTYPES                           */
    1844             : /*                                                                 */
    1845             : /*******************************************************************/
    1846             : 
    1847             : INLINE int
    1848  1079062266 : is_const_t(long t) { return (t < t_POLMOD); }
    1849             : INLINE int
    1850       45205 : is_extscalar_t(long t) { return (t <= t_POL); }
    1851             : INLINE int
    1852      928229 : is_intreal_t(long t) { return (t <= t_REAL); }
    1853             : INLINE int
    1854   357819846 : is_matvec_t(long t) { return (t >= t_VEC && t <= t_MAT); }
    1855             : INLINE int
    1856    51719034 : is_noncalc_t(long tx) { return (tx) >= t_LIST; }
    1857             : INLINE int
    1858      585156 : is_rational_t(long t) { return (t == t_INT || t == t_FRAC); }
    1859             : INLINE int
    1860      299211 : is_real_t(long t) { return (t == t_INT || t == t_REAL || t == t_FRAC); }
    1861             : INLINE int
    1862  2539751879 : is_recursive_t(long t) { return lontyp[t]; }
    1863             : INLINE int
    1864   159661633 : is_scalar_t(long t) { return (t < t_POL); }
    1865             : INLINE int
    1866      472312 : is_vec_t(long t) { return (t == t_VEC || t == t_COL); }
    1867             : 
    1868             : /*******************************************************************/
    1869             : /*                                                                 */
    1870             : /*                         TRANSCENDENTAL                          */
    1871             : /*                                                                 */
    1872             : /*******************************************************************/
    1873             : INLINE GEN
    1874    15713248 : sqrtr(GEN x) {
    1875    15713248 :   long s = signe(x);
    1876    15713248 :   if (s == 0) return real_0_bit(expo(x) >> 1);
    1877    15679680 :   if (s >= 0) return sqrtr_abs(x);
    1878       13409 :   retmkcomplex(gen_0, sqrtr_abs(x));
    1879             : }
    1880             : INLINE GEN
    1881           0 : cbrtr_abs(GEN x) { return sqrtnr_abs(x, 3); }
    1882             : INLINE GEN
    1883           0 : cbrtr(GEN x) {
    1884           0 :   long s = signe(x);
    1885             :   GEN r;
    1886           0 :   if (s == 0) return real_0_bit(expo(x) / 3);
    1887           0 :   r = cbrtr_abs(x);
    1888           0 :   if (s < 0) togglesign(r);
    1889           0 :   return r;
    1890             : }
    1891             : INLINE GEN
    1892      290816 : sqrtnr(GEN x, long n) {
    1893      290816 :   long s = signe(x);
    1894             :   GEN r;
    1895      290816 :   if (s == 0) return real_0_bit(expo(x) / n);
    1896      290816 :   r = sqrtnr_abs(x, n);
    1897      290816 :   if (s < 0) pari_err_IMPL("sqrtnr for x < 0");
    1898      290816 :   return r;
    1899             : }
    1900             : INLINE long
    1901      398803 : logint(GEN B, GEN y) { return logintall(B,y,NULL); }
    1902             : 
    1903             : /*******************************************************************/
    1904             : /*                                                                 */
    1905             : /*                         MISCELLANEOUS                           */
    1906             : /*                                                                 */
    1907             : /*******************************************************************/
    1908      928152 : INLINE int ismpzero(GEN x) { return is_intreal_t(typ(x)) && !signe(x); }
    1909   358743568 : INLINE int isintzero(GEN x) { return typ(x) == t_INT && !signe(x); }
    1910     6920424 : INLINE int isint1(GEN x) { return typ(x)==t_INT && equali1(x); }
    1911         301 : INLINE int isintm1(GEN x){ return typ(x)==t_INT && equalim1(x);}
    1912   217160056 : INLINE int equali1(GEN n)
    1913   217160056 : { return (ulong) n[1] == (evallgefint(3UL) | evalsigne(1)) && n[2] == 1; }
    1914    23549439 : INLINE int equalim1(GEN n)
    1915    23549439 : { return (ulong) n[1] == (evallgefint(3UL) | evalsigne(-1)) && n[2] == 1; }
    1916             : /* works only for POSITIVE integers */
    1917  1399718287 : INLINE int is_pm1(GEN n)
    1918  1399718287 : { return lgefint(n) == 3 && n[2] == 1; }
    1919   125912991 : INLINE int is_bigint(GEN n)
    1920   125912991 : { long l = lgefint(n); return l > 3 || (l == 3 && (n[2] & HIGHBIT)); }
    1921             : 
    1922  1319550115 : INLINE int odd(long x) { return x & 1; }
    1923     7446874 : INLINE int both_odd(long x, long y) { return x & y & 1; }
    1924             : 
    1925             : INLINE int
    1926  2097063248 : isonstack(GEN x)
    1927  4194126496 : { return ((pari_sp)x >= pari_mainstack->bot
    1928  2097063248 :        && (pari_sp)x <  pari_mainstack->top); }
    1929             : 
    1930             : /* assume x != 0 and x t_REAL, return an approximation to log2(|x|) */
    1931             : INLINE double
    1932    17019559 : dbllog2r(GEN x)
    1933    17019559 : { return log2((double)(ulong)x[2]) + (double)(expo(x) - (BITS_IN_LONG-1)); }
    1934             : 
    1935             : INLINE GEN
    1936      212958 : mul_content(GEN cx, GEN cy)
    1937             : {
    1938      212958 :   if (!cx) return cy;
    1939       51520 :   if (!cy) return cx;
    1940       36377 :   return gmul(cx,cy);
    1941             : }
    1942             : INLINE GEN
    1943      435882 : mul_denom(GEN dx, GEN dy)
    1944             : {
    1945      435882 :   if (!dx) return dy;
    1946      317727 :   if (!dy) return dx;
    1947      126973 :   return mulii(dx,dy);
    1948             : }
    1949             : 
    1950             : /* POLYNOMIALS */
    1951             : INLINE GEN
    1952    17561129 : constant_coeff(GEN x) { return signe(x)? gel(x,2): gen_0; }
    1953             : INLINE GEN
    1954    73534048 : leading_coeff(GEN x) { return lg(x) == 2? gen_0: gel(x,lg(x)-1); }
    1955             : INLINE ulong
    1956      406828 : Flx_lead(GEN x) { return lg(x) == 2? 0: x[lg(x)-1]; }
    1957             : INLINE long
    1958  2441673973 : degpol(GEN x) { return lg(x)-3; }
    1959             : INLINE long
    1960  1286787878 : lgpol(GEN x) { return lg(x)-2; }
    1961             : INLINE long
    1962    59784941 : lgcols(GEN x) { return lg(gel(x,1)); }
    1963             : INLINE long
    1964    14399944 : nbrows(GEN x) { return lg(gel(x,1))-1; }
    1965             : INLINE GEN
    1966           0 : truecoeff(GEN x, long n) { return polcoeff0(x,n,-1); }
    1967             : 
    1968             : INLINE GEN
    1969      478687 : RgXQ_mul(GEN y, GEN x, GEN T) { return RgX_rem(RgX_mul(y, x), T); }
    1970             : INLINE GEN
    1971      242287 : RgXQ_sqr(GEN x, GEN T) { return RgX_rem(RgX_sqr(x), T); }
    1972             : 
    1973             : INLINE GEN
    1974      117698 : ZXQ_mul(GEN y, GEN x, GEN T) { return ZX_rem(ZX_mul(y, x), T); }
    1975             : INLINE GEN
    1976       20986 : ZXQ_sqr(GEN x, GEN T) { return ZX_rem(ZX_sqr(x), T); }
    1977             : 
    1978             : INLINE GEN
    1979    64090588 : RgX_copy(GEN x)
    1980             : {
    1981             :   long lx, i;
    1982    64090588 :   GEN y = cgetg_copy(x, &lx); y[1] = x[1];
    1983    64090588 :   for (i = 2; i<lx; i++) gel(y,i) = gcopy(gel(x,i));
    1984    64090588 :   return y;
    1985             : }
    1986             : /* have to use ulong to avoid silly warnings from gcc "assuming signed
    1987             :  * overflow does not occur" */
    1988             : INLINE GEN
    1989     2225280 : RgX_coeff(GEN x, long n)
    1990             : {
    1991     2225280 :   ulong l = lg(x);
    1992     2225280 :   return (n < 0 || ((ulong)n+3) > l)? gen_0: gel(x,n+2);
    1993             : }
    1994             : INLINE GEN
    1995      316001 : RgX_renormalize(GEN x) { return RgX_renormalize_lg(x, lg(x)); }
    1996             : INLINE GEN
    1997     6366397 : RgX_div(GEN x, GEN y) { return RgX_divrem(x,y,NULL); }
    1998             : INLINE GEN
    1999     2542144 : RgX_rem(GEN x, GEN y) { return RgX_divrem(x,y,ONLY_REM); }
    2000             : INLINE GEN
    2001           7 : RgXQX_div(GEN x, GEN y, GEN T) { return RgXQX_divrem(x,y,T,NULL); }
    2002             : INLINE GEN
    2003       17192 : RgXQX_rem(GEN x, GEN y, GEN T) { return RgXQX_divrem(x,y,T,ONLY_REM); }
    2004             : INLINE GEN
    2005      745339 : FpX_div(GEN x, GEN y, GEN p) { return FpX_divrem(x,y,p, NULL); }
    2006             : INLINE GEN
    2007     3081978 : Flx_div(GEN x, GEN y, ulong p) { return Flx_divrem(x,y,p, NULL); }
    2008             : INLINE GEN
    2009     2859621 : F2x_div(GEN x, GEN y) { return F2x_divrem(x,y, NULL); }
    2010             : INLINE GEN
    2011           0 : FpV_FpC_mul(GEN x, GEN y, GEN p) { return FpV_dotproduct(x,y,p); }
    2012             : INLINE GEN
    2013    43502282 : pol0_Flx(long sv) { return mkvecsmall(sv); }
    2014             : INLINE GEN
    2015    17474021 : pol1_Flx(long sv) { return mkvecsmall2(sv, 1); }
    2016             : INLINE GEN
    2017    16766725 : polx_Flx(long sv) { return mkvecsmall3(sv, 0, 1); }
    2018             : INLINE GEN
    2019           0 : zero_zx(long sv) { return zero_Flx(sv); }
    2020             : INLINE GEN
    2021           0 : polx_zx(long sv) { return polx_Flx(sv); }
    2022             : INLINE GEN
    2023           0 : zx_shift(GEN x, long n) { return Flx_shift(x,n); }
    2024             : INLINE GEN
    2025           0 : zx_renormalize(GEN x, long l) { return Flx_renormalize(x,l); }
    2026             : INLINE GEN
    2027          35 : zero_F2x(long sv) { return zero_Flx(sv); }
    2028             : INLINE GEN
    2029    10877567 : pol0_F2x(long sv) { return pol0_Flx(sv); }
    2030             : INLINE GEN
    2031     2645681 : pol1_F2x(long sv) { return pol1_Flx(sv); }
    2032             : INLINE GEN
    2033      655716 : polx_F2x(long sv) { return mkvecsmall2(sv, 2); }
    2034             : INLINE int
    2035      790510 : F2x_equal1(GEN x) { return Flx_equal1(x); }
    2036             : INLINE int
    2037     3337314 : F2x_equal(GEN V, GEN W) { return Flx_equal(V,W); }
    2038             : INLINE GEN
    2039    66440487 : F2x_copy(GEN x) { return leafcopy(x); }
    2040             : INLINE GEN
    2041           0 : F2v_copy(GEN x) { return leafcopy(x); }
    2042             : INLINE GEN
    2043     2274694 : Flv_copy(GEN x) { return leafcopy(x); }
    2044             : INLINE GEN
    2045    74339980 : Flx_copy(GEN x) { return leafcopy(x); }
    2046             : INLINE GEN
    2047     1624733 : vecsmall_copy(GEN x) { return leafcopy(x); }
    2048             : INLINE int
    2049     4642868 : Flx_equal1(GEN x) { return degpol(x)==0 && x[2] == 1; }
    2050             : INLINE int
    2051       18056 : ZX_equal1(GEN x) { return degpol(x)==0 && equali1(gel(x,2)); }
    2052             : 
    2053             : INLINE GEN
    2054    73917355 : ZX_renormalize(GEN x, long lx)    { return ZXX_renormalize(x,lx); }
    2055             : INLINE GEN
    2056    87151844 : FpX_renormalize(GEN x, long lx)   { return ZXX_renormalize(x,lx); }
    2057             : INLINE GEN
    2058      949206 : FpXX_renormalize(GEN x, long lx)  { return ZXX_renormalize(x,lx); }
    2059             : INLINE GEN
    2060      988382 : FpXQX_renormalize(GEN x, long lx) { return ZXX_renormalize(x,lx); }
    2061             : INLINE GEN
    2062   126336253 : F2x_renormalize(GEN x, long lx)   { return Flx_renormalize(x,lx); }
    2063             : INLINE GEN
    2064        7187 : F2v_to_F2x(GEN x, long sv) {
    2065        7187 :   GEN y = leafcopy(x);
    2066        7187 :   y[1] = sv; F2x_renormalize(y, lg(y)); return y;
    2067             : }
    2068             : 
    2069             : INLINE GEN
    2070           0 : ZX_ZXY_resultant(GEN a, GEN b) { return ZX_ZXY_rnfequation(a,b,NULL); }
    2071             : INLINE long
    2072         448 : sturm(GEN x) { return sturmpart(x, NULL, NULL); }
    2073             : INLINE GEN
    2074       34989 : resultant(GEN x, GEN y) { return resultant_all(x,y,NULL); }
    2075             : 
    2076             : INLINE long
    2077        2205 : gval(GEN x, long v) {
    2078        2205 :   pari_sp av = avma;
    2079        2205 :   long n = gvaluation(x, pol_x(v));
    2080        2205 :   avma = av; return n;
    2081             : }
    2082             : 
    2083             : INLINE void
    2084      586413 : RgX_shift_inplace_init(long v)
    2085      586413 : { if (v) (void)cgetg(v, t_VECSMALL); }
    2086             : /* shift polynomial in place. assume v free cells have been left before x */
    2087             : INLINE GEN
    2088      586412 : RgX_shift_inplace(GEN x, long v)
    2089             : {
    2090             :   long i, lx;
    2091             :   GEN y, z;
    2092      586412 :   if (!v) return x;
    2093      258725 :   lx = lg(x);
    2094      258725 :   if (lx == 2) return x;
    2095      258725 :   y = x + v;
    2096      258725 :   z = x + lx;
    2097             :   /* stackdummy from normalizepol: move it up */
    2098      258725 :   if (lg(z) != v) x[lx + v] = z[0];
    2099      258725 :   for (i = lx-1; i >= 2; i--) gel(y,i) = gel(x,i);
    2100      258725 :   for (i = v+1;  i >= 2; i--) gel(x,i) = gen_0;
    2101             :   /* leave x[1] alone: it is correct */
    2102      258725 :   x[0] = evaltyp(t_POL) | evallg(lx+v); return x;
    2103             : }
    2104             : 
    2105             : 
    2106             : /* LINEAR ALGEBRA */
    2107             : INLINE GEN
    2108       18207 : zv_to_ZV(GEN x) { return vecsmall_to_vec(x); }
    2109             : INLINE GEN
    2110     1232835 : zc_to_ZC(GEN x) { return vecsmall_to_col(x); }
    2111             : INLINE GEN
    2112      221954 : ZV_to_zv(GEN x) { return vec_to_vecsmall(x); }
    2113             : INLINE GEN
    2114           0 : zx_to_zv(GEN x, long N) { return Flx_to_Flv(x,N); }
    2115             : INLINE GEN
    2116           0 : zv_to_zx(GEN x, long sv) { return Flv_to_Flx(x,sv); }
    2117             : INLINE GEN
    2118           0 : zm_to_zxV(GEN x, long sv) { return Flm_to_FlxV(x,sv); }
    2119             : INLINE GEN
    2120           0 : zero_zm(long x, long y) { return zero_Flm(x,y); }
    2121             : INLINE GEN
    2122    16304817 : zero_zv(long x) { return zero_Flv(x); }
    2123             : INLINE GEN
    2124         168 : zm_transpose(GEN x) { return Flm_transpose(x); }
    2125             : INLINE GEN
    2126           0 : zm_copy(GEN x) { return Flm_copy(x); }
    2127             : INLINE GEN
    2128     1975584 : zv_copy(GEN x) { return Flv_copy(x); }
    2129             : INLINE GEN
    2130           0 : zm_row(GEN x, long i) { return Flm_row(x,i); }
    2131             : 
    2132             : INLINE GEN
    2133      784760 : ZC_hnfrem(GEN x, GEN y) { return ZC_hnfremdiv(x,y,NULL); }
    2134             : INLINE GEN
    2135       23454 : ZM_hnfrem(GEN x, GEN y) { return ZM_hnfdivrem(x,y,NULL); }
    2136             : INLINE GEN
    2137     1230100 : ZM_lll(GEN x, double D, long f) { return ZM_lll_norms(x,D,f,NULL); }
    2138             : INLINE void
    2139      107524 : RgM_dimensions(GEN x, long *m, long *n) { *n = lg(x)-1; *m = *n? nbrows(x): 0; }
    2140             : INLINE GEN
    2141       24488 : RgM_inv(GEN a) { return RgM_solve(a, NULL); }
    2142             : INLINE GEN
    2143     7886355 : RgM_shallowcopy(GEN x)
    2144             : {
    2145             :   long l;
    2146     7886355 :   GEN y = cgetg_copy(x, &l);
    2147     7886355 :   while (--l > 0) gel(y,l) = leafcopy(gel(x,l));
    2148     7886355 :   return y;
    2149             : }
    2150             : INLINE GEN
    2151        1740 : F2m_copy(GEN x) { return RgM_shallowcopy(x); }
    2152             : 
    2153             : INLINE GEN
    2154      865028 : Flm_copy(GEN x) { return RgM_shallowcopy(x); }
    2155             : 
    2156             : /* divisibility: return 1 if y[i] | x[i] for all i, 0 otherwise. Assume
    2157             :  * x,y are ZV of the same length */
    2158             : INLINE int
    2159       23198 : ZV_dvd(GEN x, GEN y)
    2160             : {
    2161       23198 :   long i, l = lg(x);
    2162       36652 :   for (i=1; i < l; i++)
    2163       29519 :     if ( ! dvdii( gel(x,i), gel(y,i) ) ) return 0;
    2164        7133 :   return 1;
    2165             : }
    2166             : 
    2167             : /* Fq */
    2168             : INLINE GEN
    2169     1299940 : Fq_red(GEN x, GEN T, GEN p)
    2170     1299940 : { return typ(x)==t_INT? Fp_red(x,p): FpXQ_red(x,T,p); }
    2171             : INLINE GEN
    2172       11793 : Fq_to_FpXQ(GEN x, GEN T, GEN p /*unused*/)
    2173             : {
    2174             :   (void) p;
    2175       11793 :   return typ(x)==t_INT ? scalarpol(x, get_FpX_var(T)): x;
    2176             : }
    2177             : 
    2178             : INLINE GEN
    2179         833 : gener_Fq_local(GEN T, GEN p, GEN L)
    2180         833 : { return T? gener_FpXQ_local(T,p, L)
    2181         833 :           : pgener_Fp_local(p, L); }
    2182             : 
    2183             : /* FpXQX */
    2184             : INLINE GEN
    2185         954 : FpXQX_div(GEN x, GEN y, GEN T, GEN p) { return FpXQX_divrem(x, y, T, p, NULL); }
    2186             : INLINE GEN
    2187       31477 : FlxqX_div(GEN x, GEN y, GEN T, ulong p) { return FlxqX_divrem(x, y, T, p, NULL); }
    2188             : INLINE GEN
    2189       29785 : F2xqX_div(GEN x, GEN y, GEN T) { return F2xqX_divrem(x, y, T, NULL); }
    2190             : 
    2191             : /* FqX */
    2192             : INLINE GEN
    2193       27419 : FqX_red(GEN z, GEN T, GEN p) { return T? FpXQX_red(z, T, p): FpX_red(z, p); }
    2194             : INLINE GEN
    2195      903963 : FqX_add(GEN x,GEN y,GEN T,GEN p) { return T? FpXX_add(x,y,p): FpX_add(x,y,p); }
    2196             : INLINE GEN
    2197       16438 : FqX_neg(GEN x,GEN T,GEN p) { return T? FpXX_neg(x,p): FpX_neg(x,p); }
    2198             : INLINE GEN
    2199        2380 : FqX_sub(GEN x,GEN y,GEN T,GEN p) { return T? FpXX_sub(x,y,p): FpX_sub(x,y,p); }
    2200             : INLINE GEN
    2201      608016 : FqX_Fp_mul(GEN P, GEN u, GEN T, GEN p)
    2202      608016 : { return T? FpXX_Fp_mul(P, u, p): FpX_Fp_mul(P, u, p); }
    2203             : INLINE GEN
    2204      552791 : FqX_Fq_mul(GEN P, GEN U, GEN T, GEN p)
    2205      552791 : { return typ(U)==t_INT ? FqX_Fp_mul(P, U, T, p): FpXQX_FpXQ_mul(P, U, T, p); }
    2206             : INLINE GEN
    2207       83735 : FqX_mul(GEN x, GEN y, GEN T, GEN p)
    2208       83735 : { return T? FpXQX_mul(x, y, T, p): FpX_mul(x, y, p); }
    2209             : INLINE GEN
    2210      459889 : FqX_mulu(GEN x, ulong y, GEN T, GEN p)
    2211      459889 : { return T? FpXX_mulu(x, y, p): FpX_mulu(x, y, p); }
    2212             : INLINE GEN
    2213        4760 : FqX_sqr(GEN x, GEN T, GEN p)
    2214        4760 : { return T? FpXQX_sqr(x, T, p): FpX_sqr(x, p); }
    2215             : INLINE GEN
    2216        1428 : FqX_powu(GEN x, ulong n, GEN T, GEN p)
    2217        1428 : { return T? FpXQX_powu(x, n, T, p): FpX_powu(x, n, p); }
    2218             : INLINE GEN
    2219        2977 : FqX_div(GEN x, GEN y, GEN T, GEN p)
    2220        2977 : { return T? FpXQX_divrem(x,y,T,p,NULL): FpX_divrem(x,y,p,NULL); }
    2221             : INLINE GEN
    2222        5605 : FqX_get_red(GEN S, GEN T, GEN p)
    2223        5605 : { return T? FpXQX_get_red(S,T,p): FpX_get_red(S,p); }
    2224             : INLINE GEN
    2225       47875 : FqX_rem(GEN x, GEN y, GEN T, GEN p)
    2226       47875 : { return T? FpXQX_rem(x,y,T,p): FpX_rem(x,y,p); }
    2227             : INLINE GEN
    2228         329 : FqX_divrem(GEN x, GEN y, GEN T, GEN p, GEN *z)
    2229         329 : { return T? FpXQX_divrem(x,y,T,p,z): FpX_divrem(x,y,p,z); }
    2230             : INLINE GEN
    2231        5957 : FqX_div_by_X_x(GEN x, GEN y, GEN T, GEN p, GEN *z)
    2232        5957 : { return T? FpXQX_div_by_X_x(x,y,T,p,z): FpX_div_by_X_x(x,y,p,z); }
    2233             : INLINE GEN
    2234           0 : FqX_halfgcd(GEN P,GEN Q,GEN T,GEN p)
    2235           0 : {return T? FpXQX_halfgcd(P,Q,T,p): FpX_halfgcd(P,Q,p);}
    2236             : INLINE GEN
    2237      254116 : FqX_gcd(GEN P,GEN Q,GEN T,GEN p)
    2238      254116 : {return T? FpXQX_gcd(P,Q,T,p): FpX_gcd(P,Q,p);}
    2239             : INLINE GEN
    2240       79527 : FqX_extgcd(GEN P,GEN Q,GEN T,GEN p, GEN *U, GEN *V)
    2241       79527 : { return T? FpXQX_extgcd(P,Q,T,p,U,V): FpX_extgcd(P,Q,p,U,V); }
    2242             : INLINE GEN
    2243        1995 : FqX_normalize(GEN z, GEN T, GEN p) { return T? FpXQX_normalize(z, T, p): FpX_normalize(z, p); }
    2244             : INLINE GEN
    2245      268618 : FqX_deriv(GEN f, /*unused*/GEN T, GEN p) { (void)T; return FpXX_deriv(f, p); }
    2246             : INLINE GEN
    2247       71148 : FqX_factor(GEN f, GEN T, GEN p) { return T?FpXQX_factor(f, T, p): FpX_factor(f, p); }
    2248             : INLINE GEN
    2249        5810 : FqX_roots(GEN f, GEN T, GEN p) { return T?FpXQX_roots(f, T, p): FpX_roots(f, p); }
    2250             : 
    2251             : /*FqXQ*/
    2252             : INLINE GEN
    2253           0 : FqXQ_add(GEN x, GEN y, GEN S/*unused*/, GEN T, GEN p)
    2254           0 : { (void)S; return T? FpXX_add(x,y,p): FpX_add(x,y,p); }
    2255             : INLINE GEN
    2256           0 : FqXQ_sub(GEN x, GEN y, GEN S/*unused*/, GEN T, GEN p)
    2257           0 : { (void)S; return T? FpXX_sub(x,y,p): FpX_sub(x,y,p); }
    2258             : INLINE GEN
    2259           0 : FqXQ_div(GEN x, GEN y, GEN S, GEN T, GEN p)
    2260           0 : { return T? FpXQXQ_div(x,y,S,T,p): FpXQ_div(x,y,S,p); }
    2261             : INLINE GEN
    2262           0 : FqXQ_inv(GEN x, GEN S, GEN T, GEN p)
    2263           0 : { return T? FpXQXQ_inv(x,S,T,p): FpXQ_inv(x,S,p); }
    2264             : INLINE GEN
    2265           0 : FqXQ_invsafe(GEN x, GEN S, GEN T, GEN p)
    2266           0 : { return T? FpXQXQ_invsafe(x,S,T,p): FpXQ_inv(x,S,p); }
    2267             : INLINE GEN
    2268       21018 : FqXQ_mul(GEN x, GEN y, GEN S, GEN T, GEN p)
    2269       21018 : { return T? FpXQXQ_mul(x,y,S,T,p): FpXQ_mul(x,y,S,p); }
    2270             : INLINE GEN
    2271           0 : FqXQ_sqr(GEN x, GEN S, GEN T, GEN p)
    2272           0 : { return T? FpXQXQ_sqr(x,S,T,p): FpXQ_sqr(x,S,p); }
    2273             : INLINE GEN
    2274           0 : FqXQ_pow(GEN x, GEN n, GEN S, GEN T, GEN p)
    2275           0 : { return T? FpXQXQ_pow(x,n,S,T,p): FpXQ_pow(x,n,S,p); }
    2276             : 
    2277             : /*FpXQ*/
    2278             : INLINE GEN
    2279           0 : FpXQ_add(GEN x,GEN y,GEN T/*unused*/,GEN p)
    2280           0 : { (void)T; return FpX_add(x,y,p); }
    2281             : INLINE GEN
    2282           0 : FpXQ_sub(GEN x,GEN y,GEN T/*unused*/,GEN p)
    2283           0 : { (void)T; return FpX_sub(x,y,p); }
    2284             : 
    2285             : /*Flxq*/
    2286             : INLINE GEN
    2287           0 : Flxq_add(GEN x,GEN y,GEN T/*unused*/,ulong p)
    2288           0 : { (void)T; return Flx_add(x,y,p); }
    2289             : INLINE GEN
    2290         110 : Flxq_sub(GEN x,GEN y,GEN T/*unused*/,ulong p)
    2291         110 : { (void)T; return Flx_sub(x,y,p); }
    2292             : 
    2293             : /* F2x */
    2294             : 
    2295             : INLINE ulong
    2296   106733613 : F2x_coeff(GEN x,long v)
    2297             : {
    2298   106733613 :    ulong u=(ulong)x[2+divsBIL(v)];
    2299   106733287 :    return (u>>remsBIL(v))&1UL;
    2300             : }
    2301             : 
    2302             : INLINE void
    2303     3579184 : F2x_clear(GEN x,long v)
    2304             : {
    2305     3579184 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2306     3579184 :    *u&=~(1UL<<remsBIL(v));
    2307     3579184 : }
    2308             : 
    2309             : INLINE void
    2310    40304816 : F2x_set(GEN x,long v)
    2311             : {
    2312    40304816 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2313    40299455 :    *u|=1UL<<remsBIL(v);
    2314    40302544 : }
    2315             : 
    2316             : INLINE void
    2317     1339120 : F2x_flip(GEN x,long v)
    2318             : {
    2319     1339120 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2320     1339120 :    *u^=1UL<<remsBIL(v);
    2321     1339120 : }
    2322             : 
    2323             : /* F2v */
    2324             : 
    2325             : INLINE ulong
    2326   102930535 : F2v_coeff(GEN x,long v) { return F2x_coeff(x,v-1); }
    2327             : 
    2328             : INLINE void
    2329     3579184 : F2v_clear(GEN x,long v) { F2x_clear(x,v-1); }
    2330             : 
    2331             : INLINE void
    2332    15795216 : F2v_set(GEN x,long v)   { F2x_set(x,v-1); }
    2333             : 
    2334             : INLINE void
    2335     1339120 : F2v_flip(GEN x,long v) { F2x_flip(x,v-1); }
    2336             : 
    2337             : /* F2m */
    2338             : 
    2339             : INLINE ulong
    2340    13030394 : F2m_coeff(GEN x, long a, long b) { return F2v_coeff(gel(x,b), a); }
    2341             : 
    2342             : INLINE void
    2343           0 : F2m_clear(GEN x, long a, long b) { F2v_clear(gel(x,b), a); }
    2344             : 
    2345             : INLINE void
    2346     1668085 : F2m_set(GEN x, long a, long b) { F2v_set(gel(x,b), a); }
    2347             : 
    2348             : INLINE void
    2349     1339120 : F2m_flip(GEN x, long a, long b) { F2v_flip(gel(x,b), a); }
    2350             : 
    2351             : /* ARITHMETIC */
    2352             : INLINE GEN
    2353        1008 : matpascal(long n) { return matqpascal(n, NULL); }
    2354             : INLINE long
    2355     1969420 : Z_issquare(GEN x) { return Z_issquareall(x, NULL); }
    2356             : INLINE long
    2357          14 : Z_ispower(GEN x, ulong k) { return Z_ispowerall(x, k, NULL); }
    2358             : INLINE GEN
    2359     4655922 : sqrti(GEN x) { return sqrtremi(x,NULL); }
    2360             : INLINE GEN
    2361     7464318 : gaddgs(GEN y, long s) { return gaddsg(s,y); }
    2362             : INLINE int
    2363       23890 : gcmpgs(GEN y, long s) { return -gcmpsg(s,y); }
    2364             : INLINE int
    2365       22827 : gequalgs(GEN y, long s) { return gequalsg(s,y); }
    2366             : INLINE GEN
    2367           0 : gmaxsg(long s, GEN y) { return gmaxgs(y,s); }
    2368             : INLINE GEN
    2369           0 : gminsg(long s, GEN y) { return gmings(y,s); }
    2370             : INLINE GEN
    2371     5793991 : gmulgs(GEN y, long s) { return gmulsg(s,y); }
    2372             : INLINE GEN
    2373      554848 : gsubgs(GEN y, long s) { return gaddgs(y, -s); }
    2374             : INLINE GEN
    2375      450875 : gdivsg(long s, GEN y) { return gdiv(stoi(s), y); }
    2376             : 
    2377             : /* x t_COMPLEX */
    2378             : INLINE GEN
    2379     8747320 : cxnorm(GEN x) { return gadd(gsqr(gel(x,1)), gsqr(gel(x,2))); }
    2380             : /* q t_QUAD */
    2381             : INLINE GEN
    2382         623 : quadnorm(GEN q)
    2383             : {
    2384         623 :   GEN X = gel(q,1), b = gel(X,3), c = gel(X,2);
    2385         623 :   GEN z, u = gel(q,3), v = gel(q,2);
    2386         623 :   if (typ(u) == t_INT && typ(v) == t_INT) /* generic case */
    2387             :   {
    2388         308 :     z = signe(b)? mulii(v, addii(u,v)): sqri(v);
    2389         308 :     return addii(z, mulii(c, sqri(u)));
    2390             :   }
    2391             :   else
    2392             :   {
    2393         315 :     z = signe(b)? gmul(v, gadd(u,v)): gsqr(v);
    2394         315 :     return gadd(z, gmul(c, gsqr(u)));
    2395             :   }
    2396             : }
    2397             : /* x a t_QUAD, return the attached discriminant */
    2398             : INLINE GEN
    2399         252 : quad_disc(GEN x)
    2400             : {
    2401         252 :   GEN Q = gel(x,1), b = gel(Q,3), c = gel(Q,2), c4;
    2402         252 :   if (is_pm1(b))
    2403             :   {
    2404         196 :     pari_sp av = avma; (void)new_chunk(lgefint(c) + 1);
    2405         196 :     c4 = shifti(c,2); avma = av; return subsi(1, c4);
    2406             :   }
    2407          56 :   c4 = shifti(c,2); togglesign_safe(&c4); return c4;
    2408             : }
    2409             : INLINE GEN
    2410     6006336 : qfb_disc3(GEN x, GEN y, GEN z) { return subii(sqri(y), shifti(mulii(x,z),2)); }
    2411             : INLINE GEN
    2412     5915000 : qfb_disc(GEN x) { return qfb_disc3(gel(x,1), gel(x,2), gel(x,3)); }
    2413             : 
    2414             : INLINE GEN
    2415     1409474 : sqrfrac(GEN x)
    2416             : {
    2417     1409474 :   GEN z = cgetg(3,t_FRAC);
    2418     1409474 :   gel(z,1) = sqri(gel(x,1));
    2419     1409474 :   gel(z,2) = sqri(gel(x,2)); return z;
    2420             : }
    2421             : 
    2422             : INLINE void
    2423     8303436 : normalize_frac(GEN z) {
    2424     8303436 :   if (signe(gel(z,2)) < 0) { togglesign(gel(z,1)); setabssign(gel(z,2)); }
    2425     8303436 : }
    2426             : 
    2427             : INLINE GEN
    2428      211634 : powii(GEN x, GEN n)
    2429             : {
    2430      211634 :   long ln = lgefint(n);
    2431      211634 :   if (ln == 3) {
    2432             :     GEN z;
    2433      209723 :     if (signe(n) > 0) return powiu(x, n[2]);
    2434        2681 :     z = cgetg(3, t_FRAC);
    2435        2681 :     gel(z,1) = gen_1;
    2436        2681 :     gel(z,2) = powiu(x, n[2]);
    2437        2681 :     return z;
    2438             :   }
    2439        1911 :   if (ln == 2) return gen_1; /* rare */
    2440             :   /* should never happen */
    2441           0 :   return powgi(x, n); /* overflow unless x = 0, 1, -1 */
    2442             : }
    2443             : INLINE GEN
    2444         840 : powIs(long n) {
    2445         840 :   switch(n & 3)
    2446             :   {
    2447           7 :     case 1: return mkcomplex(gen_0,gen_1);
    2448         315 :     case 2: return gen_m1;
    2449         455 :     case 3: return mkcomplex(gen_0,gen_m1);
    2450             :   }
    2451          63 :   return gen_1;
    2452             : }
    2453             : 
    2454             : /*******************************************************************/
    2455             : /*                                                                 */
    2456             : /*                             ASSIGNMENTS                         */
    2457             : /*                                                                 */
    2458             : /*******************************************************************/
    2459           0 : INLINE void mpexpz(GEN x, GEN z)
    2460           0 : { pari_sp av = avma; gaffect(mpexp(x), z); avma = av; }
    2461           0 : INLINE void mplogz(GEN x, GEN z)
    2462           0 : { pari_sp av = avma; gaffect(mplog(x), z); avma = av; }
    2463           0 : INLINE void mpcosz(GEN x, GEN z)
    2464           0 : { pari_sp av = avma; gaffect(mpcos(x), z); avma = av; }
    2465           0 : INLINE void mpsinz(GEN x, GEN z)
    2466           0 : { pari_sp av = avma; gaffect(mpsin(x), z); avma = av; }
    2467           0 : INLINE void gnegz(GEN x, GEN z)
    2468           0 : { pari_sp av = avma; gaffect(gneg(x), z); avma = av; }
    2469           0 : INLINE void gabsz(GEN x, long prec, GEN z)
    2470           0 : { pari_sp av = avma; gaffect(gabs(x,prec), z); avma = av; }
    2471       23318 : INLINE void gaddz(GEN x, GEN y, GEN z)
    2472       23318 : { pari_sp av = avma; gaffect(gadd(x,y), z); avma = av; }
    2473           0 : INLINE void gsubz(GEN x, GEN y, GEN z)
    2474           0 : { pari_sp av = avma; gaffect(gsub(x,y), z); avma = av; }
    2475       11673 : INLINE void gmulz(GEN x, GEN y, GEN z)
    2476       11673 : { pari_sp av = avma; gaffect(gmul(x,y), z); avma = av; }
    2477           0 : INLINE void gdivz(GEN x, GEN y, GEN z)
    2478           0 : { pari_sp av = avma; gaffect(gdiv(x,y), z); avma = av; }
    2479           0 : INLINE void gdiventz(GEN x, GEN y, GEN z)
    2480           0 : { pari_sp av = avma; gaffect(gdivent(x,y), z); avma = av; }
    2481           0 : INLINE void gmodz(GEN x, GEN y, GEN z)
    2482           0 : { pari_sp av = avma; gaffect(gmod(x,y), z); avma = av; }
    2483           0 : INLINE void gmul2nz(GEN x, long s, GEN z)
    2484           0 : { pari_sp av = avma; gaffect(gmul2n(x,s), z); avma = av; }
    2485           0 : INLINE void gshiftz(GEN x, long s, GEN z)
    2486           0 : { pari_sp av = avma; gaffect(gshift(x,s), z); avma = av; }
    2487             : 
    2488             : /*******************************************************************/
    2489             : /*                                                                 */
    2490             : /*                       ELLIPTIC CURVES                           */
    2491             : /*                                                                 */
    2492             : /*******************************************************************/
    2493     5005452 : INLINE GEN ell_get_a1(GEN e) { return gel(e,1); }
    2494     3297464 : INLINE GEN ell_get_a2(GEN e) { return gel(e,2); }
    2495     4478107 : INLINE GEN ell_get_a3(GEN e) { return gel(e,3); }
    2496     4095191 : INLINE GEN ell_get_a4(GEN e) { return gel(e,4); }
    2497     4669051 : INLINE GEN ell_get_a6(GEN e) { return gel(e,5); }
    2498     3949893 : INLINE GEN ell_get_b2(GEN e) { return gel(e,6); }
    2499     1009891 : INLINE GEN ell_get_b4(GEN e) { return gel(e,7); }
    2500     1613753 : INLINE GEN ell_get_b6(GEN e) { return gel(e,8); }
    2501     1457519 : INLINE GEN ell_get_b8(GEN e) { return gel(e,9); }
    2502     6102800 : INLINE GEN ell_get_c4(GEN e) { return gel(e,10); }
    2503     8134460 : INLINE GEN ell_get_c6(GEN e) { return gel(e,11); }
    2504     9563347 : INLINE GEN ell_get_disc(GEN e) { return gel(e,12); }
    2505     1174677 : INLINE GEN ell_get_j(GEN e) { return gel(e,13); }
    2506     7854682 : INLINE long ell_get_type(GEN e) { return mael(e,14,1); }
    2507     1511480 : INLINE GEN ellff_get_field(GEN x) { return gmael(x, 15, 1); }
    2508      652843 : INLINE GEN ellff_get_a4a6(GEN x)  { return gmael(x, 15, 2); }
    2509         917 : INLINE GEN ellQp_get_zero(GEN x) { return gmael(x, 15, 1); }
    2510         287 : INLINE long ellQp_get_prec(GEN E) { GEN z = ellQp_get_zero(E); return valp(z); }
    2511         623 : INLINE GEN ellQp_get_p(GEN E) { GEN z = ellQp_get_zero(E); return gel(z,2); }
    2512       36953 : INLINE long ellR_get_prec(GEN x) { return nbits2prec(mael3(x, 15, 1, 1)); }
    2513        1507 : INLINE long ellR_get_sign(GEN x) { return mael3(x, 15, 1, 2); }
    2514      554526 : INLINE GEN ellnf_get_nf(GEN x) { return checknf_i(gmael(x,15,1)); }
    2515          49 : INLINE GEN ellnf_get_bnf(GEN x) { return checkbnf_i(gmael(x,15,1)); }
    2516             : 
    2517    25089672 : INLINE int ell_is_inf(GEN z) { return lg(z) == 2; }
    2518      806482 : INLINE GEN ellinf(void) { return mkvec(gen_0); }
    2519             : 
    2520             : /*******************************************************************/
    2521             : /*                                                                 */
    2522             : /*                    ALGEBRAIC NUMBER THEORY                      */
    2523             : /*                                                                 */
    2524             : /*******************************************************************/
    2525     6241575 : INLINE GEN modpr_get_pr(GEN x)  { return gel(x,3); }
    2526      602652 : INLINE GEN modpr_get_p(GEN x)  { return pr_get_p(modpr_get_pr(x)); }
    2527     1790383 : INLINE GEN modpr_get_T(GEN x)  { return lg(x) == 4? NULL: gel(x,4); }
    2528             : 
    2529    14906794 : INLINE GEN pr_get_p(GEN pr)  { return gel(pr,1); }
    2530     2307909 : INLINE GEN pr_get_gen(GEN pr){ return gel(pr,2); }
    2531             : /* .[2] instead of itos works: e and f are small positive integers */
    2532     2090346 : INLINE long pr_get_e(GEN pr) { return gel(pr,3)[2]; }
    2533     6192383 : INLINE long pr_get_f(GEN pr) { return gel(pr,4)[2]; }
    2534     5639956 : INLINE GEN pr_get_tau(GEN pr){ return gel(pr,5); }
    2535             : INLINE int
    2536      915226 : pr_is_inert(GEN P) { return pr_get_f(P) == lg(pr_get_gen(P))-1; }
    2537             : INLINE GEN
    2538      293337 : pr_norm(GEN pr) { return powiu(pr_get_p(pr), pr_get_f(pr)); }
    2539             : INLINE ulong
    2540       32277 : upr_norm(GEN pr) { return upowuu(pr_get_p(pr)[2], pr_get_f(pr)); }
    2541             : 
    2542             : /* assume nf a genuine nf */
    2543             : INLINE long
    2544        4402 : nf_get_varn(GEN nf) { return varn(gel(nf,1)); }
    2545             : INLINE GEN
    2546     6687956 : nf_get_pol(GEN nf) { return gel(nf,1); }
    2547             : INLINE long
    2548     2715817 : nf_get_degree(GEN nf) { return degpol( nf_get_pol(nf) ); }
    2549             : INLINE long
    2550     1159484 : nf_get_r1(GEN nf) { GEN x = gel(nf,2); return itou(gel(x,1)); }
    2551             : INLINE long
    2552        1267 : nf_get_r2(GEN nf) { GEN x = gel(nf,2); return itou(gel(x,2)); }
    2553             : INLINE GEN
    2554       23897 : nf_get_disc(GEN nf) { return gel(nf,3); }
    2555             : INLINE GEN
    2556      625071 : nf_get_index(GEN nf) { return gel(nf,4); }
    2557             : INLINE GEN
    2558     1110068 : nf_get_M(GEN nf) { return gmael(nf,5,1); }
    2559             : INLINE GEN
    2560       45497 : nf_get_G(GEN nf) { return gmael(nf,5,2); }
    2561             : INLINE GEN
    2562      394666 : nf_get_roundG(GEN nf) { return gmael(nf,5,3); }
    2563             : INLINE GEN
    2564         819 : nf_get_Tr(GEN nf) { return gmael(nf,5,4); }
    2565             : INLINE GEN
    2566        1729 : nf_get_diff(GEN nf) { return gmael(nf,5,5); }
    2567             : INLINE GEN
    2568          35 : nf_get_ramified_primes(GEN nf) { return gmael(nf,5,8); }
    2569             : INLINE GEN
    2570      100149 : nf_get_roots(GEN nf) { return gel(nf,6); }
    2571             : INLINE GEN
    2572     6409121 : nf_get_zk(GEN nf) { return gel(nf,7); }
    2573             : INLINE GEN
    2574     1649258 : nf_get_invzk(GEN nf) { return gel(nf,8); }
    2575             : INLINE void
    2576        6727 : nf_get_sign(GEN nf, long *r1, long *r2)
    2577             : {
    2578        6727 :   GEN x = gel(nf,2);
    2579        6727 :   *r1 = itou(gel(x,1));
    2580        6727 :   *r2 = itou(gel(x,2));
    2581        6727 : }
    2582             : 
    2583             : INLINE GEN
    2584        9527 : abgrp_get_no(GEN x) { return gel(x,1); }
    2585             : INLINE GEN
    2586     1231334 : abgrp_get_cyc(GEN x) { return gel(x,2); }
    2587             : INLINE GEN
    2588      302928 : abgrp_get_gen(GEN x) { return gel(x,3); }
    2589             : INLINE GEN
    2590     1374796 : bnf_get_nf(GEN bnf) { return gel(bnf,7); }
    2591             : INLINE GEN
    2592      620892 : bnf_get_clgp(GEN bnf) { return gmael(bnf,8,1); }
    2593             : INLINE GEN
    2594        1134 : bnf_get_no(GEN bnf) { return abgrp_get_no(bnf_get_clgp(bnf)); }
    2595             : INLINE GEN
    2596      325468 : bnf_get_cyc(GEN bnf) { return abgrp_get_cyc(bnf_get_clgp(bnf)); }
    2597             : INLINE GEN
    2598      293961 : bnf_get_gen(GEN bnf)  { return abgrp_get_gen(bnf_get_clgp(bnf)); }
    2599             : INLINE GEN
    2600         860 : bnf_get_reg(GEN bnf) { return gmael(bnf,8,2); }
    2601             : INLINE GEN
    2602      476648 : bnf_get_logfu(GEN bnf) { return gel(bnf,3); }
    2603             : INLINE GEN
    2604        2535 : bnf_get_tuU(GEN bnf) { return gmael3(bnf,8,4,2); }
    2605             : INLINE long
    2606        7672 : bnf_get_tuN(GEN bnf) { return gmael3(bnf,8,4,1)[2]; }
    2607             : INLINE GEN
    2608        1806 : bnf_get_fu(GEN bnf) {
    2609        1806 :   GEN fu = bnf_get_fu_nocheck(bnf);
    2610        1806 :   if (typ(fu) == t_MAT) pari_err(e_MISC,"missing units in bnf");
    2611        1806 :   return fu;
    2612             : }
    2613             : INLINE GEN
    2614        3802 : bnf_get_fu_nocheck(GEN bnf) { return gmael(bnf,8,5); }
    2615             : 
    2616             : INLINE GEN
    2617      440921 : bnr_get_bnf(GEN bnr) { return gel(bnr,1); }
    2618             : INLINE GEN
    2619      218217 : bnr_get_bid(GEN bnr) { return gel(bnr,2); }
    2620             : INLINE GEN
    2621       24563 : bnr_get_mod(GEN bnr) { return gmael(bnr,2,1); }
    2622             : INLINE GEN
    2623       13398 : bnr_get_nf(GEN bnr) { return gmael(bnr,1,7); }
    2624             : INLINE GEN
    2625      259937 : bnr_get_clgp(GEN bnr) { return gel(bnr,5); }
    2626             : INLINE GEN
    2627        8393 : bnr_get_no(GEN bnr) { return abgrp_get_no(bnr_get_clgp(bnr)); }
    2628             : INLINE GEN
    2629      237026 : bnr_get_cyc(GEN bnr) { return abgrp_get_cyc(bnr_get_clgp(bnr)); }
    2630             : INLINE GEN
    2631          70 : bnr_get_gen_nocheck(GEN bnr) { return abgrp_get_gen(bnr_get_clgp(bnr)); }
    2632             : INLINE GEN
    2633       13622 : bnr_get_gen(GEN bnr) {
    2634       13622 :   GEN G = bnr_get_clgp(bnr);
    2635       13622 :   if (lg(G) !=  4)
    2636           0 :     pari_err(e_MISC,"missing bnr generators: please use bnrinit(,,1)");
    2637       13622 :   return gel(G,3);
    2638             : }
    2639             : 
    2640             : INLINE GEN
    2641      223775 : bid_get_mod(GEN bid) { return gel(bid,1); }
    2642             : INLINE GEN
    2643       11697 : bid_get_ideal(GEN bid) { return gmael(bid,1,1); }
    2644             : INLINE GEN
    2645         448 : bid_get_arch(GEN bid) { return gmael(bid,1,2); }
    2646             : INLINE GEN
    2647      674860 : bid_get_grp(GEN bid) { return gel(bid,2); }
    2648             : INLINE GEN
    2649      238881 : bid_get_fact(GEN bid) { return gmael(bid,3,1); }
    2650             : INLINE GEN
    2651      231321 : bid_get_fact2(GEN bid) { return gmael(bid,3,2); }
    2652             : INLINE GEN
    2653      231391 : bid_get_sprk(GEN bid) { return gmael(bid,4,1); }
    2654             : INLINE GEN
    2655        6447 : bid_get_sarch(GEN bid) { return gmael(bid,4,2); }
    2656             : INLINE GEN
    2657      235108 : bid_get_archp(GEN bid) { return gmael3(bid,4,2,2); }
    2658             : INLINE GEN
    2659      455376 : bid_get_U(GEN bid) { return gel(bid,5); }
    2660             : INLINE GEN
    2661           0 : bid_get_no(GEN bid) { return abgrp_get_no(bid_get_grp(bid)); }
    2662             : INLINE GEN
    2663      666859 : bid_get_cyc(GEN bid) { return abgrp_get_cyc(bid_get_grp(bid)); }
    2664             : INLINE GEN
    2665           0 : bid_get_gen_nocheck(GEN bid)  { return abgrp_get_gen(bid_get_grp(bid)); }
    2666             : INLINE GEN
    2667        7406 : bid_get_gen(GEN bid) {
    2668        7406 :   GEN G = bid_get_grp(bid);
    2669        7406 :   if (lg(G) != 4) pari_err(e_MISC,"missing bid generators. Use idealstar(,,2)");
    2670        7406 :   return abgrp_get_gen(G);
    2671             : }
    2672             : 
    2673             : INLINE GEN
    2674       19152 : znstar_get_N(GEN G) { return gmael(G,1,1); }
    2675             : INLINE GEN
    2676       34545 : znstar_get_faN(GEN G) { return gel(G,3); }
    2677             : INLINE GEN
    2678           0 : znstar_get_no(GEN G) { return abgrp_get_no(gel(G,2)); }
    2679             : INLINE GEN
    2680         567 : znstar_get_cyc(GEN G) { return abgrp_get_cyc(gel(G,2)); }
    2681             : INLINE GEN
    2682           0 : znstar_get_gen(GEN G) { return abgrp_get_gen(gel(G,2)); }
    2683             : INLINE GEN
    2684       17213 : znstar_get_conreycyc(GEN G) { return gmael(G,4,5); }
    2685             : INLINE GEN
    2686       13335 : znstar_get_conreygen(GEN G) { return gmael(G,4,4); }
    2687             : INLINE GEN
    2688         161 : znstar_get_Ui(GEN G) { return gmael(G,4,3); }
    2689             : INLINE GEN
    2690        6902 : znstar_get_U(GEN G) { return gel(G,5); }
    2691             : INLINE GEN
    2692       13321 : znstar_get_pe(GEN G) { return gmael(G,4,1); }
    2693             : INLINE GEN
    2694        2891 : gal_get_pol(GEN gal) { return gel(gal,1); }
    2695             : INLINE GEN
    2696        1225 : gal_get_p(GEN gal) { return gmael(gal,2,1); }
    2697             : INLINE GEN
    2698          63 : gal_get_e(GEN gal) { return gmael(gal,2,2); }
    2699             : INLINE GEN
    2700        2142 : gal_get_mod(GEN gal) { return gmael(gal,2,3); }
    2701             : INLINE GEN
    2702        2520 : gal_get_roots(GEN gal) { return gel(gal,3); }
    2703             : INLINE GEN
    2704        2142 : gal_get_invvdm(GEN gal) { return gel(gal,4); }
    2705             : INLINE GEN
    2706        2142 : gal_get_den(GEN gal) { return gel(gal,5); }
    2707             : INLINE GEN
    2708        7196 : gal_get_group(GEN gal) { return gel(gal,6); }
    2709             : INLINE GEN
    2710        1862 : gal_get_gen(GEN gal) { return gel(gal,7); }
    2711             : INLINE GEN
    2712        1407 : gal_get_orders(GEN gal) { return gel(gal,8); }
    2713             : 
    2714             : /* assume rnf a genuine rnf */
    2715             : INLINE long
    2716      311276 : rnf_get_degree(GEN rnf) { return degpol(rnf_get_pol(rnf)); }
    2717             : INLINE long
    2718       14805 : rnf_get_nfdegree(GEN rnf) { return degpol(nf_get_pol(rnf_get_nf(rnf))); }
    2719             : INLINE long
    2720      156450 : rnf_get_absdegree(GEN rnf) { return degpol(gmael(rnf,11,1)); }
    2721             : INLINE GEN
    2722         434 : rnf_get_idealdisc(GEN rnf) { return gmael(rnf,3,1); }
    2723             : INLINE GEN
    2724         448 : rnf_get_k(GEN rnf) { return gmael(rnf,11,3); }
    2725             : INLINE GEN
    2726         448 : rnf_get_alpha(GEN rnf) { return gmael(rnf, 11, 2); }
    2727             : INLINE GEN
    2728      123767 : rnf_get_nf(GEN rnf) { return gel(rnf,10); }
    2729             : INLINE void
    2730        1701 : rnf_get_nfzk(GEN rnf, GEN *b, GEN *cb) {*b=gmael(rnf,2,1); *cb=gmael(rnf,2,2);}
    2731             : INLINE GEN
    2732       93674 : rnf_get_polabs(GEN rnf) { return gmael(rnf,11,1); }
    2733             : INLINE GEN
    2734      462973 : rnf_get_pol(GEN rnf) { return gel(rnf,1); }
    2735             : INLINE GEN
    2736          63 : rnf_get_disc(GEN rnf) { return gel(rnf,3); }
    2737             : INLINE GEN
    2738         105 : rnf_get_index(GEN rnf) { return gel(rnf,4); }
    2739             : INLINE long
    2740           0 : rnf_get_varn(GEN rnf) { return varn(gel(rnf,1)); }
    2741             : INLINE GEN
    2742      106519 : rnf_get_nfpol(GEN rnf) { return gmael(rnf,10,1); }
    2743             : INLINE long
    2744         483 : rnf_get_nfvarn(GEN rnf) { return varn(gmael(rnf,10,1)); }
    2745             : INLINE GEN
    2746        2443 : rnf_get_zk(GEN rnf) { return gel(rnf,7); }
    2747             : INLINE GEN
    2748       34006 : rnf_get_map(GEN rnf) { return gel(rnf,11); }
    2749             : INLINE GEN
    2750        1190 : rnf_get_invzk(GEN rnf) { return gel(rnf,8); }
    2751             : 
    2752             : /* I integral ZM (not HNF), G ZM, rounded Cholesky form of a weighted
    2753             :  * T2 matrix. Reduce I wrt G */
    2754             : INLINE GEN
    2755        5131 : idealpseudored(GEN I, GEN G)
    2756        5131 : { return ZM_mul(I, ZM_lll(ZM_mul(G, I), 0.99, LLL_IM)); }
    2757             : 
    2758             : /* I integral (not necessarily HNF), G ZM, rounded Cholesky form of a weighted
    2759             :  * T2 matrix. Return m in I with T2(m) small */
    2760             : INLINE GEN
    2761      150960 : idealpseudomin(GEN I, GEN G)
    2762             : {
    2763      150960 :   GEN u = ZM_lll(ZM_mul(G, I), 0.99, LLL_IM);
    2764      150960 :   return ZM_ZC_mul(I, gel(u,1));
    2765             : }
    2766             : /* I, G as in idealpseudomin. Return an irrational m in I with T2(m) small */
    2767             : INLINE GEN
    2768      268481 : idealpseudomin_nonscalar(GEN I, GEN G)
    2769             : {
    2770      268481 :   GEN u = ZM_lll(ZM_mul(G, I), 0.99, LLL_IM);
    2771      268481 :   GEN m = ZM_ZC_mul(I, gel(u,1));
    2772      268481 :   if (ZV_isscalar(m) && lg(u) > 2) m = ZM_ZC_mul(I, gel(u,2));
    2773      268481 :   return m;
    2774             : }
    2775             : 
    2776             : INLINE GEN
    2777           0 : idealred_elt(GEN nf, GEN I) {
    2778           0 :   pari_sp av = avma;
    2779           0 :   GEN u = idealpseudomin(I, nf_get_roundG(nf));
    2780           0 :   return gerepileupto(av, u);
    2781             : }
    2782             : INLINE GEN
    2783      155960 : idealred(GEN nf, GEN I) { return idealred0(nf, I, NULL); }
    2784             : 
    2785             : INLINE GEN
    2786        1218 : idealchineseinit(GEN nf, GEN x)
    2787        1218 : { return idealchinese(nf,x,NULL); }
    2788             : 
    2789             : /*******************************************************************/
    2790             : /*                                                                 */
    2791             : /*                              CLOSURES                           */
    2792             : /*                                                                 */
    2793             : /*******************************************************************/
    2794   186925598 : INLINE long closure_arity(GEN C)          { return ((ulong)C[1])&ARITYBITS; }
    2795    34378108 : INLINE long closure_is_variadic(GEN C) { return !!(((ulong)C[1])&VARARGBITS); }
    2796   152324286 : INLINE const char *closure_codestr(GEN C)  { return GSTR(gel(C,2))-1; }
    2797           0 : INLINE GEN closure_get_code(GEN C)  { return gel(C,2); }
    2798   152284831 : INLINE GEN closure_get_oper(GEN C)  { return gel(C,3); }
    2799   152251287 : INLINE GEN closure_get_data(GEN C)  { return gel(C,4); }
    2800       16967 : INLINE GEN closure_get_dbg(GEN C)   { return gel(C,5); }
    2801       37483 : INLINE GEN closure_get_text(GEN C)  { return gel(C,6); }
    2802      430025 : INLINE GEN closure_get_frame(GEN C) { return gel(C,7); }
    2803             : 
    2804             : /*******************************************************************/
    2805             : /*                                                                 */
    2806             : /*                               ERRORS                            */
    2807             : /*                                                                 */
    2808             : /*******************************************************************/
    2809             : INLINE long
    2810       47481 : err_get_num(GEN e) { return e[1]; }
    2811             : INLINE GEN
    2812          70 : err_get_compo(GEN e, long i) { return gel(e, i+1); }
    2813             : 
    2814             : INLINE void
    2815          14 : pari_err_BUG(const char *f) { pari_err(e_BUG,f); }
    2816             : INLINE void
    2817           7 : pari_err_CONSTPOL(const char *f) { pari_err(e_CONSTPOL, f); }
    2818             : INLINE void
    2819          63 : pari_err_COPRIME(const char *f, GEN x, GEN y) { pari_err(e_COPRIME, f,x,y); }
    2820             : INLINE void
    2821         932 : pari_err_DIM(const char *f) { pari_err(e_DIM, f); }
    2822             : INLINE void
    2823           0 : pari_err_FILE(const char *f, const char *g) { pari_err(e_FILE, f,g); }
    2824             : INLINE void
    2825          28 : pari_err_FLAG(const char *f) { pari_err(e_FLAG,f); }
    2826             : INLINE void
    2827         350 : pari_err_IMPL(const char *f) { pari_err(e_IMPL,f); }
    2828             : INLINE void
    2829         627 : pari_err_INV(const char *f, GEN x) { pari_err(e_INV,f,x); }
    2830             : INLINE void
    2831          21 : pari_err_IRREDPOL(const char *f, GEN x) { pari_err(e_IRREDPOL, f,x); }
    2832             : INLINE void
    2833        5201 : pari_err_DOMAIN(const char *f, const char *v, const char *op, GEN l, GEN x) { pari_err(e_DOMAIN, f,v,op,l,x); }
    2834             : INLINE void
    2835         224 : pari_err_COMPONENT(const char *f, const char *op, GEN l, GEN x) { pari_err(e_COMPONENT, f,op,l,x); }
    2836             : INLINE void
    2837           0 : pari_err_MAXPRIME(ulong c) { pari_err(e_MAXPRIME, c); }
    2838             : INLINE void
    2839         287 : pari_err_OP(const char *f, GEN x, GEN y) { pari_err(e_OP, f,x,y); }
    2840             : INLINE void
    2841          70 : pari_err_OVERFLOW(const char *f) { pari_err(e_OVERFLOW, f); }
    2842             : INLINE void
    2843         218 : pari_err_PREC(const char *f) { pari_err(e_PREC,f); }
    2844             : INLINE void
    2845           0 : pari_err_PACKAGE(const char *f) { pari_err(e_PACKAGE,f); }
    2846             : INLINE void
    2847          56 : pari_err_PRIME(const char *f, GEN x) { pari_err(e_PRIME, f,x); }
    2848             : INLINE void
    2849         735 : pari_err_MODULUS(const char *f, GEN x, GEN y) { pari_err(e_MODULUS, f,x,y); }
    2850             : INLINE void
    2851          42 : pari_err_ROOTS0(const char *f) { pari_err(e_ROOTS0, f); }
    2852             : INLINE void
    2853          77 : pari_err_SQRTN(const char *f, GEN x) { pari_err(e_SQRTN, f,x); }
    2854             : INLINE void
    2855       18976 : pari_err_TYPE(const char *f, GEN x) { pari_err(e_TYPE, f,x); }
    2856             : INLINE void
    2857        3073 : pari_err_TYPE2(const char *f, GEN x, GEN y) { pari_err(e_TYPE2, f,x,y); }
    2858             : INLINE void
    2859         203 : pari_err_VAR(const char *f, GEN x, GEN y) { pari_err(e_VAR, f,x,y); }
    2860             : INLINE void
    2861         119 : pari_err_PRIORITY(const char *f, GEN x, const char *op, long v)
    2862         119 : { pari_err(e_PRIORITY, f,x,op,v); }

Generated by: LCOV version 1.11