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 20459-9710128) Lines: 1237 1409 87.8 %
Date: 2017-03-30 05:32:39 Functions: 523 595 87.9 %
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      281382 : mkintmod(GEN x, GEN y) { retmkintmod(x,y); }
     141             : INLINE GEN
     142        3252 : mkintmodu(ulong x, ulong y) {
     143        3252 :   GEN v = cgetg(3,t_INTMOD);
     144        3252 :   gel(v,1) = utoipos(y);
     145        3252 :   gel(v,2) = utoi(x); return v;
     146             : }
     147             : INLINE GEN
     148      217140 : mkpolmod(GEN x, GEN y) { retmkpolmod(x,y); }
     149             : INLINE GEN
     150     1535778 : mkfrac(GEN x, GEN y) { retmkfrac(x,y); }
     151             : INLINE GEN
     152     2503746 : mkfraccopy(GEN x, GEN y) { retmkfrac(icopy(x), icopy(y)); }
     153             : INLINE GEN
     154           6 : mkrfrac(GEN x, GEN y) { GEN v = cgetg(3, t_RFRAC);
     155           6 :   gel(v,1) = x; gel(v,2) = y; return v; }
     156             : INLINE GEN
     157          12 : mkrfraccopy(GEN x, GEN y) { GEN v = cgetg(3, t_RFRAC);
     158          12 :   gel(v,1) = gcopy(x); gel(v,2) = gcopy(y); return v; }
     159             : INLINE GEN
     160     2451768 : mkcomplex(GEN x, GEN y) { retmkcomplex(x,y); }
     161             : INLINE GEN
     162      364338 : gen_I(void) { return mkcomplex(gen_0, gen_1); }
     163             : INLINE GEN
     164      171591 : cgetc(long l) { retmkcomplex(cgetr(l), cgetr(l)); }
     165             : INLINE GEN
     166          36 : mkquad(GEN n, GEN x, GEN y) { GEN v = cgetg(4, t_QUAD);
     167          36 :   gel(v,1) = n; gel(v,2) = x; gel(v,3) = y; return v; }
     168             : /* vecsmall */
     169             : INLINE GEN
     170    42178768 : mkvecsmall(long x) { GEN v = cgetg(2, t_VECSMALL); v[1] = x; return v; }
     171             : INLINE GEN
     172    92962797 : mkvecsmall2(long x,long y) { GEN v = cgetg(3, t_VECSMALL);
     173    92957802 :   v[1]=x; v[2]=y; return v; }
     174             : INLINE GEN
     175    51545416 : mkvecsmall3(long x,long y,long z) { GEN v = cgetg(4, t_VECSMALL);
     176    51542738 :   v[1]=x; v[2]=y; v[3]=z; return v; }
     177             : INLINE GEN
     178     7655700 : mkvecsmall4(long x,long y,long z,long t) { GEN v = cgetg(5, t_VECSMALL);
     179     7644919 :   v[1]=x; v[2]=y; v[3]=z; v[4]=t; return v; }
     180             : INLINE GEN
     181      367639 : mkvecsmall5(long x,long y,long z,long t,long u) { GEN v = cgetg(6, t_VECSMALL);
     182      367639 :   v[1]=x; v[2]=y; v[3]=z; v[4]=t; v[5]=u; return v; }
     183             : 
     184             : INLINE GEN
     185      135534 : mkqfi(GEN x, GEN y, GEN z) { retmkqfi(x,y,z); }
     186             : /* vec */
     187             : INLINE GEN
     188     2579261 : mkvec(GEN x) { retmkvec(x); }
     189             : INLINE GEN
     190    19357416 : mkvec2(GEN x, GEN y) { retmkvec2(x,y); }
     191             : INLINE GEN
     192    44640596 : mkvec3(GEN x, GEN y, GEN z) { retmkvec3(x,y,z); }
     193             : INLINE GEN
     194     6279849 : mkvec4(GEN x, GEN y, GEN z, GEN t) { retmkvec4(x,y,z,t); }
     195             : INLINE GEN
     196    10057535 : mkvec5(GEN x, GEN y, GEN z, GEN t, GEN u) { retmkvec5(x,y,z,t,u); }
     197             : INLINE GEN
     198           6 : mkvecs(long x) { retmkvec(stoi(x)); }
     199             : INLINE GEN
     200       10374 : mkvec2s(long x, long y) { retmkvec2(stoi(x),stoi(y)); }
     201             : INLINE GEN
     202      422316 : 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       28674 : mkveccopy(GEN x) { GEN v = cgetg(2, t_VEC); gel(v,1) = gcopy(x); return v; }
     207             : INLINE GEN
     208       71274 : mkvec2copy(GEN x, GEN y) {
     209       71274 :   GEN v = cgetg(3,t_VEC); gel(v,1) = gcopy(x); gel(v,2) = gcopy(y); return v; }
     210             : /* col */
     211             : INLINE GEN
     212     1766061 : mkcol(GEN x) { retmkcol(x); }
     213             : INLINE GEN
     214    12633109 : mkcol2(GEN x, GEN y) { retmkcol2(x,y); }
     215             : INLINE GEN
     216       35670 : 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         774 : mkcol6(GEN x, GEN y, GEN z, GEN t, GEN u, GEN v) { retmkcol6(x,y,z,t,u,v); }
     223             : INLINE GEN
     224         624 : mkcols(long x) { retmkcol(stoi(x)); }
     225             : INLINE GEN
     226     1012608 : 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       20334 : mkcolcopy(GEN x) { GEN v = cgetg(2, t_COL); gel(v,1) = gcopy(x); return v; }
     233             : /* mat */
     234             : INLINE GEN
     235      551454 : mkmat(GEN x) { retmkmat(x); }
     236             : INLINE GEN
     237    13435829 : mkmat2(GEN x, GEN y) { retmkmat2(x,y); }
     238             : INLINE GEN
     239        2016 : 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        5994 : 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       12254 : mkoo(void) { GEN v = cgetg(2, t_INFINITY); gel(v,1) = gen_1; return v; }
     250             : INLINE GEN
     251        6750 : mkmoo(void) { GEN v = cgetg(2, t_INFINITY); gel(v,1) = gen_m1; return v; }
     252             : INLINE long
     253       25078 : inf_get_sign(GEN x) { return signe(gel(x,1)); }
     254             : /* pol */
     255             : INLINE GEN
     256      553446 : pol_x(long v) {
     257      553446 :   GEN p = cgetg(4, t_POL);
     258      553446 :   p[1] = evalsigne(1)|evalvarn(v);
     259      553446 :   gel(p,2) = gen_0;
     260      553446 :   gel(p,3) = gen_1; return p;
     261             : }
     262             : /* x^n, assume n >= 0 */
     263             : INLINE GEN
     264     1980781 : pol_xn(long n, long v) {
     265     1980781 :   long i, a = n+2;
     266     1980781 :   GEN p = cgetg(a+1, t_POL);
     267     1980781 :   p[1] = evalsigne(1)|evalvarn(v);
     268     1980781 :   for (i = 2; i < a; i++) gel(p,i) = gen_0;
     269     1980781 :   gel(p,a) = gen_1; return p;
     270             : }
     271             : /* x^n, no assumption on n */
     272             : INLINE GEN
     273         114 : pol_xnall(long n, long v)
     274             : {
     275         114 :   if (n < 0) retmkrfrac(gen_1, pol_xn(-n,v));
     276          36 :   return pol_xn(n, v);
     277             : }
     278             : INLINE GEN
     279     1009949 : pol_1(long v) {
     280     1009949 :   GEN p = cgetg(3, t_POL);
     281     1009949 :   p[1] = evalsigne(1)|evalvarn(v);
     282     1009949 :   gel(p,2) = gen_1; return p;
     283             : }
     284             : INLINE GEN
     285    11352379 : pol_0(long v)
     286             : {
     287    11352379 :   GEN x = cgetg(2,t_POL);
     288    11352379 :   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     5222309 : 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       47856 : const_col(long n, GEN x) { retconst_col(n, x); }
     304             : INLINE GEN
     305     3038731 : const_vecsmall(long n, long c)
     306             : {
     307             :   long i;
     308     3038731 :   GEN V = cgetg(n+1,t_VECSMALL);
     309     3038732 :   for(i=1;i<=n;i++) V[i] = c;
     310     3038732 :   return V;
     311             : }
     312             : 
     313             : /***   ZERO   ***/
     314             : /* O(p^e) */
     315             : INLINE GEN
     316      258030 : zeropadic(GEN p, long e)
     317             : {
     318      258030 :   GEN y = cgetg(5,t_PADIC);
     319      258030 :   gel(y,4) = gen_0;
     320      258030 :   gel(y,3) = gen_1;
     321      258030 :   gel(y,2) = icopy(p);
     322      258030 :   y[1] = evalvalp(e) | _evalprecp(0);
     323      258030 :   return y;
     324             : }
     325             : INLINE GEN
     326         438 : zeropadic_shallow(GEN p, long e)
     327             : {
     328         438 :   GEN y = cgetg(5,t_PADIC);
     329         438 :   gel(y,4) = gen_0;
     330         438 :   gel(y,3) = gen_1;
     331         438 :   gel(y,2) = p;
     332         438 :   y[1] = evalvalp(e) | _evalprecp(0);
     333         438 :   return y;
     334             : }
     335             : /* O(pol_x(v)^e) */
     336             : INLINE GEN
     337       12078 : zeroser(long v, long e)
     338             : {
     339       12078 :   GEN x = cgetg(2, t_SER);
     340       12078 :   x[1] = evalvalp(e) | evalvarn(v); return x;
     341             : }
     342             : INLINE int
     343     3351582 : ser_isexactzero(GEN x)
     344             : {
     345     3351582 :   if (!signe(x)) switch(lg(x))
     346             :   {
     347       10812 :     case 2: return 1;
     348         696 :     case 3: return isexactzero(gel(x,2));
     349             :   }
     350     3340074 :   return 0;
     351             : }
     352             : /* 0 * pol_x(v) */
     353             : INLINE GEN
     354     4071534 : zeropol(long v) { return pol_0(v); }
     355             : /* vector(n) */
     356             : INLINE GEN
     357    18382490 : zerocol(long n)
     358             : {
     359    18382490 :   GEN y = cgetg(n+1,t_COL);
     360    18382490 :   long i; for (i=1; i<=n; i++) gel(y,i) = gen_0;
     361    18382490 :   return y;
     362             : }
     363             : /* vectorv(n) */
     364             : INLINE GEN
     365     6483051 : zerovec(long n)
     366             : {
     367     6483051 :   GEN y = cgetg(n+1,t_VEC);
     368     6483056 :   long i; for (i=1; i<=n; i++) gel(y,i) = gen_0;
     369     6483056 :   return y;
     370             : }
     371             : /* matrix(m, n) */
     372             : INLINE GEN
     373        4014 : zeromat(long m, long n)
     374             : {
     375        4014 :   GEN y = cgetg(n+1,t_MAT);
     376        4014 :   GEN v = zerocol(m);
     377        4014 :   long i; for (i=1; i<=n; i++) gel(y,i) = v;
     378        4014 :   return y;
     379             : }
     380             : /* = zero_zx, sv is a evalvarn()*/
     381             : INLINE GEN
     382      673170 : zero_Flx(long sv) { return pol0_Flx(sv); }
     383             : INLINE GEN
     384    25964474 : zero_Flv(long n)
     385             : {
     386    25964474 :   GEN y = cgetg(n+1,t_VECSMALL);
     387    25964674 :   long i; for (i=1; i<=n; i++) y[i] = 0;
     388    25964674 :   return y;
     389             : }
     390             : /* matrix(m, n) */
     391             : INLINE GEN
     392      647970 : zero_Flm(long m, long n)
     393             : {
     394      647970 :   GEN y = cgetg(n+1,t_MAT);
     395      647970 :   GEN v = zero_Flv(m);
     396      647970 :   long i; for (i=1; i<=n; i++) gel(y,i) = v;
     397      647970 :   return y;
     398             : }
     399             : /* matrix(m, n) */
     400             : INLINE GEN
     401       63390 : zero_Flm_copy(long m, long n)
     402             : {
     403       63390 :   GEN y = cgetg(n+1,t_MAT);
     404       63403 :   long i; for (i=1; i<=n; i++) gel(y,i) = zero_Flv(m);
     405       63395 :   return y;
     406             : }
     407             : 
     408             : INLINE GEN
     409      558854 : zero_F2v(long m)
     410             : {
     411      558854 :   long l = nbits2nlong(m);
     412      558854 :   GEN v  = zero_Flv(l+1);
     413      558854 :   v[1] = m;
     414      558854 :   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      229769 : zero_F2m_copy(long m, long n)
     431             : {
     432             :   long i;
     433      229769 :   GEN M = cgetg(n+1, t_MAT);
     434      655207 :   for (i = 1; i <= n; i++)
     435      425438 :     gel(M,i)= zero_F2v(m);
     436      229769 :   return M;
     437             : }
     438             : 
     439             : /* matrix(m, n) */
     440             : INLINE GEN
     441     1365775 : zeromatcopy(long m, long n)
     442             : {
     443     1365775 :   GEN y = cgetg(n+1,t_MAT);
     444     1365775 :   long i; for (i=1; i<=n; i++) gel(y,i) = zerocol(m);
     445     1365775 :   return y;
     446             : }
     447             : 
     448             : INLINE GEN
     449       13518 : zerovec_block(long len)
     450             : {
     451             :   long i;
     452       13518 :   GEN blk = cgetg_block(len + 1, t_VEC);
     453      446094 :   for (i = 1; i <= len; ++i)
     454      432576 :     gel(blk, i) = gen_0;
     455       13518 :   return blk;
     456             : }
     457             : 
     458             : /* i-th vector in the standard basis */
     459             : INLINE GEN
     460     1055436 : col_ei(long n, long i) { GEN e = zerocol(n); gel(e,i) = gen_1; return e; }
     461             : INLINE GEN
     462      261618 : vec_ei(long n, long i) { GEN e = zerovec(n); gel(e,i) = gen_1; return e; }
     463             : INLINE GEN
     464           6 : F2v_ei(long n, long i) { GEN e = zero_F2v(n); F2v_set(e,i); return e; }
     465             : INLINE GEN
     466       52554 : vecsmall_ei(long n, long i) { GEN e = zero_zv(n); e[i] = 1; return e; }
     467             : INLINE GEN
     468      930078 : Rg_col_ei(GEN x, long n, long i) { GEN e = zerocol(n); gel(e,i) = x; return e; }
     469             : 
     470             : INLINE GEN
     471     2241477 : shallowcopy(GEN x)
     472     2241477 : { return typ(x) == t_MAT ? RgM_shallowcopy(x): leafcopy(x); }
     473             : 
     474             : /* routines for naive growarrays */
     475             : INLINE GEN
     476     9363832 : vectrunc_init(long l)
     477             : {
     478     9363832 :   GEN z = new_chunk(l);
     479     9364226 :   z[0] = evaltyp(t_VEC) | _evallg(1); return z;
     480             : }
     481             : INLINE void
     482    36151270 : vectrunc_append(GEN x, GEN t)
     483    36151270 : { long l = lg(x); gel(x,l) = t; setlg(x, l+1); }
     484             : INLINE void
     485           0 : vectrunc_append_batch(GEN x, GEN y)
     486             : {
     487           0 :   long i, l = lg(x), ly = lg(y);
     488           0 :   GEN z = x + l-1;
     489           0 :   for (i = 1; i < ly; i++) gel(z,i) = gel(y,i);
     490           0 :   setlg(x, l+ly-1);
     491           0 : }
     492             : INLINE GEN
     493     1151864 : vecsmalltrunc_init(long l)
     494             : {
     495     1151864 :   GEN z = new_chunk(l);
     496     1151864 :   z[0] = evaltyp(t_VECSMALL) | _evallg(1); return z;
     497             : }
     498             : INLINE void
     499     2332554 : vecsmalltrunc_append(GEN x, long t)
     500     2332554 : { long l = lg(x); x[l] = t; setlg(x, l+1); }
     501             : 
     502             : /*******************************************************************/
     503             : /*                                                                 */
     504             : /*                        VEC / COL / VECSMALL                     */
     505             : /*                                                                 */
     506             : /*******************************************************************/
     507             : /* shallow*/
     508             : INLINE GEN
     509           0 : vec_shorten(GEN v, long n)
     510             : {
     511             :   long i;
     512           0 :   GEN V = cgetg(n+1,t_VEC);
     513           0 :   for(i=1;i<=n;i++) gel(V,i) = gel(v,i);
     514           0 :   return V;
     515             : }
     516             : /* shallow*/
     517             : INLINE GEN
     518        9336 : vec_lengthen(GEN v, long n)
     519             : {
     520             :   long i;
     521        9336 :   long l=lg(v);
     522        9336 :   GEN V = cgetg(n+1,t_VEC);
     523        9336 :   for(i=1;i<l;i++) gel(V,i) = gel(v,i);
     524        9336 :   return V;
     525             : }
     526             : /* shallow*/
     527             : INLINE GEN
     528       48294 : vec_append(GEN V, GEN s)
     529             : {
     530       48294 :   long i, l2 = lg(V);
     531       48294 :   GEN res = cgetg(l2+1, typ(V));
     532       48294 :   for (i = 1; i < l2; ++i) gel(res, i) = gel(V,i);
     533       48294 :   gel(res,l2) = s; return res;
     534             : }
     535             : /* shallow*/
     536             : INLINE GEN
     537           0 : vec_setconst(GEN v, GEN x)
     538             : {
     539           0 :   long i, l = lg(v);
     540           0 :   for (i = 1; i < l; i++) gel(v,i) = x;
     541           0 :   return v;
     542             : }
     543             : INLINE GEN
     544      110890 : vecsmall_shorten(GEN v, long n)
     545             : {
     546             :   long i;
     547      110890 :   GEN V = cgetg(n+1,t_VECSMALL);
     548      110893 :   for(i=1;i<=n;i++) V[i] = v[i];
     549      110893 :   return V;
     550             : }
     551             : INLINE GEN
     552          18 : vecsmall_lengthen(GEN v, long n)
     553             : {
     554          18 :   long i, l = lg(v);
     555          18 :   GEN V = cgetg(n+1,t_VECSMALL);
     556          18 :   for(i=1;i<l;i++) V[i] = v[i];
     557          18 :   return V;
     558             : }
     559             : 
     560             : INLINE GEN
     561      200562 : vec_to_vecsmall(GEN z)
     562             : {
     563      200562 :   long i, l = lg(z);
     564      200562 :   GEN x = cgetg(l, t_VECSMALL);
     565      200562 :   for (i=1; i<l; i++) x[i] = itos(gel(z,i));
     566      200562 :   return x;
     567             : }
     568             : INLINE GEN
     569       18366 : vecsmall_to_vec(GEN z)
     570             : {
     571       18366 :   long i, l = lg(z);
     572       18366 :   GEN x = cgetg(l,t_VEC);
     573       18366 :   for (i=1; i<l; i++) gel(x,i) = stoi(z[i]);
     574       18366 :   return x;
     575             : }
     576             : INLINE GEN
     577         756 : vecsmall_to_vec_inplace(GEN z)
     578             : {
     579         756 :   long i, l = lg(z);
     580         756 :   for (i=1; i<l; i++) gel(z,i) = stoi(z[i]);
     581         756 :   settyp(z, t_VEC); return z;
     582             : }
     583             : INLINE GEN
     584     1052130 : vecsmall_to_col(GEN z)
     585             : {
     586     1052130 :   long i, l = lg(z);
     587     1052130 :   GEN x = cgetg(l,t_COL);
     588     1052130 :   for (i=1; i<l; i++) gel(x,i) = stoi(z[i]);
     589     1052130 :   return x;
     590             : }
     591             : 
     592             : INLINE int
     593     7035930 : vecsmall_lexcmp(GEN x, GEN y)
     594             : {
     595             :   long lx,ly,l,i;
     596     7035930 :   lx = lg(x);
     597     7035930 :   ly = lg(y); l = minss(lx,ly);
     598    43854324 :   for (i=1; i<l; i++)
     599    42395010 :     if (x[i] != y[i]) return x[i]<y[i]? -1: 1;
     600     1459314 :   if (lx == ly) return 0;
     601          12 :   return (lx < ly)? -1 : 1;
     602             : }
     603             : 
     604             : INLINE int
     605    40343124 : vecsmall_prefixcmp(GEN x, GEN y)
     606             : {
     607    40343124 :   long i, lx = lg(x), ly = lg(y), l = minss(lx,ly);
     608   127552584 :   for (i=1; i<l; i++)
     609   115672986 :     if (x[i] != y[i]) return x[i]<y[i]? -1: 1;
     610    11879598 :   return 0;
     611             : }
     612             : 
     613             : /*Can be used on t_VEC, but coeffs not gcopy-ed*/
     614             : INLINE GEN
     615        1308 : vecsmall_prepend(GEN V, long s)
     616             : {
     617        1308 :   long i, l2 = lg(V);
     618        1308 :   GEN res = cgetg(l2+1, typ(V));
     619        1308 :   res[1] = s;
     620        1308 :   for (i = 2; i <= l2; ++i) res[i] = V[i - 1];
     621        1308 :   return res;
     622             : }
     623             : 
     624             : INLINE GEN
     625      318608 : vecsmall_append(GEN V, long s)
     626             : {
     627      318608 :   long i, l2 = lg(V);
     628      318608 :   GEN res = cgetg(l2+1, t_VECSMALL);
     629      318608 :   for (i = 1; i < l2; ++i) res[i] = V[i];
     630      318608 :   res[l2] = s; return res;
     631             : }
     632             : 
     633             : INLINE GEN
     634      512604 : vecsmall_concat(GEN u, GEN v)
     635             : {
     636      512604 :   long i, l1 = lg(u)-1, l2 = lg(v)-1;
     637      512604 :   GEN res = cgetg(l1+l2+1, t_VECSMALL);
     638      512604 :   for (i = 1; i <= l1; ++i) res[i]    = u[i];
     639      512604 :   for (i = 1; i <= l2; ++i) res[i+l1] = v[i];
     640      512604 :   return res;
     641             : }
     642             : 
     643             : /* return the number of indices where u and v are equal */
     644             : INLINE long
     645           0 : vecsmall_coincidence(GEN u, GEN v)
     646             : {
     647           0 :   long i, s = 0, l = minss(lg(u),lg(v));
     648           0 :   for(i=1; i<l; i++)
     649           0 :     if(u[i] == v[i]) s++;
     650           0 :   return s;
     651             : }
     652             : 
     653             : /* returns the first index i<=n such that x=v[i] if it exists, 0 otherwise */
     654             : INLINE long
     655           0 : vecsmall_isin(GEN v, long x)
     656             : {
     657           0 :   long i, l = lg(v);
     658           0 :   for (i = 1; i < l; i++)
     659           0 :     if (v[i] == x) return i;
     660           0 :   return 0;
     661             : }
     662             : 
     663             : INLINE long
     664          72 : vecsmall_pack(GEN V, long base, long mod)
     665             : {
     666          72 :   long i, s = 0;
     667          72 :   for(i=1; i<lg(V); i++) s = (base*s + V[i]) % mod;
     668          72 :   return s;
     669             : }
     670             : 
     671             : INLINE long
     672          12 : vecsmall_indexmax(GEN x)
     673             : {
     674          12 :   long i, i0 = 1, t = x[1], lx = lg(x);
     675          48 :   for (i=2; i<lx; i++)
     676          36 :     if (x[i] > t) t = x[i0=i];
     677          12 :   return i0;
     678             : }
     679             : 
     680             : INLINE long
     681       34846 : vecsmall_max(GEN x)
     682             : {
     683       34846 :   long i, t = x[1], lx = lg(x);
     684       63240 :   for (i=2; i<lx; i++)
     685       28394 :     if (x[i] > t) t = x[i];
     686       34846 :   return t;
     687             : }
     688             : 
     689             : INLINE long
     690          12 : vecsmall_indexmin(GEN x)
     691             : {
     692          12 :   long i, i0 = 1, t = x[1], lx =lg(x);
     693          48 :   for (i=2; i<lx; i++)
     694          36 :     if (x[i] < t) t = x[i0=i];
     695          12 :   return i0;
     696             : }
     697             : 
     698             : INLINE long
     699           0 : vecsmall_min(GEN x)
     700             : {
     701           0 :   long i, t = x[1], lx =lg(x);
     702           0 :   for (i=2; i<lx; i++)
     703           0 :     if (x[i] < t) t = x[i];
     704           0 :   return t;
     705             : }
     706             : 
     707             : INLINE int
     708     1690842 : ZV_isscalar(GEN x)
     709             : {
     710     1690842 :   long l = lg(x);
     711     6297294 :   while (--l > 1)
     712     4300596 :     if (signe(gel(x, l))) return 0;
     713      305856 :   return 1;
     714             : }
     715             : INLINE int
     716     4800896 : QV_isscalar(GEN x)
     717             : {
     718     4800896 :   long lx = lg(x),i;
     719     5683350 :   for (i=2; i<lx; i++)
     720     5465148 :     if (!isintzero(gel(x, i))) return 0;
     721      218202 :   return 1;
     722             : }
     723             : INLINE int
     724        3162 : RgV_isscalar(GEN x)
     725             : {
     726        3162 :   long lx = lg(x),i;
     727        6000 :   for (i=2; i<lx; i++)
     728        5208 :     if (!gequal0(gel(x, i))) return 0;
     729         792 :   return 1;
     730             : }
     731             : INLINE int
     732           0 : RgX_isscalar(GEN x)
     733             : {
     734             :   long i;
     735           0 :   for (i=lg(x)-1; i>2; i--)
     736           0 :     if (!gequal0(gel(x, i))) return 0;
     737           0 :   return 1;
     738             : }
     739             : INLINE long
     740     3410136 : RgX_equal_var(GEN x, GEN y) { return varn(x) == varn(y) && RgX_equal(x,y); }
     741             : 
     742             : INLINE int
     743        2256 : RgX_is_rational(GEN x)
     744             : {
     745             :   long i;
     746       14634 :   for (i = lg(x)-1; i > 1; i--)
     747       13584 :     if (!is_rational_t(typ(gel(x,i)))) return 0;
     748        1050 :   return 1;
     749             : }
     750             : INLINE int
     751    47757838 : RgX_is_ZX(GEN x)
     752             : {
     753             :   long i;
     754   214250040 :   for (i = lg(x)-1; i > 1; i--)
     755   170857433 :     if (typ(gel(x,i)) != t_INT) return 0;
     756    43392607 :   return 1;
     757             : }
     758             : INLINE int
     759       91422 : RgX_is_QX(GEN x)
     760             : {
     761       91422 :   long k = lg(x)-1;
     762      340260 :   for ( ; k>1; k--)
     763      249588 :     if (!is_rational_t(typ(gel(x,k)))) return 0;
     764       90672 :   return 1;
     765             : }
     766             : INLINE int
     767    12538318 : RgX_is_monomial(GEN x)
     768             : {
     769             :   long i;
     770    12538318 :   if (!signe(x)) return 0;
     771    20549408 :   for (i=lg(x)-2; i>1; i--)
     772    14335432 :     if (!isexactzero(gel(x,i))) return 0;
     773     6213976 :   return 1;
     774             : }
     775             : INLINE int
     776     2119790 : RgV_is_ZV(GEN x)
     777             : {
     778             :   long i;
     779     7521838 :   for (i = lg(x)-1; i > 0; i--)
     780     5402648 :     if (typ(gel(x,i)) != t_INT) return 0;
     781     2119190 :   return 1;
     782             : }
     783             : INLINE int
     784         126 : RgV_is_QV(GEN x)
     785             : {
     786             :   long i;
     787         354 :   for (i = lg(x)-1; i > 0; i--)
     788         240 :     if (!is_rational_t(typ(gel(x,i)))) return 0;
     789         114 :   return 1;
     790             : }
     791             : 
     792             : /********************************************************************/
     793             : /**                                                                **/
     794             : /**            Dynamic arrays implementation                       **/
     795             : /**                                                                **/
     796             : /********************************************************************/
     797             : INLINE void **
     798   283982806 : pari_stack_base(pari_stack *s) { return s->data; }
     799             : 
     800             : INLINE void
     801      896539 : pari_stack_init(pari_stack *s, size_t size, void **data)
     802             : {
     803      896539 :   s->data = data;
     804      896539 :   *data = NULL;
     805      896539 :   s->n = 0;
     806      896539 :   s->alloc = 0;
     807      896539 :   s->size = size;
     808      896539 : }
     809             : 
     810             : INLINE void
     811   283116676 : pari_stack_alloc(pari_stack *s, long nb)
     812             : {
     813   283116676 :   void **sdat = pari_stack_base(s);
     814   283266679 :   long alloc = s->alloc;
     815   566534298 :   if (s->n+nb <= alloc) return;
     816      299711 :   if (!alloc)
     817      259723 :     alloc = nb;
     818             :   else
     819             :   {
     820       39988 :     while (s->n+nb > alloc) alloc <<= 1;
     821             :   }
     822      299711 :   *sdat = pari_realloc(*sdat,alloc*s->size);
     823      300651 :   s->alloc = alloc;
     824             : }
     825             : 
     826             : INLINE long
     827   237286755 : pari_stack_new(pari_stack *s) { pari_stack_alloc(s, 1); return s->n++; }
     828             : 
     829             : INLINE void
     830      771152 : pari_stack_delete(pari_stack *s)
     831             : {
     832      771152 :   void **sdat = pari_stack_base(s);
     833      770811 :   if (*sdat) pari_free(*sdat);
     834      771013 : }
     835             : 
     836             : INLINE void
     837        3805 : pari_stack_pushp(pari_stack *s, void *u)
     838             : {
     839        3805 :   long n = pari_stack_new(s);
     840        3805 :   void **sdat =(void**) *pari_stack_base(s);
     841        3805 :   sdat[n] = u;
     842        3805 : }
     843             : 
     844             : /*******************************************************************/
     845             : /*                                                                 */
     846             : /*                            EXTRACT                              */
     847             : /*                                                                 */
     848             : /*******************************************************************/
     849             : INLINE GEN
     850   137970460 : vecslice(GEN A, long y1, long y2)
     851             : {
     852   137970460 :   long i,lB = y2 - y1 + 2;
     853   137970460 :   GEN B = cgetg(lB, typ(A));
     854   137970460 :   for (i=1; i<lB; i++) B[i] = A[y1-1+i];
     855   137970460 :   return B;
     856             : }
     857             : INLINE GEN
     858      582984 : vecslicepermute(GEN A, GEN p, long y1, long y2)
     859             : {
     860      582984 :   long i,lB = y2 - y1 + 2;
     861      582984 :   GEN B = cgetg(lB, typ(A));
     862      582984 :   for (i=1; i<lB; i++) B[i] = A[p[y1-1+i]];
     863      582984 :   return B;
     864             : }
     865             : /* rowslice(rowpermute(A,p), x1, x2) */
     866             : INLINE GEN
     867       30050 : rowslicepermute(GEN A, GEN p, long x1, long x2)
     868             : {
     869       30050 :   long i, lB = lg(A);
     870       30050 :   GEN B = cgetg(lB, typ(A));
     871       30050 :   for (i=1; i<lB; i++) gel(B,i) = vecslicepermute(gel(A,i),p,x1,x2);
     872       30050 :   return B;
     873             : }
     874             : INLINE GEN
     875    13714100 : rowslice(GEN A, long x1, long x2)
     876             : {
     877    13714100 :   long i, lB = lg(A);
     878    13714100 :   GEN B = cgetg(lB, typ(A));
     879    13714100 :   for (i=1; i<lB; i++) gel(B,i) = vecslice(gel(A,i),x1,x2);
     880    13714100 :   return B;
     881             : }
     882             : 
     883             : INLINE GEN
     884       98190 : matslice(GEN A, long x1, long x2, long y1, long y2)
     885             : {
     886       98190 :   return rowslice(vecslice(A, y1, y2), x1, x2);
     887             : }
     888             : 
     889             : /* shallow, remove coeff of index j */
     890             : INLINE GEN
     891         114 : rowsplice(GEN a, long j)
     892             : {
     893             :   long i, l;
     894         114 :   GEN b = cgetg_copy(a,&l);
     895         114 :   for (i = 1; i < l; i++) gel(b,i) = vecsplice(gel(a,i), j);
     896         114 :   return b;
     897             : }
     898             : /* shallow, remove coeff of index j */
     899             : INLINE GEN
     900        7272 : vecsplice(GEN a, long j)
     901             : {
     902        7272 :   long i, k, l = lg(a);
     903             :   GEN b;
     904        7272 :   if (l == 1) pari_err(e_MISC, "incorrect component in vecsplice");
     905        7272 :   b = cgetg(l-1, typ(a));
     906       40464 :   for (i = k = 1; i < l; i++)
     907       33192 :     if (i != j) gel(b, k++) = gel(a,i);
     908        7272 :   return b;
     909             : }
     910             : /* shallow */
     911             : INLINE GEN
     912         648 : RgM_minor(GEN a, long i, long j)
     913             : {
     914         648 :   GEN b = vecsplice(a, j);
     915         648 :   long k, l = lg(b);
     916         648 :   for (k = 1; k < l; k++) gel(b,k) = vecsplice(gel(b,k), i);
     917         648 :   return b;
     918             : }
     919             : 
     920             : /* A[x0,] */
     921             : INLINE GEN
     922      145380 : row(GEN A, long x0)
     923             : {
     924      145380 :   long i, lB = lg(A);
     925      145380 :   GEN B  = cgetg(lB, t_VEC);
     926      145380 :   for (i=1; i<lB; i++) gel(B, i) = gcoeff(A, x0, i);
     927      145380 :   return B;
     928             : }
     929             : INLINE GEN
     930     2690355 : Flm_row(GEN A, long x0)
     931             : {
     932     2690355 :   long i, lB = lg(A);
     933     2690355 :   GEN B  = cgetg(lB, t_VECSMALL);
     934     2690359 :   for (i=1; i<lB; i++) B[i] = coeff(A, x0, i);
     935     2690359 :   return B;
     936             : }
     937             : /* A[x0,] */
     938             : INLINE GEN
     939          48 : rowcopy(GEN A, long x0)
     940             : {
     941          48 :   long i, lB = lg(A);
     942          48 :   GEN B  = cgetg(lB, t_VEC);
     943          48 :   for (i=1; i<lB; i++) gel(B, i) = gcopy(gcoeff(A, x0, i));
     944          48 :   return B;
     945             : }
     946             : /* A[x0, x1..x2] */
     947             : INLINE GEN
     948        1866 : row_i(GEN A, long x0, long x1, long x2)
     949             : {
     950        1866 :   long i, lB = x2 - x1 + 2;
     951        1866 :   GEN B  = cgetg(lB, t_VEC);
     952        1866 :   for (i=x1; i<=x2; i++) gel(B, i) = gcoeff(A, x0, i);
     953        1866 :   return B;
     954             : }
     955             : 
     956             : INLINE GEN
     957     4043868 : vecreverse(GEN A)
     958             : {
     959             :   long i, l;
     960     4043868 :   GEN B = cgetg_copy(A, &l);
     961     4043868 :   for (i=1; i<l; i++) gel(B, i) = gel(A, l-i);
     962     4043868 :   return B;
     963             : }
     964             : 
     965             : INLINE GEN
     966         216 : vecsmall_reverse(GEN A)
     967             : {
     968             :   long i, l;
     969         216 :   GEN B = cgetg_copy(A, &l);
     970         216 :   for (i=1; i<l; i++) B[i] = A[l-i];
     971         216 :   return B;
     972             : }
     973             : 
     974             : INLINE void
     975         198 : vecreverse_inplace(GEN y)
     976             : {
     977         198 :   long ly = lg(y), lim = ly>>1, i;
     978         546 :   for (i = 1; i <= lim; i++)
     979             :   {
     980         348 :     GEN z = gel(y,i);
     981         348 :     gel(y,i)    = gel(y,ly-i);
     982         348 :     gel(y,ly-i) = z;
     983             :   }
     984         198 : }
     985             : 
     986             : INLINE GEN
     987    33708172 : vecsmallpermute(GEN A, GEN p) { return perm_mul(A, p); }
     988             : 
     989             : INLINE GEN
     990     4061052 : vecpermute(GEN A, GEN p)
     991             : {
     992     4061052 :   long i,lB = lg(p);
     993     4061052 :   GEN B = cgetg(lB, typ(A));
     994     4061052 :   for (i=1; i<lB; i++) gel(B, i) = gel(A, p[i]);
     995     4061052 :   return B;
     996             : }
     997             : INLINE GEN
     998     1889234 : rowpermute(GEN A, GEN p)
     999             : {
    1000     1889234 :   long i, lB = lg(A);
    1001     1889234 :   GEN B = cgetg(lB, typ(A));
    1002    19570881 :   for (i=1; i<lB; i++)
    1003    18814418 :     gel(B, i) = typ(gel(A,i)) == t_VECSMALL ? vecsmallpermute(gel(A, i), p):
    1004     1132771 :                                                     vecpermute(gel(A, i), p);
    1005     1889234 :   return B;
    1006             : }
    1007             : /*******************************************************************/
    1008             : /*                                                                 */
    1009             : /*                          PERMUTATIONS                           */
    1010             : /*                                                                 */
    1011             : /*******************************************************************/
    1012             : /* identity permutation */
    1013             : INLINE GEN
    1014      456978 : identity_perm(long n)
    1015             : {
    1016      456978 :   GEN perm = cgetg(n+1, t_VECSMALL);
    1017             :   long i;
    1018      456978 :   for (i = 1; i <= n; i++) perm[i] = i;
    1019      456978 :   return perm;
    1020             : }
    1021             : 
    1022             : /* assume d <= n */
    1023             : INLINE GEN
    1024           0 : cyclic_perm(long n, long d)
    1025             : {
    1026           0 :   GEN perm = cgetg(n+1, t_VECSMALL);
    1027             :   long i;
    1028           0 :   for (i = 1; i <= n-d; i++) perm[i] = i+d;
    1029           0 :   for (     ; i <= n;   i++) perm[i] = i-n+d;
    1030           0 :   return perm;
    1031             : }
    1032             : 
    1033             : /* Multiply (compose) two permutations */
    1034             : INLINE GEN
    1035    34986724 : perm_mul(GEN s, GEN t)
    1036             : {
    1037             :   GEN u;
    1038    34986724 :   long i, l = lg(t);
    1039    34986724 :   u = cgetg(l, t_VECSMALL);
    1040    34986724 :   for (i = 1; i < l; i++) u[i] = s[ t[i] ];
    1041    34986724 :   return u;
    1042             : }
    1043             : /* Compute the inverse (reciprocal) of a permutation. */
    1044             : INLINE GEN
    1045      384234 : perm_inv(GEN x)
    1046             : {
    1047             :   long i, lx;
    1048      384234 :   GEN y = cgetg_copy(x, &lx);
    1049      384234 :   for (i=1; i<lx; i++) y[ x[i] ] = i;
    1050      384234 :   return y;
    1051             : }
    1052             : /* Return s*t*s^-1 */
    1053             : INLINE GEN
    1054      175698 : perm_conj(GEN s, GEN t)
    1055             : {
    1056             :   long i, l;
    1057      175698 :   GEN v = cgetg_copy(s, &l);
    1058      175698 :   for (i = 1; i < l; i++) v[ s[i] ] = s[ t[i] ];
    1059      175698 :   return v;
    1060             : }
    1061             : 
    1062             : /*********************************************************************/
    1063             : /*                       MALLOC/FREE WRAPPERS                        */
    1064             : /*********************************************************************/
    1065             : #define BLOCK_SIGALRM_START          \
    1066             : {                                    \
    1067             :   int block=PARI_SIGINT_block;       \
    1068             :   PARI_SIGINT_block = 2;             \
    1069             :   MT_SIGINT_BLOCK(block);
    1070             : 
    1071             : #define BLOCK_SIGINT_START           \
    1072             : {                                    \
    1073             :   int block=PARI_SIGINT_block;       \
    1074             :   PARI_SIGINT_block = 1;             \
    1075             :   MT_SIGINT_BLOCK(block);
    1076             : 
    1077             : #define BLOCK_SIGINT_END             \
    1078             :   PARI_SIGINT_block = block;         \
    1079             :   MT_SIGINT_UNBLOCK(block);          \
    1080             :   if (!block && PARI_SIGINT_pending) \
    1081             :   {                                  \
    1082             :     int sig = PARI_SIGINT_pending;   \
    1083             :     PARI_SIGINT_pending = 0;         \
    1084             :     raise(sig);                      \
    1085             :   }                                  \
    1086             : }
    1087             : 
    1088             : INLINE void
    1089    39190809 : pari_free(void *pointer)
    1090             : {
    1091    39190809 :   BLOCK_SIGINT_START;
    1092    39191648 :   free(pointer);
    1093    39191648 :   BLOCK_SIGINT_END;
    1094    39191345 : }
    1095             : INLINE void*
    1096   156995326 : pari_malloc(size_t size)
    1097             : {
    1098   156995326 :   if (size)
    1099             :   {
    1100             :     char *tmp;
    1101   156995326 :     BLOCK_SIGINT_START;
    1102   156998084 :     tmp = (char*)malloc(size);
    1103   156998084 :     BLOCK_SIGINT_END;
    1104   156997990 :     if (!tmp) pari_err(e_MEM);
    1105   156997990 :     return tmp;
    1106             :   }
    1107           0 :   if (DEBUGMEM) pari_warn(warner,"mallocing NULL object");
    1108           0 :   return NULL;
    1109             : }
    1110             : INLINE void*
    1111      304568 : pari_realloc(void *pointer, size_t size)
    1112             : {
    1113             :   char *tmp;
    1114             : 
    1115      304568 :   BLOCK_SIGINT_START;
    1116      305864 :   if (!pointer) tmp = (char *) malloc(size);
    1117       43028 :   else tmp = (char *) realloc(pointer,size);
    1118      305864 :   BLOCK_SIGINT_END;
    1119      305477 :   if (!tmp) pari_err(e_MEM);
    1120      305477 :   return tmp;
    1121             : }
    1122             : INLINE void*
    1123       26295 : pari_calloc(size_t size)
    1124             : {
    1125       26295 :   void *t = pari_malloc(size);
    1126       26295 :   memset(t, 0, size); return t;
    1127             : }
    1128             : INLINE GEN
    1129        3355 : cgetalloc(long t, size_t l)
    1130             : {
    1131        3355 :   GEN x = (GEN)pari_malloc(l * sizeof(long));
    1132        3355 :   x[0] = evaltyp(t) | evallg(l); return x;
    1133             : }
    1134             : 
    1135             : /*******************************************************************/
    1136             : /*                                                                 */
    1137             : /*                       GARBAGE COLLECTION                        */
    1138             : /*                                                                 */
    1139             : /*******************************************************************/
    1140             : /* copy integer x as if we had avma = av */
    1141             : INLINE GEN
    1142  3097075421 : icopy_avma(GEN x, pari_sp av)
    1143             : {
    1144  3097075421 :   long i = lgefint(x), lx = i;
    1145  3097075421 :   GEN y = ((GEN)av) - i;
    1146  3097075421 :   while (--i > 0) y[i] = x[i];
    1147  3097075421 :   y[0] = evaltyp(t_INT)|evallg(lx);
    1148  3097002817 :   return y;
    1149             : }
    1150             : /* copy leaf x as if we had avma = av */
    1151             : INLINE GEN
    1152    80920416 : leafcopy_avma(GEN x, pari_sp av)
    1153             : {
    1154    80920416 :   long i = lg(x);
    1155    80920416 :   GEN y = ((GEN)av) - i;
    1156    80920416 :   while (--i > 0) y[i] = x[i];
    1157    80920416 :   y[0] = x[0] & (~CLONEBIT);
    1158    80920416 :   return y;
    1159             : }
    1160             : INLINE GEN
    1161   431901215 : gerepileuptoleaf(pari_sp av, GEN x)
    1162             : {
    1163             :   long lx;
    1164             :   GEN q;
    1165             : 
    1166   431901215 :   if (!isonstack(x) || (GEN)av<=x) { avma = av; return x; }
    1167   432866523 :   lx = lg(x);
    1168   432866523 :   q = ((GEN)av) - lx;
    1169   432866523 :   avma = (pari_sp)q;
    1170   432866523 :   while (--lx >= 0) q[lx] = x[lx];
    1171   432866523 :   return q;
    1172             : }
    1173             : INLINE GEN
    1174   758140719 : gerepileuptoint(pari_sp av, GEN x)
    1175             : {
    1176   758140719 :   if (!isonstack(x) || (GEN)av<=x) { avma = av; return x; }
    1177   654957308 :   avma = (pari_sp)icopy_avma(x, av);
    1178   655198720 :   return (GEN)avma;
    1179             : }
    1180             : INLINE GEN
    1181   534446188 : gerepileupto(pari_sp av, GEN x)
    1182             : {
    1183   534446188 :   if (!isonstack(x) || (GEN)av<=x) { avma = av; return x; }
    1184   476384419 :   switch(typ(x))
    1185             :   { /* non-default = !is_recursive_t(tq) */
    1186   146461458 :     case t_INT: return gerepileuptoint(av, x);
    1187             :     case t_REAL:
    1188             :     case t_STR:
    1189    97057135 :     case t_VECSMALL: return gerepileuptoleaf(av,x);
    1190             :     default:
    1191             :       /* NB: x+i --> ((long)x) + i*sizeof(long) */
    1192   232865826 :       return gerepile(av, (pari_sp) (x+lg(x)), x);
    1193             :   }
    1194             : }
    1195             : 
    1196             : /* gerepileupto(av, gcopy(x)) */
    1197             : INLINE GEN
    1198    28512591 : gerepilecopy(pari_sp av, GEN x)
    1199             : {
    1200    28512591 :   if (is_recursive_t(typ(x)))
    1201             :   {
    1202    23475639 :     GENbin *p = copy_bin(x);
    1203    23475643 :     avma = av; return bin_copy(p);
    1204             :   }
    1205             :   else
    1206             :   {
    1207     5038750 :     avma = av;
    1208     5038750 :     if (x < (GEN)av) {
    1209     3975544 :       if (x < (GEN)pari_mainstack->bot) new_chunk(lg(x));
    1210     3975544 :       x = leafcopy_avma(x, av);
    1211     3979791 :       avma = (pari_sp)x;
    1212             :     } else
    1213     1063206 :       x = leafcopy(x);
    1214     5045032 :     return x;
    1215             :   }
    1216             : }
    1217             : 
    1218             : /* Takes an array of pointers to GENs, of length n. Copies all
    1219             :  * objects to contiguous locations and cleans up the stack between
    1220             :  * av and avma. */
    1221             : INLINE void
    1222       55434 : gerepilemany(pari_sp av, GEN* gptr[], int n)
    1223             : {
    1224             :   int i;
    1225       55434 :   for (i=0; i<n; i++) *gptr[i] = (GEN)copy_bin(*gptr[i]);
    1226       55434 :   avma = av;
    1227       55434 :   for (i=0; i<n; i++) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1228       55434 : }
    1229             : 
    1230             : INLINE void
    1231     4222766 : gerepileall(pari_sp av, int n, ...)
    1232             : {
    1233             :   int i;
    1234     4222766 :   va_list a; va_start(a, n);
    1235     4222766 :   if (n < 10)
    1236             :   {
    1237             :     GEN *gptr[10];
    1238    12949228 :     for (i=0; i<n; i++)
    1239     8726469 :     { gptr[i] = va_arg(a,GEN*); *gptr[i] = (GEN)copy_bin(*gptr[i]); }
    1240     4222759 :     avma = av;
    1241     4222759 :     for (--i; i>=0; i--) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1242             : 
    1243             :   }
    1244             :   else
    1245             :   {
    1246           0 :     GEN **gptr = (GEN**)  pari_malloc(n*sizeof(GEN*));
    1247           0 :     for (i=0; i<n; i++)
    1248           0 :     { gptr[i] = va_arg(a,GEN*); *gptr[i] = (GEN)copy_bin(*gptr[i]); }
    1249           0 :     avma = av;
    1250           0 :     for (--i; i>=0; i--) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1251           0 :     pari_free(gptr);
    1252             :   }
    1253     4222758 :   va_end(a);
    1254     4222758 : }
    1255             : 
    1256             : INLINE void
    1257           6 : gerepilecoeffs(pari_sp av, GEN x, int n)
    1258             : {
    1259             :   int i;
    1260           6 :   for (i=0; i<n; i++) gel(x,i) = (GEN)copy_bin(gel(x,i));
    1261           6 :   avma = av;
    1262           6 :   for (i=0; i<n; i++) gel(x,i) = bin_copy((GENbin*)x[i]);
    1263           6 : }
    1264             : 
    1265             : /* p from copy_bin. Copy p->x back to stack, then destroy p */
    1266             : INLINE GEN
    1267    32349223 : bin_copy(GENbin *p)
    1268             : {
    1269             :   GEN x, y, base;
    1270             :   long dx, len;
    1271             : 
    1272    32349223 :   x   = p->x; if (!x) { pari_free(p); return gen_0; }
    1273    32346724 :   len = p->len;
    1274    32346724 :   base= p->base; dx = x - base;
    1275    32346724 :   y = (GEN)memcpy((void*)new_chunk(len), (void*)GENbinbase(p), len*sizeof(long));
    1276    32346696 :   y += dx;
    1277    32346696 :   p->rebase(y, ((ulong)y-(ulong)x));
    1278    32346698 :   pari_free(p); return y;
    1279             : }
    1280             : 
    1281             : INLINE GEN
    1282    64695964 : GENbinbase(GENbin *p) { return (GEN)(p + 1); }
    1283             : 
    1284             : INLINE void
    1285    22557442 : cgiv(GEN x)
    1286             : {
    1287    22557442 :   pari_sp av = (pari_sp)(x+lg(x));
    1288    22557442 :   if (isonstack((GEN)av)) avma = av;
    1289    22557295 : }
    1290             : 
    1291             : INLINE void
    1292     1018723 : killblock(GEN x) { gunclone(x); }
    1293             : 
    1294             : INLINE int
    1295    14331582 : is_universal_constant(GEN x) { return (x >= gen_0 && x <= ghalf); }
    1296             : 
    1297             : /*******************************************************************/
    1298             : /*                                                                 */
    1299             : /*                    CONVERSION / ASSIGNMENT                      */
    1300             : /*                                                                 */
    1301             : /*******************************************************************/
    1302             : /* z is a type which may be a t_COMPLEX component (not a t_QUAD) */
    1303             : INLINE GEN
    1304     1824618 : cxcompotor(GEN z, long prec)
    1305             : {
    1306     1824618 :   switch(typ(z))
    1307             :   {
    1308      937782 :     case t_INT:  return itor(z, prec);
    1309      114960 :     case t_FRAC: return fractor(z, prec);
    1310      771876 :     case t_REAL: return rtor(z, prec);
    1311           0 :     default: pari_err_TYPE("cxcompotor",z);
    1312             :              return NULL; /* LCOV_EXCL_LINE */
    1313             :   }
    1314             : }
    1315             : INLINE GEN
    1316      910704 : cxtofp(GEN x, long prec)
    1317      910704 : { retmkcomplex(cxcompotor(gel(x,1),prec), cxcompotor(gel(x,2),prec)); }
    1318             : 
    1319             : INLINE double
    1320    14000297 : gtodouble(GEN x)
    1321             : {
    1322    14000297 :   if (typ(x)!=t_REAL) {
    1323     2791718 :     pari_sp av = avma;
    1324     2791718 :     x = gtofp(x, DEFAULTPREC);
    1325     2791718 :     if (typ(x)!=t_REAL) pari_err_TYPE("gtodouble [t_REAL expected]", x);
    1326     2791718 :     avma = av;
    1327             :   }
    1328    14000297 :   return rtodbl(x);
    1329             : }
    1330             : INLINE long
    1331    57024534 : gtos(GEN x) {
    1332    57024534 :   if (typ(x) != t_INT) pari_err_TYPE("gtos [integer expected]",x);
    1333    57024528 :   return itos(x);
    1334             : }
    1335             : 
    1336             : INLINE ulong
    1337       70355 : gtou(GEN x) {
    1338       70355 :   if (typ(x) != t_INT || signe(x)<0)
    1339           0 :     pari_err_TYPE("gtou [integer >=0 expected]",x);
    1340       70557 :   return itou(x);
    1341             : }
    1342             : 
    1343             : INLINE GEN
    1344      938898 : absfrac(GEN x)
    1345             : {
    1346      938898 :   GEN y = cgetg(3, t_FRAC);
    1347      938898 :   gel(y,1) = absi(gel(x,1));
    1348      938898 :   gel(y,2) = icopy(gel(x,2)); return y;
    1349             : }
    1350             : INLINE GEN
    1351        9480 : absfrac_shallow(GEN x)
    1352        9480 : { return signe(gel(x,1))>0? x: mkfrac(negi(gel(x,1)), gel(x,2)); }
    1353             : INLINE GEN
    1354      346950 : Q_abs(GEN x) { return (typ(x) == t_INT)? absi(x): absfrac(x); }
    1355             : INLINE GEN
    1356       31572 : Q_abs_shallow(GEN x)
    1357       31572 : { return (typ(x) == t_INT)? absi_shallow(x): absfrac_shallow(x); }
    1358             : INLINE GEN
    1359         276 : R_abs_shallow(GEN x)
    1360         276 : { return (typ(x) == t_FRAC)? absfrac_shallow(x): mpabs_shallow(x); }
    1361             : INLINE GEN
    1362           0 : R_abs(GEN x)
    1363           0 : { return (typ(x) == t_FRAC)? absfrac(x): mpabs(x); }
    1364             : 
    1365             : /* Force z to be of type real/complex with floating point components */
    1366             : INLINE GEN
    1367    14421998 : gtofp(GEN z, long prec)
    1368             : {
    1369    14421998 :   switch(typ(z))
    1370             :   {
    1371     6500782 :     case t_INT:  return itor(z, prec);
    1372     3617266 :     case t_FRAC: return fractor(z, prec);
    1373     3548136 :     case t_REAL: return rtor(z, prec);
    1374             :     case t_COMPLEX: {
    1375      755814 :       GEN a = gel(z,1), b = gel(z,2);
    1376      755814 :       if (isintzero(b)) return cxcompotor(a, prec);
    1377      754332 :       if (isintzero(a)) {
    1378        1452 :         GEN y = cgetg(3, t_COMPLEX);
    1379        1452 :         b = cxcompotor(b, prec);
    1380        1452 :         gel(y,1) = real_0_bit(expo(b) - prec2nbits(prec));
    1381        1452 :         gel(y,2) = b; return y;
    1382             :       }
    1383      752880 :       return cxtofp(z, prec);
    1384             :     }
    1385           0 :     case t_QUAD: return quadtofp(z, prec);
    1386           0 :     default: pari_err_TYPE("gtofp",z);
    1387             :              return NULL; /* LCOV_EXCL_LINE */
    1388             :   }
    1389             : }
    1390             : /* Force z to be of type real / int */
    1391             : INLINE GEN
    1392       19200 : gtomp(GEN z, long prec)
    1393             : {
    1394       19200 :   switch(typ(z))
    1395             :   {
    1396          12 :     case t_INT:  return z;
    1397       19188 :     case t_FRAC: return fractor(z, prec);
    1398           0 :     case t_REAL: return rtor(z, prec);
    1399           0 :     case t_QUAD: z = quadtofp(z, prec);
    1400           0 :                  if (typ(z) == t_REAL) return z;
    1401           0 :     default: pari_err_TYPE("gtomp",z);
    1402             :              return NULL; /* LCOV_EXCL_LINE */
    1403             :   }
    1404             : }
    1405             : 
    1406             : INLINE GEN
    1407      418314 : RgX_gtofp(GEN x, long prec)
    1408             : {
    1409             :   long l;
    1410      418314 :   GEN y = cgetg_copy(x, &l);
    1411      418314 :   while (--l > 1) gel(y,l) = gtofp(gel(x,l), prec);
    1412      418314 :   y[1] = x[1]; return y;
    1413             : }
    1414             : INLINE GEN
    1415      227034 : RgC_gtofp(GEN x, long prec)
    1416             : {
    1417      227034 :   long l = lg(x);
    1418      227034 :   GEN y = cgetg(l, t_COL);
    1419      227034 :   while (--l > 0) gel(y,l) = gtofp(gel(x,l), prec);
    1420      227034 :   return y;
    1421             : }
    1422             : INLINE GEN
    1423          36 : RgV_gtofp(GEN x, long prec)
    1424             : {
    1425          36 :   long l = lg(x);
    1426          36 :   GEN y = cgetg(l, t_VEC);
    1427          36 :   while (--l > 0) gel(y,l) = gtofp(gel(x,l), prec);
    1428          36 :   return y;
    1429             : }
    1430             : INLINE GEN
    1431       16176 : RgM_gtofp(GEN x, long prec)
    1432             : {
    1433             :   long l;
    1434       16176 :   GEN y = cgetg_copy(x, &l);
    1435       16176 :   while (--l > 0) gel(y,l) = RgC_gtofp(gel(x,l), prec);
    1436       16176 :   return y;
    1437             : }
    1438             : INLINE GEN
    1439         480 : RgC_gtomp(GEN x, long prec)
    1440             : {
    1441         480 :   long l = lg(x);
    1442         480 :   GEN y = cgetg(l, t_COL);
    1443         480 :   while (--l > 0) gel(y,l) = gtomp(gel(x,l), prec);
    1444         480 :   return y;
    1445             : }
    1446             : INLINE GEN
    1447          12 : RgM_gtomp(GEN x, long prec)
    1448             : {
    1449             :   long l;
    1450          12 :   GEN y = cgetg_copy(x, &l);
    1451          12 :   while (--l > 0) gel(y,l) = RgC_gtomp(gel(x,l), prec);
    1452          12 :   return y;
    1453             : }
    1454             : 
    1455             : INLINE GEN
    1456        6120 : RgX_fpnorml2(GEN x, long prec)
    1457             : {
    1458        6120 :   pari_sp av = avma;
    1459        6120 :   return gerepileupto(av, gnorml2(RgX_gtofp(x, prec)));
    1460             : }
    1461             : INLINE GEN
    1462      113676 : RgC_fpnorml2(GEN x, long prec)
    1463             : {
    1464      113676 :   pari_sp av = avma;
    1465      113676 :   return gerepileupto(av, gnorml2(RgC_gtofp(x, prec)));
    1466             : }
    1467             : INLINE GEN
    1468        1368 : RgM_fpnorml2(GEN x, long prec)
    1469             : {
    1470        1368 :   pari_sp av = avma;
    1471        1368 :   return gerepileupto(av, gnorml2(RgM_gtofp(x, prec)));
    1472             : }
    1473             : 
    1474             : /* y a t_REAL */
    1475             : INLINE void
    1476      154476 : affgr(GEN x, GEN y)
    1477             : {
    1478             :   pari_sp av;
    1479      154476 :   switch(typ(x)) {
    1480           0 :     case t_INT:  affir(x,y); break;
    1481      154476 :     case t_REAL: affrr(x,y); break;
    1482           0 :     case t_FRAC: rdiviiz(gel(x,1),gel(x,2), y); break;
    1483           0 :     case t_QUAD: av = avma; affgr(quadtofp(x,realprec(y)), y); avma = av; break;
    1484           0 :     default: pari_err_TYPE2("=",x,y);
    1485             :   }
    1486      154476 : }
    1487             : 
    1488             : INLINE GEN
    1489      160014 : affc_fixlg(GEN x, GEN res)
    1490             : {
    1491      160014 :   if (typ(x) == t_COMPLEX)
    1492             :   {
    1493      150528 :     affrr_fixlg(gel(x,1), gel(res,1));
    1494      150528 :     affrr_fixlg(gel(x,2), gel(res,2));
    1495             :   }
    1496             :   else
    1497             :   {
    1498        9486 :     avma = (pari_sp)(res+3);
    1499        9486 :     res = cgetr(realprec(gel(res,1)));
    1500        9486 :     affrr_fixlg(x, res);
    1501             :   }
    1502      160014 :   return res;
    1503             : }
    1504             : 
    1505             : INLINE GEN
    1506           0 : trunc_safe(GEN x) { long e; return gcvtoi(x,&e); }
    1507             : 
    1508             : /*******************************************************************/
    1509             : /*                                                                 */
    1510             : /*                          LENGTH CONVERSIONS                     */
    1511             : /*                                                                 */
    1512             : /*******************************************************************/
    1513             : INLINE long
    1514       20110 : ndec2nlong(long x) { return 1 + (long)((x)*(LOG2_10/BITS_IN_LONG)); }
    1515             : INLINE long
    1516       19770 : ndec2prec(long x) { return 2 + ndec2nlong(x); }
    1517             : INLINE long
    1518         340 : ndec2nbits(long x) { return ndec2nlong(x) << TWOPOTBITS_IN_LONG; }
    1519             : /* Fast implementation of ceil(x / (8*sizeof(long))); typecast to (ulong)
    1520             :  * to avoid overflow. Faster than 1 + ((x-1)>>TWOPOTBITS_IN_LONG)) :
    1521             :  *   addl, shrl instead of subl, sarl, addl */
    1522             : INLINE long
    1523      780896 : nbits2nlong(long x) {
    1524      780896 :   return (long)(((ulong)x+BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1525             : }
    1526             : 
    1527             : INLINE long
    1528   206172123 : nbits2extraprec(long x) {
    1529   206172123 :   return (long)(((ulong)x+BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1530             : }
    1531             : 
    1532             : /* Fast implementation of 2 + nbits2nlong(x) */
    1533             : INLINE long
    1534    63212160 : nbits2prec(long x) {
    1535    63212160 :   return (long)(((ulong)x+3*BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1536             : }
    1537             : INLINE long
    1538     2915601 : nbits2lg(long x) {
    1539     2915601 :   return (long)(((ulong)x+3*BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1540             : }
    1541             : /* ceil(x / sizeof(long)) */
    1542             : INLINE long
    1543     5647063 : nchar2nlong(long x) {
    1544     5647063 :   return (long)(((ulong)x+sizeof(long)-1) >> (TWOPOTBITS_IN_LONG-3L));
    1545             : }
    1546             : INLINE long
    1547   996758274 : prec2nbits(long x) { return (x-2) * BITS_IN_LONG; }
    1548             : INLINE double
    1549      396057 : bit_accuracy_mul(long x, double y) { return (x-2) * (BITS_IN_LONG*y); }
    1550             : INLINE double
    1551      197200 : prec2nbits_mul(long x, double y) { return (x-2) * (BITS_IN_LONG*y); }
    1552             : INLINE long
    1553    19983718 : bit_prec(GEN x) { return prec2nbits(realprec(x)); }
    1554             : INLINE long
    1555   930027958 : bit_accuracy(long x) { return prec2nbits(x); }
    1556             : INLINE long
    1557       10408 : prec2ndec(long x) { return (long)prec2nbits_mul(x, LOG10_2); }
    1558             : INLINE long
    1559         154 : nbits2ndec(long x) { return (long)(x * LOG10_2); }
    1560             : INLINE long
    1561        1410 : precdbl(long x) {return (x - 1) << 1;}
    1562             : INLINE long
    1563  2453339077 : divsBIL(long n) { return n >> TWOPOTBITS_IN_LONG; }
    1564             : INLINE long
    1565  2398119020 : remsBIL(long n) { return n & (BITS_IN_LONG-1); }
    1566             : 
    1567             : /*********************************************************************/
    1568             : /**                                                                 **/
    1569             : /**                      OPERATIONS MODULO m                        **/
    1570             : /**                                                                 **/
    1571             : /*********************************************************************/
    1572             : /* Assume m > 0, more efficient if 0 <= a, b < m */
    1573             : 
    1574             : INLINE GEN
    1575     1445674 : Fp_red(GEN a, GEN m) { return modii(a, m); }
    1576             : INLINE GEN
    1577    51494763 : Fp_add(GEN a, GEN b, GEN m)
    1578             : {
    1579    51494763 :   pari_sp av=avma;
    1580    51494763 :   GEN p = addii(a,b);
    1581    51480987 :   long s = signe(p);
    1582    51480987 :   if (!s) return p; /* = gen_0 */
    1583    42337651 :   if (s > 0) /* general case */
    1584             :   {
    1585    42147418 :     GEN t = subii(p, m);
    1586    42160266 :     s = signe(t);
    1587    42160266 :     if (!s) { avma = av; return gen_0; }
    1588    37507089 :     if (s < 0) { avma = (pari_sp)p; return p; }
    1589    14509251 :     if (cmpii(t, m) < 0) return gerepileuptoint(av, t); /* general case ! */
    1590      952787 :     p = remii(t, m);
    1591             :   }
    1592             :   else
    1593      190233 :     p = modii(p, m);
    1594     1143020 :   return gerepileuptoint(av, p);
    1595             : }
    1596             : INLINE GEN
    1597    38721084 : Fp_sub(GEN a, GEN b, GEN m)
    1598             : {
    1599    38721084 :   pari_sp av=avma;
    1600    38721084 :   GEN p = subii(a,b);
    1601    38809979 :   long s = signe(p);
    1602    38809979 :   if (!s) return p; /* = gen_0 */
    1603    32263411 :   if (s > 0)
    1604             :   {
    1605    15566789 :     if (cmpii(p, m) < 0) return p; /* general case ! */
    1606      243750 :     p = remii(p, m);
    1607             :   }
    1608             :   else
    1609             :   {
    1610    16696622 :     GEN t = addii(p, m);
    1611    16688562 :     if (!s) { avma = av; return gen_0; }
    1612    16688562 :     if (s > 0) return gerepileuptoint(av, t); /* general case ! */
    1613    16688562 :     p = modii(t, m);
    1614             :   }
    1615    16922275 :   return gerepileuptoint(av, p);
    1616             : }
    1617             : INLINE GEN
    1618     9166433 : Fp_neg(GEN b, GEN m)
    1619             : {
    1620     9166433 :   pari_sp av = avma;
    1621     9166433 :   long s = signe(b);
    1622             :   GEN p;
    1623     9166433 :   if (!s) return gen_0;
    1624     6310023 :   if (s > 0)
    1625             :   {
    1626     6154785 :     p = subii(m, b);
    1627     6154499 :     if (signe(p) >= 0) return p; /* general case ! */
    1628       63912 :     p = modii(p, m);
    1629             :   } else
    1630      155238 :     p = remii(negi(b), m);
    1631      219150 :   return gerepileuptoint(av, p);
    1632             : }
    1633             : 
    1634             : INLINE GEN
    1635       16758 : Fp_halve(GEN a, GEN p)
    1636             : {
    1637       16758 :   if (mpodd(a)) a = addii(a,p);
    1638       16758 :   return shifti(a,-1);
    1639             : }
    1640             : 
    1641             : /* assume 0 <= u < p and ps2 = p>>1 */
    1642             : INLINE GEN
    1643     4852670 : Fp_center(GEN u, GEN p, GEN ps2)
    1644     4852670 : { return abscmpii(u,ps2)<=0? icopy(u): subii(u,p); }
    1645             : 
    1646             : /* x + y*z mod p */
    1647             : INLINE GEN
    1648     1293510 : Fp_addmul(GEN x, GEN y, GEN z, GEN p)
    1649             : {
    1650             :   pari_sp av;
    1651     1293510 :   if (!signe(y) || !signe(z)) return Fp_red(x, p);
    1652     1293276 :   if (!signe(x)) return Fp_mul(z,y, p);
    1653     1042662 :   av = avma;
    1654     1042662 :   return gerepileuptoint(av, modii(addii(x, mulii(y,z)), p));
    1655             : }
    1656             : 
    1657             : INLINE GEN
    1658    43146657 : Fp_mul(GEN a, GEN b, GEN m)
    1659             : {
    1660    43146657 :   pari_sp av=avma;
    1661             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1662    43146657 :   (void)new_chunk(lg(a)+lg(b)+(lg(m)<<1));
    1663    43149653 :   p = mulii(a,b);
    1664    43149766 :   avma = av; return modii(p,m);
    1665             : }
    1666             : INLINE GEN
    1667     6027836 : Fp_sqr(GEN a, GEN m)
    1668             : {
    1669     6027836 :   pari_sp av=avma;
    1670             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1671     6027836 :   (void)new_chunk((lg(a)+lg(m))<<1);
    1672     6061146 :   p = sqri(a);
    1673     6101219 :   avma = av; return modii(p,m);
    1674             : }
    1675             : INLINE GEN
    1676    38278642 : Fp_mulu(GEN a, ulong b, GEN m)
    1677             : {
    1678    38278642 :   long l = lgefint(m);
    1679    38278642 :   if (l == 3)
    1680             :   {
    1681    30074461 :     ulong mm = m[2];
    1682    30074461 :     return utoi( Fl_mul(umodiu(a, mm), b, mm) );
    1683             :   } else {
    1684     8204181 :     pari_sp av = avma;
    1685             :     GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1686     8204181 :     (void)new_chunk(lg(a)+1+(l<<1));
    1687     8220608 :     p = muliu(a,b);
    1688     7939857 :     avma = av; return modii(p,m);
    1689             :   }
    1690             : }
    1691             : INLINE GEN
    1692           0 : Fp_muls(GEN a, long b, GEN m)
    1693             : {
    1694           0 :   long l = lgefint(m);
    1695           0 :   if (l == 3)
    1696             :   {
    1697           0 :     ulong mm = m[2];
    1698           0 :     if (b < 0)
    1699             :     {
    1700           0 :       ulong t = Fl_mul(umodiu(a, mm), -b, mm);
    1701           0 :       return t? utoipos(mm - t): gen_0;
    1702             :     }
    1703             :     else
    1704           0 :       return utoi( Fl_mul(umodiu(a, mm), b, mm) );
    1705             :   } else {
    1706           0 :     pari_sp av = avma;
    1707             :     GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1708           0 :     (void)new_chunk(lg(a)+1+(l<<1));
    1709           0 :     p = mulis(a,b);
    1710           0 :     avma = av; return modii(p,m);
    1711             :   }
    1712             : }
    1713             : 
    1714             : INLINE GEN
    1715     8301047 : Fp_inv(GEN a, GEN m)
    1716             : {
    1717             :   GEN res;
    1718     8301047 :   if (! invmod(a,m,&res)) pari_err_INV("Fp_inv", mkintmod(res,m));
    1719     8288318 :   return res;
    1720             : }
    1721             : INLINE GEN
    1722      247964 : Fp_invsafe(GEN a, GEN m)
    1723             : {
    1724             :   GEN res;
    1725      247964 :   if (! invmod(a,m,&res)) return NULL;
    1726      247964 :   return res;
    1727             : }
    1728             : INLINE GEN
    1729     4113307 : Fp_div(GEN a, GEN b, GEN m)
    1730             : {
    1731     4113307 :   pari_sp av=avma;
    1732             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1733     4113307 :   (void)new_chunk(lg(a)+(lg(m)<<1));
    1734     4122579 :   p = mulii(a, Fp_inv(b,m));
    1735     4125706 :   avma = av; return modii(p,m);
    1736             : }
    1737             : 
    1738             : INLINE GEN
    1739      570871 : Flx_mulu(GEN x, ulong a, ulong p) { return Flx_Fl_mul(x,a%p,p); }
    1740             : 
    1741             : /*******************************************************************/
    1742             : /*                                                                 */
    1743             : /*                        ADDMULII / SUBMULII                      */
    1744             : /*                                                                 */
    1745             : /*******************************************************************/
    1746             : /* x - y*z */
    1747             : INLINE GEN
    1748     8934912 : submulii(GEN x, GEN y, GEN z)
    1749             : {
    1750     8934912 :   long lx = lgefint(x), ly, lz;
    1751             :   pari_sp av;
    1752             :   GEN t;
    1753     8934912 :   if (lx == 2) { t = mulii(z,y); togglesign(t); return t; }
    1754     7722294 :   ly = lgefint(y);
    1755     7722294 :   if (ly == 2) return icopy(x);
    1756     7068330 :   lz = lgefint(z);
    1757     7068330 :   av = avma; (void)new_chunk(lx+ly+lz); /* HACK */
    1758     7068330 :   t = mulii(z, y);
    1759     7068330 :   avma = av; return subii(x,t);
    1760             : }
    1761             : /* y*z - x */
    1762             : INLINE GEN
    1763     1089868 : mulsubii(GEN y, GEN z, GEN x)
    1764             : {
    1765     1089868 :   long lx = lgefint(x), ly, lz;
    1766             :   pari_sp av;
    1767             :   GEN t;
    1768     1089868 :   if (lx == 2) return mulii(z,y);
    1769      684855 :   ly = lgefint(y);
    1770      684855 :   if (ly == 2) return negi(x);
    1771      663991 :   lz = lgefint(z);
    1772      663991 :   av = avma; (void)new_chunk(lx+ly+lz); /* HACK */
    1773      663991 :   t = mulii(z, y);
    1774      663991 :   avma = av; return subii(t,x);
    1775             : }
    1776             : 
    1777             : /* x - u*y */
    1778             : INLINE GEN
    1779        6000 : submuliu(GEN x, GEN y, ulong u)
    1780             : {
    1781             :   pari_sp av;
    1782        6000 :   long ly = lgefint(y);
    1783        6000 :   if (ly == 2) return icopy(x);
    1784        6000 :   av = avma;
    1785        6000 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1786        6000 :   y = mului(u,y);
    1787        6000 :   avma = av; return subii(x, y);
    1788             : }
    1789             : /* x + u*y */
    1790             : INLINE GEN
    1791        6000 : addmuliu(GEN x, GEN y, ulong u)
    1792             : {
    1793             :   pari_sp av;
    1794        6000 :   long ly = lgefint(y);
    1795        6000 :   if (ly == 2) return icopy(x);
    1796        6000 :   av = avma;
    1797        6000 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1798        6000 :   y = mului(u,y);
    1799        6000 :   avma = av; return addii(x, y);
    1800             : }
    1801             : /* x - u*y */
    1802             : INLINE GEN
    1803    93471456 : submuliu_inplace(GEN x, GEN y, ulong u)
    1804             : {
    1805             :   pari_sp av;
    1806    93471456 :   long ly = lgefint(y);
    1807    93471456 :   if (ly == 2) return x;
    1808    74997612 :   av = avma;
    1809    74997612 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1810    74997612 :   y = mului(u,y);
    1811    74997612 :   avma = av; return subii(x, y);
    1812             : }
    1813             : /* x + u*y */
    1814             : INLINE GEN
    1815    92289828 : addmuliu_inplace(GEN x, GEN y, ulong u)
    1816             : {
    1817             :   pari_sp av;
    1818    92289828 :   long ly = lgefint(y);
    1819    92289828 :   if (ly == 2) return x;
    1820    74662998 :   av = avma;
    1821    74662998 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1822    74662998 :   y = mului(u,y);
    1823    74662998 :   avma = av; return addii(x, y);
    1824             : }
    1825             : /* ux + vy */
    1826             : INLINE GEN
    1827    15846110 : lincombii(GEN u, GEN v, GEN x, GEN y)
    1828             : {
    1829    15846110 :   long lx = lgefint(x), ly;
    1830             :   GEN p1, p2;
    1831             :   pari_sp av;
    1832    15846110 :   if (lx == 2) return mulii(v,y);
    1833    10122908 :   ly = lgefint(y);
    1834    10122908 :   if (ly == 2) return mulii(u,x);
    1835     9453481 :   av = avma; (void)new_chunk(lx+ly+lgefint(u)+lgefint(v)); /* HACK */
    1836     9453481 :   p1 = mulii(u,x);
    1837     9453481 :   p2 = mulii(v,y);
    1838     9453481 :   avma = av; return addii(p1,p2);
    1839             : }
    1840             : 
    1841             : /*******************************************************************/
    1842             : /*                                                                 */
    1843             : /*                          GEN SUBTYPES                           */
    1844             : /*                                                                 */
    1845             : /*******************************************************************/
    1846             : 
    1847             : INLINE int
    1848   877598186 : is_const_t(long t) { return (t < t_POLMOD); }
    1849             : INLINE int
    1850       38838 : is_extscalar_t(long t) { return (t <= t_POL); }
    1851             : INLINE int
    1852      803856 : is_intreal_t(long t) { return (t <= t_REAL); }
    1853             : INLINE int
    1854   281838929 : is_matvec_t(long t) { return (t >= t_VEC && t <= t_MAT); }
    1855             : INLINE int
    1856    36811761 : is_noncalc_t(long tx) { return (tx) >= t_LIST; }
    1857             : INLINE int
    1858      345420 : is_rational_t(long t) { return (t == t_INT || t == t_FRAC); }
    1859             : INLINE int
    1860      256362 : is_real_t(long t) { return (t == t_INT || t == t_REAL || t == t_FRAC); }
    1861             : INLINE int
    1862  2120121270 : is_recursive_t(long t) { return lontyp[t]; }
    1863             : INLINE int
    1864   130315310 : is_scalar_t(long t) { return (t < t_POL); }
    1865             : INLINE int
    1866      395894 : is_vec_t(long t) { return (t == t_VEC || t == t_COL); }
    1867             : 
    1868             : /*******************************************************************/
    1869             : /*                                                                 */
    1870             : /*                         TRANSCENDENTAL                          */
    1871             : /*                                                                 */
    1872             : /*******************************************************************/
    1873             : INLINE GEN
    1874    13320606 : sqrtr(GEN x) {
    1875    13320606 :   long s = signe(x);
    1876    13320606 :   if (s == 0) return real_0_bit(expo(x) >> 1);
    1877    13291860 :   if (s >= 0) return sqrtr_abs(x);
    1878       11754 :   retmkcomplex(gen_0, sqrtr_abs(x));
    1879             : }
    1880             : INLINE GEN
    1881           0 : cbrtr_abs(GEN x) { return sqrtnr_abs(x, 3); }
    1882             : INLINE GEN
    1883           0 : cbrtr(GEN x) {
    1884           0 :   long s = signe(x);
    1885             :   GEN r;
    1886           0 :   if (s == 0) return real_0_bit(expo(x) / 3);
    1887           0 :   r = cbrtr_abs(x);
    1888           0 :   if (s < 0) togglesign(r);
    1889           0 :   return r;
    1890             : }
    1891             : INLINE GEN
    1892      249174 : sqrtnr(GEN x, long n) {
    1893      249174 :   long s = signe(x);
    1894             :   GEN r;
    1895      249174 :   if (s == 0) return real_0_bit(expo(x) / n);
    1896      249174 :   r = sqrtnr_abs(x, n);
    1897      249174 :   if (s < 0) pari_err_IMPL("sqrtnr for x < 0");
    1898      249174 :   return r;
    1899             : }
    1900             : INLINE long
    1901      173340 : logint(GEN B, GEN y) { return logintall(B,y,NULL); }
    1902             : INLINE ulong
    1903        7812 : ulogint(ulong B, ulong y)
    1904             : {
    1905             :   ulong r;
    1906             :   long e;
    1907        7812 :   if (y == 2) return expu(B);
    1908        7050 :   r = y;
    1909       22764 :   for (e=1;; e++)
    1910             :   { /* here, r = y^e, r2 = y^(e-1) */
    1911       22764 :     if (r >= B) return r == B? e: e-1;
    1912       15714 :     r = umuluu_or_0(y, r);
    1913       15714 :     if (!r) return e;
    1914       15714 :   }
    1915             : }
    1916             : 
    1917             : /*******************************************************************/
    1918             : /*                                                                 */
    1919             : /*                         MISCELLANEOUS                           */
    1920             : /*                                                                 */
    1921             : /*******************************************************************/
    1922      803790 : INLINE int ismpzero(GEN x) { return is_intreal_t(typ(x)) && !signe(x); }
    1923   305526723 : INLINE int isintzero(GEN x) { return typ(x) == t_INT && !signe(x); }
    1924     5860494 : INLINE int isint1(GEN x) { return typ(x)==t_INT && equali1(x); }
    1925         258 : INLINE int isintm1(GEN x){ return typ(x)==t_INT && equalim1(x);}
    1926   179070459 : INLINE int equali1(GEN n)
    1927   179070459 : { return (ulong) n[1] == (evallgefint(3UL) | evalsigne(1)) && n[2] == 1; }
    1928    20186436 : INLINE int equalim1(GEN n)
    1929    20186436 : { return (ulong) n[1] == (evallgefint(3UL) | evalsigne(-1)) && n[2] == 1; }
    1930             : /* works only for POSITIVE integers */
    1931  1362718782 : INLINE int is_pm1(GEN n)
    1932  1362718782 : { return lgefint(n) == 3 && n[2] == 1; }
    1933   100603084 : INLINE int is_bigint(GEN n)
    1934   100603084 : { long l = lgefint(n); return l > 3 || (l == 3 && (n[2] & HIGHBIT)); }
    1935             : 
    1936  1568687459 : INLINE int odd(long x) { return x & 1; }
    1937     5485123 : INLINE int both_odd(long x, long y) { return x & y & 1; }
    1938             : 
    1939             : INLINE int
    1940  1747139360 : isonstack(GEN x)
    1941  3494278720 : { return ((pari_sp)x >= pari_mainstack->bot
    1942  1747139360 :        && (pari_sp)x <  pari_mainstack->top); }
    1943             : 
    1944             : /* assume x != 0 and x t_REAL, return an approximation to log2(|x|) */
    1945             : INLINE double
    1946    14282922 : dbllog2r(GEN x)
    1947    14282922 : { return log2((double)(ulong)x[2]) + (double)(expo(x) - (BITS_IN_LONG-1)); }
    1948             : 
    1949             : INLINE GEN
    1950      173406 : mul_content(GEN cx, GEN cy)
    1951             : {
    1952      173406 :   if (!cx) return cy;
    1953       46884 :   if (!cy) return cx;
    1954       38970 :   return gmul(cx,cy);
    1955             : }
    1956             : INLINE GEN
    1957      447744 : mul_denom(GEN dx, GEN dy)
    1958             : {
    1959      447744 :   if (!dx) return dy;
    1960      280098 :   if (!dy) return dx;
    1961      118296 :   return mulii(dx,dy);
    1962             : }
    1963             : 
    1964             : /* POLYNOMIALS */
    1965             : INLINE GEN
    1966    15051967 : constant_coeff(GEN x) { return signe(x)? gel(x,2): gen_0; }
    1967             : INLINE GEN
    1968    61959881 : leading_coeff(GEN x) { return lg(x) == 2? gen_0: gel(x,lg(x)-1); }
    1969             : INLINE ulong
    1970      348631 : Flx_lead(GEN x) { return lg(x) == 2? 0: x[lg(x)-1]; }
    1971             : INLINE long
    1972  2060899549 : degpol(GEN x) { return lg(x)-3; }
    1973             : INLINE long
    1974  1073145200 : lgpol(GEN x) { return lg(x)-2; }
    1975             : INLINE long
    1976    71891342 : lgcols(GEN x) { return lg(gel(x,1)); }
    1977             : INLINE long
    1978    14129520 : nbrows(GEN x) { return lg(gel(x,1))-1; }
    1979             : INLINE GEN
    1980           0 : truecoeff(GEN x, long n) { return polcoeff0(x,n,-1); }
    1981             : 
    1982             : INLINE GEN
    1983      381602 : RgXQ_mul(GEN y, GEN x, GEN T) { return RgX_rem(RgX_mul(y, x), T); }
    1984             : INLINE GEN
    1985      200478 : RgXQ_sqr(GEN x, GEN T) { return RgX_rem(RgX_sqr(x), T); }
    1986             : 
    1987             : INLINE GEN
    1988      101346 : ZXQ_mul(GEN y, GEN x, GEN T) { return ZX_rem(ZX_mul(y, x), T); }
    1989             : INLINE GEN
    1990       18168 : ZXQ_sqr(GEN x, GEN T) { return ZX_rem(ZX_sqr(x), T); }
    1991             : 
    1992             : INLINE GEN
    1993    53825478 : RgX_copy(GEN x)
    1994             : {
    1995             :   long lx, i;
    1996    53825478 :   GEN y = cgetg_copy(x, &lx); y[1] = x[1];
    1997    53825478 :   for (i = 2; i<lx; i++) gel(y,i) = gcopy(gel(x,i));
    1998    53825478 :   return y;
    1999             : }
    2000             : /* have to use ulong to avoid silly warnings from gcc "assuming signed
    2001             :  * overflow does not occur" */
    2002             : INLINE GEN
    2003     1912674 : RgX_coeff(GEN x, long n)
    2004             : {
    2005     1912674 :   ulong l = lg(x);
    2006     1912674 :   return (n < 0 || ((ulong)n+3) > l)? gen_0: gel(x,n+2);
    2007             : }
    2008             : INLINE GEN
    2009      270858 : RgX_renormalize(GEN x) { return RgX_renormalize_lg(x, lg(x)); }
    2010             : INLINE GEN
    2011     4892310 : RgX_div(GEN x, GEN y) { return RgX_divrem(x,y,NULL); }
    2012             : INLINE GEN
    2013     2158985 : RgX_rem(GEN x, GEN y) { return RgX_divrem(x,y,ONLY_REM); }
    2014             : INLINE GEN
    2015           6 : RgXQX_div(GEN x, GEN y, GEN T) { return RgXQX_divrem(x,y,T,NULL); }
    2016             : INLINE GEN
    2017       14736 : RgXQX_rem(GEN x, GEN y, GEN T) { return RgXQX_divrem(x,y,T,ONLY_REM); }
    2018             : INLINE GEN
    2019      627629 : FpX_div(GEN x, GEN y, GEN p) { return FpX_divrem(x,y,p, NULL); }
    2020             : INLINE GEN
    2021     2622782 : Flx_div(GEN x, GEN y, ulong p) { return Flx_divrem(x,y,p, NULL); }
    2022             : INLINE GEN
    2023     2367138 : F2x_div(GEN x, GEN y) { return F2x_divrem(x,y, NULL); }
    2024             : INLINE GEN
    2025           0 : FpV_FpC_mul(GEN x, GEN y, GEN p) { return FpV_dotproduct(x,y,p); }
    2026             : INLINE GEN
    2027    37026136 : pol0_Flx(long sv) { return mkvecsmall(sv); }
    2028             : INLINE GEN
    2029    15039894 : pol1_Flx(long sv) { return mkvecsmall2(sv, 1); }
    2030             : INLINE GEN
    2031    13735496 : polx_Flx(long sv) { return mkvecsmall3(sv, 0, 1); }
    2032             : INLINE GEN
    2033           0 : zero_zx(long sv) { return zero_Flx(sv); }
    2034             : INLINE GEN
    2035           0 : polx_zx(long sv) { return polx_Flx(sv); }
    2036             : INLINE GEN
    2037           0 : zx_shift(GEN x, long n) { return Flx_shift(x,n); }
    2038             : INLINE GEN
    2039           0 : zx_renormalize(GEN x, long l) { return Flx_renormalize(x,l); }
    2040             : INLINE GEN
    2041          30 : zero_F2x(long sv) { return zero_Flx(sv); }
    2042             : INLINE GEN
    2043     9430233 : pol0_F2x(long sv) { return pol0_Flx(sv); }
    2044             : INLINE GEN
    2045     2326494 : pol1_F2x(long sv) { return pol1_Flx(sv); }
    2046             : INLINE GEN
    2047      554652 : polx_F2x(long sv) { return mkvecsmall2(sv, 2); }
    2048             : INLINE int
    2049      677262 : F2x_equal1(GEN x) { return Flx_equal1(x); }
    2050             : INLINE int
    2051     2839555 : F2x_equal(GEN V, GEN W) { return Flx_equal(V,W); }
    2052             : INLINE GEN
    2053    55849004 : F2x_copy(GEN x) { return leafcopy(x); }
    2054             : INLINE GEN
    2055           0 : F2v_copy(GEN x) { return leafcopy(x); }
    2056             : INLINE GEN
    2057     1994589 : Flv_copy(GEN x) { return leafcopy(x); }
    2058             : INLINE GEN
    2059    62905179 : Flx_copy(GEN x) { return leafcopy(x); }
    2060             : INLINE GEN
    2061     1359024 : vecsmall_copy(GEN x) { return leafcopy(x); }
    2062             : INLINE int
    2063     3984797 : Flx_equal1(GEN x) { return degpol(x)==0 && x[2] == 1; }
    2064             : INLINE int
    2065       12808 : ZX_equal1(GEN x) { return degpol(x)==0 && equali1(gel(x,2)); }
    2066             : 
    2067             : INLINE GEN
    2068    62631429 : ZX_renormalize(GEN x, long lx)    { return ZXX_renormalize(x,lx); }
    2069             : INLINE GEN
    2070    74004005 : FpX_renormalize(GEN x, long lx)   { return ZXX_renormalize(x,lx); }
    2071             : INLINE GEN
    2072      811644 : FpXX_renormalize(GEN x, long lx)  { return ZXX_renormalize(x,lx); }
    2073             : INLINE GEN
    2074      838359 : FpXQX_renormalize(GEN x, long lx) { return ZXX_renormalize(x,lx); }
    2075             : INLINE GEN
    2076   107456463 : F2x_renormalize(GEN x, long lx)   { return Flx_renormalize(x,lx); }
    2077             : INLINE GEN
    2078        5942 : F2v_to_F2x(GEN x, long sv) {
    2079        5942 :   GEN y = leafcopy(x);
    2080        5942 :   y[1] = sv; F2x_renormalize(y, lg(y)); return y;
    2081             : }
    2082             : 
    2083             : INLINE GEN
    2084           0 : ZX_ZXY_resultant(GEN a, GEN b) { return ZX_ZXY_rnfequation(a,b,NULL); }
    2085             : INLINE long
    2086         384 : sturm(GEN x) { return sturmpart(x, NULL, NULL); }
    2087             : INLINE GEN
    2088       29730 : resultant(GEN x, GEN y) { return resultant_all(x,y,NULL); }
    2089             : 
    2090             : INLINE long
    2091        1890 : gval(GEN x, long v) {
    2092        1890 :   pari_sp av = avma;
    2093        1890 :   long n = gvaluation(x, pol_x(v));
    2094        1890 :   avma = av; return n;
    2095             : }
    2096             : 
    2097             : INLINE void
    2098      444441 : RgX_shift_inplace_init(long v)
    2099      444441 : { if (v) (void)cgetg(v, t_VECSMALL); }
    2100             : /* shift polynomial in place. assume v free cells have been left before x */
    2101             : INLINE GEN
    2102      444441 : RgX_shift_inplace(GEN x, long v)
    2103             : {
    2104             :   long i, lx;
    2105             :   GEN y, z;
    2106      444441 :   if (!v) return x;
    2107      170352 :   lx = lg(x);
    2108      170352 :   if (lx == 2) return x;
    2109      170352 :   y = x + v;
    2110      170352 :   z = x + lx;
    2111             :   /* stackdummy from normalizepol: move it up */
    2112      170352 :   if (lg(z) != v) x[lx + v] = z[0];
    2113      170352 :   for (i = lx-1; i >= 2; i--) gel(y,i) = gel(x,i);
    2114      170352 :   for (i = v+1;  i >= 2; i--) gel(x,i) = gen_0;
    2115             :   /* leave x[1] alone: it is correct */
    2116      170352 :   x[0] = evaltyp(t_POL) | evallg(lx+v); return x;
    2117             : }
    2118             : 
    2119             : 
    2120             : /* LINEAR ALGEBRA */
    2121             : INLINE GEN
    2122       15666 : zv_to_ZV(GEN x) { return vecsmall_to_vec(x); }
    2123             : INLINE GEN
    2124     1035840 : zc_to_ZC(GEN x) { return vecsmall_to_col(x); }
    2125             : INLINE GEN
    2126      191166 : ZV_to_zv(GEN x) { return vec_to_vecsmall(x); }
    2127             : INLINE GEN
    2128           0 : zx_to_zv(GEN x, long N) { return Flx_to_Flv(x,N); }
    2129             : INLINE GEN
    2130           0 : zv_to_zx(GEN x, long sv) { return Flv_to_Flx(x,sv); }
    2131             : INLINE GEN
    2132           0 : zm_to_zxV(GEN x, long sv) { return Flm_to_FlxV(x,sv); }
    2133             : INLINE GEN
    2134           0 : zero_zm(long x, long y) { return zero_Flm(x,y); }
    2135             : INLINE GEN
    2136    14410202 : zero_zv(long x) { return zero_Flv(x); }
    2137             : INLINE GEN
    2138         144 : zm_transpose(GEN x) { return Flm_transpose(x); }
    2139             : INLINE GEN
    2140           0 : zm_copy(GEN x) { return Flm_copy(x); }
    2141             : INLINE GEN
    2142     1741905 : zv_copy(GEN x) { return Flv_copy(x); }
    2143             : INLINE GEN
    2144           0 : zm_row(GEN x, long i) { return Flm_row(x,i); }
    2145             : 
    2146             : INLINE GEN
    2147      668400 : ZC_hnfrem(GEN x, GEN y) { return ZC_hnfremdiv(x,y,NULL); }
    2148             : INLINE GEN
    2149       20081 : ZM_hnfrem(GEN x, GEN y) { return ZM_hnfdivrem(x,y,NULL); }
    2150             : INLINE GEN
    2151      901188 : ZM_lll(GEN x, double D, long f) { return ZM_lll_norms(x,D,f,NULL); }
    2152             : INLINE void
    2153       92034 : RgM_dimensions(GEN x, long *m, long *n) { *n = lg(x)-1; *m = *n? nbrows(x): 0; }
    2154             : INLINE GEN
    2155       20958 : RgM_inv(GEN a) { return RgM_solve(a, NULL); }
    2156             : INLINE GEN
    2157     5141805 : RgM_shallowcopy(GEN x)
    2158             : {
    2159             :   long l;
    2160     5141805 :   GEN y = cgetg_copy(x, &l);
    2161     5141805 :   while (--l > 0) gel(y,l) = leafcopy(gel(x,l));
    2162     5141805 :   return y;
    2163             : }
    2164             : INLINE GEN
    2165         269 : F2m_copy(GEN x) { return RgM_shallowcopy(x); }
    2166             : 
    2167             : INLINE GEN
    2168      987404 : Flm_copy(GEN x) { return RgM_shallowcopy(x); }
    2169             : 
    2170             : /* divisibility: return 1 if y[i] | x[i] for all i, 0 otherwise. Assume
    2171             :  * x,y are ZV of the same length */
    2172             : INLINE int
    2173       19884 : ZV_dvd(GEN x, GEN y)
    2174             : {
    2175       19884 :   long i, l = lg(x);
    2176       31416 :   for (i=1; i < l; i++)
    2177       25302 :     if ( ! dvdii( gel(x,i), gel(y,i) ) ) return 0;
    2178        6114 :   return 1;
    2179             : }
    2180             : 
    2181             : /* Fq */
    2182             : INLINE GEN
    2183     1166640 : Fq_red(GEN x, GEN T, GEN p)
    2184     1166640 : { return typ(x)==t_INT? Fp_red(x,p): FpXQ_red(x,T,p); }
    2185             : INLINE GEN
    2186        9654 : Fq_to_FpXQ(GEN x, GEN T, GEN p /*unused*/)
    2187             : {
    2188             :   (void) p;
    2189        9654 :   return typ(x)==t_INT ? scalarpol(x, get_FpX_var(T)): x;
    2190             : }
    2191             : 
    2192             : INLINE GEN
    2193         714 : gener_Fq_local(GEN T, GEN p, GEN L)
    2194         714 : { return T? gener_FpXQ_local(T,p, L)
    2195         714 :           : pgener_Fp_local(p, L); }
    2196             : 
    2197             : /* FpXQX */
    2198             : INLINE GEN
    2199         822 : FpXQX_div(GEN x, GEN y, GEN T, GEN p) { return FpXQX_divrem(x, y, T, p, NULL); }
    2200             : INLINE GEN
    2201       27000 : FlxqX_div(GEN x, GEN y, GEN T, ulong p) { return FlxqX_divrem(x, y, T, p, NULL); }
    2202             : INLINE GEN
    2203       25530 : F2xqX_div(GEN x, GEN y, GEN T) { return F2xqX_divrem(x, y, T, NULL); }
    2204             : 
    2205             : /* FqX */
    2206             : INLINE GEN
    2207       23502 : FqX_red(GEN z, GEN T, GEN p) { return T? FpXQX_red(z, T, p): FpX_red(z, p); }
    2208             : INLINE GEN
    2209      774822 : FqX_add(GEN x,GEN y,GEN T,GEN p) { return T? FpXX_add(x,y,p): FpX_add(x,y,p); }
    2210             : INLINE GEN
    2211       14076 : FqX_neg(GEN x,GEN T,GEN p) { return T? FpXX_neg(x,p): FpX_neg(x,p); }
    2212             : INLINE GEN
    2213        2040 : FqX_sub(GEN x,GEN y,GEN T,GEN p) { return T? FpXX_sub(x,y,p): FpX_sub(x,y,p); }
    2214             : INLINE GEN
    2215      521442 : FqX_Fp_mul(GEN P, GEN u, GEN T, GEN p)
    2216      521442 : { return T? FpXX_Fp_mul(P, u, p): FpX_Fp_mul(P, u, p); }
    2217             : INLINE GEN
    2218      473175 : FqX_Fq_mul(GEN P, GEN U, GEN T, GEN p)
    2219      473175 : { return typ(U)==t_INT ? FqX_Fp_mul(P, U, T, p): FpXQX_FpXQ_mul(P, U, T, p); }
    2220             : INLINE GEN
    2221       71922 : FqX_mul(GEN x, GEN y, GEN T, GEN p)
    2222       71922 : { return T? FpXQX_mul(x, y, T, p): FpX_mul(x, y, p); }
    2223             : INLINE GEN
    2224      394182 : FqX_mulu(GEN x, ulong y, GEN T, GEN p)
    2225      394182 : { return T? FpXX_mulu(x, y, p): FpX_mulu(x, y, p); }
    2226             : INLINE GEN
    2227        4080 : FqX_sqr(GEN x, GEN T, GEN p)
    2228        4080 : { return T? FpXQX_sqr(x, T, p): FpX_sqr(x, p); }
    2229             : INLINE GEN
    2230        1224 : FqX_powu(GEN x, ulong n, GEN T, GEN p)
    2231        1224 : { return T? FpXQX_powu(x, n, T, p): FpX_powu(x, n, p); }
    2232             : INLINE GEN
    2233        2550 : FqX_div(GEN x, GEN y, GEN T, GEN p)
    2234        2550 : { return T? FpXQX_divrem(x,y,T,p,NULL): FpX_divrem(x,y,p,NULL); }
    2235             : INLINE GEN
    2236        4800 : FqX_get_red(GEN S, GEN T, GEN p)
    2237        4800 : { return T? FpXQX_get_red(S,T,p): FpX_get_red(S,p); }
    2238             : INLINE GEN
    2239       41016 : FqX_rem(GEN x, GEN y, GEN T, GEN p)
    2240       41016 : { return T? FpXQX_rem(x,y,T,p): FpX_rem(x,y,p); }
    2241             : INLINE GEN
    2242         282 : FqX_divrem(GEN x, GEN y, GEN T, GEN p, GEN *z)
    2243         282 : { return T? FpXQX_divrem(x,y,T,p,z): FpX_divrem(x,y,p,z); }
    2244             : INLINE GEN
    2245        5106 : FqX_div_by_X_x(GEN x, GEN y, GEN T, GEN p, GEN *z)
    2246        5106 : { return T? FpXQX_div_by_X_x(x,y,T,p,z): FpX_div_by_X_x(x,y,p,z); }
    2247             : INLINE GEN
    2248           0 : FqX_halfgcd(GEN P,GEN Q,GEN T,GEN p)
    2249           0 : {return T? FpXQX_halfgcd(P,Q,T,p): FpX_halfgcd(P,Q,p);}
    2250             : INLINE GEN
    2251      217842 : FqX_gcd(GEN P,GEN Q,GEN T,GEN p)
    2252      217842 : {return T? FpXQX_gcd(P,Q,T,p): FpX_gcd(P,Q,p);}
    2253             : INLINE GEN
    2254       68328 : FqX_extgcd(GEN P,GEN Q,GEN T,GEN p, GEN *U, GEN *V)
    2255       68328 : { return T? FpXQX_extgcd(P,Q,T,p,U,V): FpX_extgcd(P,Q,p,U,V); }
    2256             : INLINE GEN
    2257        1710 : FqX_normalize(GEN z, GEN T, GEN p) { return T? FpXQX_normalize(z, T, p): FpX_normalize(z, p); }
    2258             : INLINE GEN
    2259      230274 : FqX_deriv(GEN f, /*unused*/GEN T, GEN p) { (void)T; return FpXX_deriv(f, p); }
    2260             : INLINE GEN
    2261       60984 : FqX_factor(GEN f, GEN T, GEN p) { return T?FpXQX_factor(f, T, p): FpX_factor(f, p); }
    2262             : INLINE GEN
    2263        4980 : FqX_roots(GEN f, GEN T, GEN p) { return T?FpXQX_roots(f, T, p): FpX_roots(f, p); }
    2264             : 
    2265             : /*FqXQ*/
    2266             : INLINE GEN
    2267           0 : FqXQ_add(GEN x, GEN y, GEN S/*unused*/, GEN T, GEN p)
    2268           0 : { (void)S; return T? FpXX_add(x,y,p): FpX_add(x,y,p); }
    2269             : INLINE GEN
    2270           0 : FqXQ_sub(GEN x, GEN y, GEN S/*unused*/, GEN T, GEN p)
    2271           0 : { (void)S; return T? FpXX_sub(x,y,p): FpX_sub(x,y,p); }
    2272             : INLINE GEN
    2273           0 : FqXQ_div(GEN x, GEN y, GEN S, GEN T, GEN p)
    2274           0 : { return T? FpXQXQ_div(x,y,S,T,p): FpXQ_div(x,y,S,p); }
    2275             : INLINE GEN
    2276           0 : FqXQ_inv(GEN x, GEN S, GEN T, GEN p)
    2277           0 : { return T? FpXQXQ_inv(x,S,T,p): FpXQ_inv(x,S,p); }
    2278             : INLINE GEN
    2279           0 : FqXQ_invsafe(GEN x, GEN S, GEN T, GEN p)
    2280           0 : { return T? FpXQXQ_invsafe(x,S,T,p): FpXQ_inv(x,S,p); }
    2281             : INLINE GEN
    2282       18000 : FqXQ_mul(GEN x, GEN y, GEN S, GEN T, GEN p)
    2283       18000 : { return T? FpXQXQ_mul(x,y,S,T,p): FpXQ_mul(x,y,S,p); }
    2284             : INLINE GEN
    2285           0 : FqXQ_sqr(GEN x, GEN S, GEN T, GEN p)
    2286           0 : { return T? FpXQXQ_sqr(x,S,T,p): FpXQ_sqr(x,S,p); }
    2287             : INLINE GEN
    2288           0 : FqXQ_pow(GEN x, GEN n, GEN S, GEN T, GEN p)
    2289           0 : { return T? FpXQXQ_pow(x,n,S,T,p): FpXQ_pow(x,n,S,p); }
    2290             : 
    2291             : /*FpXQ*/
    2292             : INLINE GEN
    2293           0 : FpXQ_add(GEN x,GEN y,GEN T/*unused*/,GEN p)
    2294           0 : { (void)T; return FpX_add(x,y,p); }
    2295             : INLINE GEN
    2296           0 : FpXQ_sub(GEN x,GEN y,GEN T/*unused*/,GEN p)
    2297           0 : { (void)T; return FpX_sub(x,y,p); }
    2298             : 
    2299             : /*Flxq*/
    2300             : INLINE GEN
    2301           0 : Flxq_add(GEN x,GEN y,GEN T/*unused*/,ulong p)
    2302           0 : { (void)T; return Flx_add(x,y,p); }
    2303             : INLINE GEN
    2304          96 : Flxq_sub(GEN x,GEN y,GEN T/*unused*/,ulong p)
    2305          96 : { (void)T; return Flx_sub(x,y,p); }
    2306             : 
    2307             : /* F2x */
    2308             : 
    2309             : INLINE ulong
    2310    89611437 : F2x_coeff(GEN x,long v)
    2311             : {
    2312    89611437 :    ulong u=(ulong)x[2+divsBIL(v)];
    2313    89612185 :    return (u>>remsBIL(v))&1UL;
    2314             : }
    2315             : 
    2316             : INLINE void
    2317     3041868 : F2x_clear(GEN x,long v)
    2318             : {
    2319     3041868 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2320     3041868 :    *u&=~(1UL<<remsBIL(v));
    2321     3041868 : }
    2322             : 
    2323             : INLINE void
    2324    28934376 : F2x_set(GEN x,long v)
    2325             : {
    2326    28934376 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2327    28938161 :    *u|=1UL<<remsBIL(v);
    2328    28941140 : }
    2329             : 
    2330             : INLINE void
    2331     1148226 : F2x_flip(GEN x,long v)
    2332             : {
    2333     1148226 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2334     1148226 :    *u^=1UL<<remsBIL(v);
    2335     1148226 : }
    2336             : 
    2337             : /* F2v */
    2338             : 
    2339             : INLINE ulong
    2340    86072513 : F2v_coeff(GEN x,long v) { return F2x_coeff(x,v-1); }
    2341             : 
    2342             : INLINE void
    2343     3041868 : F2v_clear(GEN x,long v) { F2x_clear(x,v-1); }
    2344             : 
    2345             : INLINE void
    2346     8017080 : F2v_set(GEN x,long v)   { F2x_set(x,v-1); }
    2347             : 
    2348             : INLINE void
    2349     1148226 : F2v_flip(GEN x,long v) { F2x_flip(x,v-1); }
    2350             : 
    2351             : /* F2m */
    2352             : 
    2353             : INLINE ulong
    2354    11569458 : F2m_coeff(GEN x, long a, long b) { return F2v_coeff(gel(x,b), a); }
    2355             : 
    2356             : INLINE void
    2357           0 : F2m_clear(GEN x, long a, long b) { F2v_clear(gel(x,b), a); }
    2358             : 
    2359             : INLINE void
    2360     1477482 : F2m_set(GEN x, long a, long b) { F2v_set(gel(x,b), a); }
    2361             : 
    2362             : INLINE void
    2363     1148226 : F2m_flip(GEN x, long a, long b) { F2v_flip(gel(x,b), a); }
    2364             : 
    2365             : /* ARITHMETIC */
    2366             : INLINE GEN
    2367         864 : matpascal(long n) { return matqpascal(n, NULL); }
    2368             : INLINE long
    2369     1677028 : Z_issquare(GEN x) { return Z_issquareall(x, NULL); }
    2370             : INLINE long
    2371          12 : Z_ispower(GEN x, ulong k) { return Z_ispowerall(x, k, NULL); }
    2372             : INLINE GEN
    2373     4039471 : sqrti(GEN x) { return sqrtremi(x,NULL); }
    2374             : INLINE GEN
    2375     6434694 : gaddgs(GEN y, long s) { return gaddsg(s,y); }
    2376             : INLINE int
    2377       20454 : gcmpgs(GEN y, long s) { return -gcmpsg(s,y); }
    2378             : INLINE int
    2379       19566 : gequalgs(GEN y, long s) { return gequalsg(s,y); }
    2380             : INLINE GEN
    2381           0 : gmaxsg(long s, GEN y) { return gmaxgs(y,s); }
    2382             : INLINE GEN
    2383           0 : gminsg(long s, GEN y) { return gmings(y,s); }
    2384             : INLINE GEN
    2385     4965538 : gmulgs(GEN y, long s) { return gmulsg(s,y); }
    2386             : INLINE GEN
    2387      475608 : gsubgs(GEN y, long s) { return gaddgs(y, -s); }
    2388             : INLINE GEN
    2389      384051 : gdivsg(long s, GEN y) { return gdiv(stoi(s), y); }
    2390             : 
    2391             : /* x t_COMPLEX */
    2392             : INLINE GEN
    2393     7388814 : cxnorm(GEN x) { return gadd(gsqr(gel(x,1)), gsqr(gel(x,2))); }
    2394             : /* q t_QUAD */
    2395             : INLINE GEN
    2396         534 : quadnorm(GEN q)
    2397             : {
    2398         534 :   GEN X = gel(q,1), b = gel(X,3), c = gel(X,2);
    2399         534 :   GEN z, u = gel(q,3), v = gel(q,2);
    2400         534 :   if (typ(u) == t_INT && typ(v) == t_INT) /* generic case */
    2401             :   {
    2402         264 :     z = signe(b)? mulii(v, addii(u,v)): sqri(v);
    2403         264 :     return addii(z, mulii(c, sqri(u)));
    2404             :   }
    2405             :   else
    2406             :   {
    2407         270 :     z = signe(b)? gmul(v, gadd(u,v)): gsqr(v);
    2408         270 :     return gadd(z, gmul(c, gsqr(u)));
    2409             :   }
    2410             : }
    2411             : /* x a t_QUAD, return the attached discriminant */
    2412             : INLINE GEN
    2413         216 : quad_disc(GEN x)
    2414             : {
    2415         216 :   GEN Q = gel(x,1), b = gel(Q,3), c = gel(Q,2), c4;
    2416         216 :   if (is_pm1(b))
    2417             :   {
    2418         168 :     pari_sp av = avma; (void)new_chunk(lgefint(c) + 1);
    2419         168 :     c4 = shifti(c,2); avma = av; return subsi(1, c4);
    2420             :   }
    2421          48 :   c4 = shifti(c,2); togglesign_safe(&c4); return c4;
    2422             : }
    2423             : INLINE GEN
    2424     5128560 : qfb_disc3(GEN x, GEN y, GEN z) { return subii(sqri(y), shifti(mulii(x,z),2)); }
    2425             : INLINE GEN
    2426     5059272 : qfb_disc(GEN x) { return qfb_disc3(gel(x,1), gel(x,2), gel(x,3)); }
    2427             : 
    2428             : INLINE GEN
    2429     1204722 : sqrfrac(GEN x)
    2430             : {
    2431     1204722 :   GEN z = cgetg(3,t_FRAC);
    2432     1204722 :   gel(z,1) = sqri(gel(x,1));
    2433     1204722 :   gel(z,2) = sqri(gel(x,2)); return z;
    2434             : }
    2435             : 
    2436             : INLINE void
    2437     7283940 : normalize_frac(GEN z) {
    2438     7283940 :   if (signe(gel(z,2)) < 0) { togglesign(gel(z,1)); setabssign(gel(z,2)); }
    2439     7283940 : }
    2440             : 
    2441             : INLINE GEN
    2442      180436 : powii(GEN x, GEN n)
    2443             : {
    2444      180436 :   long ln = lgefint(n);
    2445      180436 :   if (ln == 3) {
    2446             :     GEN z;
    2447      178798 :     if (signe(n) > 0) return powiu(x, n[2]);
    2448        2298 :     z = cgetg(3, t_FRAC);
    2449        2298 :     gel(z,1) = gen_1;
    2450        2298 :     gel(z,2) = powiu(x, n[2]);
    2451        2298 :     return z;
    2452             :   }
    2453        1638 :   if (ln == 2) return gen_1; /* rare */
    2454             :   /* should never happen */
    2455           0 :   return powgi(x, n); /* overflow unless x = 0, 1, -1 */
    2456             : }
    2457             : INLINE GEN
    2458         720 : powIs(long n) {
    2459         720 :   switch(n & 3)
    2460             :   {
    2461           6 :     case 1: return mkcomplex(gen_0,gen_1);
    2462         270 :     case 2: return gen_m1;
    2463         390 :     case 3: return mkcomplex(gen_0,gen_m1);
    2464             :   }
    2465          54 :   return gen_1;
    2466             : }
    2467             : 
    2468             : /*******************************************************************/
    2469             : /*                                                                 */
    2470             : /*                             ASSIGNMENTS                         */
    2471             : /*                                                                 */
    2472             : /*******************************************************************/
    2473           0 : INLINE void mpexpz(GEN x, GEN z)
    2474           0 : { pari_sp av = avma; gaffect(mpexp(x), z); avma = av; }
    2475           0 : INLINE void mplogz(GEN x, GEN z)
    2476           0 : { pari_sp av = avma; gaffect(mplog(x), z); avma = av; }
    2477           0 : INLINE void mpcosz(GEN x, GEN z)
    2478           0 : { pari_sp av = avma; gaffect(mpcos(x), z); avma = av; }
    2479           0 : INLINE void mpsinz(GEN x, GEN z)
    2480           0 : { pari_sp av = avma; gaffect(mpsin(x), z); avma = av; }
    2481           0 : INLINE void gnegz(GEN x, GEN z)
    2482           0 : { pari_sp av = avma; gaffect(gneg(x), z); avma = av; }
    2483           0 : INLINE void gabsz(GEN x, long prec, GEN z)
    2484           0 : { pari_sp av = avma; gaffect(gabs(x,prec), z); avma = av; }
    2485       20472 : INLINE void gaddz(GEN x, GEN y, GEN z)
    2486       20472 : { pari_sp av = avma; gaffect(gadd(x,y), z); avma = av; }
    2487           0 : INLINE void gsubz(GEN x, GEN y, GEN z)
    2488           0 : { pari_sp av = avma; gaffect(gsub(x,y), z); avma = av; }
    2489       10248 : INLINE void gmulz(GEN x, GEN y, GEN z)
    2490       10248 : { pari_sp av = avma; gaffect(gmul(x,y), z); avma = av; }
    2491           0 : INLINE void gdivz(GEN x, GEN y, GEN z)
    2492           0 : { pari_sp av = avma; gaffect(gdiv(x,y), z); avma = av; }
    2493           0 : INLINE void gdiventz(GEN x, GEN y, GEN z)
    2494           0 : { pari_sp av = avma; gaffect(gdivent(x,y), z); avma = av; }
    2495           0 : INLINE void gmodz(GEN x, GEN y, GEN z)
    2496           0 : { pari_sp av = avma; gaffect(gmod(x,y), z); avma = av; }
    2497           0 : INLINE void gmul2nz(GEN x, long s, GEN z)
    2498           0 : { pari_sp av = avma; gaffect(gmul2n(x,s), z); avma = av; }
    2499           0 : INLINE void gshiftz(GEN x, long s, GEN z)
    2500           0 : { pari_sp av = avma; gaffect(gshift(x,s), z); avma = av; }
    2501             : 
    2502             : /*******************************************************************/
    2503             : /*                                                                 */
    2504             : /*                       ELLIPTIC CURVES                           */
    2505             : /*                                                                 */
    2506             : /*******************************************************************/
    2507     4312115 : INLINE GEN ell_get_a1(GEN e) { return gel(e,1); }
    2508     2842665 : INLINE GEN ell_get_a2(GEN e) { return gel(e,2); }
    2509     3854898 : INLINE GEN ell_get_a3(GEN e) { return gel(e,3); }
    2510     3521211 : INLINE GEN ell_get_a4(GEN e) { return gel(e,4); }
    2511     4013187 : INLINE GEN ell_get_a6(GEN e) { return gel(e,5); }
    2512     3385888 : INLINE GEN ell_get_b2(GEN e) { return gel(e,6); }
    2513      865956 : INLINE GEN ell_get_b4(GEN e) { return gel(e,7); }
    2514     1383588 : INLINE GEN ell_get_b6(GEN e) { return gel(e,8); }
    2515     1249500 : INLINE GEN ell_get_b8(GEN e) { return gel(e,9); }
    2516     5229682 : INLINE GEN ell_get_c4(GEN e) { return gel(e,10); }
    2517     6971134 : INLINE GEN ell_get_c6(GEN e) { return gel(e,11); }
    2518     8196232 : INLINE GEN ell_get_disc(GEN e) { return gel(e,12); }
    2519     1006944 : INLINE GEN ell_get_j(GEN e) { return gel(e,13); }
    2520     6769727 : INLINE long ell_get_type(GEN e) { return mael(e,14,1); }
    2521     1337481 : INLINE GEN ellff_get_field(GEN x) { return gmael(x, 15, 1); }
    2522      580707 : INLINE GEN ellff_get_a4a6(GEN x)  { return gmael(x, 15, 2); }
    2523         786 : INLINE GEN ellQp_get_zero(GEN x) { return gmael(x, 15, 1); }
    2524         246 : INLINE long ellQp_get_prec(GEN E) { GEN z = ellQp_get_zero(E); return valp(z); }
    2525         534 : INLINE GEN ellQp_get_p(GEN E) { GEN z = ellQp_get_zero(E); return gel(z,2); }
    2526       31680 : INLINE long ellR_get_prec(GEN x) { return nbits2prec(mael3(x, 15, 1, 1)); }
    2527        1530 : INLINE long ellR_get_sign(GEN x) { return mael3(x, 15, 1, 2); }
    2528      475794 : INLINE GEN ellnf_get_nf(GEN x) { return checknf_i(gmael(x,15,1)); }
    2529          42 : INLINE GEN ellnf_get_bnf(GEN x) { return checkbnf_i(gmael(x,15,1)); }
    2530             : 
    2531    22158750 : INLINE int ell_is_inf(GEN z) { return lg(z) == 2; }
    2532      703805 : INLINE GEN ellinf(void) { return mkvec(gen_0); }
    2533             : 
    2534             : /*******************************************************************/
    2535             : /*                                                                 */
    2536             : /*                    ALGEBRAIC NUMBER THEORY                      */
    2537             : /*                                                                 */
    2538             : /*******************************************************************/
    2539     5315421 : INLINE GEN modpr_get_pr(GEN x)  { return gel(x,3); }
    2540      516981 : INLINE GEN modpr_get_p(GEN x)  { return pr_get_p(modpr_get_pr(x)); }
    2541     1515906 : INLINE GEN modpr_get_T(GEN x)  { return lg(x) == 4? NULL: gel(x,4); }
    2542             : 
    2543    13599865 : INLINE GEN pr_get_p(GEN pr)  { return gel(pr,1); }
    2544     3623160 : INLINE GEN pr_get_gen(GEN pr){ return gel(pr,2); }
    2545             : /* .[2] instead of itos works: e and f are small positive integers */
    2546     1789878 : INLINE long pr_get_e(GEN pr) { return gel(pr,3)[2]; }
    2547     6132588 : INLINE long pr_get_f(GEN pr) { return gel(pr,4)[2]; }
    2548     4746498 : INLINE GEN pr_get_tau(GEN pr){ return gel(pr,5); }
    2549             : INLINE int
    2550     1717220 : pr_is_inert(GEN P) { return pr_get_f(P) == lg(pr_get_gen(P))-1; }
    2551             : INLINE GEN
    2552      251238 : pr_norm(GEN pr) { return powiu(pr_get_p(pr), pr_get_f(pr)); }
    2553             : INLINE ulong
    2554       27666 : upr_norm(GEN pr) { return upowuu(pr_get_p(pr)[2], pr_get_f(pr)); }
    2555             : 
    2556             : /* assume nf a genuine nf */
    2557             : INLINE long
    2558        1806 : nf_get_varn(GEN nf) { return varn(gel(nf,1)); }
    2559             : INLINE GEN
    2560    10492914 : nf_get_pol(GEN nf) { return gel(nf,1); }
    2561             : INLINE long
    2562     7124002 : nf_get_degree(GEN nf) { return degpol( nf_get_pol(nf) ); }
    2563             : INLINE long
    2564      962694 : nf_get_r1(GEN nf) { GEN x = gel(nf,2); return itou(gel(x,1)); }
    2565             : INLINE long
    2566        1494 : nf_get_r2(GEN nf) { GEN x = gel(nf,2); return itou(gel(x,2)); }
    2567             : INLINE GEN
    2568       19632 : nf_get_disc(GEN nf) { return gel(nf,3); }
    2569             : INLINE GEN
    2570      528389 : nf_get_index(GEN nf) { return gel(nf,4); }
    2571             : INLINE GEN
    2572      923856 : nf_get_M(GEN nf) { return gmael(nf,5,1); }
    2573             : INLINE GEN
    2574       39096 : nf_get_G(GEN nf) { return gmael(nf,5,2); }
    2575             : INLINE GEN
    2576      327438 : nf_get_roundG(GEN nf) { return gmael(nf,5,3); }
    2577             : INLINE GEN
    2578       20862 : nf_get_Tr(GEN nf) { return gmael(nf,5,4); }
    2579             : INLINE GEN
    2580        1500 : nf_get_diff(GEN nf) { return gmael(nf,5,5); }
    2581             : INLINE GEN
    2582          24 : nf_get_ramified_primes(GEN nf) { return gmael(nf,5,8); }
    2583             : INLINE GEN
    2584       86016 : nf_get_roots(GEN nf) { return gel(nf,6); }
    2585             : INLINE GEN
    2586          66 : nf_get_zk(GEN nf)
    2587             : {
    2588          66 :   GEN y = gel(nf,7), D = nf_get_zkden(nf);
    2589          66 :   if (!equali1(D)) y = gdiv(y, D);
    2590          66 :   return y;
    2591             : }
    2592             : INLINE GEN
    2593      106320 : nf_get_zkprimpart(GEN nf)
    2594             : {
    2595      106320 :   GEN y = gel(nf,7);
    2596             :   /* test for old format of nf.zk: non normalized */
    2597      106320 :   if (!equali1(gel(nf,4)) && gequal1(gel(y,1))) y = Q_remove_denom(y,NULL);
    2598      106320 :   return y;
    2599             : }
    2600             : INLINE GEN
    2601      108366 : nf_get_zkden(GEN nf)
    2602             : {
    2603      108366 :   GEN y = gel(nf,7), D = gel(y,1);
    2604      108366 :   if (typ(D) == t_POL) D = gel(D,2);
    2605             :   /* test for old format of nf.zk: non normalized */
    2606      108366 :   if (!equali1(gel(nf,4)) && equali1(D)) D = Q_denom(y);
    2607      108366 :   return D;
    2608             : }
    2609             : INLINE GEN
    2610     1405138 : nf_get_invzk(GEN nf) { return gel(nf,8); }
    2611             : INLINE void
    2612        5778 : nf_get_sign(GEN nf, long *r1, long *r2)
    2613             : {
    2614        5778 :   GEN x = gel(nf,2);
    2615        5778 :   *r1 = itou(gel(x,1));
    2616        5778 :   *r2 = itou(gel(x,2));
    2617        5778 : }
    2618             : 
    2619             : INLINE GEN
    2620        8166 : abgrp_get_no(GEN x) { return gel(x,1); }
    2621             : INLINE GEN
    2622      992142 : abgrp_get_cyc(GEN x) { return gel(x,2); }
    2623             : INLINE GEN
    2624      239154 : abgrp_get_gen(GEN x) { return gel(x,3); }
    2625             : INLINE GEN
    2626     1302174 : bnf_get_nf(GEN bnf) { return gel(bnf,7); }
    2627             : INLINE GEN
    2628      484446 : bnf_get_clgp(GEN bnf) { return gmael(bnf,8,1); }
    2629             : INLINE GEN
    2630         972 : bnf_get_no(GEN bnf) { return abgrp_get_no(bnf_get_clgp(bnf)); }
    2631             : INLINE GEN
    2632      251724 : bnf_get_cyc(GEN bnf) { return abgrp_get_cyc(bnf_get_clgp(bnf)); }
    2633             : INLINE GEN
    2634      231468 : bnf_get_gen(GEN bnf)  { return abgrp_get_gen(bnf_get_clgp(bnf)); }
    2635             : INLINE GEN
    2636         738 : bnf_get_reg(GEN bnf) { return gmael(bnf,8,2); }
    2637             : INLINE GEN
    2638      367308 : bnf_get_logfu(GEN bnf) { return gel(bnf,3); }
    2639             : INLINE GEN
    2640        2172 : bnf_get_tuU(GEN bnf) { return gmael3(bnf,8,4,2); }
    2641             : INLINE long
    2642        6576 : bnf_get_tuN(GEN bnf) { return gmael3(bnf,8,4,1)[2]; }
    2643             : INLINE GEN
    2644        1548 : bnf_get_fu(GEN bnf) {
    2645        1548 :   GEN fu = bnf_get_fu_nocheck(bnf);
    2646        1548 :   if (typ(fu) == t_MAT) pari_err(e_MISC,"missing units in bnf");
    2647        1548 :   return fu;
    2648             : }
    2649             : INLINE GEN
    2650        3258 : bnf_get_fu_nocheck(GEN bnf) { return gmael(bnf,8,5); }
    2651             : 
    2652             : INLINE GEN
    2653      359910 : bnr_get_bnf(GEN bnr) { return gel(bnr,1); }
    2654             : INLINE GEN
    2655      180822 : bnr_get_bid(GEN bnr) { return gel(bnr,2); }
    2656             : INLINE GEN
    2657       15474 : bnr_get_mod(GEN bnr) { return gmael(bnr,2,1); }
    2658             : INLINE GEN
    2659       11484 : bnr_get_nf(GEN bnr) { return gmael(bnr,1,7); }
    2660             : INLINE GEN
    2661      211002 : bnr_get_clgp(GEN bnr) { return gel(bnr,5); }
    2662             : INLINE GEN
    2663        7194 : bnr_get_no(GEN bnr) { return abgrp_get_no(bnr_get_clgp(bnr)); }
    2664             : INLINE GEN
    2665      196944 : bnr_get_cyc(GEN bnr) { return abgrp_get_cyc(bnr_get_clgp(bnr)); }
    2666             : INLINE GEN
    2667          60 : bnr_get_gen_nocheck(GEN bnr) { return abgrp_get_gen(bnr_get_clgp(bnr)); }
    2668             : INLINE GEN
    2669        6096 : bnr_get_gen(GEN bnr) {
    2670        6096 :   GEN G = bnr_get_clgp(bnr);
    2671        6096 :   if (lg(G) !=  4)
    2672           0 :     pari_err(e_MISC,"missing bnr generators: please use bnrinit(,,1)");
    2673        6096 :   return gel(G,3);
    2674             : }
    2675             : 
    2676             : INLINE GEN
    2677      180006 : bid_get_mod(GEN bid) { return gel(bid,1); }
    2678             : INLINE GEN
    2679       10146 : bid_get_ideal(GEN bid) { return gmael(bid,1,1); }
    2680             : INLINE GEN
    2681         384 : bid_get_arch(GEN bid) { return gmael(bid,1,2); }
    2682             : INLINE GEN
    2683      548634 : bid_get_grp(GEN bid) { return gel(bid,2); }
    2684             : INLINE GEN
    2685      192954 : bid_get_fact(GEN bid) { return gmael(bid,3,1); }
    2686             : INLINE GEN
    2687      186474 : bid_get_fact2(GEN bid) { return gmael(bid,3,2); }
    2688             : INLINE GEN
    2689      186534 : bid_get_sprk(GEN bid) { return gmael(bid,4,1); }
    2690             : INLINE GEN
    2691        5532 : bid_get_sarch(GEN bid) { return gmael(bid,4,2); }
    2692             : INLINE GEN
    2693      189720 : bid_get_archp(GEN bid) { return gmael3(bid,4,2,2); }
    2694             : INLINE GEN
    2695      366720 : bid_get_U(GEN bid) { return gel(bid,5); }
    2696             : INLINE GEN
    2697           0 : bid_get_no(GEN bid) { return abgrp_get_no(bid_get_grp(bid)); }
    2698             : INLINE GEN
    2699      541776 : bid_get_cyc(GEN bid) { return abgrp_get_cyc(bid_get_grp(bid)); }
    2700             : INLINE GEN
    2701           0 : bid_get_gen_nocheck(GEN bid)  { return abgrp_get_gen(bid_get_grp(bid)); }
    2702             : INLINE GEN
    2703        6348 : bid_get_gen(GEN bid) {
    2704        6348 :   GEN G = bid_get_grp(bid);
    2705        6348 :   if (lg(G) != 4) pari_err(e_MISC,"missing bid generators. Use idealstar(,,2)");
    2706        6348 :   return abgrp_get_gen(G);
    2707             : }
    2708             : 
    2709             : INLINE GEN
    2710       17904 : znstar_get_N(GEN G) { return gmael(G,1,1); }
    2711             : INLINE GEN
    2712       32550 : znstar_get_faN(GEN G) { return gel(G,3); }
    2713             : INLINE GEN
    2714           0 : znstar_get_no(GEN G) { return abgrp_get_no(gel(G,2)); }
    2715             : INLINE GEN
    2716         486 : znstar_get_cyc(GEN G) { return abgrp_get_cyc(gel(G,2)); }
    2717             : INLINE GEN
    2718           0 : znstar_get_gen(GEN G) { return abgrp_get_gen(gel(G,2)); }
    2719             : INLINE GEN
    2720       16638 : znstar_get_conreycyc(GEN G) { return gmael(G,4,5); }
    2721             : INLINE GEN
    2722       12522 : znstar_get_conreygen(GEN G) { return gmael(G,4,4); }
    2723             : INLINE GEN
    2724         138 : znstar_get_Ui(GEN G) { return gmael(G,4,3); }
    2725             : INLINE GEN
    2726        5916 : znstar_get_U(GEN G) { return gel(G,5); }
    2727             : INLINE GEN
    2728       12498 : znstar_get_pe(GEN G) { return gmael(G,4,1); }
    2729             : INLINE GEN
    2730        2478 : gal_get_pol(GEN gal) { return gel(gal,1); }
    2731             : INLINE GEN
    2732        1050 : gal_get_p(GEN gal) { return gmael(gal,2,1); }
    2733             : INLINE GEN
    2734          54 : gal_get_e(GEN gal) { return gmael(gal,2,2); }
    2735             : INLINE GEN
    2736        1830 : gal_get_mod(GEN gal) { return gmael(gal,2,3); }
    2737             : INLINE GEN
    2738        2154 : gal_get_roots(GEN gal) { return gel(gal,3); }
    2739             : INLINE GEN
    2740        1830 : gal_get_invvdm(GEN gal) { return gel(gal,4); }
    2741             : INLINE GEN
    2742        1830 : gal_get_den(GEN gal) { return gel(gal,5); }
    2743             : INLINE GEN
    2744        6354 : gal_get_group(GEN gal) { return gel(gal,6); }
    2745             : INLINE GEN
    2746        1602 : gal_get_gen(GEN gal) { return gel(gal,7); }
    2747             : INLINE GEN
    2748        1212 : gal_get_orders(GEN gal) { return gel(gal,8); }
    2749             : 
    2750             : /* assume rnf a genuine rnf */
    2751             : INLINE long
    2752      266910 : rnf_get_degree(GEN rnf) { return degpol(rnf_get_pol(rnf)); }
    2753             : INLINE long
    2754       12690 : rnf_get_nfdegree(GEN rnf) { return degpol(nf_get_pol(rnf_get_nf(rnf))); }
    2755             : INLINE long
    2756      134100 : rnf_get_absdegree(GEN rnf) { return degpol(gmael(rnf,11,1)); }
    2757             : INLINE GEN
    2758         372 : rnf_get_idealdisc(GEN rnf) { return gmael(rnf,3,1); }
    2759             : INLINE GEN
    2760         384 : rnf_get_k(GEN rnf) { return gmael(rnf,11,3); }
    2761             : INLINE GEN
    2762         384 : rnf_get_alpha(GEN rnf) { return gmael(rnf, 11, 2); }
    2763             : INLINE GEN
    2764      106086 : rnf_get_nf(GEN rnf) { return gel(rnf,10); }
    2765             : INLINE void
    2766        1458 : rnf_get_nfzk(GEN rnf, GEN *b, GEN *cb) {*b=gmael(rnf,2,1); *cb=gmael(rnf,2,2);}
    2767             : INLINE GEN
    2768       80292 : rnf_get_polabs(GEN rnf) { return gmael(rnf,11,1); }
    2769             : INLINE GEN
    2770      396936 : rnf_get_pol(GEN rnf) { return gel(rnf,1); }
    2771             : INLINE GEN
    2772          54 : rnf_get_disc(GEN rnf) { return gel(rnf,3); }
    2773             : INLINE GEN
    2774          90 : rnf_get_index(GEN rnf) { return gel(rnf,4); }
    2775             : INLINE long
    2776           0 : rnf_get_varn(GEN rnf) { return varn(gel(rnf,1)); }
    2777             : INLINE GEN
    2778       91302 : rnf_get_nfpol(GEN rnf) { return gmael(rnf,10,1); }
    2779             : INLINE long
    2780         414 : rnf_get_nfvarn(GEN rnf) { return varn(gmael(rnf,10,1)); }
    2781             : INLINE GEN
    2782        2094 : rnf_get_zk(GEN rnf) { return gel(rnf,7); }
    2783             : INLINE GEN
    2784       29148 : rnf_get_map(GEN rnf) { return gel(rnf,11); }
    2785             : INLINE GEN
    2786        1020 : rnf_get_invzk(GEN rnf) { return gel(rnf,8); }
    2787             : 
    2788             : /* I integral ZM (not HNF), G ZM, rounded Cholesky form of a weighted
    2789             :  * T2 matrix. Reduce I wrt G */
    2790             : INLINE GEN
    2791        4398 : idealpseudored(GEN I, GEN G)
    2792        4398 : { return ZM_mul(I, ZM_lll(ZM_mul(G, I), 0.99, LLL_IM)); }
    2793             : 
    2794             : /* I integral (not necessarily HNF), G ZM, rounded Cholesky form of a weighted
    2795             :  * T2 matrix. Return m in I with T2(m) small */
    2796             : INLINE GEN
    2797      120594 : idealpseudomin(GEN I, GEN G)
    2798             : {
    2799      120594 :   GEN u = ZM_lll(ZM_mul(G, I), 0.99, LLL_IM);
    2800      120594 :   return ZM_ZC_mul(I, gel(u,1));
    2801             : }
    2802             : /* I, G as in idealpseudomin. Return an irrational m in I with T2(m) small */
    2803             : INLINE GEN
    2804      228840 : idealpseudomin_nonscalar(GEN I, GEN G)
    2805             : {
    2806      228840 :   GEN u = ZM_lll(ZM_mul(G, I), 0.99, LLL_IM);
    2807      228840 :   GEN m = ZM_ZC_mul(I, gel(u,1));
    2808      228840 :   if (ZV_isscalar(m) && lg(u) > 2) m = ZM_ZC_mul(I, gel(u,2));
    2809      228840 :   return m;
    2810             : }
    2811             : 
    2812             : INLINE GEN
    2813           0 : idealred_elt(GEN nf, GEN I) {
    2814           0 :   pari_sp av = avma;
    2815           0 :   GEN u = idealpseudomin(I, nf_get_roundG(nf));
    2816           0 :   return gerepileupto(av, u);
    2817             : }
    2818             : INLINE GEN
    2819      124968 : idealred(GEN nf, GEN I) { return idealred0(nf, I, NULL); }
    2820             : 
    2821             : INLINE GEN
    2822        1044 : idealchineseinit(GEN nf, GEN x)
    2823        1044 : { return idealchinese(nf,x,NULL); }
    2824             : 
    2825             : /*******************************************************************/
    2826             : /*                                                                 */
    2827             : /*                              CLOSURES                           */
    2828             : /*                                                                 */
    2829             : /*******************************************************************/
    2830   160140879 : INLINE long closure_arity(GEN C)          { return ((ulong)C[1])&ARITYBITS; }
    2831    29454381 : INLINE long closure_is_variadic(GEN C) { return !!(((ulong)C[1])&VARARGBITS); }
    2832   130505597 : INLINE const char *closure_codestr(GEN C)  { return GSTR(gel(C,2))-1; }
    2833           0 : INLINE GEN closure_get_code(GEN C)  { return gel(C,2); }
    2834   130452270 : INLINE GEN closure_get_oper(GEN C)  { return gel(C,3); }
    2835   130433109 : INLINE GEN closure_get_data(GEN C)  { return gel(C,4); }
    2836        7250 : INLINE GEN closure_get_dbg(GEN C)   { return gel(C,5); }
    2837       17542 : INLINE GEN closure_get_text(GEN C)  { return gel(C,6); }
    2838      321335 : INLINE GEN closure_get_frame(GEN C) { return gel(C,7); }
    2839             : 
    2840             : /*******************************************************************/
    2841             : /*                                                                 */
    2842             : /*                               ERRORS                            */
    2843             : /*                                                                 */
    2844             : /*******************************************************************/
    2845             : INLINE long
    2846       26136 : err_get_num(GEN e) { return e[1]; }
    2847             : INLINE GEN
    2848          60 : err_get_compo(GEN e, long i) { return gel(e, i+1); }
    2849             : 
    2850             : INLINE void
    2851          12 : pari_err_BUG(const char *f) { pari_err(e_BUG,f); }
    2852             : INLINE void
    2853           6 : pari_err_CONSTPOL(const char *f) { pari_err(e_CONSTPOL, f); }
    2854             : INLINE void
    2855          54 : pari_err_COPRIME(const char *f, GEN x, GEN y) { pari_err(e_COPRIME, f,x,y); }
    2856             : INLINE void
    2857         360 : pari_err_DIM(const char *f) { pari_err(e_DIM, f); }
    2858             : INLINE void
    2859           0 : pari_err_FILE(const char *f, const char *g) { pari_err(e_FILE, f,g); }
    2860             : INLINE void
    2861          24 : pari_err_FLAG(const char *f) { pari_err(e_FLAG,f); }
    2862             : INLINE void
    2863         300 : pari_err_IMPL(const char *f) { pari_err(e_IMPL,f); }
    2864             : INLINE void
    2865         562 : pari_err_INV(const char *f, GEN x) { pari_err(e_INV,f,x); }
    2866             : INLINE void
    2867          18 : pari_err_IRREDPOL(const char *f, GEN x) { pari_err(e_IRREDPOL, f,x); }
    2868             : INLINE void
    2869        1394 : 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); }
    2870             : INLINE void
    2871         192 : pari_err_COMPONENT(const char *f, const char *op, GEN l, GEN x) { pari_err(e_COMPONENT, f,op,l,x); }
    2872             : INLINE void
    2873           0 : pari_err_MAXPRIME(ulong c) { pari_err(e_MAXPRIME, c); }
    2874             : INLINE void
    2875         246 : pari_err_OP(const char *f, GEN x, GEN y) { pari_err(e_OP, f,x,y); }
    2876             : INLINE void
    2877          60 : pari_err_OVERFLOW(const char *f) { pari_err(e_OVERFLOW, f); }
    2878             : INLINE void
    2879         186 : pari_err_PREC(const char *f) { pari_err(e_PREC,f); }
    2880             : INLINE void
    2881           0 : pari_err_PACKAGE(const char *f) { pari_err(e_PACKAGE,f); }
    2882             : INLINE void
    2883          48 : pari_err_PRIME(const char *f, GEN x) { pari_err(e_PRIME, f,x); }
    2884             : INLINE void
    2885         630 : pari_err_MODULUS(const char *f, GEN x, GEN y) { pari_err(e_MODULUS, f,x,y); }
    2886             : INLINE void
    2887          36 : pari_err_ROOTS0(const char *f) { pari_err(e_ROOTS0, f); }
    2888             : INLINE void
    2889          66 : pari_err_SQRTN(const char *f, GEN x) { pari_err(e_SQRTN, f,x); }
    2890             : INLINE void
    2891        9792 : pari_err_TYPE(const char *f, GEN x) { pari_err(e_TYPE, f,x); }
    2892             : INLINE void
    2893        2634 : pari_err_TYPE2(const char *f, GEN x, GEN y) { pari_err(e_TYPE2, f,x,y); }
    2894             : INLINE void
    2895         174 : pari_err_VAR(const char *f, GEN x, GEN y) { pari_err(e_VAR, f,x,y); }
    2896             : INLINE void
    2897         102 : pari_err_PRIORITY(const char *f, GEN x, const char *op, long v)
    2898         102 : { pari_err(e_PRIORITY, f,x,op,v); }

Generated by: LCOV version 1.11