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 20116-58a92a9) Lines: 1196 1366 87.6 %
Date: 2017-01-23 05:49:11 Functions: 509 580 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      332350 : 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      288712 : mkpolmod(GEN x, GEN y) { retmkpolmod(x,y); }
     149             : INLINE GEN
     150     1835911 : mkfrac(GEN x, GEN y) { retmkfrac(x,y); }
     151             : INLINE GEN
     152     2789746 : 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     2776638 : mkcomplex(GEN x, GEN y) { retmkcomplex(x,y); }
     161             : INLINE GEN
     162      423871 : gen_I(void) { return mkcomplex(gen_0, gen_1); }
     163             : INLINE GEN
     164      203917 : 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    49485478 : mkvecsmall(long x) { GEN v = cgetg(2, t_VECSMALL); v[1] = x; return v; }
     171             : INLINE GEN
     172   110187167 : mkvecsmall2(long x,long y) { GEN v = cgetg(3, t_VECSMALL);
     173   110183123 :   v[1]=x; v[2]=y; return v; }
     174             : INLINE GEN
     175    61860257 : mkvecsmall3(long x,long y,long z) { GEN v = cgetg(4, t_VECSMALL);
     176    61858711 :   v[1]=x; v[2]=y; v[3]=z; return v; }
     177             : INLINE GEN
     178     9277156 : mkvecsmall4(long x,long y,long z,long t) { GEN v = cgetg(5, t_VECSMALL);
     179     9272270 :   v[1]=x; v[2]=y; v[3]=z; v[4]=t; return v; }
     180             : INLINE GEN
     181      443052 : mkvecsmall5(long x,long y,long z,long t,long u) { GEN v = cgetg(6, t_VECSMALL);
     182      443052 :   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     5777739 : mkvec(GEN x) { retmkvec(x); }
     189             : INLINE GEN
     190    22549711 : mkvec2(GEN x, GEN y) { retmkvec2(x,y); }
     191             : INLINE GEN
     192    50866136 : mkvec3(GEN x, GEN y, GEN z) { retmkvec3(x,y,z); }
     193             : INLINE GEN
     194     7328905 : mkvec4(GEN x, GEN y, GEN z, GEN t) { retmkvec4(x,y,z,t); }
     195             : INLINE GEN
     196    11756372 : 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       12026 : 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       33278 : mkveccopy(GEN x) { GEN v = cgetg(2, t_VEC); gel(v,1) = gcopy(x); return v; }
     207             : INLINE GEN
     208      195304 : mkvec2copy(GEN x, GEN y) {
     209      195304 :   GEN v = cgetg(3,t_VEC); gel(v,1) = gcopy(x); gel(v,2) = gcopy(y); return v; }
     210             : /* col */
     211             : INLINE GEN
     212     2093632 : mkcol(GEN x) { retmkcol(x); }
     213             : INLINE GEN
     214    14738374 : 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         729 : 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       25832 : mkcolcopy(GEN x) { GEN v = cgetg(2, t_COL); gel(v,1) = gcopy(x); return v; }
     233             : /* mat */
     234             : INLINE GEN
     235      713062 : mkmat(GEN x) { retmkmat(x); }
     236             : INLINE GEN
     237    15696620 : 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        7117 : 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       14023 : mkoo(void) { GEN v = cgetg(2, t_INFINITY); gel(v,1) = gen_1; return v; }
     250             : INLINE GEN
     251        7853 : mkmoo(void) { GEN v = cgetg(2, t_INFINITY); gel(v,1) = gen_m1; return v; }
     252             : INLINE long
     253       28915 : inf_get_sign(GEN x) { return signe(gel(x,1)); }
     254             : /* pol */
     255             : INLINE GEN
     256      682922 : pol_x(long v) {
     257      682922 :   GEN p = cgetg(4, t_POL);
     258      682922 :   p[1] = evalsigne(1)|evalvarn(v);
     259      682922 :   gel(p,2) = gen_0;
     260      682922 :   gel(p,3) = gen_1; return p;
     261             : }
     262             : /* x^n, assume n >= 0 */
     263             : INLINE GEN
     264     2310100 : pol_xn(long n, long v) {
     265     2310100 :   long i, a = n+2;
     266     2310100 :   GEN p = cgetg(a+1, t_POL);
     267     2310101 :   p[1] = evalsigne(1)|evalvarn(v);
     268     2310101 :   for (i = 2; i < a; i++) gel(p,i) = gen_0;
     269     2310101 :   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     1191430 : pol_1(long v) {
     280     1191430 :   GEN p = cgetg(3, t_POL);
     281     1191430 :   p[1] = evalsigne(1)|evalvarn(v);
     282     1191430 :   gel(p,2) = gen_1; return p;
     283             : }
     284             : INLINE GEN
     285    13729641 : pol_0(long v)
     286             : {
     287    13729641 :   GEN x = cgetg(2,t_POL);
     288    13729641 :   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     9340062 : 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       32189 : const_col(long n, GEN x) { retconst_col(n, x); }
     304             : INLINE GEN
     305     5061074 : const_vecsmall(long n, long c)
     306             : {
     307             :   long i;
     308     5061074 :   GEN V = cgetg(n+1,t_VECSMALL);
     309     5061075 :   for(i=1;i<=n;i++) V[i] = c;
     310     5061075 :   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     4025890 : ser_isexactzero(GEN x)
     344             : {
     345     4025890 :   if (!signe(x)) switch(lg(x))
     346             :   {
     347       12614 :     case 2: return 1;
     348         812 :     case 3: return isexactzero(gel(x,2));
     349             :   }
     350     4012464 :   return 0;
     351             : }
     352             : /* 0 * pol_x(v) */
     353             : INLINE GEN
     354     5046834 : zeropol(long v) { return pol_0(v); }
     355             : /* vector(n) */
     356             : INLINE GEN
     357    22104961 : zerocol(long n)
     358             : {
     359    22104961 :   GEN y = cgetg(n+1,t_COL);
     360    22104961 :   long i; for (i=1; i<=n; i++) gel(y,i) = gen_0;
     361    22104961 :   return y;
     362             : }
     363             : /* vectorv(n) */
     364             : INLINE GEN
     365     7826641 : zerovec(long n)
     366             : {
     367     7826641 :   GEN y = cgetg(n+1,t_VEC);
     368     7826646 :   long i; for (i=1; i<=n; i++) gel(y,i) = gen_0;
     369     7826646 :   return y;
     370             : }
     371             : /* matrix(m, n) */
     372             : INLINE GEN
     373        4662 : zeromat(long m, long n)
     374             : {
     375        4662 :   GEN y = cgetg(n+1,t_MAT);
     376        4662 :   GEN v = zerocol(m);
     377        4662 :   long i; for (i=1; i<=n; i++) gel(y,i) = v;
     378        4662 :   return y;
     379             : }
     380             : /* = zero_zx, sv is a evalvarn()*/
     381             : INLINE GEN
     382      777657 : zero_Flx(long sv) { return pol0_Flx(sv); }
     383             : INLINE GEN
     384    31980854 : zero_Flv(long n)
     385             : {
     386    31980854 :   GEN y = cgetg(n+1,t_VECSMALL);
     387    31981064 :   long i; for (i=1; i<=n; i++) y[i] = 0;
     388    31981064 :   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       74206 : zero_Flm_copy(long m, long n)
     402             : {
     403       74206 :   GEN y = cgetg(n+1,t_MAT);
     404       74208 :   long i; for (i=1; i<=n; i++) gel(y,i) = zero_Flv(m);
     405       74215 :   return y;
     406             : }
     407             : 
     408             : INLINE GEN
     409     3385491 : zero_F2v(long m)
     410             : {
     411     3385491 :   long l = nbits2nlong(m);
     412     3385491 :   GEN v  = zero_Flv(l+1);
     413     3385491 :   v[1] = m;
     414     3385491 :   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      269665 : zero_F2m_copy(long m, long n)
     431             : {
     432             :   long i;
     433      269665 :   GEN M = cgetg(n+1, t_MAT);
     434      765370 :   for (i = 1; i <= n; i++)
     435      495705 :     gel(M,i)= zero_F2v(m);
     436      269665 :   return M;
     437             : }
     438             : 
     439             : /* matrix(m, n) */
     440             : INLINE GEN
     441     1960207 : zeromatcopy(long m, long n)
     442             : {
     443     1960207 :   GEN y = cgetg(n+1,t_MAT);
     444     1960207 :   long i; for (i=1; i<=n; i++) gel(y,i) = zerocol(m);
     445     1960207 :   return y;
     446             : }
     447             : 
     448             : /* i-th vector in the standard basis */
     449             : INLINE GEN
     450     1316648 : col_ei(long n, long i) { GEN e = zerocol(n); gel(e,i) = gen_1; return e; }
     451             : INLINE GEN
     452      304179 : vec_ei(long n, long i) { GEN e = zerovec(n); gel(e,i) = gen_1; return e; }
     453             : INLINE GEN
     454           7 : F2v_ei(long n, long i) { GEN e = zero_F2v(n); F2v_set(e,i); return e; }
     455             : INLINE GEN
     456       40345 : vecsmall_ei(long n, long i) { GEN e = zero_zv(n); e[i] = 1; return e; }
     457             : INLINE GEN
     458     2879828 : Rg_col_ei(GEN x, long n, long i) { GEN e = zerocol(n); gel(e,i) = x; return e; }
     459             : 
     460             : INLINE GEN
     461     2273173 : shallowcopy(GEN x)
     462     2273173 : { return typ(x) == t_MAT ? RgM_shallowcopy(x): leafcopy(x); }
     463             : 
     464             : /* routines for naive growarrays */
     465             : INLINE GEN
     466    11510626 : vectrunc_init(long l)
     467             : {
     468    11510626 :   GEN z = new_chunk(l);
     469    11510993 :   z[0] = evaltyp(t_VEC) | _evallg(1); return z;
     470             : }
     471             : INLINE void
     472    42849843 : vectrunc_append(GEN x, GEN t)
     473    42849843 : { long l = lg(x); gel(x,l) = t; setlg(x, l+1); }
     474             : INLINE void
     475           0 : vectrunc_append_batch(GEN x, GEN y)
     476             : {
     477           0 :   long i, l = lg(x), ly = lg(y);
     478           0 :   GEN z = x + l-1;
     479           0 :   for (i = 1; i < ly; i++) gel(z,i) = gel(y,i);
     480           0 :   setlg(x, l+ly-1);
     481           0 : }
     482             : INLINE GEN
     483     1401807 : vecsmalltrunc_init(long l)
     484             : {
     485     1401807 :   GEN z = new_chunk(l);
     486     1401807 :   z[0] = evaltyp(t_VECSMALL) | _evallg(1); return z;
     487             : }
     488             : INLINE void
     489     2869442 : vecsmalltrunc_append(GEN x, long t)
     490     2869442 : { long l = lg(x); x[l] = t; setlg(x, l+1); }
     491             : 
     492             : /*******************************************************************/
     493             : /*                                                                 */
     494             : /*                        VEC / COL / VECSMALL                     */
     495             : /*                                                                 */
     496             : /*******************************************************************/
     497             : /* shallow*/
     498             : INLINE GEN
     499           0 : vec_shorten(GEN v, long n)
     500             : {
     501             :   long i;
     502           0 :   GEN V = cgetg(n+1,t_VEC);
     503           0 :   for(i=1;i<=n;i++) gel(V,i) = gel(v,i);
     504           0 :   return V;
     505             : }
     506             : /* shallow*/
     507             : INLINE GEN
     508       10577 : vec_lengthen(GEN v, long n)
     509             : {
     510             :   long i;
     511       10577 :   long l=lg(v);
     512       10577 :   GEN V = cgetg(n+1,t_VEC);
     513       10577 :   for(i=1;i<l;i++) gel(V,i) = gel(v,i);
     514       10577 :   return V;
     515             : }
     516             : /* shallow*/
     517             : INLINE GEN
     518       56056 : vec_append(GEN V, GEN s)
     519             : {
     520       56056 :   long i, l2 = lg(V);
     521       56056 :   GEN res = cgetg(l2+1, typ(V));
     522       56056 :   for (i = 1; i < l2; ++i) gel(res, i) = gel(V,i);
     523       56056 :   gel(res,l2) = s; return res;
     524             : }
     525             : /* shallow*/
     526             : INLINE GEN
     527           0 : vec_setconst(GEN v, GEN x)
     528             : {
     529           0 :   long i, l = lg(v);
     530           0 :   for (i = 1; i < l; i++) gel(v,i) = x;
     531           0 :   return v;
     532             : }
     533             : INLINE GEN
     534      127784 : vecsmall_shorten(GEN v, long n)
     535             : {
     536             :   long i;
     537      127784 :   GEN V = cgetg(n+1,t_VECSMALL);
     538      127786 :   for(i=1;i<=n;i++) V[i] = v[i];
     539      127786 :   return V;
     540             : }
     541             : INLINE GEN
     542          21 : vecsmall_lengthen(GEN v, long n)
     543             : {
     544          21 :   long i, l = lg(v);
     545          21 :   GEN V = cgetg(n+1,t_VECSMALL);
     546          21 :   for(i=1;i<l;i++) V[i] = v[i];
     547          21 :   return V;
     548             : }
     549             : 
     550             : INLINE GEN
     551      232706 : vec_to_vecsmall(GEN z)
     552             : {
     553      232706 :   long i, l = lg(z);
     554      232706 :   GEN x = cgetg(l, t_VECSMALL);
     555      232706 :   for (i=1; i<l; i++) x[i] = itos(gel(z,i));
     556      232706 :   return x;
     557             : }
     558             : INLINE GEN
     559       17066 : vecsmall_to_vec(GEN z)
     560             : {
     561       17066 :   long i, l = lg(z);
     562       17066 :   GEN x = cgetg(l,t_VEC);
     563       17066 :   for (i=1; i<l; i++) gel(x,i) = stoi(z[i]);
     564       17066 :   return x;
     565             : }
     566             : INLINE GEN
     567     1269697 : vecsmall_to_col(GEN z)
     568             : {
     569     1269697 :   long i, l = lg(z);
     570     1269697 :   GEN x = cgetg(l,t_COL);
     571     1269697 :   for (i=1; i<l; i++) gel(x,i) = stoi(z[i]);
     572     1269697 :   return x;
     573             : }
     574             : 
     575             : INLINE int
     576    25701387 : vecsmall_lexcmp(GEN x, GEN y)
     577             : {
     578             :   long lx,ly,l,i;
     579    25701387 :   lx = lg(x);
     580    25701387 :   ly = lg(y); l = minss(lx,ly);
     581    99174476 :   for (i=1; i<l; i++)
     582    94106072 :     if (x[i] != y[i]) return x[i]<y[i]? -1: 1;
     583     5068404 :   if (lx == ly) return 0;
     584          14 :   return (lx < ly)? -1 : 1;
     585             : }
     586             : 
     587             : INLINE int
     588    47066978 : vecsmall_prefixcmp(GEN x, GEN y)
     589             : {
     590    47066978 :   long i, lx = lg(x), ly = lg(y), l = minss(lx,ly);
     591   148811348 :   for (i=1; i<l; i++)
     592   134951817 :     if (x[i] != y[i]) return x[i]<y[i]? -1: 1;
     593    13859531 :   return 0;
     594             : }
     595             : 
     596             : /*Can be used on t_VEC, but coeffs not gcopy-ed*/
     597             : INLINE GEN
     598        1253 : vecsmall_prepend(GEN V, long s)
     599             : {
     600        1253 :   long i, l2 = lg(V);
     601        1253 :   GEN res = cgetg(l2+1, typ(V));
     602        1253 :   res[1] = s;
     603        1253 :   for (i = 2; i <= l2; ++i) res[i] = V[i - 1];
     604        1253 :   return res;
     605             : }
     606             : 
     607             : INLINE GEN
     608      371468 : vecsmall_append(GEN V, long s)
     609             : {
     610      371468 :   long i, l2 = lg(V);
     611      371468 :   GEN res = cgetg(l2+1, t_VECSMALL);
     612      371468 :   for (i = 1; i < l2; ++i) res[i] = V[i];
     613      371468 :   res[l2] = s; return res;
     614             : }
     615             : 
     616             : INLINE GEN
     617      243201 : vecsmall_concat(GEN u, GEN v)
     618             : {
     619      243201 :   long i, l1 = lg(u)-1, l2 = lg(v)-1;
     620      243201 :   GEN res = cgetg(l1+l2+1, t_VECSMALL);
     621      243201 :   for (i = 1; i <= l1; ++i) res[i]    = u[i];
     622      243201 :   for (i = 1; i <= l2; ++i) res[i+l1] = v[i];
     623      243201 :   return res;
     624             : }
     625             : 
     626             : /* return the number of indices where u and v are equal */
     627             : INLINE long
     628           0 : vecsmall_coincidence(GEN u, GEN v)
     629             : {
     630           0 :   long i, s = 0, l = minss(lg(u),lg(v));
     631           0 :   for(i=1; i<l; i++)
     632           0 :     if(u[i] == v[i]) s++;
     633           0 :   return s;
     634             : }
     635             : 
     636             : /* returns the first index i<=n such that x=v[i] if it exists, 0 otherwise */
     637             : INLINE long
     638           0 : vecsmall_isin(GEN v, long x)
     639             : {
     640           0 :   long i, l = lg(v);
     641           0 :   for (i = 1; i < l; i++)
     642           0 :     if (v[i] == x) return i;
     643           0 :   return 0;
     644             : }
     645             : 
     646             : INLINE long
     647          84 : vecsmall_pack(GEN V, long base, long mod)
     648             : {
     649          84 :   long i, s = 0;
     650          84 :   for(i=1; i<lg(V); i++) s = (base*s + V[i]) % mod;
     651          84 :   return s;
     652             : }
     653             : 
     654             : INLINE long
     655          14 : vecsmall_indexmax(GEN x)
     656             : {
     657          14 :   long i, i0 = 1, t = x[1], lx = lg(x);
     658          56 :   for (i=2; i<lx; i++)
     659          42 :     if (x[i] > t) t = x[i0=i];
     660          14 :   return i0;
     661             : }
     662             : 
     663             : INLINE long
     664       39841 : vecsmall_max(GEN x)
     665             : {
     666       39841 :   long i, t = x[1], lx = lg(x);
     667       67208 :   for (i=2; i<lx; i++)
     668       27367 :     if (x[i] > t) t = x[i];
     669       39841 :   return t;
     670             : }
     671             : 
     672             : INLINE long
     673          14 : vecsmall_indexmin(GEN x)
     674             : {
     675          14 :   long i, i0 = 1, t = x[1], lx =lg(x);
     676          56 :   for (i=2; i<lx; i++)
     677          42 :     if (x[i] < t) t = x[i0=i];
     678          14 :   return i0;
     679             : }
     680             : 
     681             : INLINE long
     682           0 : vecsmall_min(GEN x)
     683             : {
     684           0 :   long i, t = x[1], lx =lg(x);
     685           0 :   for (i=2; i<lx; i++)
     686           0 :     if (x[i] < t) t = x[i];
     687           0 :   return t;
     688             : }
     689             : 
     690             : INLINE int
     691     2038253 : ZV_isscalar(GEN x)
     692             : {
     693     2038253 :   long l = lg(x);
     694     7515195 :   while (--l > 1)
     695     5109559 :     if (signe(gel(x, l))) return 0;
     696      367383 :   return 1;
     697             : }
     698             : INLINE int
     699     6172218 : QV_isscalar(GEN x)
     700             : {
     701     6172218 :   long lx = lg(x),i;
     702     7212526 :   for (i=2; i<lx; i++)
     703     6684342 :     if (!isintzero(gel(x, i))) return 0;
     704      528184 :   return 1;
     705             : }
     706             : INLINE int
     707        3752 : RgV_isscalar(GEN x)
     708             : {
     709        3752 :   long lx = lg(x),i;
     710        7134 :   for (i=2; i<lx; i++)
     711        6202 :     if (!gequal0(gel(x, i))) return 0;
     712         932 :   return 1;
     713             : }
     714             : INLINE int
     715           0 : RgX_isscalar(GEN x)
     716             : {
     717             :   long i;
     718           0 :   for (i=lg(x)-1; i>2; i--)
     719           0 :     if (!gequal0(gel(x, i))) return 0;
     720           0 :   return 1;
     721             : }
     722             : INLINE long
     723     4035229 : RgX_equal_var(GEN x, GEN y) { return varn(x) == varn(y) && RgX_equal(x,y); }
     724             : 
     725             : INLINE int
     726        2493 : RgX_is_rational(GEN x)
     727             : {
     728             :   long i;
     729       16583 :   for (i = lg(x)-1; i > 1; i--)
     730       15385 :     if (!is_rational_t(typ(gel(x,i)))) return 0;
     731        1198 :   return 1;
     732             : }
     733             : INLINE int
     734    55097097 : RgX_is_ZX(GEN x)
     735             : {
     736             :   long i;
     737   249731130 :   for (i = lg(x)-1; i > 1; i--)
     738   199871612 :     if (typ(gel(x,i)) != t_INT) return 0;
     739    49859518 :   return 1;
     740             : }
     741             : INLINE int
     742      162200 : RgX_is_QX(GEN x)
     743             : {
     744      162200 :   long k = lg(x)-1;
     745      636132 :   for ( ; k>1; k--)
     746      474786 :     if (!is_rational_t(typ(gel(x,k)))) return 0;
     747      161346 :   return 1;
     748             : }
     749             : INLINE int
     750    15223027 : RgX_is_monomial(GEN x)
     751             : {
     752             :   long i;
     753    15223027 :   if (!signe(x)) return 0;
     754    24996422 :   for (i=lg(x)-2; i>1; i--)
     755    17376842 :     if (!isexactzero(gel(x,i))) return 0;
     756     7619580 :   return 1;
     757             : }
     758             : INLINE int
     759     2481657 : RgV_is_ZV(GEN x)
     760             : {
     761             :   long i;
     762     8797764 :   for (i = lg(x)-1; i > 0; i--)
     763     6316800 :     if (typ(gel(x,i)) != t_INT) return 0;
     764     2480964 :   return 1;
     765             : }
     766             : INLINE int
     767         147 : RgV_is_QV(GEN x)
     768             : {
     769             :   long i;
     770         413 :   for (i = lg(x)-1; i > 0; i--)
     771         280 :     if (!is_rational_t(typ(gel(x,i)))) return 0;
     772         133 :   return 1;
     773             : }
     774             : 
     775             : /********************************************************************/
     776             : /**                                                                **/
     777             : /**            Dynamic arrays implementation                       **/
     778             : /**                                                                **/
     779             : /********************************************************************/
     780             : INLINE void **
     781   329965201 : pari_stack_base(pari_stack *s) { return s->data; }
     782             : 
     783             : INLINE void
     784      897088 : pari_stack_init(pari_stack *s, size_t size, void **data)
     785             : {
     786      897088 :   s->data = data;
     787      897088 :   *data = NULL;
     788      897088 :   s->n = 0;
     789      897088 :   s->alloc = 0;
     790      897088 :   s->size = size;
     791      897088 : }
     792             : 
     793             : INLINE void
     794   329112470 : pari_stack_alloc(pari_stack *s, long nb)
     795             : {
     796   329112470 :   void **sdat = pari_stack_base(s);
     797   329254947 :   long alloc = s->alloc;
     798   658510819 :   if (s->n+nb <= alloc) return;
     799      308452 :   if (!alloc)
     800      261915 :     alloc = nb;
     801             :   else
     802             :   {
     803       46537 :     while (s->n+nb > alloc) alloc <<= 1;
     804             :   }
     805      308452 :   *sdat = pari_realloc(*sdat,alloc*s->size);
     806      309377 :   s->alloc = alloc;
     807             : }
     808             : 
     809             : INLINE long
     810   275684802 : pari_stack_new(pari_stack *s) { pari_stack_alloc(s, 1); return s->n++; }
     811             : 
     812             : INLINE void
     813      778027 : pari_stack_delete(pari_stack *s)
     814             : {
     815      778027 :   void **sdat = pari_stack_base(s);
     816      777738 :   if (*sdat) pari_free(*sdat);
     817      777899 : }
     818             : 
     819             : INLINE void
     820        5803 : pari_stack_pushp(pari_stack *s, void *u)
     821             : {
     822        5803 :   long n = pari_stack_new(s);
     823        5803 :   void **sdat =(void**) *pari_stack_base(s);
     824        5803 :   sdat[n] = u;
     825        5803 : }
     826             : 
     827             : /*******************************************************************/
     828             : /*                                                                 */
     829             : /*                            EXTRACT                              */
     830             : /*                                                                 */
     831             : /*******************************************************************/
     832             : INLINE GEN
     833     3778640 : vecslice(GEN A, long y1, long y2)
     834             : {
     835     3778640 :   long i,lB = y2 - y1 + 2;
     836     3778640 :   GEN B = cgetg(lB, typ(A));
     837     3778640 :   for (i=1; i<lB; i++) B[i] = A[y1-1+i];
     838     3778640 :   return B;
     839             : }
     840             : INLINE GEN
     841      140600 : vecslicepermute(GEN A, GEN p, long y1, long y2)
     842             : {
     843      140600 :   long i,lB = y2 - y1 + 2;
     844      140600 :   GEN B = cgetg(lB, typ(A));
     845      140600 :   for (i=1; i<lB; i++) B[i] = A[p[y1-1+i]];
     846      140600 :   return B;
     847             : }
     848             : /* rowslice(rowpermute(A,p), x1, x2) */
     849             : INLINE GEN
     850       35196 : rowslicepermute(GEN A, GEN p, long x1, long x2)
     851             : {
     852       35196 :   long i, lB = lg(A);
     853       35196 :   GEN B = cgetg(lB, typ(A));
     854       35196 :   for (i=1; i<lB; i++) gel(B,i) = vecslicepermute(gel(A,i),p,x1,x2);
     855       35196 :   return B;
     856             : }
     857             : INLINE GEN
     858      229976 : rowslice(GEN A, long x1, long x2)
     859             : {
     860      229976 :   long i, lB = lg(A);
     861      229976 :   GEN B = cgetg(lB, typ(A));
     862      229976 :   for (i=1; i<lB; i++) gel(B,i) = vecslice(gel(A,i),x1,x2);
     863      229976 :   return B;
     864             : }
     865             : 
     866             : INLINE GEN
     867      114555 : matslice(GEN A, long x1, long x2, long y1, long y2)
     868             : {
     869      114555 :   return rowslice(vecslice(A, y1, y2), x1, x2);
     870             : }
     871             : 
     872             : /* shallow, remove coeff of index j */
     873             : INLINE GEN
     874         133 : rowsplice(GEN a, long j)
     875             : {
     876             :   long i, l;
     877         133 :   GEN b = cgetg_copy(a,&l);
     878         133 :   for (i = 1; i < l; i++) gel(b,i) = vecsplice(gel(a,i), j);
     879         133 :   return b;
     880             : }
     881             : /* shallow, remove coeff of index j */
     882             : INLINE GEN
     883        8288 : vecsplice(GEN a, long j)
     884             : {
     885        8288 :   long i, k, l = lg(a);
     886             :   GEN b;
     887        8288 :   if (l == 1) pari_err(e_MISC, "incorrect component in vecsplice");
     888        8288 :   b = cgetg(l-1, typ(a));
     889       45962 :   for (i = k = 1; i < l; i++)
     890       37674 :     if (i != j) gel(b, k++) = gel(a,i);
     891        8288 :   return b;
     892             : }
     893             : /* shallow */
     894             : INLINE GEN
     895         756 : RgM_minor(GEN a, long i, long j)
     896             : {
     897         756 :   GEN b = vecsplice(a, j);
     898         756 :   long k, l = lg(b);
     899         756 :   for (k = 1; k < l; k++) gel(b,k) = vecsplice(gel(b,k), i);
     900         756 :   return b;
     901             : }
     902             : 
     903             : /* A[x0,] */
     904             : INLINE GEN
     905      115510 : row(GEN A, long x0)
     906             : {
     907      115510 :   long i, lB = lg(A);
     908      115510 :   GEN B  = cgetg(lB, t_VEC);
     909      115510 :   for (i=1; i<lB; i++) gel(B, i) = gcoeff(A, x0, i);
     910      115510 :   return B;
     911             : }
     912             : INLINE GEN
     913       25672 : Flm_row(GEN A, long x0)
     914             : {
     915       25672 :   long i, lB = lg(A);
     916       25672 :   GEN B  = cgetg(lB, t_VECSMALL);
     917       25672 :   for (i=1; i<lB; i++) B[i] = coeff(A, x0, i);
     918       25672 :   return B;
     919             : }
     920             : /* A[x0,] */
     921             : INLINE GEN
     922          56 : rowcopy(GEN A, long x0)
     923             : {
     924          56 :   long i, lB = lg(A);
     925          56 :   GEN B  = cgetg(lB, t_VEC);
     926          56 :   for (i=1; i<lB; i++) gel(B, i) = gcopy(gcoeff(A, x0, i));
     927          56 :   return B;
     928             : }
     929             : /* A[x0, x1..x2] */
     930             : INLINE GEN
     931        2177 : row_i(GEN A, long x0, long x1, long x2)
     932             : {
     933        2177 :   long i, lB = x2 - x1 + 2;
     934        2177 :   GEN B  = cgetg(lB, t_VEC);
     935        2177 :   for (i=x1; i<=x2; i++) gel(B, i) = gcoeff(A, x0, i);
     936        2177 :   return B;
     937             : }
     938             : 
     939             : INLINE GEN
     940     4730006 : vecreverse(GEN A)
     941             : {
     942             :   long i, l;
     943     4730006 :   GEN B = cgetg_copy(A, &l);
     944     4730006 :   for (i=1; i<l; i++) gel(B, i) = gel(A, l-i);
     945     4730006 :   return B;
     946             : }
     947             : 
     948             : INLINE GEN
     949         252 : vecsmall_reverse(GEN A)
     950             : {
     951             :   long i, l;
     952         252 :   GEN B = cgetg_copy(A, &l);
     953         252 :   for (i=1; i<l; i++) B[i] = A[l-i];
     954         252 :   return B;
     955             : }
     956             : 
     957             : INLINE void
     958         232 : vecreverse_inplace(GEN y)
     959             : {
     960         232 :   long ly = lg(y), lim = ly>>1, i;
     961         640 :   for (i = 1; i <= lim; i++)
     962             :   {
     963         408 :     GEN z = gel(y,i);
     964         408 :     gel(y,i)    = gel(y,ly-i);
     965         408 :     gel(y,ly-i) = z;
     966             :   }
     967         232 : }
     968             : 
     969             : INLINE GEN
     970    20065304 : vecsmallpermute(GEN A, GEN p) { return perm_mul(A, p); }
     971             : 
     972             : INLINE GEN
     973     4340794 : vecpermute(GEN A, GEN p)
     974             : {
     975     4340794 :   long i,lB = lg(p);
     976     4340794 :   GEN B = cgetg(lB, typ(A));
     977     4340794 :   for (i=1; i<lB; i++) gel(B, i) = gel(A, p[i]);
     978     4340794 :   return B;
     979             : }
     980             : INLINE GEN
     981       85093 : rowpermute(GEN A, GEN p)
     982             : {
     983       85093 :   long i, lB = lg(A);
     984       85093 :   GEN B = cgetg(lB, typ(A));
     985     1389410 :   for (i=1; i<lB; i++)
     986     2566753 :     gel(B, i) = typ(gel(A,i)) == t_VECSMALL ? vecsmallpermute(gel(A, i), p):
     987     1262436 :                                                     vecpermute(gel(A, i), p);
     988       85093 :   return B;
     989             : }
     990             : /*******************************************************************/
     991             : /*                                                                 */
     992             : /*                          PERMUTATIONS                           */
     993             : /*                                                                 */
     994             : /*******************************************************************/
     995             : /* identity permutation */
     996             : INLINE GEN
     997       70023 : identity_perm(long n)
     998             : {
     999       70023 :   GEN perm = cgetg(n+1, t_VECSMALL);
    1000             :   long i;
    1001       70023 :   for (i = 1; i <= n; i++) perm[i] = i;
    1002       70023 :   return perm;
    1003             : }
    1004             : 
    1005             : /* assume d <= n */
    1006             : INLINE GEN
    1007           0 : cyclic_perm(long n, long d)
    1008             : {
    1009           0 :   GEN perm = cgetg(n+1, t_VECSMALL);
    1010             :   long i;
    1011           0 :   for (i = 1; i <= n-d; i++) perm[i] = i+d;
    1012           0 :   for (     ; i <= n;   i++) perm[i] = i-n+d;
    1013           0 :   return perm;
    1014             : }
    1015             : 
    1016             : /* Multiply (compose) two permutations */
    1017             : INLINE GEN
    1018    23115918 : perm_mul(GEN s, GEN t)
    1019             : {
    1020             :   GEN u;
    1021    23115918 :   long i, l = lg(t);
    1022    23115918 :   u = cgetg(l, t_VECSMALL);
    1023    23115918 :   for (i = 1; i < l; i++) u[i] = s[ t[i] ];
    1024    23115918 :   return u;
    1025             : }
    1026             : /* Compute the inverse (reciprocal) of a permutation. */
    1027             : INLINE GEN
    1028      862519 : perm_inv(GEN x)
    1029             : {
    1030             :   long i, lx;
    1031      862519 :   GEN y = cgetg_copy(x, &lx);
    1032      862519 :   for (i=1; i<lx; i++) y[ x[i] ] = i;
    1033      862519 :   return y;
    1034             : }
    1035             : /* Return s*t*s^-1 */
    1036             : INLINE GEN
    1037          35 : perm_conj(GEN s, GEN t)
    1038             : {
    1039             :   long i, l;
    1040          35 :   GEN v = cgetg_copy(s, &l);
    1041          35 :   for (i = 1; i < l; i++) v[ s[i] ] = s[ t[i] ];
    1042          35 :   return v;
    1043             : }
    1044             : 
    1045             : /*********************************************************************/
    1046             : /*                       MALLOC/FREE WRAPPERS                        */
    1047             : /*********************************************************************/
    1048             : #define BLOCK_SIGALRM_START          \
    1049             : {                                    \
    1050             :   int block=PARI_SIGINT_block;       \
    1051             :   PARI_SIGINT_block = 2;             \
    1052             :   MT_SIGINT_BLOCK(block);
    1053             : 
    1054             : #define BLOCK_SIGINT_START           \
    1055             : {                                    \
    1056             :   int block=PARI_SIGINT_block;       \
    1057             :   PARI_SIGINT_block = 1;             \
    1058             :   MT_SIGINT_BLOCK(block);
    1059             : 
    1060             : #define BLOCK_SIGINT_END             \
    1061             :   PARI_SIGINT_block = block;         \
    1062             :   MT_SIGINT_UNBLOCK(block);          \
    1063             :   if (!block && PARI_SIGINT_pending) \
    1064             :   {                                  \
    1065             :     int sig = PARI_SIGINT_pending;   \
    1066             :     PARI_SIGINT_pending = 0;         \
    1067             :     raise(sig);                      \
    1068             :   }                                  \
    1069             : }
    1070             : 
    1071             : INLINE void
    1072    48755834 : pari_free(void *pointer)
    1073             : {
    1074    48755834 :   BLOCK_SIGINT_START;
    1075    48756709 :   free(pointer);
    1076    48756709 :   BLOCK_SIGINT_END;
    1077    48756428 : }
    1078             : INLINE void*
    1079   186207211 : pari_malloc(size_t size)
    1080             : {
    1081   186207211 :   if (size)
    1082             :   {
    1083             :     char *tmp;
    1084   186207211 :     BLOCK_SIGINT_START;
    1085   186208344 :     tmp = (char*)malloc(size);
    1086   186208344 :     BLOCK_SIGINT_END;
    1087   186208360 :     if (!tmp) pari_err(e_MEM);
    1088   186208360 :     return tmp;
    1089             :   }
    1090           0 :   if (DEBUGMEM) pari_warn(warner,"mallocing NULL object");
    1091           0 :   return NULL;
    1092             : }
    1093             : INLINE void*
    1094      314006 : pari_realloc(void *pointer, size_t size)
    1095             : {
    1096             :   char *tmp;
    1097             : 
    1098      314006 :   BLOCK_SIGINT_START;
    1099      315347 :   if (!pointer) tmp = (char *) malloc(size);
    1100       50005 :   else tmp = (char *) realloc(pointer,size);
    1101      315347 :   BLOCK_SIGINT_END;
    1102      314831 :   if (!tmp) pari_err(e_MEM);
    1103      314831 :   return tmp;
    1104             : }
    1105             : INLINE void*
    1106       30147 : pari_calloc(size_t size)
    1107             : {
    1108       30147 :   void *t = pari_malloc(size);
    1109       30147 :   memset(t, 0, size); return t;
    1110             : }
    1111             : INLINE GEN
    1112        5339 : cgetalloc(long t, size_t l)
    1113             : {
    1114        5339 :   GEN x = (GEN)pari_malloc(l * sizeof(long));
    1115        5339 :   x[0] = evaltyp(t) | evallg(l); return x;
    1116             : }
    1117             : 
    1118             : /*******************************************************************/
    1119             : /*                                                                 */
    1120             : /*                       GARBAGE COLLECTION                        */
    1121             : /*                                                                 */
    1122             : /*******************************************************************/
    1123             : /* copy integer x as if we had avma = av */
    1124             : INLINE GEN
    1125  3648366898 : icopy_avma(GEN x, pari_sp av)
    1126             : {
    1127  3648366898 :   long i = lgefint(x), lx = i;
    1128  3648366898 :   GEN y = ((GEN)av) - i;
    1129  3648366898 :   while (--i > 0) y[i] = x[i];
    1130  3648366898 :   y[0] = evaltyp(t_INT)|evallg(lx);
    1131  3648276092 :   return y;
    1132             : }
    1133             : /* copy leaf x as if we had avma = av */
    1134             : INLINE GEN
    1135   103625063 : leafcopy_avma(GEN x, pari_sp av)
    1136             : {
    1137   103625063 :   long i = lg(x);
    1138   103625063 :   GEN y = ((GEN)av) - i;
    1139   103625063 :   while (--i > 0) y[i] = x[i];
    1140   103625063 :   y[0] = x[0] & (~CLONEBIT);
    1141   103625063 :   return y;
    1142             : }
    1143             : INLINE GEN
    1144   512489076 : gerepileuptoleaf(pari_sp av, GEN x)
    1145             : {
    1146             :   long lx;
    1147             :   GEN q;
    1148             : 
    1149   512489076 :   if (!isonstack(x) || (GEN)av<=x) { avma = av; return x; }
    1150   513197565 :   lx = lg(x);
    1151   513197565 :   q = ((GEN)av) - lx;
    1152   513197565 :   avma = (pari_sp)q;
    1153   513197565 :   while (--lx >= 0) q[lx] = x[lx];
    1154   513197565 :   return q;
    1155             : }
    1156             : INLINE GEN
    1157   920985281 : gerepileuptoint(pari_sp av, GEN x)
    1158             : {
    1159   920985281 :   if (!isonstack(x) || (GEN)av<=x) { avma = av; return x; }
    1160   798115782 :   avma = (pari_sp)icopy_avma(x, av);
    1161   798353467 :   return (GEN)avma;
    1162             : }
    1163             : INLINE GEN
    1164   628010918 : gerepileupto(pari_sp av, GEN x)
    1165             : {
    1166   628010918 :   if (!isonstack(x) || (GEN)av<=x) { avma = av; return x; }
    1167   559766911 :   switch(typ(x))
    1168             :   { /* non-default = !is_recursive_t(tq) */
    1169   170032452 :     case t_INT: return gerepileuptoint(av, x);
    1170             :     case t_REAL:
    1171             :     case t_STR:
    1172   110360605 :     case t_VECSMALL: return gerepileuptoleaf(av,x);
    1173             :     default:
    1174             :       /* NB: x+i --> ((long)x) + i*sizeof(long) */
    1175   279373854 :       return gerepile(av, (pari_sp) (x+lg(x)), x);
    1176             :   }
    1177             : }
    1178             : 
    1179             : /* gerepileupto(av, gcopy(x)) */
    1180             : INLINE GEN
    1181    36192933 : gerepilecopy(pari_sp av, GEN x)
    1182             : {
    1183    36192933 :   if (is_recursive_t(typ(x)))
    1184             :   {
    1185    30121844 :     GENbin *p = copy_bin(x);
    1186    30121849 :     avma = av; return bin_copy(p);
    1187             :   }
    1188             :   else
    1189             :   {
    1190     6073338 :     avma = av;
    1191     6073338 :     if (x < (GEN)av) {
    1192     4826339 :       if (x < (GEN)pari_mainstack->bot) new_chunk(lg(x));
    1193     4826339 :       x = leafcopy_avma(x, av);
    1194     4832138 :       avma = (pari_sp)x;
    1195             :     } else
    1196     1246999 :       x = leafcopy(x);
    1197     6083475 :     return x;
    1198             :   }
    1199             : }
    1200             : 
    1201             : /* Takes an array of pointers to GENs, of length n. Copies all
    1202             :  * objects to contiguous locations and cleans up the stack between
    1203             :  * av and avma. */
    1204             : INLINE void
    1205       64820 : gerepilemany(pari_sp av, GEN* gptr[], int n)
    1206             : {
    1207             :   int i;
    1208       64820 :   for (i=0; i<n; i++) *gptr[i] = (GEN)copy_bin(*gptr[i]);
    1209       64820 :   avma = av;
    1210       64820 :   for (i=0; i<n; i++) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1211       64820 : }
    1212             : 
    1213             : INLINE void
    1214     4918208 : gerepileall(pari_sp av, int n, ...)
    1215             : {
    1216             :   int i;
    1217     4918208 :   va_list a; va_start(a, n);
    1218     4918208 :   if (n < 10)
    1219             :   {
    1220             :     GEN *gptr[10];
    1221    15075125 :     for (i=0; i<n; i++)
    1222    10156918 :     { gptr[i] = va_arg(a,GEN*); *gptr[i] = (GEN)copy_bin(*gptr[i]); }
    1223     4918207 :     avma = av;
    1224     4918207 :     for (--i; i>=0; i--) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1225             : 
    1226             :   }
    1227             :   else
    1228             :   {
    1229           0 :     GEN **gptr = (GEN**)  pari_malloc(n*sizeof(GEN*));
    1230           0 :     for (i=0; i<n; i++)
    1231           0 :     { gptr[i] = va_arg(a,GEN*); *gptr[i] = (GEN)copy_bin(*gptr[i]); }
    1232           0 :     avma = av;
    1233           0 :     for (--i; i>=0; i--) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1234           0 :     pari_free(gptr);
    1235             :   }
    1236     4918216 :   va_end(a);
    1237     4918216 : }
    1238             : 
    1239             : INLINE void
    1240           8 : gerepilecoeffs(pari_sp av, GEN x, int n)
    1241             : {
    1242             :   int i;
    1243           8 :   for (i=0; i<n; i++) gel(x,i) = (GEN)copy_bin(gel(x,i));
    1244           8 :   avma = av;
    1245           8 :   for (i=0; i<n; i++) gel(x,i) = bin_copy((GENbin*)x[i]);
    1246           8 : }
    1247             : 
    1248             : /* p from copy_bin. Copy p->x back to stack, then destroy p */
    1249             : INLINE GEN
    1250    40452553 : bin_copy(GENbin *p)
    1251             : {
    1252             :   GEN x, y, base;
    1253             :   long dx, len;
    1254             : 
    1255    40452553 :   x   = p->x; if (!x) { pari_free(p); return gen_0; }
    1256    40449951 :   len = p->len;
    1257    40449951 :   base= p->base; dx = x - base;
    1258    40449951 :   y = (GEN)memcpy((void*)new_chunk(len), (void*)GENbinbase(p), len*sizeof(long));
    1259    40449915 :   y += dx;
    1260    40449915 :   p->rebase(y, ((ulong)y-(ulong)x));
    1261    40449933 :   pari_free(p); return y;
    1262             : }
    1263             : 
    1264             : INLINE GEN
    1265    80902500 : GENbinbase(GENbin *p) { return (GEN)(p + 1); }
    1266             : 
    1267             : INLINE void
    1268    26988763 : cgiv(GEN x)
    1269             : {
    1270    26988763 :   pari_sp av = (pari_sp)(x+lg(x));
    1271    26988763 :   if (isonstack((GEN)av)) avma = av;
    1272    26988602 : }
    1273             : 
    1274             : INLINE void
    1275     1109379 : killblock(GEN x) { gunclone(x); }
    1276             : 
    1277             : INLINE int
    1278    17057224 : is_universal_constant(GEN x) { return (x >= gen_0 && x <= ghalf); }
    1279             : 
    1280             : /*******************************************************************/
    1281             : /*                                                                 */
    1282             : /*                    CONVERSION / ASSIGNMENT                      */
    1283             : /*                                                                 */
    1284             : /*******************************************************************/
    1285             : /* z is a type which may be a t_COMPLEX component (not a t_QUAD) */
    1286             : INLINE GEN
    1287     2076301 : cxcompotor(GEN z, long prec)
    1288             : {
    1289     2076301 :   switch(typ(z))
    1290             :   {
    1291     1049843 :     case t_INT:  return itor(z, prec);
    1292      134120 :     case t_FRAC: return fractor(z, prec);
    1293      892338 :     case t_REAL: return rtor(z, prec);
    1294           0 :     default: pari_err_TYPE("cxcompotor",z);
    1295             :              return NULL; /* LCOV_EXCL_LINE */
    1296             :   }
    1297             : }
    1298             : INLINE GEN
    1299     1036448 : cxtofp(GEN x, long prec)
    1300     1036448 : { retmkcomplex(cxcompotor(gel(x,1),prec), cxcompotor(gel(x,2),prec)); }
    1301             : 
    1302             : INLINE double
    1303    21265938 : gtodouble(GEN x)
    1304             : {
    1305    21265938 :   if (typ(x)!=t_REAL) {
    1306     4108503 :     pari_sp av = avma;
    1307     4108503 :     x = gtofp(x, DEFAULTPREC);
    1308     4108503 :     if (typ(x)!=t_REAL) pari_err_TYPE("gtodouble [t_REAL expected]", x);
    1309     4108503 :     avma = av;
    1310             :   }
    1311    21265938 :   return rtodbl(x);
    1312             : }
    1313             : INLINE long
    1314    64664792 : gtos(GEN x) {
    1315    64664792 :   if (typ(x) != t_INT) pari_err_TYPE("gtos [integer expected]",x);
    1316    64664785 :   return itos(x);
    1317             : }
    1318             : 
    1319             : INLINE ulong
    1320       82489 : gtou(GEN x) {
    1321       82489 :   if (typ(x) != t_INT || signe(x)<0)
    1322           0 :     pari_err_TYPE("gtou [integer >=0 expected]",x);
    1323       82695 :   return itou(x);
    1324             : }
    1325             : 
    1326             : INLINE GEN
    1327     1673061 : absfrac(GEN x)
    1328             : {
    1329     1673061 :   GEN y = cgetg(3, t_FRAC);
    1330     1673061 :   gel(y,1) = absi(gel(x,1));
    1331     1673061 :   gel(y,2) = icopy(gel(x,2)); return y;
    1332             : }
    1333             : INLINE GEN
    1334       10909 : absfrac_shallow(GEN x)
    1335       10909 : { return signe(gel(x,1))>0? x: mkfrac(negi(gel(x,1)), gel(x,2)); }
    1336             : INLINE GEN
    1337      531664 : Q_abs(GEN x) { return (typ(x) == t_INT)? absi(x): absfrac(x); }
    1338             : INLINE GEN
    1339       31799 : Q_abs_shallow(GEN x)
    1340       31799 : { return (typ(x) == t_INT)? absi_shallow(x): absfrac_shallow(x); }
    1341             : INLINE GEN
    1342         322 : R_abs_shallow(GEN x)
    1343         322 : { return (typ(x) == t_FRAC)? absfrac_shallow(x): mpabs_shallow(x); }
    1344             : INLINE GEN
    1345           0 : R_abs(GEN x)
    1346           0 : { return (typ(x) == t_FRAC)? absfrac(x): mpabs(x); }
    1347             : 
    1348             : /* Force z to be of type real/complex with floating point components */
    1349             : INLINE GEN
    1350    17474142 : gtofp(GEN z, long prec)
    1351             : {
    1352    17474142 :   switch(typ(z))
    1353             :   {
    1354     7935027 :     case t_INT:  return itor(z, prec);
    1355     4600241 :     case t_FRAC: return fractor(z, prec);
    1356     4074511 :     case t_REAL: return rtor(z, prec);
    1357             :     case t_COMPLEX: {
    1358      864363 :       GEN a = gel(z,1), b = gel(z,2);
    1359      864363 :       if (isintzero(b)) return cxcompotor(a, prec);
    1360      862662 :       if (isintzero(a)) {
    1361        1662 :         GEN y = cgetg(3, t_COMPLEX);
    1362        1662 :         b = cxcompotor(b, prec);
    1363        1662 :         gel(y,1) = real_0_bit(expo(b) - prec2nbits(prec));
    1364        1662 :         gel(y,2) = b; return y;
    1365             :       }
    1366      861000 :       return cxtofp(z, prec);
    1367             :     }
    1368           0 :     case t_QUAD: return quadtofp(z, prec);
    1369           0 :     default: pari_err_TYPE("gtofp",z);
    1370             :              return NULL; /* LCOV_EXCL_LINE */
    1371             :   }
    1372             : }
    1373             : /* Force z to be of type real / int */
    1374             : INLINE GEN
    1375       22400 : gtomp(GEN z, long prec)
    1376             : {
    1377       22400 :   switch(typ(z))
    1378             :   {
    1379          14 :     case t_INT:  return z;
    1380       22386 :     case t_FRAC: return fractor(z, prec);
    1381           0 :     case t_REAL: return rtor(z, prec);
    1382           0 :     case t_QUAD: z = quadtofp(z, prec);
    1383           0 :                  if (typ(z) == t_REAL) return z;
    1384           0 :     default: pari_err_TYPE("gtomp",z);
    1385             :              return NULL; /* LCOV_EXCL_LINE */
    1386             :   }
    1387             : }
    1388             : 
    1389             : INLINE GEN
    1390      460730 : RgX_gtofp(GEN x, long prec)
    1391             : {
    1392             :   long l;
    1393      460730 :   GEN y = cgetg_copy(x, &l);
    1394      460730 :   while (--l > 1) gel(y,l) = gtofp(gel(x,l), prec);
    1395      460730 :   y[1] = x[1]; return y;
    1396             : }
    1397             : INLINE GEN
    1398      264576 : RgC_gtofp(GEN x, long prec)
    1399             : {
    1400      264576 :   long l = lg(x);
    1401      264576 :   GEN y = cgetg(l, t_COL);
    1402      264576 :   while (--l > 0) gel(y,l) = gtofp(gel(x,l), prec);
    1403      264576 :   return y;
    1404             : }
    1405             : INLINE GEN
    1406       18747 : RgM_gtofp(GEN x, long prec)
    1407             : {
    1408             :   long l;
    1409       18747 :   GEN y = cgetg_copy(x, &l);
    1410       18747 :   while (--l > 0) gel(y,l) = RgC_gtofp(gel(x,l), prec);
    1411       18747 :   return y;
    1412             : }
    1413             : INLINE GEN
    1414         560 : RgC_gtomp(GEN x, long prec)
    1415             : {
    1416         560 :   long l = lg(x);
    1417         560 :   GEN y = cgetg(l, t_COL);
    1418         560 :   while (--l > 0) gel(y,l) = gtomp(gel(x,l), prec);
    1419         560 :   return y;
    1420             : }
    1421             : INLINE GEN
    1422          14 : RgM_gtomp(GEN x, long prec)
    1423             : {
    1424             :   long l;
    1425          14 :   GEN y = cgetg_copy(x, &l);
    1426          14 :   while (--l > 0) gel(y,l) = RgC_gtomp(gel(x,l), prec);
    1427          14 :   return y;
    1428             : }
    1429             : 
    1430             : INLINE GEN
    1431        7162 : RgX_fpnorml2(GEN x, long prec)
    1432             : {
    1433        7162 :   pari_sp av = avma;
    1434        7162 :   return gerepileupto(av, gnorml2(RgX_gtofp(x, prec)));
    1435             : }
    1436             : INLINE GEN
    1437      132616 : RgC_fpnorml2(GEN x, long prec)
    1438             : {
    1439      132616 :   pari_sp av = avma;
    1440      132616 :   return gerepileupto(av, gnorml2(RgC_gtofp(x, prec)));
    1441             : }
    1442             : INLINE GEN
    1443        1472 : RgM_fpnorml2(GEN x, long prec)
    1444             : {
    1445        1472 :   pari_sp av = avma;
    1446        1472 :   return gerepileupto(av, gnorml2(RgM_gtofp(x, prec)));
    1447             : }
    1448             : 
    1449             : /* y a t_REAL */
    1450             : INLINE void
    1451      180482 : affgr(GEN x, GEN y)
    1452             : {
    1453             :   pari_sp av;
    1454      180482 :   switch(typ(x)) {
    1455         260 :     case t_INT:  affir(x,y); break;
    1456      180222 :     case t_REAL: affrr(x,y); break;
    1457           0 :     case t_FRAC: rdiviiz(gel(x,1),gel(x,2), y); break;
    1458           0 :     case t_QUAD: av = avma; affgr(quadtofp(x,realprec(y)), y); avma = av; break;
    1459           0 :     default: pari_err_TYPE2("=",x,y);
    1460             :   }
    1461      180482 : }
    1462             : 
    1463             : INLINE GEN
    1464      186420 : affc_fixlg(GEN x, GEN res)
    1465             : {
    1466      186420 :   if (typ(x) == t_COMPLEX)
    1467             :   {
    1468      175525 :     affrr_fixlg(gel(x,1), gel(res,1));
    1469      175525 :     affrr_fixlg(gel(x,2), gel(res,2));
    1470             :   }
    1471             :   else
    1472             :   {
    1473       10895 :     avma = (pari_sp)(res+3);
    1474       10895 :     res = cgetr(realprec(gel(res,1)));
    1475       10895 :     affrr_fixlg(x, res);
    1476             :   }
    1477      186420 :   return res;
    1478             : }
    1479             : 
    1480             : INLINE GEN
    1481           0 : trunc_safe(GEN x) { long e; return gcvtoi(x,&e); }
    1482             : 
    1483             : /*******************************************************************/
    1484             : /*                                                                 */
    1485             : /*                          LENGTH CONVERSIONS                     */
    1486             : /*                                                                 */
    1487             : /*******************************************************************/
    1488             : INLINE long
    1489       23139 : ndec2nlong(long x) { return 1 + (long)((x)*(LOG2_10/BITS_IN_LONG)); }
    1490             : INLINE long
    1491       22678 : ndec2prec(long x) { return 2 + ndec2nlong(x); }
    1492             : INLINE long
    1493         461 : ndec2nbits(long x) { return ndec2nlong(x) << TWOPOTBITS_IN_LONG; }
    1494             : /* Fast implementation of ceil(x / (8*sizeof(long))); typecast to (ulong)
    1495             :  * to avoid overflow. Faster than 1 + ((x-1)>>TWOPOTBITS_IN_LONG)) :
    1496             :  *   addl, shrl instead of subl, sarl, addl */
    1497             : INLINE long
    1498     3644805 : nbits2nlong(long x) {
    1499     3644805 :   return (long)(((ulong)x+BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1500             : }
    1501             : 
    1502             : INLINE long
    1503   240349318 : nbits2extraprec(long x) {
    1504   240349318 :   return (long)(((ulong)x+BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1505             : }
    1506             : 
    1507             : /* Fast implementation of 2 + nbits2nlong(x) */
    1508             : INLINE long
    1509    74509489 : nbits2prec(long x) {
    1510    74509489 :   return (long)(((ulong)x+3*BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1511             : }
    1512             : INLINE long
    1513     3281934 : nbits2lg(long x) {
    1514     3281934 :   return (long)(((ulong)x+3*BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1515             : }
    1516             : /* ceil(x / sizeof(long)) */
    1517             : INLINE long
    1518     6779124 : nchar2nlong(long x) {
    1519     6779124 :   return (long)(((ulong)x+sizeof(long)-1) >> (TWOPOTBITS_IN_LONG-3L));
    1520             : }
    1521             : INLINE long
    1522  1178712417 : prec2nbits(long x) { return (x-2) * BITS_IN_LONG; }
    1523             : INLINE double
    1524      453079 : bit_accuracy_mul(long x, double y) { return (x-2) * (BITS_IN_LONG*y); }
    1525             : INLINE double
    1526      229431 : prec2nbits_mul(long x, double y) { return (x-2) * (BITS_IN_LONG*y); }
    1527             : INLINE long
    1528    23581752 : bit_prec(GEN x) { return prec2nbits(realprec(x)); }
    1529             : INLINE long
    1530  1099643361 : bit_accuracy(long x) { return prec2nbits(x); }
    1531             : INLINE long
    1532       12057 : prec2ndec(long x) { return (long)prec2nbits_mul(x, LOG10_2); }
    1533             : INLINE long
    1534         172 : nbits2ndec(long x) { return (long)(x * LOG10_2); }
    1535             : INLINE long
    1536        1650 : precdbl(long x) {return (x - 1) << 1;}
    1537             : INLINE long
    1538  2992429286 : divsBIL(long n) { return n >> TWOPOTBITS_IN_LONG; }
    1539             : INLINE long
    1540  2928088752 : remsBIL(long n) { return n & (BITS_IN_LONG-1); }
    1541             : 
    1542             : /*********************************************************************/
    1543             : /**                                                                 **/
    1544             : /**                      OPERATIONS MODULO m                        **/
    1545             : /**                                                                 **/
    1546             : /*********************************************************************/
    1547             : /* Assume m > 0, more efficient if 0 <= a, b < m */
    1548             : 
    1549             : INLINE GEN
    1550     1723301 : Fp_red(GEN a, GEN m) { return modii(a, m); }
    1551             : INLINE GEN
    1552    62862311 : Fp_add(GEN a, GEN b, GEN m)
    1553             : {
    1554    62862311 :   pari_sp av=avma;
    1555    62862311 :   GEN p = addii(a,b);
    1556    62840068 :   long s = signe(p);
    1557    62840068 :   if (!s) return p; /* = gen_0 */
    1558    52193286 :   if (s > 0) /* general case */
    1559             :   {
    1560    51971370 :     GEN t = subii(p, m);
    1561    51987745 :     s = signe(t);
    1562    51987745 :     if (!s) { avma = av; return gen_0; }
    1563    46302316 :     if (s < 0) { avma = (pari_sp)p; return p; }
    1564    18008608 :     if (cmpii(t, m) < 0) return gerepileuptoint(av, t); /* general case ! */
    1565     1122335 :     p = remii(t, m);
    1566             :   }
    1567             :   else
    1568      221916 :     p = modii(p, m);
    1569     1344251 :   return gerepileuptoint(av, p);
    1570             : }
    1571             : INLINE GEN
    1572    45694085 : Fp_sub(GEN a, GEN b, GEN m)
    1573             : {
    1574    45694085 :   pari_sp av=avma;
    1575    45694085 :   GEN p = subii(a,b);
    1576    45770007 :   long s = signe(p);
    1577    45770007 :   if (!s) return p; /* = gen_0 */
    1578    38351204 :   if (s > 0)
    1579             :   {
    1580    18680201 :     if (cmpii(p, m) < 0) return p; /* general case ! */
    1581      742259 :     p = remii(p, m);
    1582             :   }
    1583             :   else
    1584             :   {
    1585    19671003 :     GEN t = addii(p, m);
    1586    19660898 :     if (!s) { avma = av; return gen_0; }
    1587    19660898 :     if (s > 0) return gerepileuptoint(av, t); /* general case ! */
    1588    19660898 :     p = modii(t, m);
    1589             :   }
    1590    20406523 :   return gerepileuptoint(av, p);
    1591             : }
    1592             : INLINE GEN
    1593    10738576 : Fp_neg(GEN b, GEN m)
    1594             : {
    1595    10738576 :   pari_sp av = avma;
    1596    10738576 :   long s = signe(b);
    1597             :   GEN p;
    1598    10738576 :   if (!s) return gen_0;
    1599     7406757 :   if (s > 0)
    1600             :   {
    1601     7225307 :     p = subii(m, b);
    1602     7225118 :     if (signe(p) >= 0) return p; /* general case ! */
    1603       74515 :     p = modii(p, m);
    1604             :   } else
    1605      181450 :     p = remii(negi(b), m);
    1606      255965 :   return gerepileuptoint(av, p);
    1607             : }
    1608             : 
    1609             : INLINE GEN
    1610       19785 : Fp_halve(GEN a, GEN p)
    1611             : {
    1612       19785 :   if (mpodd(a)) a = addii(a,p);
    1613       19785 :   return shifti(a,-1);
    1614             : }
    1615             : 
    1616             : /* assume 0 <= u < p and ps2 = p>>1 */
    1617             : INLINE GEN
    1618     5184662 : Fp_center(GEN u, GEN p, GEN ps2)
    1619     5184662 : { return abscmpii(u,ps2)<=0? icopy(u): subii(u,p); }
    1620             : 
    1621             : /* x + y*z mod p */
    1622             : INLINE GEN
    1623     1437485 : Fp_addmul(GEN x, GEN y, GEN z, GEN p)
    1624             : {
    1625             :   pari_sp av;
    1626     1437485 :   if (!signe(y) || !signe(z)) return Fp_red(x, p);
    1627     1437212 :   if (!signe(x)) return Fp_mul(z,y, p);
    1628     1147832 :   av = avma;
    1629     1147832 :   return gerepileuptoint(av, modii(addii(x, mulii(y,z)), p));
    1630             : }
    1631             : 
    1632             : INLINE GEN
    1633    50288347 : Fp_mul(GEN a, GEN b, GEN m)
    1634             : {
    1635    50288347 :   pari_sp av=avma;
    1636             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1637    50288347 :   (void)new_chunk(lg(a)+lg(b)+(lg(m)<<1));
    1638    50288716 :   p = mulii(a,b);
    1639    50287361 :   avma = av; return modii(p,m);
    1640             : }
    1641             : INLINE GEN
    1642     6951051 : Fp_sqr(GEN a, GEN m)
    1643             : {
    1644     6951051 :   pari_sp av=avma;
    1645             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1646     6951051 :   (void)new_chunk((lg(a)+lg(m))<<1);
    1647     6987374 :   p = sqri(a);
    1648     7017912 :   avma = av; return modii(p,m);
    1649             : }
    1650             : INLINE GEN
    1651    43388281 : Fp_mulu(GEN a, ulong b, GEN m)
    1652             : {
    1653    43388281 :   long l = lgefint(m);
    1654    43388281 :   if (l == 3)
    1655             :   {
    1656    30697387 :     ulong mm = m[2];
    1657    30697387 :     return utoi( Fl_mul(umodiu(a, mm), b, mm) );
    1658             :   } else {
    1659    12690894 :     pari_sp av = avma;
    1660             :     GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1661    12690894 :     (void)new_chunk(lg(a)+1+(l<<1));
    1662    12710660 :     p = muliu(a,b);
    1663    12441243 :     avma = av; return modii(p,m);
    1664             :   }
    1665             : }
    1666             : INLINE GEN
    1667           0 : Fp_muls(GEN a, long b, GEN m)
    1668             : {
    1669           0 :   long l = lgefint(m);
    1670           0 :   if (l == 3)
    1671             :   {
    1672           0 :     ulong mm = m[2];
    1673           0 :     if (b < 0)
    1674             :     {
    1675           0 :       ulong t = Fl_mul(umodiu(a, mm), -b, mm);
    1676           0 :       return t? utoipos(mm - t): gen_0;
    1677             :     }
    1678             :     else
    1679           0 :       return utoi( Fl_mul(umodiu(a, mm), b, mm) );
    1680             :   } else {
    1681           0 :     pari_sp av = avma;
    1682             :     GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1683           0 :     (void)new_chunk(lg(a)+1+(l<<1));
    1684           0 :     p = mulis(a,b);
    1685           0 :     avma = av; return modii(p,m);
    1686             :   }
    1687             : }
    1688             : 
    1689             : INLINE GEN
    1690     7684564 : Fp_inv(GEN a, GEN m)
    1691             : {
    1692             :   GEN res;
    1693     7684564 :   if (! invmod(a,m,&res)) pari_err_INV("Fp_inv", mkintmod(res,m));
    1694     7670450 :   return res;
    1695             : }
    1696             : INLINE GEN
    1697      291287 : Fp_invsafe(GEN a, GEN m)
    1698             : {
    1699             :   GEN res;
    1700      291287 :   if (! invmod(a,m,&res)) return NULL;
    1701      291287 :   return res;
    1702             : }
    1703             : INLINE GEN
    1704     4694118 : Fp_div(GEN a, GEN b, GEN m)
    1705             : {
    1706     4694118 :   pari_sp av=avma;
    1707             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1708     4694118 :   (void)new_chunk(lg(a)+(lg(m)<<1));
    1709     4705781 :   p = mulii(a, Fp_inv(b,m));
    1710     4711643 :   avma = av; return modii(p,m);
    1711             : }
    1712             : 
    1713             : INLINE GEN
    1714      665952 : Flx_mulu(GEN x, ulong a, ulong p) { return Flx_Fl_mul(x,a%p,p); }
    1715             : 
    1716             : /*******************************************************************/
    1717             : /*                                                                 */
    1718             : /*                        ADDMULII / SUBMULII                      */
    1719             : /*                                                                 */
    1720             : /*******************************************************************/
    1721             : /* x - y*z */
    1722             : INLINE GEN
    1723    13422682 : submulii(GEN x, GEN y, GEN z)
    1724             : {
    1725    13422682 :   long lx = lgefint(x), ly, lz;
    1726             :   pari_sp av;
    1727             :   GEN t;
    1728    13422682 :   if (lx == 2) { t = mulii(z,y); togglesign(t); return t; }
    1729    11616434 :   ly = lgefint(y);
    1730    11616434 :   if (ly == 2) return icopy(x);
    1731    10621418 :   lz = lgefint(z);
    1732    10621418 :   av = avma; (void)new_chunk(lx+ly+lz); /* HACK */
    1733    10621418 :   t = mulii(z, y);
    1734    10621418 :   avma = av; return subii(x,t);
    1735             : }
    1736             : /* y*z - x */
    1737             : INLINE GEN
    1738     2246276 : mulsubii(GEN y, GEN z, GEN x)
    1739             : {
    1740     2246276 :   long lx = lgefint(x), ly, lz;
    1741             :   pari_sp av;
    1742             :   GEN t;
    1743     2246276 :   if (lx == 2) return mulii(z,y);
    1744     1396745 :   ly = lgefint(y);
    1745     1396745 :   if (ly == 2) return negi(x);
    1746     1345999 :   lz = lgefint(z);
    1747     1345999 :   av = avma; (void)new_chunk(lx+ly+lz); /* HACK */
    1748     1345999 :   t = mulii(z, y);
    1749     1345999 :   avma = av; return subii(t,x);
    1750             : }
    1751             : 
    1752             : /* x - u*y */
    1753             : INLINE GEN
    1754        7000 : submuliu(GEN x, GEN y, ulong u)
    1755             : {
    1756             :   pari_sp av;
    1757        7000 :   long ly = lgefint(y);
    1758        7000 :   if (ly == 2) return icopy(x);
    1759        7000 :   av = avma;
    1760        7000 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1761        7000 :   y = mului(u,y);
    1762        7000 :   avma = av; return subii(x, y);
    1763             : }
    1764             : /* x + u*y */
    1765             : INLINE GEN
    1766        7000 : addmuliu(GEN x, GEN y, ulong u)
    1767             : {
    1768             :   pari_sp av;
    1769        7000 :   long ly = lgefint(y);
    1770        7000 :   if (ly == 2) return icopy(x);
    1771        7000 :   av = avma;
    1772        7000 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1773        7000 :   y = mului(u,y);
    1774        7000 :   avma = av; return addii(x, y);
    1775             : }
    1776             : /* x - u*y */
    1777             : INLINE GEN
    1778   110528578 : submuliu_inplace(GEN x, GEN y, ulong u)
    1779             : {
    1780             :   pari_sp av;
    1781   110528578 :   long ly = lgefint(y);
    1782   110528578 :   if (ly == 2) return x;
    1783    88596871 :   av = avma;
    1784    88596871 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1785    88596871 :   y = mului(u,y);
    1786    88596871 :   avma = av; return subii(x, y);
    1787             : }
    1788             : /* x + u*y */
    1789             : INLINE GEN
    1790   109189883 : addmuliu_inplace(GEN x, GEN y, ulong u)
    1791             : {
    1792             :   pari_sp av;
    1793   109189883 :   long ly = lgefint(y);
    1794   109189883 :   if (ly == 2) return x;
    1795    88252006 :   av = avma;
    1796    88252006 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1797    88252006 :   y = mului(u,y);
    1798    88252006 :   avma = av; return addii(x, y);
    1799             : }
    1800             : /* ux + vy */
    1801             : INLINE GEN
    1802    26483891 : lincombii(GEN u, GEN v, GEN x, GEN y)
    1803             : {
    1804    26483891 :   long lx = lgefint(x), ly;
    1805             :   GEN p1, p2;
    1806             :   pari_sp av;
    1807    26483891 :   if (lx == 2) return mulii(v,y);
    1808    16209499 :   ly = lgefint(y);
    1809    16209499 :   if (ly == 2) return mulii(u,x);
    1810    14989895 :   av = avma; (void)new_chunk(lx+ly+lgefint(u)+lgefint(v)); /* HACK */
    1811    14989895 :   p1 = mulii(u,x);
    1812    14989895 :   p2 = mulii(v,y);
    1813    14989895 :   avma = av; return addii(p1,p2);
    1814             : }
    1815             : 
    1816             : /*******************************************************************/
    1817             : /*                                                                 */
    1818             : /*                          GEN SUBTYPES                           */
    1819             : /*                                                                 */
    1820             : /*******************************************************************/
    1821             : 
    1822             : INLINE int
    1823  1058399787 : is_const_t(long t) { return (t < t_POLMOD); }
    1824             : INLINE int
    1825       26557 : is_extscalar_t(long t) { return (t <= t_POL); }
    1826             : INLINE int
    1827      929650 : is_intreal_t(long t) { return (t <= t_REAL); }
    1828             : INLINE int
    1829   354342015 : is_matvec_t(long t) { return (t >= t_VEC && t <= t_MAT); }
    1830             : INLINE int
    1831    51827727 : is_noncalc_t(long tx) { return (tx) >= t_LIST; }
    1832             : INLINE int
    1833      587851 : is_rational_t(long t) { return (t == t_INT || t == t_FRAC); }
    1834             : INLINE int
    1835       42896 : is_real_t(long t) { return (t == t_INT || t == t_REAL || t == t_FRAC); }
    1836             : INLINE int
    1837  2520332882 : is_recursive_t(long t) { return lontyp[t]; }
    1838             : INLINE int
    1839   152644086 : is_scalar_t(long t) { return (t < t_POL); }
    1840             : INLINE int
    1841      473061 : is_vec_t(long t) { return (t == t_VEC || t == t_COL); }
    1842             : 
    1843             : /*******************************************************************/
    1844             : /*                                                                 */
    1845             : /*                         TRANSCENDENTAL                          */
    1846             : /*                                                                 */
    1847             : /*******************************************************************/
    1848             : INLINE GEN
    1849    15763177 : sqrtr(GEN x) {
    1850    15763177 :   long s = signe(x);
    1851    15763177 :   if (s == 0) return real_0_bit(expo(x) >> 1);
    1852    15729597 :   if (s >= 0) return sqrtr_abs(x);
    1853       13349 :   retmkcomplex(gen_0, sqrtr_abs(x));
    1854             : }
    1855             : INLINE GEN
    1856           0 : cbrtr_abs(GEN x) { return sqrtnr_abs(x, 3); }
    1857             : INLINE GEN
    1858           0 : cbrtr(GEN x) {
    1859           0 :   long s = signe(x);
    1860             :   GEN r;
    1861           0 :   if (s == 0) return real_0_bit(expo(x) / 3);
    1862           0 :   r = cbrtr_abs(x);
    1863           0 :   if (s < 0) togglesign(r);
    1864           0 :   return r;
    1865             : }
    1866             : INLINE GEN
    1867       35138 : sqrtnr(GEN x, long n) {
    1868       35138 :   long s = signe(x);
    1869             :   GEN r;
    1870       35138 :   if (s == 0) return real_0_bit(expo(x) / n);
    1871       35138 :   r = sqrtnr_abs(x, n);
    1872       35138 :   if (s < 0) pari_err_IMPL("sqrtnr for x < 0");
    1873       35138 :   return r;
    1874             : }
    1875             : INLINE long
    1876      407840 : logint(GEN B, GEN y) { return logintall(B,y,NULL); }
    1877             : 
    1878             : /*******************************************************************/
    1879             : /*                                                                 */
    1880             : /*                         MISCELLANEOUS                           */
    1881             : /*                                                                 */
    1882             : /*******************************************************************/
    1883      929573 : INLINE int ismpzero(GEN x) { return is_intreal_t(typ(x)) && !signe(x); }
    1884   360070580 : INLINE int isintzero(GEN x) { return typ(x) == t_INT && !signe(x); }
    1885     6350658 : INLINE int isint1(GEN x) { return typ(x)==t_INT && equali1(x); }
    1886         301 : INLINE int isintm1(GEN x){ return typ(x)==t_INT && equalim1(x);}
    1887   211337407 : INLINE int equali1(GEN n)
    1888   211337407 : { return (ulong) n[1] == (evallgefint(3UL) | evalsigne(1)) && n[2] == 1; }
    1889    23514365 : INLINE int equalim1(GEN n)
    1890    23514365 : { return (ulong) n[1] == (evallgefint(3UL) | evalsigne(-1)) && n[2] == 1; }
    1891             : /* works only for POSITIVE integers */
    1892  1355557961 : INLINE int is_pm1(GEN n)
    1893  1355557961 : { return lgefint(n) == 3 && n[2] == 1; }
    1894   127068961 : INLINE int is_bigint(GEN n)
    1895   127068961 : { long l = lgefint(n); return l > 3 || (l == 3 && (n[2] & HIGHBIT)); }
    1896             : 
    1897  1316303075 : INLINE int odd(long x) { return x & 1; }
    1898     7410011 : INLINE int both_odd(long x, long y) { return x & y & 1; }
    1899             : 
    1900             : INLINE int
    1901  2088541809 : isonstack(GEN x)
    1902  4177083618 : { return ((pari_sp)x >= pari_mainstack->bot
    1903  2088541809 :        && (pari_sp)x <  pari_mainstack->top); }
    1904             : 
    1905             : /* assume x != 0 and x t_REAL, return an approximation to log2(|x|) */
    1906             : INLINE double
    1907    16959113 : dbllog2r(GEN x)
    1908    16959113 : { return log2((double)(ulong)x[2]) + (double)(expo(x) - (BITS_IN_LONG-1)); }
    1909             : 
    1910             : INLINE GEN
    1911      225152 : mul_content(GEN cx, GEN cy)
    1912             : {
    1913      225152 :   if (!cx) return cy;
    1914       52395 :   if (!cy) return cx;
    1915       37280 :   return gmul(cx,cy);
    1916             : }
    1917             : INLINE GEN
    1918      435973 : mul_denom(GEN dx, GEN dy)
    1919             : {
    1920      435973 :   if (!dx) return dy;
    1921      317678 :   if (!dy) return dx;
    1922      126931 :   return mulii(dx,dy);
    1923             : }
    1924             : 
    1925             : /* POLYNOMIALS */
    1926             : INLINE GEN
    1927    17560973 : constant_coeff(GEN x) { return signe(x)? gel(x,2): gen_0; }
    1928             : INLINE GEN
    1929    73447899 : leading_coeff(GEN x) { return lg(x) == 2? gen_0: gel(x,lg(x)-1); }
    1930             : INLINE ulong
    1931      407028 : Flx_lead(GEN x) { return lg(x) == 2? 0: x[lg(x)-1]; }
    1932             : INLINE long
    1933  2435095632 : degpol(GEN x) { return lg(x)-3; }
    1934             : INLINE long
    1935  1285920090 : lgpol(GEN x) { return lg(x)-2; }
    1936             : INLINE long
    1937    60002456 : lgcols(GEN x) { return lg(gel(x,1)); }
    1938             : INLINE long
    1939    14470113 : nbrows(GEN x) { return lg(gel(x,1))-1; }
    1940             : INLINE GEN
    1941           0 : truecoeff(GEN x, long n) { return polcoeff0(x,n,-1); }
    1942             : 
    1943             : INLINE GEN
    1944      475060 : RgXQ_mul(GEN y, GEN x, GEN T) { return RgX_rem(RgX_mul(y, x), T); }
    1945             : INLINE GEN
    1946      241476 : RgXQ_sqr(GEN x, GEN T) { return RgX_rem(RgX_sqr(x), T); }
    1947             : 
    1948             : INLINE GEN
    1949      117698 : ZXQ_mul(GEN y, GEN x, GEN T) { return ZX_rem(ZX_mul(y, x), T); }
    1950             : INLINE GEN
    1951       20958 : ZXQ_sqr(GEN x, GEN T) { return ZX_rem(ZX_sqr(x), T); }
    1952             : 
    1953             : INLINE GEN
    1954    62259989 : RgX_copy(GEN x)
    1955             : {
    1956             :   long lx, i;
    1957    62259989 :   GEN y = cgetg_copy(x, &lx); y[1] = x[1];
    1958    62259987 :   for (i = 2; i<lx; i++) gel(y,i) = gcopy(gel(x,i));
    1959    62259989 :   return y;
    1960             : }
    1961             : /* have to use ulong to avoid silly warnings from gcc "assuming signed
    1962             :  * overflow does not occur" */
    1963             : INLINE GEN
    1964     2233127 : RgX_coeff(GEN x, long n)
    1965             : {
    1966     2233127 :   ulong l = lg(x);
    1967     2233127 :   return (n < 0 || ((ulong)n+3) > l)? gen_0: gel(x,n+2);
    1968             : }
    1969             : INLINE GEN
    1970      316001 : RgX_renormalize(GEN x) { return RgX_renormalize_lg(x, lg(x)); }
    1971             : INLINE GEN
    1972     6099865 : RgX_div(GEN x, GEN y) { return RgX_divrem(x,y,NULL); }
    1973             : INLINE GEN
    1974     2525454 : RgX_rem(GEN x, GEN y) { return RgX_divrem(x,y,ONLY_REM); }
    1975             : INLINE GEN
    1976           7 : RgXQX_div(GEN x, GEN y, GEN T) { return RgXQX_divrem(x,y,T,NULL); }
    1977             : INLINE GEN
    1978       17192 : RgXQX_rem(GEN x, GEN y, GEN T) { return RgXQX_divrem(x,y,T,ONLY_REM); }
    1979             : INLINE GEN
    1980      750284 : FpX_div(GEN x, GEN y, GEN p) { return FpX_divrem(x,y,p, NULL); }
    1981             : INLINE GEN
    1982     3051753 : Flx_div(GEN x, GEN y, ulong p) { return Flx_divrem(x,y,p, NULL); }
    1983             : INLINE GEN
    1984     2861883 : F2x_div(GEN x, GEN y) { return F2x_divrem(x,y, NULL); }
    1985             : INLINE GEN
    1986           0 : FpV_FpC_mul(GEN x, GEN y, GEN p) { return FpV_dotproduct(x,y,p); }
    1987             : INLINE GEN
    1988    43477417 : pol0_Flx(long sv) { return mkvecsmall(sv); }
    1989             : INLINE GEN
    1990    17448927 : pol1_Flx(long sv) { return mkvecsmall2(sv, 1); }
    1991             : INLINE GEN
    1992    16791029 : polx_Flx(long sv) { return mkvecsmall3(sv, 0, 1); }
    1993             : INLINE GEN
    1994           0 : zero_zx(long sv) { return zero_Flx(sv); }
    1995             : INLINE GEN
    1996           0 : polx_zx(long sv) { return polx_Flx(sv); }
    1997             : INLINE GEN
    1998           0 : zx_shift(GEN x, long n) { return Flx_shift(x,n); }
    1999             : INLINE GEN
    2000           0 : zx_renormalize(GEN x, long l) { return Flx_renormalize(x,l); }
    2001             : INLINE GEN
    2002          35 : zero_F2x(long sv) { return zero_Flx(sv); }
    2003             : INLINE GEN
    2004    10876760 : pol0_F2x(long sv) { return pol0_Flx(sv); }
    2005             : INLINE GEN
    2006     2645453 : pol1_F2x(long sv) { return pol1_Flx(sv); }
    2007             : INLINE GEN
    2008      655781 : polx_F2x(long sv) { return mkvecsmall2(sv, 2); }
    2009             : INLINE int
    2010      790986 : F2x_equal1(GEN x) { return Flx_equal1(x); }
    2011             : INLINE int
    2012     3339807 : F2x_equal(GEN V, GEN W) { return Flx_equal(V,W); }
    2013             : INLINE GEN
    2014    66254070 : F2x_copy(GEN x) { return leafcopy(x); }
    2015             : INLINE GEN
    2016           0 : F2v_copy(GEN x) { return leafcopy(x); }
    2017             : INLINE GEN
    2018     2281500 : Flv_copy(GEN x) { return leafcopy(x); }
    2019             : INLINE GEN
    2020    74339300 : Flx_copy(GEN x) { return leafcopy(x); }
    2021             : INLINE GEN
    2022     1612236 : vecsmall_copy(GEN x) { return leafcopy(x); }
    2023             : INLINE int
    2024     4642063 : Flx_equal1(GEN x) { return degpol(x)==0 && x[2] == 1; }
    2025             : INLINE int
    2026       18029 : ZX_equal1(GEN x) { return degpol(x)==0 && equali1(gel(x,2)); }
    2027             : 
    2028             : INLINE GEN
    2029    73707498 : ZX_renormalize(GEN x, long lx)    { return ZXX_renormalize(x,lx); }
    2030             : INLINE GEN
    2031    87045674 : FpX_renormalize(GEN x, long lx)   { return ZXX_renormalize(x,lx); }
    2032             : INLINE GEN
    2033      949087 : FpXX_renormalize(GEN x, long lx)  { return ZXX_renormalize(x,lx); }
    2034             : INLINE GEN
    2035      987941 : FpXQX_renormalize(GEN x, long lx) { return ZXX_renormalize(x,lx); }
    2036             : INLINE GEN
    2037   126375563 : F2x_renormalize(GEN x, long lx)   { return Flx_renormalize(x,lx); }
    2038             : INLINE GEN
    2039        7187 : F2v_to_F2x(GEN x, long sv) {
    2040        7187 :   GEN y = leafcopy(x);
    2041        7187 :   y[1] = sv; F2x_renormalize(y, lg(y)); return y;
    2042             : }
    2043             : 
    2044             : INLINE GEN
    2045           0 : ZX_ZXY_resultant(GEN a, GEN b) { return ZX_ZXY_rnfequation(a,b,NULL); }
    2046             : INLINE long
    2047         448 : sturm(GEN x) { return sturmpart(x, NULL, NULL); }
    2048             : INLINE GEN
    2049       34961 : resultant(GEN x, GEN y) { return resultant_all(x,y,NULL); }
    2050             : 
    2051             : INLINE long
    2052        2205 : gval(GEN x, long v) {
    2053        2205 :   pari_sp av = avma;
    2054        2205 :   long n = gvaluation(x, pol_x(v));
    2055        2205 :   avma = av; return n;
    2056             : }
    2057             : 
    2058             : INLINE void
    2059      582393 : RgX_shift_inplace_init(long v)
    2060      582393 : { if (v) (void)cgetg(v, t_VECSMALL); }
    2061             : /* shift polynomial in place. assume v free cells have been left before x */
    2062             : INLINE GEN
    2063      582396 : RgX_shift_inplace(GEN x, long v)
    2064             : {
    2065             :   long i, lx;
    2066             :   GEN y, z;
    2067      582396 :   if (!v) return x;
    2068      257816 :   lx = lg(x);
    2069      257816 :   if (lx == 2) return x;
    2070      257816 :   y = x + v;
    2071      257816 :   z = x + lx;
    2072             :   /* stackdummy from normalizepol: move it up */
    2073      257816 :   if (lg(z) != v) x[lx + v] = z[0];
    2074      257816 :   for (i = lx-1; i >= 2; i--) gel(y,i) = gel(x,i);
    2075      257816 :   for (i = v+1;  i >= 2; i--) gel(x,i) = gen_0;
    2076             :   /* leave x[1] alone: it is correct */
    2077      257816 :   x[0] = evaltyp(t_POL) | evallg(lx+v); return x;
    2078             : }
    2079             : 
    2080             : 
    2081             : /* LINEAR ALGEBRA */
    2082             : INLINE GEN
    2083       14413 : zv_to_ZV(GEN x) { return vecsmall_to_vec(x); }
    2084             : INLINE GEN
    2085     1232254 : zc_to_ZC(GEN x) { return vecsmall_to_col(x); }
    2086             : INLINE GEN
    2087      221947 : ZV_to_zv(GEN x) { return vec_to_vecsmall(x); }
    2088             : INLINE GEN
    2089           0 : zx_to_zv(GEN x, long N) { return Flx_to_Flv(x,N); }
    2090             : INLINE GEN
    2091           0 : zv_to_zx(GEN x, long sv) { return Flv_to_Flx(x,sv); }
    2092             : INLINE GEN
    2093           0 : zm_to_zxV(GEN x, long sv) { return Flm_to_FlxV(x,sv); }
    2094             : INLINE GEN
    2095           0 : zero_zm(long x, long y) { return zero_Flm(x,y); }
    2096             : INLINE GEN
    2097    16314482 : zero_zv(long x) { return zero_Flv(x); }
    2098             : INLINE GEN
    2099         168 : zm_transpose(GEN x) { return Flm_transpose(x); }
    2100             : INLINE GEN
    2101           0 : zm_copy(GEN x) { return Flm_copy(x); }
    2102             : INLINE GEN
    2103     1982673 : zv_copy(GEN x) { return Flv_copy(x); }
    2104             : INLINE GEN
    2105           0 : zm_row(GEN x, long i) { return Flm_row(x,i); }
    2106             : 
    2107             : INLINE GEN
    2108      785173 : ZC_hnfrem(GEN x, GEN y) { return ZC_hnfremdiv(x,y,NULL); }
    2109             : INLINE GEN
    2110       23454 : ZM_hnfrem(GEN x, GEN y) { return ZM_hnfdivrem(x,y,NULL); }
    2111             : INLINE GEN
    2112     1265891 : ZM_lll(GEN x, double D, long f) { return ZM_lll_norms(x,D,f,NULL); }
    2113             : INLINE void
    2114      107496 : RgM_dimensions(GEN x, long *m, long *n) { *n = lg(x)-1; *m = *n? nbrows(x): 0; }
    2115             : INLINE GEN
    2116       24397 : RgM_inv(GEN a) { return RgM_solve(a, NULL); }
    2117             : INLINE GEN
    2118     8050113 : RgM_shallowcopy(GEN x)
    2119             : {
    2120             :   long l;
    2121     8050113 :   GEN y = cgetg_copy(x, &l);
    2122     8050113 :   while (--l > 0) gel(y,l) = leafcopy(gel(x,l));
    2123     8050113 :   return y;
    2124             : }
    2125             : INLINE GEN
    2126        1733 : F2m_copy(GEN x) { return RgM_shallowcopy(x); }
    2127             : 
    2128             : INLINE GEN
    2129      868000 : Flm_copy(GEN x) { return RgM_shallowcopy(x); }
    2130             : 
    2131             : /* divisibility: return 1 if y[i] | x[i] for all i, 0 otherwise. Assume
    2132             :  * x,y are ZV of the same length */
    2133             : INLINE int
    2134       23198 : ZV_dvd(GEN x, GEN y)
    2135             : {
    2136       23198 :   long i, l = lg(x);
    2137       36652 :   for (i=1; i < l; i++)
    2138       29519 :     if ( ! dvdii( gel(x,i), gel(y,i) ) ) return 0;
    2139        7133 :   return 1;
    2140             : }
    2141             : 
    2142             : /* Fq */
    2143             : INLINE GEN
    2144     1299835 : Fq_red(GEN x, GEN T, GEN p)
    2145     1299835 : { return typ(x)==t_INT? Fp_red(x,p): FpXQ_red(x,T,p); }
    2146             : INLINE GEN
    2147       11821 : Fq_to_FpXQ(GEN x, GEN T, GEN p /*unused*/)
    2148             : {
    2149             :   (void) p;
    2150       11821 :   return typ(x)==t_INT ? scalarpol(x, get_FpX_var(T)): x;
    2151             : }
    2152             : 
    2153             : INLINE GEN
    2154         833 : gener_Fq_local(GEN T, GEN p, GEN L)
    2155         833 : { return T? gener_FpXQ_local(T,p, L)
    2156         833 :           : pgener_Fp_local(p, L); }
    2157             : 
    2158             : /* FpXQX */
    2159             : INLINE GEN
    2160         954 : FpXQX_div(GEN x, GEN y, GEN T, GEN p) { return FpXQX_divrem(x, y, T, p, NULL); }
    2161             : INLINE GEN
    2162       31470 : FlxqX_div(GEN x, GEN y, GEN T, ulong p) { return FlxqX_divrem(x, y, T, p, NULL); }
    2163             : INLINE GEN
    2164       29785 : F2xqX_div(GEN x, GEN y, GEN T) { return F2xqX_divrem(x, y, T, NULL); }
    2165             : 
    2166             : /* FqX */
    2167             : INLINE GEN
    2168       27419 : FqX_red(GEN z, GEN T, GEN p) { return T? FpXQX_red(z, T, p): FpX_red(z, p); }
    2169             : INLINE GEN
    2170      903963 : FqX_add(GEN x,GEN y,GEN T,GEN p) { return T? FpXX_add(x,y,p): FpX_add(x,y,p); }
    2171             : INLINE GEN
    2172       16438 : FqX_neg(GEN x,GEN T,GEN p) { return T? FpXX_neg(x,p): FpX_neg(x,p); }
    2173             : INLINE GEN
    2174        2380 : FqX_sub(GEN x,GEN y,GEN T,GEN p) { return T? FpXX_sub(x,y,p): FpX_sub(x,y,p); }
    2175             : INLINE GEN
    2176      603186 : FqX_Fp_mul(GEN P, GEN u, GEN T, GEN p)
    2177      603186 : { return T? FpXX_Fp_mul(P, u, p): FpX_Fp_mul(P, u, p); }
    2178             : INLINE GEN
    2179      552791 : FqX_Fq_mul(GEN P, GEN U, GEN T, GEN p)
    2180      552791 : { return typ(U)==t_INT ? FqX_Fp_mul(P, U, T, p): FpXQX_FpXQ_mul(P, U, T, p); }
    2181             : INLINE GEN
    2182       81915 : FqX_mul(GEN x, GEN y, GEN T, GEN p)
    2183       81915 : { return T? FpXQX_mul(x, y, T, p): FpX_mul(x, y, p); }
    2184             : INLINE GEN
    2185      459861 : FqX_mulu(GEN x, ulong y, GEN T, GEN p)
    2186      459861 : { return T? FpXX_mulu(x, y, p): FpX_mulu(x, y, p); }
    2187             : INLINE GEN
    2188        4760 : FqX_sqr(GEN x, GEN T, GEN p)
    2189        4760 : { return T? FpXQX_sqr(x, T, p): FpX_sqr(x, p); }
    2190             : INLINE GEN
    2191        1428 : FqX_powu(GEN x, ulong n, GEN T, GEN p)
    2192        1428 : { return T? FpXQX_powu(x, n, T, p): FpX_powu(x, n, p); }
    2193             : INLINE GEN
    2194        2977 : FqX_div(GEN x, GEN y, GEN T, GEN p)
    2195        2977 : { return T? FpXQX_divrem(x,y,T,p,NULL): FpX_divrem(x,y,p,NULL); }
    2196             : INLINE GEN
    2197        5605 : FqX_get_red(GEN S, GEN T, GEN p)
    2198        5605 : { return T? FpXQX_get_red(S,T,p): FpX_get_red(S,p); }
    2199             : INLINE GEN
    2200       47875 : FqX_rem(GEN x, GEN y, GEN T, GEN p)
    2201       47875 : { return T? FpXQX_rem(x,y,T,p): FpX_rem(x,y,p); }
    2202             : INLINE GEN
    2203         329 : FqX_divrem(GEN x, GEN y, GEN T, GEN p, GEN *z)
    2204         329 : { return T? FpXQX_divrem(x,y,T,p,z): FpX_divrem(x,y,p,z); }
    2205             : INLINE GEN
    2206        5957 : FqX_div_by_X_x(GEN x, GEN y, GEN T, GEN p, GEN *z)
    2207        5957 : { return T? FpXQX_div_by_X_x(x,y,T,p,z): FpX_div_by_X_x(x,y,p,z); }
    2208             : INLINE GEN
    2209           0 : FqX_halfgcd(GEN P,GEN Q,GEN T,GEN p)
    2210           0 : {return T? FpXQX_halfgcd(P,Q,T,p): FpX_halfgcd(P,Q,p);}
    2211             : INLINE GEN
    2212      254102 : FqX_gcd(GEN P,GEN Q,GEN T,GEN p)
    2213      254102 : {return T? FpXQX_gcd(P,Q,T,p): FpX_gcd(P,Q,p);}
    2214             : INLINE GEN
    2215       77196 : FqX_extgcd(GEN P,GEN Q,GEN T,GEN p, GEN *U, GEN *V)
    2216       77196 : { return T? FpXQX_extgcd(P,Q,T,p,U,V): FpX_extgcd(P,Q,p,U,V); }
    2217             : INLINE GEN
    2218        1995 : FqX_normalize(GEN z, GEN T, GEN p) { return T? FpXQX_normalize(z, T, p): FpX_normalize(z, p); }
    2219             : INLINE GEN
    2220      268604 : FqX_deriv(GEN f, /*unused*/GEN T, GEN p) { (void)T; return FpXX_deriv(f, p); }
    2221             : INLINE GEN
    2222       71141 : FqX_factor(GEN f, GEN T, GEN p) { return T?FpXQX_factor(f, T, p): FpX_factor(f, p); }
    2223             : INLINE GEN
    2224        5810 : FqX_roots(GEN f, GEN T, GEN p) { return T?FpXQX_roots(f, T, p): FpX_roots(f, p); }
    2225             : 
    2226             : /*FqXQ*/
    2227             : INLINE GEN
    2228           0 : FqXQ_add(GEN x, GEN y, GEN S/*unused*/, GEN T, GEN p)
    2229           0 : { (void)S; return T? FpXX_add(x,y,p): FpX_add(x,y,p); }
    2230             : INLINE GEN
    2231           0 : FqXQ_sub(GEN x, GEN y, GEN S/*unused*/, GEN T, GEN p)
    2232           0 : { (void)S; return T? FpXX_sub(x,y,p): FpX_sub(x,y,p); }
    2233             : INLINE GEN
    2234           0 : FqXQ_div(GEN x, GEN y, GEN S, GEN T, GEN p)
    2235           0 : { return T? FpXQXQ_div(x,y,S,T,p): FpXQ_div(x,y,S,p); }
    2236             : INLINE GEN
    2237           0 : FqXQ_inv(GEN x, GEN S, GEN T, GEN p)
    2238           0 : { return T? FpXQXQ_inv(x,S,T,p): FpXQ_inv(x,S,p); }
    2239             : INLINE GEN
    2240           0 : FqXQ_invsafe(GEN x, GEN S, GEN T, GEN p)
    2241           0 : { return T? FpXQXQ_invsafe(x,S,T,p): FpXQ_inv(x,S,p); }
    2242             : INLINE GEN
    2243       21018 : FqXQ_mul(GEN x, GEN y, GEN S, GEN T, GEN p)
    2244       21018 : { return T? FpXQXQ_mul(x,y,S,T,p): FpXQ_mul(x,y,S,p); }
    2245             : INLINE GEN
    2246           0 : FqXQ_sqr(GEN x, GEN S, GEN T, GEN p)
    2247           0 : { return T? FpXQXQ_sqr(x,S,T,p): FpXQ_sqr(x,S,p); }
    2248             : INLINE GEN
    2249           0 : FqXQ_pow(GEN x, GEN n, GEN S, GEN T, GEN p)
    2250           0 : { return T? FpXQXQ_pow(x,n,S,T,p): FpXQ_pow(x,n,S,p); }
    2251             : 
    2252             : /*FpXQ*/
    2253             : INLINE GEN
    2254           0 : FpXQ_add(GEN x,GEN y,GEN T/*unused*/,GEN p)
    2255           0 : { (void)T; return FpX_add(x,y,p); }
    2256             : INLINE GEN
    2257           0 : FpXQ_sub(GEN x,GEN y,GEN T/*unused*/,GEN p)
    2258           0 : { (void)T; return FpX_sub(x,y,p); }
    2259             : 
    2260             : /*Flxq*/
    2261             : INLINE GEN
    2262           0 : Flxq_add(GEN x,GEN y,GEN T/*unused*/,ulong p)
    2263           0 : { (void)T; return Flx_add(x,y,p); }
    2264             : INLINE GEN
    2265         110 : Flxq_sub(GEN x,GEN y,GEN T/*unused*/,ulong p)
    2266         110 : { (void)T; return Flx_sub(x,y,p); }
    2267             : 
    2268             : /* F2x */
    2269             : 
    2270             : INLINE ulong
    2271   158793981 : F2x_coeff(GEN x,long v)
    2272             : {
    2273   158793981 :    ulong u=(ulong)x[2+divsBIL(v)];
    2274   158793110 :    return (u>>remsBIL(v))&1UL;
    2275             : }
    2276             : 
    2277             : INLINE void
    2278     3555470 : F2x_clear(GEN x,long v)
    2279             : {
    2280     3555470 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2281     3555470 :    *u&=~(1UL<<remsBIL(v));
    2282     3555470 : }
    2283             : 
    2284             : INLINE void
    2285    92716990 : F2x_set(GEN x,long v)
    2286             : {
    2287    92716990 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2288    92716363 :    *u|=1UL<<remsBIL(v);
    2289    92719532 : }
    2290             : 
    2291             : INLINE void
    2292     1338630 : F2x_flip(GEN x,long v)
    2293             : {
    2294     1338630 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2295     1338630 :    *u^=1UL<<remsBIL(v);
    2296     1338630 : }
    2297             : 
    2298             : /* F2v */
    2299             : 
    2300             : INLINE ulong
    2301   154995642 : F2v_coeff(GEN x,long v) { return F2x_coeff(x,v-1); }
    2302             : 
    2303             : INLINE void
    2304     3555470 : F2v_clear(GEN x,long v) { F2x_clear(x,v-1); }
    2305             : 
    2306             : INLINE void
    2307    68208433 : F2v_set(GEN x,long v)   { F2x_set(x,v-1); }
    2308             : 
    2309             : INLINE void
    2310     1338630 : F2v_flip(GEN x,long v) { F2x_flip(x,v-1); }
    2311             : 
    2312             : /* F2m */
    2313             : 
    2314             : INLINE ulong
    2315    12884396 : F2m_coeff(GEN x, long a, long b) { return F2v_coeff(gel(x,b), a); }
    2316             : 
    2317             : INLINE void
    2318           0 : F2m_clear(GEN x, long a, long b) { F2v_clear(gel(x,b), a); }
    2319             : 
    2320             : INLINE void
    2321     1643183 : F2m_set(GEN x, long a, long b) { F2v_set(gel(x,b), a); }
    2322             : 
    2323             : INLINE void
    2324     1338630 : F2m_flip(GEN x, long a, long b) { F2v_flip(gel(x,b), a); }
    2325             : 
    2326             : /* ARITHMETIC */
    2327             : INLINE GEN
    2328        1008 : matpascal(long n) { return matqpascal(n, NULL); }
    2329             : INLINE long
    2330     1964345 : Z_issquare(GEN x) { return Z_issquareall(x, NULL); }
    2331             : INLINE long
    2332          14 : Z_ispower(GEN x, ulong k) { return Z_ispowerall(x, k, NULL); }
    2333             : INLINE GEN
    2334     4669026 : sqrti(GEN x) { return sqrtremi(x,NULL); }
    2335             : INLINE GEN
    2336     7451100 : gaddgs(GEN y, long s) { return gaddsg(s,y); }
    2337             : INLINE int
    2338       23855 : gcmpgs(GEN y, long s) { return -gcmpsg(s,y); }
    2339             : INLINE int
    2340       22827 : gequalgs(GEN y, long s) { return gequalsg(s,y); }
    2341             : INLINE GEN
    2342           0 : gmaxsg(long s, GEN y) { return gmaxgs(y,s); }
    2343             : INLINE GEN
    2344           0 : gminsg(long s, GEN y) { return gmings(y,s); }
    2345             : INLINE GEN
    2346     5715283 : gmulgs(GEN y, long s) { return gmulsg(s,y); }
    2347             : INLINE GEN
    2348      557366 : gsubgs(GEN y, long s) { return gaddgs(y, -s); }
    2349             : INLINE GEN
    2350      452115 : gdivsg(long s, GEN y) { return gdiv(stoi(s), y); }
    2351             : 
    2352             : /* x t_COMPLEX */
    2353             : INLINE GEN
    2354     8731431 : cxnorm(GEN x) { return gadd(gsqr(gel(x,1)), gsqr(gel(x,2))); }
    2355             : /* q t_QUAD */
    2356             : INLINE GEN
    2357         623 : quadnorm(GEN q)
    2358             : {
    2359         623 :   GEN X = gel(q,1), b = gel(X,3), c = gel(X,2);
    2360         623 :   GEN z, u = gel(q,3), v = gel(q,2);
    2361         623 :   if (typ(u) == t_INT && typ(v) == t_INT) /* generic case */
    2362             :   {
    2363         308 :     z = signe(b)? mulii(v, addii(u,v)): sqri(v);
    2364         308 :     return addii(z, mulii(c, sqri(u)));
    2365             :   }
    2366             :   else
    2367             :   {
    2368         315 :     z = signe(b)? gmul(v, gadd(u,v)): gsqr(v);
    2369         315 :     return gadd(z, gmul(c, gsqr(u)));
    2370             :   }
    2371             : }
    2372             : /* x a t_QUAD, return the attached discriminant */
    2373             : INLINE GEN
    2374         252 : quad_disc(GEN x)
    2375             : {
    2376         252 :   GEN Q = gel(x,1), b = gel(Q,3), c = gel(Q,2), c4;
    2377         252 :   if (is_pm1(b))
    2378             :   {
    2379         196 :     pari_sp av = avma; (void)new_chunk(lgefint(c) + 1);
    2380         196 :     c4 = shifti(c,2); avma = av; return subsi(1, c4);
    2381             :   }
    2382          56 :   c4 = shifti(c,2); togglesign_safe(&c4); return c4;
    2383             : }
    2384             : INLINE GEN
    2385     5997600 : qfb_disc3(GEN x, GEN y, GEN z) { return subii(sqri(y), shifti(mulii(x,z),2)); }
    2386             : INLINE GEN
    2387     5905760 : qfb_disc(GEN x) { return qfb_disc3(gel(x,1), gel(x,2), gel(x,3)); }
    2388             : 
    2389             : INLINE GEN
    2390     1414726 : sqrfrac(GEN x)
    2391             : {
    2392     1414726 :   GEN z = cgetg(3,t_FRAC);
    2393     1414726 :   gel(z,1) = sqri(gel(x,1));
    2394     1414726 :   gel(z,2) = sqri(gel(x,2)); return z;
    2395             : }
    2396             : 
    2397             : INLINE void
    2398     8190530 : normalize_frac(GEN z) {
    2399     8190530 :   if (signe(gel(z,2)) < 0) { togglesign(gel(z,1)); setabssign(gel(z,2)); }
    2400     8190530 : }
    2401             : 
    2402             : INLINE GEN
    2403      211466 : powii(GEN x, GEN n)
    2404             : {
    2405      211466 :   long ln = lgefint(n);
    2406      211466 :   if (ln == 3) {
    2407             :     GEN z;
    2408      209555 :     if (signe(n) > 0) return powiu(x, n[2]);
    2409        2674 :     z = cgetg(3, t_FRAC);
    2410        2674 :     gel(z,1) = gen_1;
    2411        2674 :     gel(z,2) = powiu(x, n[2]);
    2412        2674 :     return z;
    2413             :   }
    2414        1911 :   if (ln == 2) return gen_1; /* rare */
    2415             :   /* should never happen */
    2416           0 :   return powgi(x, n); /* overflow unless x = 0, 1, -1 */
    2417             : }
    2418             : INLINE GEN
    2419         840 : powIs(long n) {
    2420         840 :   switch(n & 3)
    2421             :   {
    2422           7 :     case 1: return mkcomplex(gen_0,gen_1);
    2423         315 :     case 2: return gen_m1;
    2424         455 :     case 3: return mkcomplex(gen_0,gen_m1);
    2425             :   }
    2426          63 :   return gen_1;
    2427             : }
    2428             : 
    2429             : /*******************************************************************/
    2430             : /*                                                                 */
    2431             : /*                             ASSIGNMENTS                         */
    2432             : /*                                                                 */
    2433             : /*******************************************************************/
    2434           0 : INLINE void mpexpz(GEN x, GEN z)
    2435           0 : { pari_sp av = avma; gaffect(mpexp(x), z); avma = av; }
    2436           0 : INLINE void mplogz(GEN x, GEN z)
    2437           0 : { pari_sp av = avma; gaffect(mplog(x), z); avma = av; }
    2438           0 : INLINE void mpcosz(GEN x, GEN z)
    2439           0 : { pari_sp av = avma; gaffect(mpcos(x), z); avma = av; }
    2440           0 : INLINE void mpsinz(GEN x, GEN z)
    2441           0 : { pari_sp av = avma; gaffect(mpsin(x), z); avma = av; }
    2442           0 : INLINE void gnegz(GEN x, GEN z)
    2443           0 : { pari_sp av = avma; gaffect(gneg(x), z); avma = av; }
    2444           0 : INLINE void gabsz(GEN x, long prec, GEN z)
    2445           0 : { pari_sp av = avma; gaffect(gabs(x,prec), z); avma = av; }
    2446       23318 : INLINE void gaddz(GEN x, GEN y, GEN z)
    2447       23318 : { pari_sp av = avma; gaffect(gadd(x,y), z); avma = av; }
    2448           0 : INLINE void gsubz(GEN x, GEN y, GEN z)
    2449           0 : { pari_sp av = avma; gaffect(gsub(x,y), z); avma = av; }
    2450       11673 : INLINE void gmulz(GEN x, GEN y, GEN z)
    2451       11673 : { pari_sp av = avma; gaffect(gmul(x,y), z); avma = av; }
    2452           0 : INLINE void gdivz(GEN x, GEN y, GEN z)
    2453           0 : { pari_sp av = avma; gaffect(gdiv(x,y), z); avma = av; }
    2454           0 : INLINE void gdiventz(GEN x, GEN y, GEN z)
    2455           0 : { pari_sp av = avma; gaffect(gdivent(x,y), z); avma = av; }
    2456           0 : INLINE void gmodz(GEN x, GEN y, GEN z)
    2457           0 : { pari_sp av = avma; gaffect(gmod(x,y), z); avma = av; }
    2458           0 : INLINE void gmul2nz(GEN x, long s, GEN z)
    2459           0 : { pari_sp av = avma; gaffect(gmul2n(x,s), z); avma = av; }
    2460           0 : INLINE void gshiftz(GEN x, long s, GEN z)
    2461           0 : { pari_sp av = avma; gaffect(gshift(x,s), z); avma = av; }
    2462             : 
    2463             : /*******************************************************************/
    2464             : /*                                                                 */
    2465             : /*                       ELLIPTIC CURVES                           */
    2466             : /*                                                                 */
    2467             : /*******************************************************************/
    2468     5005040 : INLINE GEN ell_get_a1(GEN e) { return gel(e,1); }
    2469     3297197 : INLINE GEN ell_get_a2(GEN e) { return gel(e,2); }
    2470     4477710 : INLINE GEN ell_get_a3(GEN e) { return gel(e,3); }
    2471     4094938 : INLINE GEN ell_get_a4(GEN e) { return gel(e,4); }
    2472     4668805 : INLINE GEN ell_get_a6(GEN e) { return gel(e,5); }
    2473     3949463 : INLINE GEN ell_get_b2(GEN e) { return gel(e,6); }
    2474     1009632 : INLINE GEN ell_get_b4(GEN e) { return gel(e,7); }
    2475     1613480 : INLINE GEN ell_get_b6(GEN e) { return gel(e,8); }
    2476     1457365 : INLINE GEN ell_get_b8(GEN e) { return gel(e,9); }
    2477     6110848 : INLINE GEN ell_get_c4(GEN e) { return gel(e,10); }
    2478     8142507 : INLINE GEN ell_get_c6(GEN e) { return gel(e,11); }
    2479     9571388 : INLINE GEN ell_get_disc(GEN e) { return gel(e,12); }
    2480     1174642 : INLINE GEN ell_get_j(GEN e) { return gel(e,13); }
    2481     7853692 : INLINE long ell_get_type(GEN e) { return mael(e,14,1); }
    2482     1510874 : INLINE GEN ellff_get_field(GEN x) { return gmael(x, 15, 1); }
    2483      652665 : INLINE GEN ellff_get_a4a6(GEN x)  { return gmael(x, 15, 2); }
    2484         917 : INLINE GEN ellQp_get_zero(GEN x) { return gmael(x, 15, 1); }
    2485         287 : INLINE long ellQp_get_prec(GEN E) { GEN z = ellQp_get_zero(E); return valp(z); }
    2486         623 : INLINE GEN ellQp_get_p(GEN E) { GEN z = ellQp_get_zero(E); return gel(z,2); }
    2487       36946 : INLINE long ellR_get_prec(GEN x) { return nbits2prec(mael3(x, 15, 1, 1)); }
    2488        1409 : INLINE long ellR_get_sign(GEN x) { return mael3(x, 15, 1, 2); }
    2489      522039 : INLINE GEN ellnf_get_nf(GEN x) { return checknf_i(gmael(x,15,1)); }
    2490          42 : INLINE GEN ellnf_get_bnf(GEN x) { return checkbnf_i(gmael(x,15,1)); }
    2491             : 
    2492    25382893 : INLINE int ell_is_inf(GEN z) { return lg(z) == 2; }
    2493      812454 : INLINE GEN ellinf(void) { return mkvec(gen_0); }
    2494             : 
    2495             : /*******************************************************************/
    2496             : /*                                                                 */
    2497             : /*                    ALGEBRAIC NUMBER THEORY                      */
    2498             : /*                                                                 */
    2499             : /*******************************************************************/
    2500     6275541 : INLINE GEN modpr_get_pr(GEN x)  { return gel(x,3); }
    2501      602486 : INLINE GEN modpr_get_p(GEN x)  { return pr_get_p(modpr_get_pr(x)); }
    2502     1809507 : INLINE GEN modpr_get_T(GEN x)  { return lg(x) == 4? NULL: gel(x,4); }
    2503             : 
    2504    14851655 : INLINE GEN pr_get_p(GEN pr)  { return gel(pr,1); }
    2505     2177623 : INLINE GEN pr_get_gen(GEN pr){ return gel(pr,2); }
    2506             : /* .[2] instead of itos works: e and f are small positive integers */
    2507     2053736 : INLINE long pr_get_e(GEN pr) { return gel(pr,3)[2]; }
    2508     6091917 : INLINE long pr_get_f(GEN pr) { return gel(pr,4)[2]; }
    2509     5794688 : INLINE GEN pr_get_tau(GEN pr){ return gel(pr,5); }
    2510             : INLINE int
    2511      771881 : pr_is_inert(GEN P) { return pr_get_f(P) == lg(pr_get_gen(P))-1; }
    2512             : INLINE GEN
    2513      309857 : pr_norm(GEN pr) { return powiu(pr_get_p(pr), pr_get_f(pr)); }
    2514             : INLINE ulong
    2515       32368 : upr_norm(GEN pr) { return upowuu(pr_get_p(pr)[2], pr_get_f(pr)); }
    2516             : 
    2517             : /* assume nf a genuine nf */
    2518             : INLINE long
    2519        3002 : nf_get_varn(GEN nf) { return varn(gel(nf,1)); }
    2520             : INLINE GEN
    2521     7102631 : nf_get_pol(GEN nf) { return gel(nf,1); }
    2522             : INLINE long
    2523     3059142 : nf_get_degree(GEN nf) { return degpol( nf_get_pol(nf) ); }
    2524             : INLINE long
    2525     1168515 : nf_get_r1(GEN nf) { GEN x = gel(nf,2); return itou(gel(x,1)); }
    2526             : INLINE long
    2527        1113 : nf_get_r2(GEN nf) { GEN x = gel(nf,2); return itou(gel(x,2)); }
    2528             : INLINE GEN
    2529       23442 : nf_get_disc(GEN nf) { return gel(nf,3); }
    2530             : INLINE GEN
    2531      628940 : nf_get_index(GEN nf) { return gel(nf,4); }
    2532             : INLINE GEN
    2533     1119351 : nf_get_M(GEN nf) { return gmael(nf,5,1); }
    2534             : INLINE GEN
    2535       45427 : nf_get_G(GEN nf) { return gmael(nf,5,2); }
    2536             : INLINE GEN
    2537      413685 : nf_get_roundG(GEN nf) { return gmael(nf,5,3); }
    2538             : INLINE GEN
    2539         819 : nf_get_Tr(GEN nf) { return gmael(nf,5,4); }
    2540             : INLINE GEN
    2541        1729 : nf_get_diff(GEN nf) { return gmael(nf,5,5); }
    2542             : INLINE GEN
    2543          35 : nf_get_ramified_primes(GEN nf) { return gmael(nf,5,8); }
    2544             : INLINE GEN
    2545       99792 : nf_get_roots(GEN nf) { return gel(nf,6); }
    2546             : INLINE GEN
    2547     6455776 : nf_get_zk(GEN nf) { return gel(nf,7); }
    2548             : INLINE GEN
    2549     1683449 : nf_get_invzk(GEN nf) { return gel(nf,8); }
    2550             : INLINE void
    2551        6685 : nf_get_sign(GEN nf, long *r1, long *r2)
    2552             : {
    2553        6685 :   GEN x = gel(nf,2);
    2554        6685 :   *r1 = itou(gel(x,1));
    2555        6685 :   *r2 = itou(gel(x,2));
    2556        6685 : }
    2557             : 
    2558             : INLINE GEN
    2559        9520 : abgrp_get_no(GEN x) { return gel(x,1); }
    2560             : INLINE GEN
    2561     1234946 : abgrp_get_cyc(GEN x) { return gel(x,2); }
    2562             : INLINE GEN
    2563      304020 : abgrp_get_gen(GEN x) { return gel(x,3); }
    2564             : INLINE GEN
    2565     1379598 : bnf_get_nf(GEN bnf) { return gel(bnf,7); }
    2566             : INLINE GEN
    2567      623279 : bnf_get_clgp(GEN bnf) { return gmael(bnf,8,1); }
    2568             : INLINE GEN
    2569        1127 : bnf_get_no(GEN bnf) { return abgrp_get_no(bnf_get_clgp(bnf)); }
    2570             : INLINE GEN
    2571      326763 : bnf_get_cyc(GEN bnf) { return abgrp_get_cyc(bnf_get_clgp(bnf)); }
    2572             : INLINE GEN
    2573      295060 : bnf_get_gen(GEN bnf)  { return abgrp_get_gen(bnf_get_clgp(bnf)); }
    2574             : INLINE GEN
    2575         860 : bnf_get_reg(GEN bnf) { return gmael(bnf,8,2); }
    2576             : INLINE GEN
    2577      478853 : bnf_get_logfu(GEN bnf) { return gel(bnf,3); }
    2578             : INLINE GEN
    2579        2528 : bnf_get_tuU(GEN bnf) { return gmael3(bnf,8,4,2); }
    2580             : INLINE long
    2581        7665 : bnf_get_tuN(GEN bnf) { return gmael3(bnf,8,4,1)[2]; }
    2582             : INLINE GEN
    2583        1806 : bnf_get_fu(GEN bnf) {
    2584        1806 :   GEN fu = bnf_get_fu_nocheck(bnf);
    2585        1806 :   if (typ(fu) == t_MAT) pari_err(e_MISC,"missing units in bnf");
    2586        1806 :   return fu;
    2587             : }
    2588             : INLINE GEN
    2589        3802 : bnf_get_fu_nocheck(GEN bnf) { return gmael(bnf,8,5); }
    2590             : 
    2591             : INLINE GEN
    2592      442125 : bnr_get_bnf(GEN bnr) { return gel(bnr,1); }
    2593             : INLINE GEN
    2594      218651 : bnr_get_bid(GEN bnr) { return gel(bnr,2); }
    2595             : INLINE GEN
    2596       24906 : bnr_get_mod(GEN bnr) { return gmael(bnr,2,1); }
    2597             : INLINE GEN
    2598       13398 : bnr_get_nf(GEN bnr) { return gmael(bnr,1,7); }
    2599             : INLINE GEN
    2600      260714 : bnr_get_clgp(GEN bnr) { return gel(bnr,5); }
    2601             : INLINE GEN
    2602        8393 : bnr_get_no(GEN bnr) { return abgrp_get_no(bnr_get_clgp(bnr)); }
    2603             : INLINE GEN
    2604      237460 : bnr_get_cyc(GEN bnr) { return abgrp_get_cyc(bnr_get_clgp(bnr)); }
    2605             : INLINE GEN
    2606          70 : bnr_get_gen_nocheck(GEN bnr) { return abgrp_get_gen(bnr_get_clgp(bnr)); }
    2607             : INLINE GEN
    2608       13965 : bnr_get_gen(GEN bnr) {
    2609       13965 :   GEN G = bnr_get_clgp(bnr);
    2610       13965 :   if (lg(G) !=  4)
    2611           0 :     pari_err(e_MISC,"missing bnr generators: please use bnrinit(,,1)");
    2612       13965 :   return gel(G,3);
    2613             : }
    2614             : 
    2615             : INLINE GEN
    2616      263682 : bid_get_mod(GEN bid) { return gel(bid,1); }
    2617             : INLINE GEN
    2618       30485 : bid_get_ideal(GEN bid) { return gmael(bid,1,1); }
    2619             : INLINE GEN
    2620         448 : bid_get_arch(GEN bid) { return gmael(bid,1,2); }
    2621             : INLINE GEN
    2622      677303 : bid_get_grp(GEN bid) { return gel(bid,2); }
    2623             : INLINE GEN
    2624      239637 : bid_get_fact(GEN bid) { return gmael(bid,3,1); }
    2625             : INLINE GEN
    2626      232084 : bid_get_fact2(GEN bid) { return gmael(bid,3,2); }
    2627             : INLINE GEN
    2628      232154 : bid_get_sprk(GEN bid) { return gmael(bid,4,1); }
    2629             : INLINE GEN
    2630        6447 : bid_get_sarch(GEN bid) { return gmael(bid,4,2); }
    2631             : INLINE GEN
    2632      235871 : bid_get_archp(GEN bid) { return gmael3(bid,4,2,2); }
    2633             : INLINE GEN
    2634           0 : bid_get_ind(GEN bid) { return gmael(bid,4,3); }
    2635             : INLINE GEN
    2636      463804 : bid_get_U(GEN bid) { return gel(bid,5); }
    2637             : INLINE GEN
    2638           0 : bid_get_no(GEN bid) { return abgrp_get_no(bid_get_grp(bid)); }
    2639             : INLINE GEN
    2640      669309 : bid_get_cyc(GEN bid) { return abgrp_get_cyc(bid_get_grp(bid)); }
    2641             : INLINE GEN
    2642           0 : bid_get_gen_nocheck(GEN bid)  { return abgrp_get_gen(bid_get_grp(bid)); }
    2643             : INLINE GEN
    2644        7399 : bid_get_gen(GEN bid) {
    2645        7399 :   GEN G = bid_get_grp(bid);
    2646        7399 :   if (lg(G) != 4) pari_err(e_MISC,"missing bid generators. Use idealstar(,,2)");
    2647        7399 :   return abgrp_get_gen(G);
    2648             : }
    2649             : INLINE GEN
    2650        2247 : gal_get_pol(GEN gal) { return gel(gal,1); }
    2651             : INLINE GEN
    2652         994 : gal_get_p(GEN gal) { return gmael(gal,2,1); }
    2653             : INLINE GEN
    2654          63 : gal_get_e(GEN gal) { return gmael(gal,2,2); }
    2655             : INLINE GEN
    2656        1820 : gal_get_mod(GEN gal) { return gmael(gal,2,3); }
    2657             : INLINE GEN
    2658        2198 : gal_get_roots(GEN gal) { return gel(gal,3); }
    2659             : INLINE GEN
    2660        1827 : gal_get_invvdm(GEN gal) { return gel(gal,4); }
    2661             : INLINE GEN
    2662        1827 : gal_get_den(GEN gal) { return gel(gal,5); }
    2663             : INLINE GEN
    2664        3843 : gal_get_group(GEN gal) { return gel(gal,6); }
    2665             : INLINE GEN
    2666        1267 : gal_get_gen(GEN gal) { return gel(gal,7); }
    2667             : INLINE GEN
    2668         812 : gal_get_orders(GEN gal) { return gel(gal,8); }
    2669             : 
    2670             : /* assume rnf a genuine rnf */
    2671             : INLINE long
    2672      311276 : rnf_get_degree(GEN rnf) { return degpol(rnf_get_pol(rnf)); }
    2673             : INLINE long
    2674       14805 : rnf_get_nfdegree(GEN rnf) { return degpol(nf_get_pol(rnf_get_nf(rnf))); }
    2675             : INLINE long
    2676      156450 : rnf_get_absdegree(GEN rnf) { return degpol(gmael(rnf,11,1)); }
    2677             : INLINE GEN
    2678         434 : rnf_get_idealdisc(GEN rnf) { return gmael(rnf,3,1); }
    2679             : INLINE GEN
    2680         448 : rnf_get_k(GEN rnf) { return gmael(rnf,11,3); }
    2681             : INLINE GEN
    2682         448 : rnf_get_alpha(GEN rnf) { return gmael(rnf, 11, 2); }
    2683             : INLINE GEN
    2684      123767 : rnf_get_nf(GEN rnf) { return gel(rnf,10); }
    2685             : INLINE void
    2686        1701 : rnf_get_nfzk(GEN rnf, GEN *b, GEN *cb) {*b=gmael(rnf,2,1); *cb=gmael(rnf,2,2);}
    2687             : INLINE GEN
    2688       93674 : rnf_get_polabs(GEN rnf) { return gmael(rnf,11,1); }
    2689             : INLINE GEN
    2690      462973 : rnf_get_pol(GEN rnf) { return gel(rnf,1); }
    2691             : INLINE GEN
    2692          63 : rnf_get_disc(GEN rnf) { return gel(rnf,3); }
    2693             : INLINE GEN
    2694         105 : rnf_get_index(GEN rnf) { return gel(rnf,4); }
    2695             : INLINE long
    2696           0 : rnf_get_varn(GEN rnf) { return varn(gel(rnf,1)); }
    2697             : INLINE GEN
    2698      106519 : rnf_get_nfpol(GEN rnf) { return gmael(rnf,10,1); }
    2699             : INLINE long
    2700         483 : rnf_get_nfvarn(GEN rnf) { return varn(gmael(rnf,10,1)); }
    2701             : INLINE GEN
    2702        2443 : rnf_get_zk(GEN rnf) { return gel(rnf,7); }
    2703             : INLINE GEN
    2704       34006 : rnf_get_map(GEN rnf) { return gel(rnf,11); }
    2705             : INLINE GEN
    2706        1190 : rnf_get_invzk(GEN rnf) { return gel(rnf,8); }
    2707             : 
    2708             : /* I integral ZM (not HNF), G ZM, rounded Cholesky form of a weighted
    2709             :  * T2 matrix. Reduce I wrt G */
    2710             : INLINE GEN
    2711        5124 : idealpseudored(GEN I, GEN G)
    2712        5124 : { return ZM_mul(I, ZM_lll(ZM_mul(G, I), 0.99, LLL_IM)); }
    2713             : 
    2714             : /* I integral (not necessarily HNF), G ZM, rounded Cholesky form of a weighted
    2715             :  * T2 matrix. Return m in I with T2(m) small */
    2716             : INLINE GEN
    2717      169426 : idealpseudomin(GEN I, GEN G)
    2718             : {
    2719      169426 :   GEN u = ZM_lll(ZM_mul(G, I), 0.99, LLL_IM);
    2720      169426 :   return ZM_ZC_mul(I, gel(u,1));
    2721             : }
    2722             : /* I, G as in idealpseudomin. Return an irrational m in I with T2(m) small */
    2723             : INLINE GEN
    2724      276518 : idealpseudomin_nonscalar(GEN I, GEN G)
    2725             : {
    2726      276518 :   GEN u = ZM_lll(ZM_mul(G, I), 0.99, LLL_IM);
    2727      276518 :   GEN m = ZM_ZC_mul(I, gel(u,1));
    2728      276518 :   if (ZV_isscalar(m) && lg(u) > 2) m = ZM_ZC_mul(I, gel(u,2));
    2729      276518 :   return m;
    2730             : }
    2731             : 
    2732             : INLINE GEN
    2733           0 : idealred_elt(GEN nf, GEN I) {
    2734           0 :   pari_sp av = avma;
    2735           0 :   GEN u = idealpseudomin(I, nf_get_roundG(nf));
    2736           0 :   return gerepileupto(av, u);
    2737             : }
    2738             : INLINE GEN
    2739      174398 : idealred(GEN nf, GEN I) { return idealred0(nf, I, NULL); }
    2740             : 
    2741             : INLINE GEN
    2742        1218 : idealchineseinit(GEN nf, GEN x)
    2743        1218 : { return idealchinese(nf,x,NULL); }
    2744             : 
    2745             : /*******************************************************************/
    2746             : /*                                                                 */
    2747             : /*                              CLOSURES                           */
    2748             : /*                                                                 */
    2749             : /*******************************************************************/
    2750   186163837 : INLINE long closure_arity(GEN C)          { return ((ulong)C[1])&ARITYBITS; }
    2751    34325601 : INLINE long closure_is_variadic(GEN C) { return !!(((ulong)C[1])&VARARGBITS); }
    2752   151642995 : INLINE const char *closure_codestr(GEN C)  { return GSTR(gel(C,2))-1; }
    2753           0 : INLINE GEN closure_get_code(GEN C)  { return gel(C,2); }
    2754   151583298 : INLINE GEN closure_get_oper(GEN C)  { return gel(C,3); }
    2755   151555514 : INLINE GEN closure_get_data(GEN C)  { return gel(C,4); }
    2756       16932 : INLINE GEN closure_get_dbg(GEN C)   { return gel(C,5); }
    2757       37063 : INLINE GEN closure_get_text(GEN C)  { return gel(C,6); }
    2758      431095 : INLINE GEN closure_get_frame(GEN C) { return gel(C,7); }
    2759             : 
    2760             : /*******************************************************************/
    2761             : /*                                                                 */
    2762             : /*                               ERRORS                            */
    2763             : /*                                                                 */
    2764             : /*******************************************************************/
    2765             : INLINE long
    2766       51261 : err_get_num(GEN e) { return e[1]; }
    2767             : INLINE GEN
    2768          70 : err_get_compo(GEN e, long i) { return gel(e, i+1); }
    2769             : 
    2770             : INLINE void
    2771          14 : pari_err_BUG(const char *f) { pari_err(e_BUG,f); }
    2772             : INLINE void
    2773           7 : pari_err_CONSTPOL(const char *f) { pari_err(e_CONSTPOL, f); }
    2774             : INLINE void
    2775          63 : pari_err_COPRIME(const char *f, GEN x, GEN y) { pari_err(e_COPRIME, f,x,y); }
    2776             : INLINE void
    2777         925 : pari_err_DIM(const char *f) { pari_err(e_DIM, f); }
    2778             : INLINE void
    2779           0 : pari_err_FILE(const char *f, const char *g) { pari_err(e_FILE, f,g); }
    2780             : INLINE void
    2781          28 : pari_err_FLAG(const char *f) { pari_err(e_FLAG,f); }
    2782             : INLINE void
    2783         322 : pari_err_IMPL(const char *f) { pari_err(e_IMPL,f); }
    2784             : INLINE void
    2785         627 : pari_err_INV(const char *f, GEN x) { pari_err(e_INV,f,x); }
    2786             : INLINE void
    2787          21 : pari_err_IRREDPOL(const char *f, GEN x) { pari_err(e_IRREDPOL, f,x); }
    2788             : INLINE void
    2789        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); }
    2790             : INLINE void
    2791         224 : pari_err_COMPONENT(const char *f, const char *op, GEN l, GEN x) { pari_err(e_COMPONENT, f,op,l,x); }
    2792             : INLINE void
    2793           0 : pari_err_MAXPRIME(ulong c) { pari_err(e_MAXPRIME, c); }
    2794             : INLINE void
    2795         287 : pari_err_OP(const char *f, GEN x, GEN y) { pari_err(e_OP, f,x,y); }
    2796             : INLINE void
    2797          70 : pari_err_OVERFLOW(const char *f) { pari_err(e_OVERFLOW, f); }
    2798             : INLINE void
    2799         218 : pari_err_PREC(const char *f) { pari_err(e_PREC,f); }
    2800             : INLINE void
    2801           0 : pari_err_PACKAGE(const char *f) { pari_err(e_PACKAGE,f); }
    2802             : INLINE void
    2803          56 : pari_err_PRIME(const char *f, GEN x) { pari_err(e_PRIME, f,x); }
    2804             : INLINE void
    2805         735 : pari_err_MODULUS(const char *f, GEN x, GEN y) { pari_err(e_MODULUS, f,x,y); }
    2806             : INLINE void
    2807          42 : pari_err_ROOTS0(const char *f) { pari_err(e_ROOTS0, f); }
    2808             : INLINE void
    2809          77 : pari_err_SQRTN(const char *f, GEN x) { pari_err(e_SQRTN, f,x); }
    2810             : INLINE void
    2811       22826 : pari_err_TYPE(const char *f, GEN x) { pari_err(e_TYPE, f,x); }
    2812             : INLINE void
    2813        3073 : pari_err_TYPE2(const char *f, GEN x, GEN y) { pari_err(e_TYPE2, f,x,y); }
    2814             : INLINE void
    2815         203 : pari_err_VAR(const char *f, GEN x, GEN y) { pari_err(e_VAR, f,x,y); }
    2816             : INLINE void
    2817         119 : pari_err_PRIORITY(const char *f, GEN x, const char *op, long v)
    2818         119 : { pari_err(e_PRIORITY, f,x,op,v); }

Generated by: LCOV version 1.11