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 to exceed 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.18.1 lcov report (development 30101-620df3499e) Lines: 1427 1569 90.9 %
Date: 2025-03-28 09:18:47 Functions: 648 719 90.1 %
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; either version 2 of the License, or (at your option) any later
       8             : version. It is distributed in the hope that it will be useful, but WITHOUT
       9             : ANY WARRANTY WHATSOEVER.
      10             : 
      11             : Check the License for details. You should have received a copy of it, along
      12             : with the package; see the file 'COPYING'. If not, write to the Free Software
      13             : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
      14             : 
      15             : 
      16             : /*********************************************************************/
      17             : /*                       MALLOC/FREE WRAPPERS                        */
      18             : /*********************************************************************/
      19             : #define BLOCK_SIGALRM_START          \
      20             : {                                    \
      21             :   int block=PARI_SIGINT_block;       \
      22             :   PARI_SIGINT_block = 2;             \
      23             :   MT_SIGINT_BLOCK(block);
      24             : 
      25             : #define BLOCK_SIGINT_START           \
      26             : {                                    \
      27             :   int block=PARI_SIGINT_block;       \
      28             :   PARI_SIGINT_block = 1;             \
      29             :   MT_SIGINT_BLOCK(block);
      30             : 
      31             : #define BLOCK_SIGINT_END             \
      32             :   PARI_SIGINT_block = block;         \
      33             :   MT_SIGINT_UNBLOCK(block);          \
      34             :   if (!block && PARI_SIGINT_pending) \
      35             :   {                                  \
      36             :     int sig = PARI_SIGINT_pending;   \
      37             :     PARI_SIGINT_pending = 0;         \
      38             :     raise(sig);                      \
      39             :   }                                  \
      40             : }
      41             : 
      42             : /*******************************************************************/
      43             : /*                                                                 */
      44             : /*                          CONSTRUCTORS                           */
      45             : /*                                                                 */
      46             : /*******************************************************************/
      47             : #define retmkfrac(x,y)\
      48             :   do { GEN _v = cgetg(3, t_FRAC);\
      49             :        gel(_v,1) = (x);\
      50             :        gel(_v,2) = (y); return _v; } while(0)
      51             : #define retmkrfrac(x,y)\
      52             :   do { GEN _v = cgetg(3, t_RFRAC);\
      53             :        gel(_v,1) = (x);\
      54             :        gel(_v,2) = (y); return _v; } while(0)
      55             : #define retmkintmod(x,y)\
      56             :   do { GEN _v = cgetg(3, t_INTMOD);\
      57             :        gel(_v,1) = (y);\
      58             :        gel(_v,2) = (x); return _v; } while(0)
      59             : #define retmkcomplex(x,y)\
      60             :   do { GEN _v = cgetg(3, t_COMPLEX);\
      61             :        gel(_v,1) = (x);\
      62             :        gel(_v,2) = (y); return _v; } while(0)
      63             : #define retmkpolmod(x,y)\
      64             :   do { GEN _v = cgetg(3, t_POLMOD);\
      65             :        gel(_v,1) = (y);\
      66             :        gel(_v,2) = (x); return _v; } while(0)
      67             : #define retmkvec(x)\
      68             :   do { GEN _v = cgetg(2, t_VEC);\
      69             :        gel(_v,1) = (x); return _v; } while(0)
      70             : #define retmkvec2(x,y)\
      71             :   do { GEN _v = cgetg(3, t_VEC);\
      72             :        gel(_v,1) = (x);\
      73             :        gel(_v,2) = (y); return _v; } while(0)
      74             : #define retmkvec3(x,y,z)\
      75             :   do { GEN _v = cgetg(4, t_VEC);\
      76             :        gel(_v,1) = (x);\
      77             :        gel(_v,2) = (y);\
      78             :        gel(_v,3) = (z); return _v; } while(0)
      79             : #define retmkpadic(x,p,pd,e,d)\
      80             :   do { GEN _v = cgetg(5, t_PADIC);\
      81             :        _v[1] = evalvalp(e) | evalprecp(d);\
      82             :        gel(_v,2) = (p);\
      83             :        gel(_v,3) = (pd);\
      84             :        gel(_v,4) = (x); return _v; } while(0)
      85             : /* x allowed to contain _pd */
      86             : #define retmkpadic_i(x,p,pd,e,d)\
      87             :   do { GEN _v = cgetg(5, t_PADIC), _pd = (pd);\
      88             :        _v[1] = evalvalp(e) | evalprecp(d);\
      89             :        gel(_v,2) = (p);\
      90             :        gel(_v,3) = (_pd);\
      91             :        gel(_v,4) = (x); return _v; } while(0)
      92             : #define retmkqfb(x,y,z,d)\
      93             :   do { GEN _v = cgetg(5, t_QFB);\
      94             :        gel(_v,1) = (x);\
      95             :        gel(_v,2) = (y);\
      96             :        gel(_v,3) = (z);\
      97             :        gel(_v,4) = (d); return _v; } while(0)
      98             : #define retmkquad(x,y,z)\
      99             :   do { GEN _v = cgetg(4, t_QUAD);\
     100             :        gel(_v,1) = (x);\
     101             :        gel(_v,2) = (y);\
     102             :        gel(_v,3) = (z); return _v; } while(0)
     103             : #define retmkvec4(x,y,z,t)\
     104             :   do { GEN _v = cgetg(5, t_VEC);\
     105             :        gel(_v,1) = (x);\
     106             :        gel(_v,2) = (y);\
     107             :        gel(_v,3) = (z);\
     108             :        gel(_v,4) = (t); return _v; } while(0)
     109             : #define retmkvec5(x,y,z,t,u)\
     110             :   do { GEN _v = cgetg(6, t_VEC);\
     111             :        gel(_v,1) = (x);\
     112             :        gel(_v,2) = (y);\
     113             :        gel(_v,3) = (z);\
     114             :        gel(_v,4) = (t);\
     115             :        gel(_v,5) = (u); return _v; } while(0)
     116             : #define retmkcol(x)\
     117             :   do { GEN _v = cgetg(2, t_COL);\
     118             :        gel(_v,1) = (x); return _v; } while(0)
     119             : #define retmkcol2(x,y)\
     120             :   do { GEN _v = cgetg(3, t_COL);\
     121             :        gel(_v,1) = (x);\
     122             :        gel(_v,2) = (y); return _v; } while(0)
     123             : #define retmkcol3(x,y,z)\
     124             :   do { GEN _v = cgetg(4, t_COL);\
     125             :        gel(_v,1) = (x);\
     126             :        gel(_v,2) = (y);\
     127             :        gel(_v,3) = (z); return _v; } while(0)
     128             : #define retmkcol4(x,y,z,t)\
     129             :   do { GEN _v = cgetg(5, t_COL);\
     130             :        gel(_v,1) = (x);\
     131             :        gel(_v,2) = (y);\
     132             :        gel(_v,3) = (z);\
     133             :        gel(_v,4) = (t); return _v; } while(0)
     134             : #define retmkcol5(x,y,z,t,u)\
     135             :   do { GEN _v = cgetg(6, t_COL);\
     136             :        gel(_v,1) = (x);\
     137             :        gel(_v,2) = (y);\
     138             :        gel(_v,3) = (z);\
     139             :        gel(_v,4) = (t);\
     140             :        gel(_v,5) = (u); return _v; } while(0)
     141             : #define retmkcol6(x,y,z,t,u,v)\
     142             :   do { GEN _v = cgetg(7, t_COL);\
     143             :        gel(_v,1) = (x);\
     144             :        gel(_v,2) = (y);\
     145             :        gel(_v,3) = (z);\
     146             :        gel(_v,4) = (t);\
     147             :        gel(_v,5) = (u);\
     148             :        gel(_v,6) = (v); return _v; } while(0)
     149             : #define retmkmat(x)\
     150             :   do { GEN _v = cgetg(2, t_MAT);\
     151             :        gel(_v,1) = (x); return _v; } while(0)
     152             : #define retmkmat2(x,y)\
     153             :   do { GEN _v = cgetg(3, t_MAT);\
     154             :        gel(_v,1) = (x);\
     155             :        gel(_v,2) = (y); return _v; } while(0)
     156             : #define retmkmat3(x,y,z)\
     157             :   do { GEN _v = cgetg(4, t_MAT);\
     158             :        gel(_v,1) = (x);\
     159             :        gel(_v,2) = (y);\
     160             :        gel(_v,3) = (z); return _v; } while(0)
     161             : #define retmkmat4(x,y,z,t)\
     162             :   do { GEN _v = cgetg(5, t_MAT);\
     163             :        gel(_v,1) = (x);\
     164             :        gel(_v,2) = (y);\
     165             :        gel(_v,3) = (z);\
     166             :        gel(_v,4) = (t); return _v; } while(0)
     167             : #define retmkmat5(x,y,z,t,u)\
     168             :   do { GEN _v = cgetg(6, t_MAT);\
     169             :        gel(_v,1) = (x);\
     170             :        gel(_v,2) = (y);\
     171             :        gel(_v,3) = (z);\
     172             :        gel(_v,4) = (t);\
     173             :        gel(_v,5) = (u); return _v; } while(0)
     174             : #define retmkmat22(a,b,c,d)\
     175             :   do { GEN _v = cgetg(3, t_MAT);\
     176             :        gel(_v,1) = mkcol2(a,c);\
     177             :        gel(_v,2) = mkcol2(b,d); return _v; } while(0)
     178             : INLINE GEN
     179     8025468 : mkintmod(GEN x, GEN y) { retmkintmod(x,y); }
     180             : INLINE GEN
     181        1813 : mkintmodu(ulong x, ulong y) {
     182        1813 :   GEN v = cgetg(3,t_INTMOD);
     183        1813 :   gel(v,1) = utoipos(y);
     184        1813 :   gel(v,2) = utoi(x); return v;
     185             : }
     186             : INLINE GEN
     187           0 : mkpadic(GEN x, GEN p, GEN pd, long e, long d) { retmkpadic(x,p,pd,e,d); }
     188             : INLINE GEN
     189     3018050 : mkpolmod(GEN x, GEN y) { retmkpolmod(x,y); }
     190             : INLINE GEN
     191    41018729 : mkfrac(GEN x, GEN y) { retmkfrac(x,y); }
     192             : INLINE GEN
     193     1209626 : mkfracss(long x, long y) { retmkfrac(stoi(x),utoipos(y)); }
     194             : /* q = n/d a t_FRAC or t_INT; recover (n,d) */
     195             : INLINE void
     196       19922 : Qtoss(GEN q, long *n, long *d)
     197             : {
     198       19922 :   if (typ(q) == t_INT) { *n = itos(q); *d = 1; }
     199        5796 :   else { *n = itos(gel(q,1)); *d = itou(gel(q,2)); }
     200       19922 : }
     201             : INLINE GEN
     202     1074164 : sstoQ(long n, long d)
     203             : {
     204             :   ulong r;
     205             :   long g, q;
     206     1074164 :   if (!n)
     207             :   {
     208       95095 :     if (!d) pari_err_INV("sstoQ",gen_0);
     209       95095 :     return gen_0;
     210             :   }
     211      979069 :   if (d < 0) { d = -d; n = -n; }
     212      979069 :   if (d == 1) return stoi(n);
     213      959756 :   r = labs(n);
     214      959756 :   if (r == 1) retmkfrac(n > 0? gen_1: gen_m1, utoipos(d));
     215      909748 :   q = udivuu_rem(r, d, &r);
     216      909748 :   if (!r) return n > 0? utoipos(q): utoineg(q);
     217      854875 :   g = ugcd(d,r); /* gcd(n,d) */
     218      854875 :   if (g != 1) { n /= g; d /= g; }
     219      854875 :   retmkfrac(stoi(n), utoipos(d));
     220             : }
     221             : 
     222             : INLINE GEN
     223   158072807 : uutoQ(ulong n, ulong d)
     224             : {
     225             :   ulong r;
     226             :   long g, q;
     227   158072807 :   if (!n)
     228             :   {
     229       38108 :     if (!d) pari_err_INV("uutoQ",gen_0);
     230       38108 :     return gen_0;
     231             :   }
     232   158034699 :   if (d == 1) return utoipos(n);
     233   158023597 :   if (n == 1) retmkfrac(gen_1, utoipos(d));
     234   157934621 :   q = udivuu_rem(n,d,&r);
     235   157934621 :   if (!r) return utoipos(q);
     236     5180040 :   g = ugcd(d,r); /* gcd(n,d) */
     237     5180040 :   if (g != 1) { n /= g; d /= g; }
     238     5180040 :   retmkfrac(utoipos(n), utoipos(d));
     239             : }
     240             : 
     241             : INLINE GEN
     242     4844525 : mkfraccopy(GEN x, GEN y) { retmkfrac(icopy(x), icopy(y)); }
     243             : INLINE GEN
     244      698131 : mkrfrac(GEN x, GEN y) { GEN v = cgetg(3, t_RFRAC);
     245      698131 :   gel(v,1) = x; gel(v,2) = y; return v; }
     246             : INLINE GEN
     247          14 : mkrfraccopy(GEN x, GEN y) { GEN v = cgetg(3, t_RFRAC);
     248          14 :   gel(v,1) = gcopy(x); gel(v,2) = gcopy(y); return v; }
     249             : INLINE GEN
     250    90152877 : mkcomplex(GEN x, GEN y) { retmkcomplex(x,y); }
     251             : INLINE GEN
     252     1269300 : gen_I(void) { return mkcomplex(gen_0, gen_1); }
     253             : INLINE GEN
     254      968280 : cgetc(long l) { retmkcomplex(cgetr(l), cgetr(l)); }
     255             : INLINE GEN
     256       69118 : mkquad(GEN n, GEN x, GEN y) { GEN v = cgetg(4, t_QUAD);
     257       69118 :   gel(v,1) = n; gel(v,2) = x; gel(v,3) = y; return v; }
     258             : /* vecsmall */
     259             : INLINE GEN
     260   129152182 : mkvecsmall(long x) { GEN v = cgetg(2, t_VECSMALL); v[1] = x; return v; }
     261             : INLINE GEN
     262   223649321 : mkvecsmall2(long x,long y) { GEN v = cgetg(3, t_VECSMALL);
     263   223667367 :   v[1]=x; v[2]=y; return v; }
     264             : INLINE GEN
     265   100294677 : mkvecsmall3(long x,long y,long z) { GEN v = cgetg(4, t_VECSMALL);
     266   100290644 :   v[1]=x; v[2]=y; v[3]=z; return v; }
     267             : INLINE GEN
     268    15454358 : mkvecsmall4(long x,long y,long z,long t) { GEN v = cgetg(5, t_VECSMALL);
     269    15455102 :   v[1]=x; v[2]=y; v[3]=z; v[4]=t; return v; }
     270             : INLINE GEN
     271      691954 : mkvecsmall5(long x,long y,long z,long t,long u) { GEN v = cgetg(6, t_VECSMALL);
     272      691955 :   v[1]=x; v[2]=y; v[3]=z; v[4]=t; v[5]=u; return v; }
     273             : 
     274             : INLINE GEN
     275    27798682 : mkqfb(GEN x, GEN y, GEN z, GEN d) { retmkqfb(x,y,z,d); }
     276             : /* vec */
     277             : INLINE GEN
     278    68026718 : mkvec(GEN x) { retmkvec(x); }
     279             : INLINE GEN
     280   182648099 : mkvec2(GEN x, GEN y) { retmkvec2(x,y); }
     281             : INLINE GEN
     282   115279395 : mkvec3(GEN x, GEN y, GEN z) { retmkvec3(x,y,z); }
     283             : INLINE GEN
     284     6637562 : mkvec4(GEN x, GEN y, GEN z, GEN t) { retmkvec4(x,y,z,t); }
     285             : INLINE GEN
     286    14486807 : mkvec5(GEN x, GEN y, GEN z, GEN t, GEN u) { retmkvec5(x,y,z,t,u); }
     287             : INLINE GEN
     288         168 : mkvecs(long x) { retmkvec(stoi(x)); }
     289             : INLINE GEN
     290      219950 : mkvec2s(long x, long y) { retmkvec2(stoi(x),stoi(y)); }
     291             : INLINE GEN
     292      524441 : mkvec3s(long x, long y, long z) { retmkvec3(stoi(x),stoi(y),stoi(z)); }
     293             : INLINE GEN
     294          21 : mkvec4s(long x, long y, long z, long t) { retmkvec4(stoi(x),stoi(y),stoi(z),stoi(t)); }
     295             : INLINE GEN
     296      122507 : mkveccopy(GEN x) { GEN v = cgetg(2, t_VEC); gel(v,1) = gcopy(x); return v; }
     297             : INLINE GEN
     298      114445 : mkvec2copy(GEN x, GEN y) {
     299      114445 :   GEN v = cgetg(3,t_VEC); gel(v,1) = gcopy(x); gel(v,2) = gcopy(y); return v; }
     300             : /* col */
     301             : INLINE GEN
     302    10180159 : mkcol(GEN x) { retmkcol(x); }
     303             : INLINE GEN
     304   156650163 : mkcol2(GEN x, GEN y) { retmkcol2(x,y); }
     305             : INLINE GEN
     306       88314 : mkcol3(GEN x, GEN y, GEN z) { retmkcol3(x,y,z); }
     307             : INLINE GEN
     308      103467 : mkcol4(GEN x, GEN y, GEN z, GEN t) { retmkcol4(x,y,z,t); }
     309             : INLINE GEN
     310          94 : mkcol5(GEN x, GEN y, GEN z, GEN t, GEN u) { retmkcol5(x,y,z,t,u); }
     311             : INLINE GEN
     312      232344 : mkcol6(GEN x, GEN y, GEN z, GEN t, GEN u, GEN v) { retmkcol6(x,y,z,t,u,v); }
     313             : INLINE GEN
     314       40411 : mkcols(long x) { retmkcol(stoi(x)); }
     315             : INLINE GEN
     316     4415390 : mkcol2s(long x, long y) { retmkcol2(stoi(x),stoi(y)); }
     317             : INLINE GEN
     318         315 : mkcol3s(long x, long y, long z) { retmkcol3(stoi(x),stoi(y),stoi(z)); }
     319             : INLINE GEN
     320           0 : mkcol4s(long x, long y, long z, long t) { retmkcol4(stoi(x),stoi(y),stoi(z),stoi(t)); }
     321             : INLINE GEN
     322       33493 : mkcolcopy(GEN x) { GEN v = cgetg(2, t_COL); gel(v,1) = gcopy(x); return v; }
     323             : /* mat */
     324             : INLINE GEN
     325     4610224 : mkmat(GEN x) { retmkmat(x); }
     326             : INLINE GEN
     327    32592912 : mkmat2(GEN x, GEN y) { retmkmat2(x,y); }
     328             : INLINE GEN
     329       17001 : mkmat3(GEN x, GEN y, GEN z) { retmkmat3(x,y,z); }
     330             : INLINE GEN
     331          84 : mkmat4(GEN x, GEN y, GEN z, GEN t) { retmkmat4(x,y,z,t); }
     332             : INLINE GEN
     333           0 : mkmat5(GEN x, GEN y, GEN z, GEN t, GEN u) { retmkmat5(x,y,z,t,u); }
     334             : INLINE GEN
     335      121048 : mkmatcopy(GEN x) { GEN v = cgetg(2, t_MAT); gel(v,1) = gcopy(x); return v; }
     336             : INLINE GEN
     337           0 : mkerr(long x) { GEN v = cgetg(2, t_ERROR); v[1] = x; return v; }
     338             : INLINE GEN
     339     1077520 : mkoo(void) { GEN v = cgetg(2, t_INFINITY); gel(v,1) = gen_1; return v; }
     340             : INLINE GEN
     341      105907 : mkmoo(void) { GEN v = cgetg(2, t_INFINITY); gel(v,1) = gen_m1; return v; }
     342             : INLINE long
     343     1195695 : inf_get_sign(GEN x) { return signe(gel(x,1)); }
     344             : INLINE GEN
     345      207501 : mkmat22s(long a, long b, long c, long d) {retmkmat2(mkcol2s(a,c),mkcol2s(b,d));}
     346             : INLINE GEN
     347    50594279 : mkmat22(GEN a, GEN b, GEN c, GEN d) { retmkmat2(mkcol2(a,c),mkcol2(b,d)); }
     348             : 
     349             : /* pol */
     350             : INLINE GEN
     351     3565072 : pol_x(long v) {
     352     3565072 :   GEN p = cgetg(4, t_POL);
     353     3565058 :   p[1] = evalsigne(1)|evalvarn(v);
     354     3565058 :   gel(p,2) = gen_0;
     355     3565058 :   gel(p,3) = gen_1; return p;
     356             : }
     357             : /* x^n, assume n >= 0 */
     358             : INLINE GEN
     359     2231886 : pol_xn(long n, long v) {
     360     2231886 :   long i, a = n+2;
     361     2231886 :   GEN p = cgetg(a+1, t_POL);
     362     2231886 :   p[1] = evalsigne(1)|evalvarn(v);
     363     5382840 :   for (i = 2; i < a; i++) gel(p,i) = gen_0;
     364     2231886 :   gel(p,a) = gen_1; return p;
     365             : }
     366             : /* x^n, no assumption on n */
     367             : INLINE GEN
     368         294 : pol_xnall(long n, long v)
     369             : {
     370         294 :   if (n < 0) retmkrfrac(gen_1, pol_xn(-n,v));
     371         287 :   return pol_xn(n, v);
     372             : }
     373             : /* x^n, assume n >= 0 */
     374             : INLINE GEN
     375         371 : polxn_Flx(long n, long sv) {
     376         371 :   long i, a = n+2;
     377         371 :   GEN p = cgetg(a+1, t_VECSMALL);
     378         371 :   p[1] = sv;
     379        1806 :   for (i = 2; i < a; i++) p[i] = 0;
     380         371 :   p[a] = 1; return p;
     381             : }
     382             : INLINE GEN
     383     4459461 : pol_1(long v) {
     384     4459461 :   GEN p = cgetg(3, t_POL);
     385     4459461 :   p[1] = evalsigne(1)|evalvarn(v);
     386     4459461 :   gel(p,2) = gen_1; return p;
     387             : }
     388             : INLINE GEN
     389    82482882 : pol_0(long v)
     390             : {
     391    82482882 :   GEN x = cgetg(2,t_POL);
     392    82482871 :   x[1] = evalvarn(v); return x;
     393             : }
     394             : #define retconst_vec(n,x)\
     395             :   do { long _i, _n = (n);\
     396             :        GEN _v = cgetg(_n+1, t_VEC), _x = (x);\
     397             :        for (_i = 1; _i <= _n; _i++) gel(_v,_i) = _x;\
     398             :        return _v; } while(0)
     399             : INLINE GEN
     400   233984780 : const_vec(long n, GEN x) { retconst_vec(n, x); }
     401             : #define retconst_col(n,x)\
     402             :   do { long _i, _n = (n);\
     403             :        GEN _v = cgetg(_n+1, t_COL), _x = (x);\
     404             :        for (_i = 1; _i <= _n; _i++) gel(_v,_i) = _x;\
     405             :        return _v; } while(0)
     406             : INLINE GEN
     407    39271288 : const_col(long n, GEN x) { retconst_col(n, x); }
     408             : INLINE GEN
     409    19055708 : const_vecsmall(long n, long c)
     410             : {
     411             :   long i;
     412    19055708 :   GEN V = cgetg(n+1,t_VECSMALL);
     413   752922538 :   for(i=1;i<=n;i++) V[i] = c;
     414    19056491 :   return V;
     415             : }
     416             : 
     417             : /***   ZERO   ***/
     418             : /* O(p^e) */
     419             : INLINE GEN
     420      855758 : zeropadic(GEN p, long e) { retmkpadic(gen_0, icopy(p), gen_1, e, 0); }
     421             : INLINE GEN
     422       17010 : zeropadic_shallow(GEN p, long e) { retmkpadic(gen_0, icopy(p), gen_1, e, 0); }
     423             : /* O(pol_x(v)^e) */
     424             : INLINE GEN
     425      138698 : zeroser(long v, long e)
     426             : {
     427      138698 :   GEN x = cgetg(2, t_SER);
     428      138698 :   x[1] = evalvalser(e) | evalvarn(v); return x;
     429             : }
     430             : INLINE int
     431    10079052 : ser_isexactzero(GEN x)
     432             : {
     433    10079052 :   if (!signe(x)) switch(lg(x))
     434             :   {
     435      132741 :     case 2: return 1;
     436        4648 :     case 3: return isexactzero(gel(x,2));
     437             :   }
     438     9941663 :   return 0;
     439             : }
     440             : /* 0 * pol_x(v) */
     441             : INLINE GEN
     442    42303292 : zeropol(long v) { return pol_0(v); }
     443             : /* vector(n) */
     444             : INLINE GEN
     445   118820980 : zerocol(long n)
     446             : {
     447   118820980 :   GEN y = cgetg(n+1,t_COL);
     448   803781590 :   long i; for (i=1; i<=n; i++) gel(y,i) = gen_0;
     449   118822118 :   return y;
     450             : }
     451             : /* vectorv(n) */
     452             : INLINE GEN
     453    26629559 : zerovec(long n)
     454             : {
     455    26629559 :   GEN y = cgetg(n+1,t_VEC);
     456   391579656 :   long i; for (i=1; i<=n; i++) gel(y,i) = gen_0;
     457    26629543 :   return y;
     458             : }
     459             : /* matrix(m, n) */
     460             : INLINE GEN
     461      109084 : zeromat(long m, long n)
     462             : {
     463      109084 :   GEN y = cgetg(n+1,t_MAT);
     464      109085 :   GEN v = zerocol(m);
     465      403707 :   long i; for (i=1; i<=n; i++) gel(y,i) = v;
     466      109086 :   return y;
     467             : }
     468             : /* = zero_zx, sv is a evalvarn()*/
     469             : INLINE GEN
     470     1426037 : zero_Flx(long sv) { return pol0_Flx(sv); }
     471             : INLINE GEN
     472    58741256 : zero_Flv(long n)
     473             : {
     474    58741256 :   GEN y = cgetg(n+1,t_VECSMALL);
     475   946087291 :   long i; for (i=1; i<=n; i++) y[i] = 0;
     476    58741481 :   return y;
     477             : }
     478             : /* matrix(m, n) */
     479             : INLINE GEN
     480     2783237 : zero_Flm(long m, long n)
     481             : {
     482     2783237 :   GEN y = cgetg(n+1,t_MAT);
     483     2783222 :   GEN v = zero_Flv(m);
     484    17701554 :   long i; for (i=1; i<=n; i++) gel(y,i) = v;
     485     2783222 :   return y;
     486             : }
     487             : /* matrix(m, n) */
     488             : INLINE GEN
     489      232089 : zero_Flm_copy(long m, long n)
     490             : {
     491      232089 :   GEN y = cgetg(n+1,t_MAT);
     492     2397157 :   long i; for (i=1; i<=n; i++) gel(y,i) = zero_Flv(m);
     493      232086 :   return y;
     494             : }
     495             : 
     496             : INLINE GEN
     497     3627967 : zero_F2v(long m)
     498             : {
     499     3627967 :   long l = nbits2nlong(m);
     500     3627961 :   GEN v  = zero_Flv(l+1);
     501     3627935 :   v[1] = m;
     502     3627935 :   return v;
     503             : }
     504             : 
     505             : INLINE GEN
     506           0 : zero_F2m(long m, long n)
     507             : {
     508             :   long i;
     509           0 :   GEN M = cgetg(n+1, t_MAT);
     510           0 :   GEN v = zero_F2v(m);
     511           0 :   for (i = 1; i <= n; i++)
     512           0 :     gel(M,i) = v;
     513           0 :   return M;
     514             : }
     515             : 
     516             : 
     517             : INLINE GEN
     518      840091 : zero_F2m_copy(long m, long n)
     519             : {
     520             :   long i;
     521      840091 :   GEN M = cgetg(n+1, t_MAT);
     522     2006777 :   for (i = 1; i <= n; i++)
     523     1166691 :     gel(M,i)= zero_F2v(m);
     524      840086 :   return M;
     525             : }
     526             : 
     527             : /* matrix(m, n) */
     528             : INLINE GEN
     529    14024263 : zeromatcopy(long m, long n)
     530             : {
     531    14024263 :   GEN y = cgetg(n+1,t_MAT);
     532    70988274 :   long i; for (i=1; i<=n; i++) gel(y,i) = zerocol(m);
     533    14024264 :   return y;
     534             : }
     535             : 
     536             : INLINE GEN
     537       28009 : zerovec_block(long len)
     538             : {
     539             :   long i;
     540       28009 :   GEN blk = cgetg_block(len + 1, t_VEC);
     541      924297 :   for (i = 1; i <= len; ++i)
     542      896288 :     gel(blk, i) = gen_0;
     543       28009 :   return blk;
     544             : }
     545             : 
     546             : /* i-th vector in the standard basis */
     547             : INLINE GEN
     548     5679229 : col_ei(long n, long i) { GEN e = zerocol(n); gel(e,i) = gen_1; return e; }
     549             : INLINE GEN
     550     1711378 : vec_ei(long n, long i) { GEN e = zerovec(n); gel(e,i) = gen_1; return e; }
     551             : INLINE GEN
     552          42 : F2v_ei(long n, long i) { GEN e = zero_F2v(n); F2v_set(e,i); return e; }
     553             : INLINE GEN
     554      494381 : vecsmall_ei(long n, long i) { GEN e = zero_zv(n); e[i] = 1; return e; }
     555             : INLINE GEN
     556     1293451 : Rg_col_ei(GEN x, long n, long i) { GEN e = zerocol(n); gel(e,i) = x; return e; }
     557             : 
     558             : INLINE GEN
     559    25866274 : shallowcopy(GEN x)
     560    25866274 : { return typ(x) == t_MAT ? RgM_shallowcopy(x): leafcopy(x); }
     561             : 
     562             : /* routines for naive growarrays */
     563             : INLINE GEN
     564    11683067 : vectrunc_init(long l)
     565             : {
     566    11683067 :   GEN z = new_chunk(l);
     567    11682883 :   z[0] = evaltyp(t_VEC) | _evallg(1); return z;
     568             : }
     569             : INLINE GEN
     570      393680 : coltrunc_init(long l)
     571             : {
     572      393680 :   GEN z = new_chunk(l);
     573      393680 :   z[0] = evaltyp(t_COL) | _evallg(1); return z;
     574             : }
     575             : INLINE void
     576   313088682 : lg_increase(GEN x) { x[0]++; }
     577             : INLINE void
     578    15216584 : vectrunc_append(GEN x, GEN t) { gel(x, lg(x)) = t; lg_increase(x); }
     579             : INLINE void
     580        9821 : vectrunc_append_batch(GEN x, GEN y)
     581             : {
     582        9821 :   long i, l = lg(x), ly = lg(y);
     583        9821 :   GEN z = x + l-1;
     584       33229 :   for (i = 1; i < ly; i++) gel(z,i) = gel(y,i);
     585        9821 :   setlg(x, l+ly-1);
     586        9821 : }
     587             : INLINE GEN
     588   187989914 : vecsmalltrunc_init(long l)
     589             : {
     590   187989914 :   GEN z = new_chunk(l);
     591   188067575 :   z[0] = evaltyp(t_VECSMALL) | _evallg(1); return z;
     592             : }
     593             : INLINE void
     594    99615262 : vecsmalltrunc_append(GEN x, long t) { x[ lg(x) ] = t; lg_increase(x); }
     595             : 
     596             : /*******************************************************************/
     597             : /*                                                                 */
     598             : /*                    STRING HASH FUNCTIONS                        */
     599             : /*                                                                 */
     600             : /*******************************************************************/
     601             : INLINE ulong
     602     2737312 : hash_str(const char *str)
     603             : {
     604     2737312 :   ulong hash = 5381UL, c;
     605    28449371 :   while ( (c = (ulong)*str++) )
     606    25712059 :     hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
     607     2737312 :   return hash;
     608             : }
     609             : INLINE ulong
     610    18203083 : hash_str_len(const char *str, long len)
     611             : {
     612    18203083 :   ulong hash = 5381UL;
     613             :   long i;
     614   166334077 :   for (i = 0; i < len; i++)
     615             :   {
     616   148130994 :     ulong c = (ulong)*str++;
     617   148130994 :     hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
     618             :   }
     619    18203083 :   return hash;
     620             : }
     621             : 
     622             : /*******************************************************************/
     623             : /*                                                                 */
     624             : /*                        VEC / COL / VECSMALL                     */
     625             : /*                                                                 */
     626             : /*******************************************************************/
     627             : /* shallow*/
     628             : INLINE GEN
     629       11550 : vec_shorten(GEN v, long n)
     630             : {
     631       11550 :   GEN V = cgetg(n+1, t_VEC);
     632             :   long i;
     633       13006 :   for(i = 1; i <= n; i++) gel(V,i) = gel(v,i);
     634       11550 :   return V;
     635             : }
     636             : /* shallow*/
     637             : INLINE GEN
     638       18941 : vec_lengthen(GEN v, long n)
     639             : {
     640       18941 :   GEN V = cgetg(n+1, t_VEC);
     641       18941 :   long i, l = lg(v);
     642     1935639 :   for(i = 1; i < l; i++) gel(V,i) = gel(v,i);
     643       18941 :   return V;
     644             : }
     645             : /* shallow*/
     646             : INLINE GEN
     647     3431760 : vec_append(GEN V, GEN s)
     648             : {
     649     3431760 :   long i, l2 = lg(V);
     650     3431760 :   GEN res = cgetg(l2+1, typ(V));
     651    10736409 :   for (i = 1; i < l2; i++) gel(res, i) = gel(V,i);
     652     3431759 :   gel(res,l2) = s; return res;
     653             : }
     654             : /* shallow*/
     655             : INLINE GEN
     656      300961 : vec_prepend(GEN v, GEN s)
     657             : {
     658      300961 :   long i, l = lg(v);
     659      300961 :   GEN w = cgetg(l+1, typ(v));
     660      300963 :   gel(w,1) = s;
     661      769567 :   for (i = 2; i <= l; i++) gel(w,i) = gel(v,i-1);
     662      300963 :   return w;
     663             : }
     664             : /* shallow*/
     665             : INLINE GEN
     666           0 : vec_setconst(GEN v, GEN x)
     667             : {
     668           0 :   long i, l = lg(v);
     669           0 :   for (i = 1; i < l; i++) gel(v,i) = x;
     670           0 :   return v;
     671             : }
     672             : INLINE GEN
     673       72686 : vecsmall_shorten(GEN v, long n)
     674             : {
     675       72686 :   GEN V = cgetg(n+1,t_VECSMALL);
     676             :   long i;
     677      892249 :   for(i = 1; i <= n; i++) V[i] = v[i];
     678       72685 :   return V;
     679             : }
     680             : INLINE GEN
     681         526 : vecsmall_lengthen(GEN v, long n)
     682             : {
     683         526 :   long i, l = lg(v);
     684         526 :   GEN V = cgetg(n+1,t_VECSMALL);
     685       46315 :   for(i = 1; i < l; i++) V[i] = v[i];
     686         526 :   return V;
     687             : }
     688             : 
     689             : INLINE GEN
     690     4015855 : vec_to_vecsmall(GEN x)
     691    18860289 : { pari_APPLY_long(itos(gel(x,i))) }
     692             : INLINE GEN
     693      511088 : vecsmall_to_vec(GEN x)
     694     7069105 : { pari_APPLY_type(t_VEC, stoi(x[i])) }
     695             : INLINE GEN
     696        3304 : vecsmall_to_vec_inplace(GEN z)
     697             : {
     698        3304 :   long i, l = lg(z);
     699       79604 :   for (i=1; i<l; i++) gel(z,i) = stoi(z[i]);
     700        3304 :   settyp(z, t_VEC); return z;
     701             : }
     702             : INLINE GEN
     703     7761525 : vecsmall_to_col(GEN x)
     704    59564368 : { pari_APPLY_type(t_COL, stoi(x[i])) }
     705             : 
     706             : INLINE int
     707     7209139 : vecsmall_lexcmp(GEN x, GEN y)
     708             : {
     709             :   long lx,ly,l,i;
     710     7209139 :   lx = lg(x);
     711     7209139 :   ly = lg(y); l = minss(lx,ly);
     712    30649306 :   for (i=1; i<l; i++)
     713    29021866 :     if (x[i] != y[i]) return x[i]<y[i]? -1: 1;
     714     1627440 :   if (lx == ly) return 0;
     715       30578 :   return (lx < ly)? -1 : 1;
     716             : }
     717             : 
     718             : INLINE int
     719   108088071 : vecsmall_prefixcmp(GEN x, GEN y)
     720             : {
     721   108088071 :   long i, lx = lg(x), ly = lg(y), l = minss(lx,ly);
     722   542691324 :   for (i=1; i<l; i++)
     723   519806035 :     if (x[i] != y[i]) return x[i]<y[i]? -1: 1;
     724    22885289 :   return 0;
     725             : }
     726             : 
     727             : /*Can be used on t_VEC, but coeffs not gcopy-ed*/
     728             : INLINE GEN
     729      186753 : vecsmall_prepend(GEN V, long s)
     730             : {
     731      186753 :   long i, l2 = lg(V);
     732      186753 :   GEN res = cgetg(l2+1, typ(V));
     733      186753 :   res[1] = s;
     734      624853 :   for (i = 2; i <= l2; ++i) res[i] = V[i - 1];
     735      186753 :   return res;
     736             : }
     737             : 
     738             : INLINE GEN
     739     4071287 : vecsmall_append(GEN V, long s)
     740             : {
     741     4071287 :   long i, l2 = lg(V);
     742     4071287 :   GEN res = cgetg(l2+1, t_VECSMALL);
     743     5982615 :   for (i = 1; i < l2; ++i) res[i] = V[i];
     744     4071289 :   res[l2] = s; return res;
     745             : }
     746             : 
     747             : INLINE GEN
     748     1464160 : vecsmall_concat(GEN u, GEN v)
     749             : {
     750     1464160 :   long i, l1 = lg(u)-1, l2 = lg(v)-1;
     751     1464160 :   GEN res = cgetg(l1+l2+1, t_VECSMALL);
     752    11616724 :   for (i = 1; i <= l1; ++i) res[i]    = u[i];
     753    15218166 :   for (i = 1; i <= l2; ++i) res[i+l1] = v[i];
     754     1464157 :   return res;
     755             : }
     756             : 
     757             : /* return the number of indices where u and v are equal */
     758             : INLINE long
     759           0 : vecsmall_coincidence(GEN u, GEN v)
     760             : {
     761           0 :   long i, s = 0, l = minss(lg(u),lg(v));
     762           0 :   for(i=1; i<l; i++)
     763           0 :     if(u[i] == v[i]) s++;
     764           0 :   return s;
     765             : }
     766             : 
     767             : /* returns the first index i<=n such that x=v[i] if it exists, 0 otherwise */
     768             : INLINE long
     769          84 : vecsmall_isin(GEN v, long x)
     770             : {
     771          84 :   long i, l = lg(v);
     772         124 :   for (i = 1; i < l; i++)
     773          80 :     if (v[i] == x) return i;
     774          44 :   return 0;
     775             : }
     776             : 
     777             : INLINE long
     778          84 : vecsmall_pack(GEN V, long base, long mod)
     779             : {
     780          84 :   long i, s = 0;
     781         273 :   for(i=1; i<lg(V); i++) s = (base*s + V[i]) % mod;
     782          84 :   return s;
     783             : }
     784             : 
     785             : INLINE long
     786          21 : vecsmall_indexmax(GEN x)
     787             : {
     788          21 :   long i, i0 = 1, t = x[1], lx = lg(x);
     789          84 :   for (i=2; i<lx; i++)
     790          63 :     if (x[i] > t) t = x[i0=i];
     791          21 :   return i0;
     792             : }
     793             : 
     794             : INLINE long
     795     1011232 : vecsmall_max(GEN x)
     796             : {
     797     1011232 :   long i, t = x[1], lx = lg(x);
     798     2825334 :   for (i=2; i<lx; i++)
     799     1814102 :     if (x[i] > t) t = x[i];
     800     1011232 :   return t;
     801             : }
     802             : 
     803             : INLINE long
     804          21 : vecsmall_indexmin(GEN x)
     805             : {
     806          21 :   long i, i0 = 1, t = x[1], lx =lg(x);
     807          84 :   for (i=2; i<lx; i++)
     808          63 :     if (x[i] < t) t = x[i0=i];
     809          21 :   return i0;
     810             : }
     811             : 
     812             : INLINE long
     813        2324 : vecsmall_min(GEN x)
     814             : {
     815        2324 :   long i, t = x[1], lx =lg(x);
     816       16268 :   for (i=2; i<lx; i++)
     817       13944 :     if (x[i] < t) t = x[i];
     818        2324 :   return t;
     819             : }
     820             : 
     821             : INLINE int
     822    22760807 : ZV_isscalar(GEN x)
     823             : {
     824    22760807 :   long l = lg(x);
     825    54254999 :   while (--l > 1)
     826    53860917 :     if (signe(gel(x, l))) return 0;
     827      394082 :   return 1;
     828             : }
     829             : INLINE int
     830    52360320 : QV_isscalar(GEN x)
     831             : {
     832    52360320 :   long lx = lg(x),i;
     833    68049086 :   for (i=2; i<lx; i++)
     834    64331787 :     if (!isintzero(gel(x, i))) return 0;
     835     3717299 :   return 1;
     836             : }
     837             : INLINE int
     838     1140179 : RgV_isscalar(GEN x)
     839             : {
     840     1140179 :   long lx = lg(x),i;
     841     1166343 :   for (i=2; i<lx; i++)
     842     1162637 :     if (!gequal0(gel(x, i))) return 0;
     843        3706 :   return 1;
     844             : }
     845             : INLINE int
     846           0 : RgX_isscalar(GEN x)
     847             : {
     848             :   long i;
     849           0 :   for (i=lg(x)-1; i>2; i--)
     850           0 :     if (!gequal0(gel(x, i))) return 0;
     851           0 :   return 1;
     852             : }
     853             : INLINE long
     854    26877609 : RgX_equal_var(GEN x, GEN y) { return varn(x) == varn(y) && RgX_equal(x,y); }
     855             : INLINE GEN
     856         140 : RgX_to_RgV(GEN x, long N) { x = RgX_to_RgC(x, N); settyp(x, t_VEC); return x; }
     857             : 
     858             : #define RgX_type_code(t1,t2) ((t1 << 6) | t2)
     859             : 
     860             : INLINE int
     861       67689 : RgX_is_rational(GEN x)
     862             : {
     863             :   long i;
     864      308229 :   for (i = lg(x)-1; i > 1; i--)
     865      292434 :     if (!is_rational_t(typ(gel(x,i)))) return 0;
     866       15795 :   return 1;
     867             : }
     868             : INLINE int
     869    15293117 : RgX_is_ZX(GEN x)
     870             : {
     871             :   long i;
     872    65349068 :   for (i = lg(x)-1; i > 1; i--)
     873    50120293 :     if (typ(gel(x,i)) != t_INT) return 0;
     874    15228775 :   return 1;
     875             : }
     876             : INLINE int
     877      395594 : RgX_is_QX(GEN x)
     878             : {
     879      395594 :   long k = lg(x)-1;
     880     1482268 :   for ( ; k>1; k--)
     881     1086955 :     if (!is_rational_t(typ(gel(x,k)))) return 0;
     882      395313 :   return 1;
     883             : }
     884             : INLINE int
     885     3111057 : RgX_is_monomial(GEN x)
     886             : {
     887             :   long i;
     888     3111057 :   if (!signe(x)) return 0;
     889     7119066 :   for (i=lg(x)-2; i>1; i--)
     890     4721146 :     if (!isexactzero(gel(x,i))) return 0;
     891     2397920 :   return 1;
     892             : }
     893             : INLINE int
     894    31358318 : RgV_is_ZV(GEN x)
     895             : {
     896             :   long i;
     897   124665765 :   for (i = lg(x)-1; i > 0; i--)
     898    93339878 :     if (typ(gel(x,i)) != t_INT) return 0;
     899    31325887 :   return 1;
     900             : }
     901             : INLINE int
     902      140073 : RgV_is_QV(GEN x)
     903             : {
     904             :   long i;
     905      619646 :   for (i = lg(x)-1; i > 0; i--)
     906      482527 :     if (!is_rational_t(typ(gel(x,i)))) return 0;
     907      137119 :   return 1;
     908             : }
     909             : INLINE long
     910      110130 : RgV_isin_i(GEN v, GEN x, long n)
     911             : {
     912             :   long i;
     913     1033437 :   for (i = 1; i <= n; i++)
     914     1026703 :     if (gequal(gel(v,i), x)) return i;
     915        6734 :   return 0;
     916             : }
     917             : INLINE long
     918      110130 : RgV_isin(GEN v, GEN x) { return RgV_isin_i(v, x, lg(v)-1); }
     919             : 
     920             : /********************************************************************/
     921             : /**                                                                **/
     922             : /**            Dynamic arrays implementation                       **/
     923             : /**                                                                **/
     924             : /********************************************************************/
     925             : INLINE void **
     926   703903966 : pari_stack_base(pari_stack *s) { return s->data; }
     927             : 
     928             : INLINE void
     929     5738133 : pari_stack_init(pari_stack *s, size_t size, void **data)
     930             : {
     931     5738133 :   s->data = data;
     932     5738133 :   *data = NULL;
     933     5738133 :   s->n = 0;
     934     5738133 :   s->alloc = 0;
     935     5738133 :   s->size = size;
     936     5738133 : }
     937             : 
     938             : INLINE void
     939   698615912 : pari_stack_alloc(pari_stack *s, long nb)
     940             : {
     941   698615912 :   void **sdat = pari_stack_base(s);
     942   698534371 :   long alloc = s->alloc;
     943   698534371 :   if (s->n+nb <= alloc) return;
     944     2138270 :   if (!alloc)
     945     2041303 :     alloc = nb;
     946             :   else
     947             :   {
     948      197792 :     while (s->n+nb > alloc) alloc <<= 1;
     949             :   }
     950     2138270 :   pari_realloc_ip(sdat,alloc*s->size);
     951     2139955 :   s->alloc = alloc;
     952             : }
     953             : 
     954             : INLINE long
     955   605578815 : pari_stack_new(pari_stack *s) { pari_stack_alloc(s, 1); return s->n++; }
     956             : 
     957             : INLINE void
     958     5316568 : pari_stack_delete(pari_stack *s)
     959             : {
     960     5316568 :   void **sdat = pari_stack_base(s);
     961     5308136 :   if (*sdat) pari_free(*sdat);
     962     5331599 : }
     963             : 
     964             : INLINE void
     965        5830 : pari_stack_pushp(pari_stack *s, void *u)
     966             : {
     967        5830 :   long n = pari_stack_new(s);
     968        5830 :   void **sdat =(void**) *pari_stack_base(s);
     969        5830 :   sdat[n] = u;
     970        5830 : }
     971             : 
     972             : /*******************************************************************/
     973             : /*                                                                 */
     974             : /*                            EXTRACT                              */
     975             : /*                                                                 */
     976             : /*******************************************************************/
     977             : INLINE GEN
     978   641298225 : vecslice(GEN A, long y1, long y2)
     979             : {
     980   641298225 :   long i,lB = y2 - y1 + 2;
     981   641298225 :   GEN B = cgetg(lB, typ(A));
     982  2855024107 :   for (i=1; i<lB; i++) B[i] = A[y1-1+i];
     983   641302034 :   return B;
     984             : }
     985             : INLINE GEN
     986     2645210 : vecslicepermute(GEN A, GEN p, long y1, long y2)
     987             : {
     988     2645210 :   long i,lB = y2 - y1 + 2;
     989     2645210 :   GEN B = cgetg(lB, typ(A));
     990    29932059 :   for (i=1; i<lB; i++) B[i] = A[p[y1-1+i]];
     991     2645202 :   return B;
     992             : }
     993             : /* rowslice(rowpermute(A,p), x1, x2) */
     994             : INLINE GEN
     995      182774 : rowslicepermute(GEN x, GEN p, long j1, long j2)
     996      771451 : { pari_APPLY_same(vecslicepermute(gel(x,i),p,j1,j2)) }
     997             : 
     998             : INLINE GEN
     999    78325946 : rowslice(GEN x, long j1, long j2)
    1000   657232633 : { pari_APPLY_same(vecslice(gel(x,i), j1, j2)) }
    1001             : 
    1002             : INLINE GEN
    1003    16594795 : matslice(GEN A, long x1, long x2, long y1, long y2)
    1004    16594795 : { return rowslice(vecslice(A, y1, y2), x1, x2); }
    1005             : 
    1006             : /* shallow, remove coeff of index j */
    1007             : INLINE GEN
    1008         273 : rowsplice(GEN x, long j)
    1009        1225 : { pari_APPLY_same(vecsplice(gel(x,i), j)) }
    1010             : 
    1011             : /* shallow, remove coeff of index j */
    1012             : INLINE GEN
    1013      354683 : vecsplice(GEN a, long j)
    1014             : {
    1015      354683 :   long i, k, l = lg(a);
    1016             :   GEN b;
    1017      354683 :   if (l == 1) pari_err(e_MISC, "incorrect component in vecsplice");
    1018      354683 :   b = cgetg(l-1, typ(a));
    1019     1503108 :   for (i = k = 1; i < l; i++)
    1020     1148432 :     if (i != j) gel(b, k++) = gel(a,i);
    1021      354676 :   return b;
    1022             : }
    1023             : /* shallow */
    1024             : INLINE GEN
    1025        1036 : RgM_minor(GEN a, long i, long j)
    1026             : {
    1027        1036 :   GEN b = vecsplice(a, j);
    1028        1036 :   long k, l = lg(b);
    1029        4242 :   for (k = 1; k < l; k++) gel(b,k) = vecsplice(gel(b,k), i);
    1030        1036 :   return b;
    1031             : }
    1032             : 
    1033             : /* A[x0,] */
    1034             : INLINE GEN
    1035      762810 : row(GEN x, long j)
    1036     6687288 : { pari_APPLY_type(t_VEC, gcoeff(x, j, i)) }
    1037             : INLINE GEN
    1038     8741175 : Flm_row(GEN x, long j)
    1039   231878249 : { pari_APPLY_ulong((ulong)coeff(x, j, i)) }
    1040             : /* A[x0,] */
    1041             : INLINE GEN
    1042      204988 : rowcopy(GEN x, long j)
    1043     2105509 : { pari_APPLY_type(t_VEC, gcopy(gcoeff(x, j, i))) }
    1044             : /* A[x0, x1..x2] */
    1045             : INLINE GEN
    1046         987 : row_i(GEN A, long x0, long x1, long x2)
    1047             : {
    1048         987 :   long i, lB = x2 - x1 + 2;
    1049         987 :   GEN B  = cgetg(lB, t_VEC);
    1050        2989 :   for (i=x1; i<=x2; i++) gel(B, i) = gcoeff(A, x0, i);
    1051         987 :   return B;
    1052             : }
    1053             : 
    1054             : INLINE GEN
    1055      697039 : vecreverse(GEN A)
    1056             : {
    1057             :   long i, l;
    1058      697039 :   GEN B = cgetg_copy(A, &l);
    1059     2407783 :   for (i=1; i<l; i++) gel(B, i) = gel(A, l-i);
    1060      697039 :   return B;
    1061             : }
    1062             : 
    1063             : INLINE GEN
    1064        3052 : vecsmall_reverse(GEN A)
    1065             : {
    1066             :   long i, l;
    1067        3052 :   GEN B = cgetg_copy(A, &l);
    1068       12698 :   for (i=1; i<l; i++) B[i] = A[l-i];
    1069        3052 :   return B;
    1070             : }
    1071             : 
    1072             : INLINE void
    1073        2570 : vecreverse_inplace(GEN y)
    1074             : {
    1075        2570 :   long l = lg(y), lim = l>>1, i;
    1076        8242 :   for (i = 1; i <= lim; i++)
    1077             :   {
    1078        5672 :     GEN z = gel(y,i);
    1079        5672 :     gel(y,i)    = gel(y,l-i);
    1080        5672 :     gel(y,l-i) = z;
    1081             :   }
    1082        2570 : }
    1083             : 
    1084             : INLINE GEN
    1085    77947701 : vecsmallpermute(GEN A, GEN p) { return perm_mul(A, p); }
    1086             : 
    1087             : INLINE GEN
    1088    19831911 : vecpermute(GEN A, GEN x)
    1089   112457516 : { pari_APPLY_type(typ(A), gel(A, x[i])) }
    1090             : 
    1091             : INLINE GEN
    1092     6933198 : veclast(GEN A) { return gel(A, lg(A)-1); }
    1093             : 
    1094             : INLINE GEN
    1095    14413312 : rowpermute(GEN x, GEN p)
    1096   100757856 : { pari_APPLY_same(typ(gel(x,i)) == t_VECSMALL ? vecsmallpermute(gel(x, i), p)
    1097             :                                               : vecpermute(gel(x, i), p))
    1098             : }
    1099             : /*******************************************************************/
    1100             : /*                                                                 */
    1101             : /*                          PERMUTATIONS                           */
    1102             : /*                                                                 */
    1103             : /*******************************************************************/
    1104             : INLINE GEN
    1105     3149326 : identity_zv(long n)
    1106             : {
    1107     3149326 :   GEN v = cgetg(n+1, t_VECSMALL);
    1108             :   long i;
    1109    32212504 :   for (i = 1; i <= n; i++) v[i] = i;
    1110     3149311 :   return v;
    1111             : }
    1112             : INLINE GEN
    1113        4333 : identity_ZV(long n)
    1114             : {
    1115        4333 :   GEN v = cgetg(n+1, t_VEC);
    1116             :   long i;
    1117       51898 :   for (i = 1; i <= n; i++) gel(v,i) = utoipos(i);
    1118        4333 :   return v;
    1119             : }
    1120             : /* identity permutation */
    1121             : INLINE GEN
    1122     3124983 : identity_perm(long n) { return identity_zv(n); }
    1123             : 
    1124             : /* assume d <= n */
    1125             : INLINE GEN
    1126       99911 : cyclic_perm(long n, long d)
    1127             : {
    1128       99911 :   GEN perm = cgetg(n+1, t_VECSMALL);
    1129             :   long i;
    1130      520240 :   for (i = 1; i <= n-d; i++) perm[i] = i+d;
    1131      226702 :   for (     ; i <= n;   i++) perm[i] = i-n+d;
    1132       99911 :   return perm;
    1133             : }
    1134             : 
    1135             : /* Multiply (compose) two permutations */
    1136             : INLINE GEN
    1137    80141928 : perm_mul(GEN s, GEN x)
    1138  1014085538 : { pari_APPLY_long(s[x[i]]) }
    1139             : 
    1140             : INLINE GEN
    1141         728 : perm_sqr(GEN x)
    1142       18284 : { pari_APPLY_long(x[x[i]]) }
    1143             : 
    1144             : /* Compute the inverse (reciprocal) of a permutation. */
    1145             : INLINE GEN
    1146     2778237 : perm_inv(GEN x)
    1147             : {
    1148             :   long i, lx;
    1149     2778237 :   GEN y = cgetg_copy(x, &lx);
    1150    39054910 :   for (i=1; i<lx; i++) y[ x[i] ] = i;
    1151     2778225 :   return y;
    1152             : }
    1153             : /* Return s*t*s^-1 */
    1154             : INLINE GEN
    1155      418299 : perm_conj(GEN s, GEN t)
    1156             : {
    1157             :   long i, l;
    1158      418299 :   GEN v = cgetg_copy(s, &l);
    1159     6857893 :   for (i = 1; i < l; i++) v[ s[i] ] = s[ t[i] ];
    1160      418299 :   return v;
    1161             : }
    1162             : 
    1163             : INLINE void
    1164   490272678 : pari_free(void *pointer)
    1165             : {
    1166   490272678 :   BLOCK_SIGINT_START;
    1167   490321302 :   free(pointer);
    1168   490321302 :   BLOCK_SIGINT_END;
    1169   490319619 : }
    1170             : INLINE void*
    1171   720596287 : pari_malloc(size_t size)
    1172             : {
    1173   720596287 :   if (size)
    1174             :   {
    1175             :     char *tmp;
    1176   720597049 :     BLOCK_SIGINT_START;
    1177   720666608 :     tmp = (char*)malloc(size);
    1178   720666608 :     BLOCK_SIGINT_END;
    1179   720663087 :     if (!tmp) pari_err(e_MEM);
    1180   720673603 :     return tmp;
    1181             :   }
    1182           0 :   return NULL;
    1183             : }
    1184             : INLINE void*
    1185        1883 : pari_realloc(void *pointer, size_t size)
    1186             : {
    1187             :   char *tmp;
    1188             : 
    1189        1883 :   BLOCK_SIGINT_START;
    1190        1883 :   if (!pointer) tmp = (char *) malloc(size);
    1191        1883 :   else tmp = (char *) realloc(pointer,size);
    1192        1883 :   BLOCK_SIGINT_END;
    1193        1883 :   if (!tmp) pari_err(e_MEM);
    1194        1883 :   return tmp;
    1195             : }
    1196             : INLINE void
    1197     2142170 : pari_realloc_ip(void **pointer, size_t size)
    1198             : {
    1199             :   char *tmp;
    1200     2142170 :   BLOCK_SIGINT_START;
    1201     2141815 :   if (!*pointer) tmp = (char *) malloc(size);
    1202      101123 :   else tmp = (char *) realloc(*pointer,size);
    1203     2141815 :   if (!tmp) pari_err(e_MEM);
    1204     2141815 :   *pointer = tmp;
    1205     2141815 :   BLOCK_SIGINT_END;
    1206     2141531 : }
    1207             : 
    1208             : INLINE void*
    1209       47377 : pari_calloc(size_t size)
    1210             : {
    1211       47377 :   void *t = pari_malloc(size);
    1212       47377 :   memset(t, 0, size); return t;
    1213             : }
    1214             : INLINE GEN
    1215       10138 : cgetalloc(size_t l, long t)
    1216             : { /* evallg may raise e_OVERFLOW, which would leak x */
    1217       10138 :   ulong x0 = evaltyp(t) | evallg(l);
    1218       10138 :   GEN x = (GEN)pari_malloc(l * sizeof(long));
    1219       10138 :   x[0] = x0; return x;
    1220             : }
    1221             : 
    1222             : /*******************************************************************/
    1223             : /*                                                                 */
    1224             : /*                       GARBAGE COLLECTION                        */
    1225             : /*                                                                 */
    1226             : /*******************************************************************/
    1227             : /* copy integer x as if we had set_avma(av) */
    1228             : INLINE GEN
    1229  7893037831 : icopy_avma(GEN x, pari_sp av)
    1230             : {
    1231  7893037831 :   long i = lgefint(x), lx = i;
    1232  7893037831 :   GEN y = ((GEN)av) - i;
    1233 57832132996 :   while (--i > 0) y[i] = x[i];
    1234  7893037831 :   y[0] = evaltyp(t_INT)|evallg(lx);
    1235  7896219252 :   return y;
    1236             : }
    1237             : /* copy leaf x as if we had set_avma(av) */
    1238             : INLINE GEN
    1239   548500010 : leafcopy_avma(GEN x, pari_sp av)
    1240             : {
    1241   548500010 :   long i = lg(x);
    1242   548500010 :   GEN y = ((GEN)av) - i;
    1243  2983750989 :   while (--i > 0) y[i] = x[i];
    1244   548500010 :   y[0] = x[0] & (~CLONEBIT);
    1245   548500010 :   return y;
    1246             : }
    1247             : INLINE GEN
    1248  1072812101 : gerepileuptoleaf(pari_sp av, GEN x)
    1249             : {
    1250             :   long lx;
    1251             :   GEN q;
    1252             : 
    1253  1072812101 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1254  1071512887 :   lx = lg(x);
    1255  1071512887 :   q = ((GEN)av) - lx;
    1256  1071512887 :   set_avma((pari_sp)q);
    1257 10804180098 :   while (--lx >= 0) q[lx] = x[lx];
    1258  1071099661 :   return q;
    1259             : }
    1260             : INLINE GEN
    1261  4035044433 : gc_INT(pari_sp av, GEN x)
    1262             : {
    1263  4035044433 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1264  3599317257 :   set_avma((pari_sp)icopy_avma(x, av));
    1265  3602751740 :   return (GEN)avma;
    1266             : }
    1267             : INLINE GEN
    1268  1860579891 : gerepileupto(pari_sp av, GEN x)
    1269             : {
    1270  1860579891 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1271  1677417403 :   switch(typ(x))
    1272             :   { /* non-default = !is_recursive_t(tq) */
    1273   480691692 :     case t_INT: return gc_INT(av, x);
    1274   338210630 :     case t_REAL:
    1275             :     case t_STR:
    1276   338210630 :     case t_VECSMALL: return gerepileuptoleaf(av,x);
    1277   858516674 :     default:
    1278             :       /* NB: x+i --> ((long)x) + i*sizeof(long) */
    1279   858516674 :       return gerepile(av, (pari_sp) (x+lg(x)), x);
    1280             :   }
    1281             : }
    1282             : 
    1283             : /* gerepileupto(av, gcopy(x)) */
    1284             : INLINE GEN
    1285   227238039 : gc_GEN(pari_sp av, GEN x)
    1286             : {
    1287   227238039 :   if (is_recursive_t(typ(x)))
    1288             :   {
    1289   207811978 :     GENbin *p = copy_bin(x);
    1290   207831799 :     set_avma(av); return bin_copy(p);
    1291             :   }
    1292             :   else
    1293             :   {
    1294    19425910 :     set_avma(av);
    1295    19426100 :     if (x < (GEN)av) {
    1296    19218324 :       if (x < (GEN)pari_mainstack->bot) new_chunk(lg(x));
    1297    19218331 :       x = leafcopy_avma(x, av);
    1298    19218356 :       set_avma((pari_sp)x);
    1299             :     } else
    1300      207780 :       x = leafcopy(x);
    1301    19426131 :     return x;
    1302             :   }
    1303             : }
    1304             : 
    1305             : INLINE void
    1306    47774524 : guncloneNULL(GEN x) { if (x) gunclone(x); }
    1307             : INLINE void
    1308     1365120 : guncloneNULL_deep(GEN x) { if (x) gunclone_deep(x); }
    1309             : 
    1310             : /* Takes an array of pointers to GENs, of length n. Copies all
    1311             :  * objects to contiguous locations and cleans up the stack between
    1312             :  * av and avma. */
    1313             : INLINE void
    1314      984774 : gerepilemany(pari_sp av, GEN* gptr[], int n)
    1315             : {
    1316             :   int i;
    1317     3912389 :   for (i=0; i<n; i++) *gptr[i] = (GEN)copy_bin(*gptr[i]);
    1318      984703 :   set_avma(av);
    1319     3912917 :   for (i=0; i<n; i++) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1320      984949 : }
    1321             : 
    1322             : INLINE void
    1323    19230516 : gerepileall(pari_sp av, int n, ...)
    1324             : {
    1325             :   int i;
    1326    19230516 :   va_list a; va_start(a, n);
    1327    19230516 :   if (n < 10)
    1328             :   {
    1329             :     GEN *gptr[10];
    1330    58313122 :     for (i=0; i<n; i++)
    1331    39081894 :     { gptr[i] = va_arg(a,GEN*); *gptr[i] = (GEN)copy_bin(*gptr[i]); }
    1332    19231228 :     set_avma(av);
    1333    58314194 :     for (--i; i>=0; i--) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1334             : 
    1335             :   }
    1336             :   else
    1337             :   {
    1338           1 :     GEN **gptr = (GEN**)  pari_malloc(n*sizeof(GEN*));
    1339           0 :     for (i=0; i<n; i++)
    1340           0 :     { gptr[i] = va_arg(a,GEN*); *gptr[i] = (GEN)copy_bin(*gptr[i]); }
    1341           0 :     set_avma(av);
    1342           0 :     for (--i; i>=0; i--) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1343           0 :     pari_free(gptr);
    1344             :   }
    1345    19231907 :   va_end(a);
    1346    19231907 : }
    1347             : 
    1348             : /* assume 1 <= n < 10 */
    1349             : INLINE GEN
    1350    86046084 : gc_all(pari_sp av, int n, ...)
    1351             : {
    1352             :   int i;
    1353             :   GEN *v[10];
    1354    86046084 :   va_list a; va_start(a, n);
    1355   289117908 :   for (i=0; i<n; i++) { v[i] = va_arg(a,GEN*); *v[i] = (GEN)copy_bin(*v[i]); }
    1356    86046390 :   set_avma(av);
    1357   289118803 :   for (i=0; i<n; i++) *v[i] = bin_copy((GENbin*)*v[i]);
    1358    86046595 :   return *v[0];
    1359             : }
    1360             : 
    1361             : INLINE void
    1362     2202151 : gerepilecoeffs(pari_sp av, GEN x, int n)
    1363             : {
    1364             :   int i;
    1365    26224665 :   for (i=0; i<n; i++) gel(x,i) = (GEN)copy_bin(gel(x,i));
    1366     2202693 :   set_avma(av);
    1367    26226051 :   for (i=0; i<n; i++) gel(x,i) = bin_copy((GENbin*)x[i]);
    1368     2202338 : }
    1369             : 
    1370             : /* p from copy_bin. Copy p->x back to stack, then destroy p */
    1371             : INLINE GEN
    1372   476984412 : bin_copy(GENbin *p)
    1373             : {
    1374             :   GEN x, y, base;
    1375             :   long dx, len;
    1376             : 
    1377   476984412 :   x   = p->x; if (!x) { pari_free(p); return gen_0; }
    1378   447986551 :   len = p->len;
    1379   447986551 :   base= p->base; dx = x - base;
    1380   447986551 :   y = (GEN)memcpy((void*)new_chunk(len), (void*)GENbinbase(p), len*sizeof(long));
    1381   447980052 :   y += dx;
    1382   447980052 :   p->rebase(y, ((ulong)y-(ulong)x));
    1383   447984407 :   pari_free(p); return y;
    1384             : }
    1385             : 
    1386             : INLINE GEN
    1387   924965187 : GENbinbase(GENbin *p) { return (GEN)(p + 1); }
    1388             : 
    1389             : INLINE void
    1390   117687099 : cgiv(GEN x)
    1391             : {
    1392   117687099 :   pari_sp av = (pari_sp)(x+lg(x));
    1393   117687099 :   if (isonstack((GEN)av)) set_avma(av);
    1394   117700634 : }
    1395             : 
    1396             : INLINE void
    1397     1881569 : killblock(GEN x) { gunclone(x); }
    1398             : 
    1399             : INLINE int
    1400   291184252 : is_universal_constant(GEN x) { return (x >= gen_0 && x <= ghalf); }
    1401             : 
    1402             : /*******************************************************************/
    1403             : /*                                                                 */
    1404             : /*                    CONVERSION / ASSIGNMENT                      */
    1405             : /*                                                                 */
    1406             : /*******************************************************************/
    1407             : /* z is a type which may be a t_COMPLEX component (not a t_QUAD) */
    1408             : INLINE GEN
    1409    17937234 : cxcompotor(GEN z, long prec)
    1410             : {
    1411    17937234 :   switch(typ(z))
    1412             :   {
    1413    11784734 :     case t_INT:  return itor(z, prec);
    1414      293293 :     case t_FRAC: return fractor(z, prec);
    1415     5859426 :     case t_REAL: return rtor(z, prec);
    1416           0 :     default: pari_err_TYPE("cxcompotor",z);
    1417             :              return NULL; /* LCOV_EXCL_LINE */
    1418             :   }
    1419             : }
    1420             : INLINE GEN
    1421     8951920 : cxtofp(GEN x, long prec)
    1422     8951920 : { retmkcomplex(cxcompotor(gel(x,1),prec), cxcompotor(gel(x,2),prec)); }
    1423             : 
    1424             : INLINE GEN
    1425      389553 : cxtoreal(GEN q)
    1426      389553 : { return (typ(q) == t_COMPLEX && gequal0(gel(q,2)))? gel(q,1): q; }
    1427             : 
    1428             : INLINE double
    1429    60616712 : gtodouble(GEN x)
    1430             : {
    1431    60616712 :   if (typ(x)!=t_REAL) {
    1432     8160439 :     pari_sp av = avma;
    1433     8160439 :     x = gtofp(x, DEFAULTPREC);
    1434     8159896 :     if (typ(x)!=t_REAL) pari_err_TYPE("gtodouble [t_REAL expected]", x);
    1435     8159896 :     set_avma(av);
    1436             :   }
    1437    60616067 :   return rtodbl(x);
    1438             : }
    1439             : 
    1440             : INLINE int
    1441     2966925 : gisdouble(GEN x, double *g)
    1442             : {
    1443     2966925 :   if (typ(x)!=t_REAL) {
    1444       41899 :     pari_sp av = avma;
    1445       41899 :     x = gtofp(x, DEFAULTPREC);
    1446       41899 :     if (typ(x)!=t_REAL) pari_err_TYPE("gisdouble [t_REAL expected]", x);
    1447       41899 :     set_avma(av);
    1448             :   }
    1449     2966926 :   if (expo(x) >= 0x3ff) return 0;
    1450     2966926 :   *g = rtodbl(x); return 1;
    1451             : }
    1452             : 
    1453             : INLINE long
    1454    85802303 : gtos(GEN x) {
    1455    85802303 :   if (typ(x) != t_INT) pari_err_TYPE("gtos [integer expected]",x);
    1456    85802289 :   return itos(x);
    1457             : }
    1458             : 
    1459             : INLINE ulong
    1460      102549 : gtou(GEN x) {
    1461      102549 :   if (typ(x) != t_INT || signe(x)<0)
    1462           7 :     pari_err_TYPE("gtou [integer >=0 expected]",x);
    1463      102542 :   return itou(x);
    1464             : }
    1465             : 
    1466             : INLINE GEN
    1467    45562176 : absfrac(GEN x)
    1468             : {
    1469    45562176 :   GEN y = cgetg(3, t_FRAC);
    1470    45562204 :   gel(y,1) = absi(gel(x,1));
    1471    45562227 :   gel(y,2) = icopy(gel(x,2)); return y;
    1472             : }
    1473             : INLINE GEN
    1474       27313 : absfrac_shallow(GEN x)
    1475       27313 : { return signe(gel(x,1))>0? x: mkfrac(negi(gel(x,1)), gel(x,2)); }
    1476             : INLINE GEN
    1477     7911649 : Q_abs(GEN x) { return (typ(x) == t_INT)? absi(x): absfrac(x); }
    1478             : INLINE GEN
    1479      118528 : Q_abs_shallow(GEN x)
    1480      118528 : { return (typ(x) == t_INT)? absi_shallow(x): absfrac_shallow(x); }
    1481             : INLINE GEN
    1482       13083 : R_abs_shallow(GEN x)
    1483       13083 : { return (typ(x) == t_FRAC)? absfrac_shallow(x): mpabs_shallow(x); }
    1484             : INLINE GEN
    1485           0 : R_abs(GEN x)
    1486           0 : { return (typ(x) == t_FRAC)? absfrac(x): mpabs(x); }
    1487             : 
    1488             : /* Force z to be of type real/complex with floating point components */
    1489             : INLINE GEN
    1490   252435105 : gtofp(GEN z, long prec)
    1491             : {
    1492   252435105 :   switch(typ(z))
    1493             :   {
    1494   213698920 :     case t_INT:  return itor(z, prec);
    1495     4097489 :     case t_FRAC: return fractor(z, prec);
    1496    25947259 :     case t_REAL: return rtor(z, prec);
    1497     8698867 :     case t_COMPLEX: {
    1498     8698867 :       GEN a = gel(z,1), b = gel(z,2);
    1499     8698867 :       if (isintzero(b)) return cxcompotor(a, prec);
    1500     8698871 :       if (isintzero(a)) {
    1501        9198 :         GEN y = cgetg(3, t_COMPLEX);
    1502        9198 :         b = cxcompotor(b, prec);
    1503        9198 :         gel(y,1) = real_0_bit(expo(b) - prec);
    1504        9198 :         gel(y,2) = b; return y;
    1505             :       }
    1506     8689651 :       return cxtofp(z, prec);
    1507             :     }
    1508           0 :     case t_QUAD: return quadtofp(z, prec);
    1509           0 :     default: pari_err_TYPE("gtofp",z);
    1510             :              return NULL; /* LCOV_EXCL_LINE */
    1511             :   }
    1512             : }
    1513             : /* Force z to be of type real / int */
    1514             : INLINE GEN
    1515       22428 : gtomp(GEN z, long prec)
    1516             : {
    1517       22428 :   switch(typ(z))
    1518             :   {
    1519          42 :     case t_INT:  return z;
    1520       22386 :     case t_FRAC: return fractor(z, prec);
    1521           0 :     case t_REAL: return rtor(z, prec);
    1522           0 :     case t_QUAD: z = quadtofp(z, prec);
    1523           0 :                  if (typ(z) == t_REAL) return z;
    1524           0 :     default: pari_err_TYPE("gtomp",z);
    1525             :              return NULL; /* LCOV_EXCL_LINE */
    1526             :   }
    1527             : }
    1528             : 
    1529             : INLINE GEN
    1530     7131748 : RgX_gtofp(GEN x, long prec)
    1531    37206870 : { pari_APPLY_pol_normalized(gtofp(gel(x,i), prec)); }
    1532             : 
    1533             : INLINE GEN
    1534    33705734 : RgC_gtofp(GEN x, long prec)
    1535   217354335 : { pari_APPLY_type(t_COL, gtofp(gel(x,i), prec)) }
    1536             : 
    1537             : INLINE GEN
    1538          56 : RgV_gtofp(GEN x, long prec)
    1539        4781 : { pari_APPLY_type(t_VEC, gtofp(gel(x,i), prec)) }
    1540             : 
    1541             : INLINE GEN
    1542     8177993 : RgM_gtofp(GEN x, long prec)
    1543    41255041 : { pari_APPLY_same(RgC_gtofp(gel(x,i), prec)) }
    1544             : 
    1545             : INLINE GEN
    1546         574 : RgC_gtomp(GEN x, long prec)
    1547       23002 : { pari_APPLY_type(t_COL, gtomp(gel(x,i), prec)) }
    1548             : 
    1549             : INLINE GEN
    1550          21 : RgM_gtomp(GEN x, long prec)
    1551         595 : { pari_APPLY_same(RgC_gtomp(gel(x,i), prec)) }
    1552             : 
    1553             : INLINE GEN
    1554       60522 : RgX_fpnorml2(GEN x, long prec)
    1555             : {
    1556       60522 :   pari_sp av = avma;
    1557       60522 :   return gerepileupto(av, gnorml2(RgX_gtofp(x, prec)));
    1558             : }
    1559             : INLINE GEN
    1560      617599 : RgC_fpnorml2(GEN x, long prec)
    1561             : {
    1562      617599 :   pari_sp av = avma;
    1563      617599 :   return gerepileupto(av, gnorml2(RgC_gtofp(x, prec)));
    1564             : }
    1565             : INLINE GEN
    1566       22374 : RgM_fpnorml2(GEN x, long prec)
    1567             : {
    1568       22374 :   pari_sp av = avma;
    1569       22374 :   return gerepileupto(av, gnorml2(RgM_gtofp(x, prec)));
    1570             : }
    1571             : 
    1572             : /* y a t_REAL */
    1573             : INLINE void
    1574      220535 : affgr(GEN x, GEN y)
    1575             : {
    1576             :   pari_sp av;
    1577      220535 :   switch(typ(x)) {
    1578        5999 :     case t_INT:  affir(x,y); break;
    1579      214536 :     case t_REAL: affrr(x,y); break;
    1580           0 :     case t_FRAC: rdiviiz(gel(x,1),gel(x,2), y); break;
    1581           0 :     case t_QUAD: av = avma; affgr(quadtofp(x,realprec(y)), y); set_avma(av); break;
    1582           0 :     default: pari_err_TYPE2("=",x,y);
    1583             :   }
    1584      220535 : }
    1585             : 
    1586             : INLINE GEN
    1587      244489 : affc_fixlg(GEN x, GEN res)
    1588             : {
    1589      244489 :   if (typ(x) == t_COMPLEX)
    1590             :   {
    1591      206878 :     affrr_fixlg(gel(x,1), gel(res,1));
    1592      206878 :     affrr_fixlg(gel(x,2), gel(res,2));
    1593             :   }
    1594             :   else
    1595             :   {
    1596       37611 :     set_avma((pari_sp)(res+3));
    1597       37611 :     res = cgetr(realprec(gel(res,1)));
    1598       37612 :     affrr_fixlg(x, res);
    1599             :   }
    1600      244491 :   return res;
    1601             : }
    1602             : 
    1603             : INLINE GEN
    1604           0 : trunc_safe(GEN x) { long e; return gcvtoi(x,&e); }
    1605             : 
    1606             : /*******************************************************************/
    1607             : /*                                                                 */
    1608             : /*                          LENGTH CONVERSIONS                     */
    1609             : /*                                                                 */
    1610             : /*******************************************************************/
    1611             : INLINE long
    1612       41486 : ndec2nlong(long x) { return 1 + (long)((x)*(LOG2_10/BITS_IN_LONG)); }
    1613             : INLINE long
    1614       33216 : ndec2prec(long x) { return ndec2nlong(x) << TWOPOTBITS_IN_LONG; }
    1615             : INLINE long
    1616        8270 : ndec2nbits(long x) { return ndec2nlong(x) << TWOPOTBITS_IN_LONG; }
    1617             : /* Fast implementation of ceil(x / (8*sizeof(long))); typecast to (ulong)
    1618             :  * to avoid overflow. Faster than 1 + ((x-1)>>TWOPOTBITS_IN_LONG)) :
    1619             :  *   addl, shrl instead of subl, sarl, addl */
    1620             : INLINE long
    1621    12567211 : nbits2nlong(long x) {
    1622    12567211 :   return (long)(((ulong)x+BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1623             : }
    1624             : 
    1625             : INLINE long
    1626  1477211232 : nbits2extraprec(long x) {
    1627  1477211232 :   return (((ulong)x+BITS_IN_LONG-1)>>TWOPOTBITS_IN_LONG) << TWOPOTBITS_IN_LONG;
    1628             : }
    1629             : 
    1630             : INLINE long
    1631   185619154 : nbits2prec(long x) {
    1632   185619154 :   return (((ulong)x+BITS_IN_LONG-1)>>TWOPOTBITS_IN_LONG) << TWOPOTBITS_IN_LONG;
    1633             : }
    1634             : 
    1635             : INLINE long
    1636  4461938250 : prec2lg(long x) {
    1637  4461938250 :   return (long)(((ulong)x+3*BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1638             : }
    1639             : /* ceil(x / sizeof(long)) */
    1640             : INLINE long
    1641   120799880 : nchar2nlong(long x) {
    1642   120799880 :   return (long)(((ulong)x+sizeof(long)-1) >> (TWOPOTBITS_IN_LONG-3L));
    1643             : }
    1644             : INLINE long
    1645   104446311 : prec2nbits(long x) { return x; }
    1646             : INLINE double
    1647     3175234 : bit_accuracy_mul(long x, double y) { return (x-2) * (BITS_IN_LONG*y); }
    1648             : INLINE double
    1649      575818 : prec2nbits_mul(long x, double y) { return x * y; }
    1650             : INLINE long
    1651   141500056 : bit_prec(GEN x) { return realprec(x); }
    1652             : INLINE long
    1653  3118621709 : bit_accuracy(long x) { return (x-2) * BITS_IN_LONG; }
    1654             : INLINE long
    1655        9778 : prec2ndec(long x) { return (long)(x * LOG10_2); }
    1656             : INLINE long
    1657         228 : nbits2ndec(long x) { return prec2ndec(x); }
    1658             : INLINE long
    1659      475317 : precdbl(long x) {return x << 1;}
    1660             : INLINE long
    1661  8066387155 : divsBIL(long n) { return n >> TWOPOTBITS_IN_LONG; }
    1662             : INLINE long
    1663  7976537454 : remsBIL(long n) { return n & (BITS_IN_LONG-1); }
    1664             : 
    1665             : /*********************************************************************/
    1666             : /**                                                                 **/
    1667             : /**                      OPERATIONS MODULO m                        **/
    1668             : /**                                                                 **/
    1669             : /*********************************************************************/
    1670             : /* Assume m > 0, more efficient if 0 <= a, b < m */
    1671             : 
    1672             : INLINE GEN
    1673    80582557 : Fp_red(GEN a, GEN m) { return modii(a, m); }
    1674             : INLINE GEN
    1675   173385515 : Fp_add(GEN a, GEN b, GEN m)
    1676             : {
    1677   173385515 :   pari_sp av=avma;
    1678   173385515 :   GEN p = addii(a,b);
    1679   172834240 :   long s = signe(p);
    1680   172834240 :   if (!s) return p; /* = gen_0 */
    1681   160013330 :   if (s > 0) /* general case */
    1682             :   {
    1683   159757379 :     GEN t = subii(p, m);
    1684   159645342 :     s = signe(t);
    1685   159645342 :     if (!s) return gc_const(av, gen_0);
    1686   151371030 :     if (s < 0) return gc_const((pari_sp)p, p);
    1687    72305730 :     if (cmpii(t, m) < 0) return gc_INT(av, t); /* general case ! */
    1688     3289324 :     p = remii(t, m);
    1689             :   }
    1690             :   else
    1691      260352 :     p = modii(p, m);
    1692     3549782 :   return gc_INT(av, p);
    1693             : }
    1694             : INLINE GEN
    1695    21206150 : Fp_double(GEN x, GEN N)
    1696             : {
    1697    21206150 :   GEN z = shifti(x, 1);
    1698    20844327 :   return cmpii(z, N) >= 0? subii(z, N): z;
    1699             : }
    1700             : INLINE GEN
    1701   203118348 : Fp_sub(GEN a, GEN b, GEN m)
    1702             : {
    1703   203118348 :   pari_sp av=avma;
    1704   203118348 :   GEN p = subii(a,b);
    1705   201554517 :   long s = signe(p);
    1706   201554517 :   if (!s) return p; /* = gen_0 */
    1707   185881925 :   if (s > 0)
    1708             :   {
    1709    93200919 :     if (cmpii(p, m) < 0) return p; /* general case ! */
    1710     1449965 :     p = remii(p, m);
    1711             :   }
    1712             :   else
    1713             :   {
    1714    92681006 :     GEN t = addii(p, m);
    1715    94198436 :     if (!s) return gc_const(av, gen_0);
    1716    94196219 :     if (s > 0) return gc_INT(av, t); /* general case ! */
    1717    94196219 :     p = modii(t, m);
    1718             :   }
    1719    95992013 :   return gc_INT(av, p);
    1720             : }
    1721             : INLINE GEN
    1722    28821907 : Fp_neg(GEN b, GEN m)
    1723             : {
    1724    28821907 :   pari_sp av = avma;
    1725    28821907 :   long s = signe(b);
    1726             :   GEN p;
    1727    28821907 :   if (!s) return gen_0;
    1728    24388134 :   if (s > 0)
    1729             :   {
    1730    23262065 :     p = subii(m, b);
    1731    23261810 :     if (signe(p) >= 0) return p; /* general case ! */
    1732      387034 :     p = modii(p, m);
    1733             :   } else
    1734     1126513 :     p = remii(negi(b), m);
    1735     1513795 :   return gc_INT(av, p);
    1736             : }
    1737             : 
    1738             : INLINE GEN
    1739      246991 : Fp_halve(GEN a, GEN p)
    1740             : {
    1741      246991 :   if (mpodd(a)) a = addii(a,p);
    1742      246991 :   return shifti(a,-1);
    1743             : }
    1744             : 
    1745             : /* assume 0 <= u < p and ps2 = p>>1 */
    1746             : INLINE GEN
    1747    75601471 : Fp_center(GEN u, GEN p, GEN ps2)
    1748    75601471 : { return abscmpii(u,ps2)<=0? icopy(u): subii(u,p); }
    1749             : /* same without copy */
    1750             : INLINE GEN
    1751    14147564 : Fp_center_i(GEN u, GEN p, GEN ps2)
    1752    14147564 : { return abscmpii(u,ps2)<=0? u: subii(u,p); }
    1753             : 
    1754             : /* x + y*z mod p */
    1755             : INLINE GEN
    1756    11285183 : Fp_addmul(GEN x, GEN y, GEN z, GEN p)
    1757             : {
    1758             :   pari_sp av;
    1759    11285183 :   if (!signe(y) || !signe(z)) return Fp_red(x, p);
    1760    10794483 :   if (!signe(x)) return Fp_mul(z,y, p);
    1761     9796593 :   av = avma;
    1762     9796593 :   return gc_INT(av, modii(addii(x, mulii(y,z)), p));
    1763             : }
    1764             : 
    1765             : INLINE GEN
    1766   199594861 : Fp_mul(GEN a, GEN b, GEN m)
    1767             : {
    1768   199594861 :   pari_sp av=avma;
    1769             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1770   199594861 :   (void)new_chunk(lg(a)+lg(b)+(lg(m)<<1));
    1771   199661328 :   p = mulii(a,b);
    1772   199489401 :   set_avma(av); return modii(p,m);
    1773             : }
    1774             : INLINE GEN
    1775    63968445 : Fp_sqr(GEN a, GEN m)
    1776             : {
    1777    63968445 :   pari_sp av=avma;
    1778             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1779    63968445 :   (void)new_chunk((lg(a)+lg(m))<<1);
    1780    64332302 :   p = sqri(a);
    1781    62625304 :   set_avma(av); return remii(p,m); /*Use remii: p >= 0 */
    1782             : }
    1783             : INLINE GEN
    1784    67061090 : Fp_mulu(GEN a, ulong b, GEN m)
    1785             : {
    1786    67061090 :   long l = lgefint(m);
    1787    67061090 :   if (l == 3)
    1788             :   {
    1789    45423855 :     ulong mm = m[2];
    1790    45423855 :     return utoi( Fl_mul(umodiu(a, mm), b, mm) );
    1791             :   } else {
    1792    21637235 :     pari_sp av = avma;
    1793             :     GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1794    21637235 :     (void)new_chunk(lg(a)+1+(l<<1));
    1795    21602762 :     p = muliu(a,b);
    1796    21394497 :     set_avma(av); return modii(p,m);
    1797             :   }
    1798             : }
    1799             : INLINE GEN
    1800       17780 : Fp_muls(GEN a, long b, GEN m)
    1801             : {
    1802       17780 :   long l = lgefint(m);
    1803       17780 :   if (l == 3)
    1804             :   {
    1805        3578 :     ulong mm = m[2];
    1806        3578 :     if (b < 0)
    1807             :     {
    1808        3578 :       ulong t = Fl_mul(umodiu(a, mm), -b, mm);
    1809        3578 :       return t? utoipos(mm - t): gen_0;
    1810             :     }
    1811             :     else
    1812           0 :       return utoi( Fl_mul(umodiu(a, mm), b, mm) );
    1813             :   } else {
    1814       14202 :     pari_sp av = avma;
    1815             :     GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1816       14202 :     (void)new_chunk(lg(a)+1+(l<<1));
    1817       14202 :     p = mulis(a,b);
    1818       14202 :     set_avma(av); return modii(p,m);
    1819             :   }
    1820             : }
    1821             : 
    1822             : INLINE GEN
    1823    23211728 : Fp_inv(GEN a, GEN m)
    1824             : {
    1825             :   GEN res;
    1826    23211728 :   if (! invmod(a,m,&res)) pari_err_INV("Fp_inv", mkintmod(res,m));
    1827    23211406 :   return res;
    1828             : }
    1829             : INLINE GEN
    1830     1099929 : Fp_invsafe(GEN a, GEN m)
    1831             : {
    1832             :   GEN res;
    1833     1099929 :   if (! invmod(a,m,&res)) return NULL;
    1834     1099873 :   return res;
    1835             : }
    1836             : INLINE GEN
    1837    14986634 : Fp_div(GEN a, GEN b, GEN m)
    1838             : {
    1839    14986634 :   pari_sp av = avma;
    1840             :   GEN p;
    1841    14986634 :   if (lgefint(b) == 3)
    1842             :   {
    1843    13842100 :     a = Fp_divu(a, b[2], m);
    1844    13843184 :     if (signe(b) < 0) a = Fp_neg(a, m);
    1845    13843187 :     return a;
    1846             :   }
    1847             :   /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1848     1144534 :   (void)new_chunk(lg(a)+(lg(m)<<1));
    1849     1144538 :   p = mulii(a, Fp_inv(b,m));
    1850     1144538 :   set_avma(av); return modii(p,m);
    1851             : }
    1852             : INLINE GEN
    1853    15086494 : Fp_divu(GEN x, ulong a, GEN p)
    1854             : {
    1855    15086494 :   pari_sp av = avma;
    1856             :   ulong b;
    1857    15086494 :   if (lgefint(p) == 3)
    1858             :   {
    1859    14553535 :     ulong pp = p[2], xp = umodiu(x, pp);
    1860    14554224 :     return xp? utoipos(Fl_div(xp, a % pp, pp)): gen_0;
    1861             :   }
    1862      532959 :   x = Fp_red(x, p);
    1863      532964 :   b = Fl_neg(Fl_div(umodiu(x,a), umodiu(p,a), a), a); /* x + pb = 0 (mod a) */
    1864      532966 :   return gc_INT(av, diviuexact(addmuliu(x, p, b), a));
    1865             : }
    1866             : 
    1867             : INLINE GEN
    1868     1094713 : Flx_mulu(GEN x, ulong a, ulong p) { return Flx_Fl_mul(x,a%p,p); }
    1869             : 
    1870             : INLINE GEN
    1871     2498998 : get_F2x_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1872             : 
    1873             : INLINE long
    1874     2532657 : get_F2x_var(GEN T) { return typ(T)==t_VEC? mael(T,2,1): T[1]; }
    1875             : 
    1876             : INLINE long
    1877     1929017 : get_F2x_degree(GEN T) { return typ(T)==t_VEC? F2x_degree(gel(T,2)): F2x_degree(T); }
    1878             : 
    1879             : INLINE GEN
    1880         343 : get_F2xqX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1881             : 
    1882             : INLINE long
    1883      375375 : get_F2xqX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1884             : 
    1885             : INLINE long
    1886      200851 : get_F2xqX_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1887             : 
    1888             : INLINE GEN
    1889    25406564 : get_Flx_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1890             : 
    1891             : INLINE long
    1892    67620910 : get_Flx_var(GEN T) { return typ(T)==t_VEC? mael(T,2,1): T[1]; }
    1893             : 
    1894             : INLINE long
    1895    81658337 : get_Flx_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1896             : 
    1897             : INLINE GEN
    1898        8033 : get_FlxqX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1899             : 
    1900             : INLINE long
    1901      264420 : get_FlxqX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1902             : 
    1903             : INLINE long
    1904      317565 : get_FlxqX_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1905             : 
    1906             : INLINE GEN
    1907     3393079 : get_FpX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1908             : 
    1909             : INLINE long
    1910     7237097 : get_FpX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1911             : 
    1912             : INLINE long
    1913     6005786 : get_FpX_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1914             : 
    1915             : INLINE GEN
    1916      146583 : get_FpXQX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1917             : 
    1918             : INLINE long
    1919       51630 : get_FpXQX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1920             : 
    1921             : INLINE long
    1922        3589 : get_FpXQX_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1923             : 
    1924             : /*******************************************************************/
    1925             : /*                                                                 */
    1926             : /*                        ADDMULII / SUBMULII                      */
    1927             : /*                                                                 */
    1928             : /*******************************************************************/
    1929             : /* x - y*z */
    1930             : INLINE GEN
    1931    32800182 : submulii(GEN x, GEN y, GEN z)
    1932             : {
    1933    32800182 :   long lx = lgefint(x), ly, lz;
    1934             :   pari_sp av;
    1935             :   GEN t;
    1936    32800182 :   if (lx == 2) { t = mulii(z,y); togglesign(t); return t; }
    1937    30268074 :   ly = lgefint(y);
    1938    30268074 :   if (ly == 2) return icopy(x);
    1939    28999820 :   lz = lgefint(z);
    1940    28999820 :   av = avma; (void)new_chunk(lx+ly+lz); /* HACK */
    1941    28999820 :   t = mulii(z, y);
    1942    28999820 :   set_avma(av); return subii(x,t);
    1943             : }
    1944             : /* y*z - x */
    1945             : INLINE GEN
    1946     3848399 : mulsubii(GEN y, GEN z, GEN x)
    1947             : {
    1948     3848399 :   long lx = lgefint(x), ly, lz;
    1949             :   pari_sp av;
    1950             :   GEN t;
    1951     3848399 :   if (lx == 2) return mulii(z,y);
    1952     2429388 :   ly = lgefint(y);
    1953     2429388 :   if (ly == 2) return negi(x);
    1954     2151859 :   lz = lgefint(z);
    1955     2151859 :   av = avma; (void)new_chunk(lx+ly+lz); /* HACK */
    1956     2151899 :   t = mulii(z, y);
    1957     2151869 :   set_avma(av); return subii(t,x);
    1958             : }
    1959             : 
    1960             : /* x - u*y */
    1961             : INLINE GEN
    1962        7728 : submuliu(GEN x, GEN y, ulong u)
    1963             : {
    1964             :   pari_sp av;
    1965        7728 :   long ly = lgefint(y);
    1966        7728 :   if (ly == 2) return icopy(x);
    1967        7728 :   av = avma;
    1968        7728 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1969        7728 :   y = mului(u,y);
    1970        7728 :   set_avma(av); return subii(x, y);
    1971             : }
    1972             : /* x + u*y */
    1973             : INLINE GEN
    1974      541069 : addmuliu(GEN x, GEN y, ulong u)
    1975             : {
    1976             :   pari_sp av;
    1977      541069 :   long ly = lgefint(y);
    1978      541069 :   if (ly == 2) return icopy(x);
    1979      541069 :   av = avma;
    1980      541069 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1981      541069 :   y = mului(u,y);
    1982      541069 :   set_avma(av); return addii(x, y);
    1983             : }
    1984             : /* x - u*y */
    1985             : INLINE GEN
    1986    59968220 : submuliu_inplace(GEN x, GEN y, ulong u)
    1987             : {
    1988             :   pari_sp av;
    1989    59968220 :   long ly = lgefint(y);
    1990    59968220 :   if (ly == 2) return x;
    1991    38006405 :   av = avma;
    1992    38006405 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1993    38011107 :   y = mului(u,y);
    1994    38010878 :   set_avma(av); return subii(x, y);
    1995             : }
    1996             : /* x + u*y */
    1997             : INLINE GEN
    1998    59471813 : addmuliu_inplace(GEN x, GEN y, ulong u)
    1999             : {
    2000             :   pari_sp av;
    2001    59471813 :   long ly = lgefint(y);
    2002    59471813 :   if (ly == 2) return x;
    2003    37913895 :   av = avma;
    2004    37913895 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    2005    37918197 :   y = mului(u,y);
    2006    37918027 :   set_avma(av); return addii(x, y);
    2007             : }
    2008             : /* ux + vy */
    2009             : INLINE GEN
    2010    37826392 : lincombii(GEN u, GEN v, GEN x, GEN y)
    2011             : {
    2012    37826392 :   long lx = lgefint(x), ly;
    2013             :   GEN p1, p2;
    2014             :   pari_sp av;
    2015    37826392 :   if (lx == 2) return mulii(v,y);
    2016    23784506 :   ly = lgefint(y);
    2017    23784506 :   if (ly == 2) return mulii(u,x);
    2018    21102068 :   av = avma; (void)new_chunk(lx+ly+lgefint(u)+lgefint(v)); /* HACK */
    2019    21105449 :   p1 = mulii(u,x);
    2020    21103985 :   p2 = mulii(v,y);
    2021    21103647 :   set_avma(av); return addii(p1,p2);
    2022             : }
    2023             : 
    2024             : /*******************************************************************/
    2025             : /*                                                                 */
    2026             : /*                          GEN SUBTYPES                           */
    2027             : /*                                                                 */
    2028             : /*******************************************************************/
    2029             : 
    2030             : INLINE int
    2031  4884635619 : is_const_t(long t) { return (t < t_POLMOD); }
    2032             : INLINE int
    2033        6960 : is_extscalar_t(long t) { return (t <= t_POL); }
    2034             : INLINE int
    2035     9575203 : is_intreal_t(long t) { return (t <= t_REAL); }
    2036             : INLINE int
    2037   655725046 : is_matvec_t(long t) { return (t >= t_VEC && t <= t_MAT); }
    2038             : INLINE int
    2039    90576695 : is_noncalc_t(long tx) { return (tx) >= t_LIST; }
    2040             : INLINE int
    2041           0 : is_qfb_t(long t) { return (t == t_QFB); }
    2042             : INLINE int
    2043     5015518 : is_rational_t(long t) { return (t == t_INT || t == t_FRAC); }
    2044             : INLINE int
    2045    62560882 : is_real_t(long t) { return (t == t_INT || t == t_REAL || t == t_FRAC); }
    2046             : INLINE int
    2047  9165269587 : is_recursive_t(long t) { return lontyp[t]; }
    2048             : INLINE int
    2049   368258204 : is_scalar_t(long t) { return (t < t_POL); }
    2050             : INLINE int
    2051    43381486 : is_vec_t(long t) { return (t == t_VEC || t == t_COL); }
    2052             : 
    2053             : INLINE int
    2054    67776646 : qfb_is_qfi(GEN q) { return signe(gel(q,4)) < 0; }
    2055             : 
    2056             : /*******************************************************************/
    2057             : /*                                                                 */
    2058             : /*                         TRANSCENDENTAL                          */
    2059             : /*                                                                 */
    2060             : /*******************************************************************/
    2061             : INLINE GEN
    2062    79919054 : sqrtr(GEN x) {
    2063    79919054 :   long s = signe(x);
    2064    79919054 :   if (s == 0) return real_0_bit(expo(x) >> 1);
    2065    79885939 :   if (s >= 0) return sqrtr_abs(x);
    2066      433258 :   retmkcomplex(gen_0, sqrtr_abs(x));
    2067             : }
    2068             : INLINE GEN
    2069           0 : cbrtr_abs(GEN x) { return sqrtnr_abs(x, 3); }
    2070             : INLINE GEN
    2071           0 : cbrtr(GEN x) {
    2072           0 :   long s = signe(x);
    2073             :   GEN r;
    2074           0 :   if (s == 0) return real_0_bit(expo(x) / 3);
    2075           0 :   r = cbrtr_abs(x);
    2076           0 :   if (s < 0) togglesign(r);
    2077           0 :   return r;
    2078             : }
    2079             : INLINE GEN
    2080     2795010 : sqrtnr(GEN x, long n) {
    2081     2795010 :   long s = signe(x);
    2082             :   GEN r;
    2083     2795010 :   if (s == 0) return real_0_bit(expo(x) / n);
    2084     2795010 :   r = sqrtnr_abs(x, n);
    2085     2795004 :   if (s < 0) pari_err_IMPL("sqrtnr for x < 0");
    2086     2795004 :   return r;
    2087             : }
    2088             : INLINE long
    2089      752104 : logint(GEN B, GEN y) { return logintall(B,y,NULL); }
    2090             : INLINE ulong
    2091     1720600 : ulogint(ulong B, ulong y)
    2092             : {
    2093             :   ulong r;
    2094             :   long e;
    2095     1720600 :   if (y == 2) return expu(B);
    2096     1672586 :   r = y;
    2097     5054448 :   for (e=1;; e++)
    2098             :   { /* here, r = y^e, r2 = y^(e-1) */
    2099     5054448 :     if (r >= B) return r == B? e: e-1;
    2100     3383383 :     r = umuluu_or_0(y, r);
    2101     3383388 :     if (!r) return e;
    2102             :   }
    2103             : }
    2104             : 
    2105             : /*******************************************************************/
    2106             : /*                                                                 */
    2107             : /*                         MISCELLANEOUS                           */
    2108             : /*                                                                 */
    2109             : /*******************************************************************/
    2110     9575086 : INLINE int ismpzero(GEN x) { return is_intreal_t(typ(x)) && !signe(x); }
    2111  2800365333 : INLINE int isintzero(GEN x) { return typ(x) == t_INT && !signe(x); }
    2112    17004663 : INLINE int isint1(GEN x) { return typ(x)==t_INT && equali1(x); }
    2113     5701421 : INLINE int isintm1(GEN x){ return typ(x)==t_INT && equalim1(x);}
    2114  1275573774 : INLINE int equali1(GEN n)
    2115  1275573774 : { return (ulong) n[1] == (evallgefint(3UL) | evalsigne(1)) && n[2] == 1; }
    2116   139008666 : INLINE int equalim1(GEN n)
    2117   139008666 : { return (ulong) n[1] == (evallgefint(3UL) | evalsigne(-1)) && n[2] == 1; }
    2118             : /* works only for POSITIVE integers */
    2119  2187674121 : INLINE int is_pm1(GEN n)
    2120  2187674121 : { return lgefint(n) == 3 && n[2] == 1; }
    2121   557522330 : INLINE int is_bigint(GEN n)
    2122   557522330 : { long l = lgefint(n); return l > 3 || (l == 3 && (n[2] & HIGHBIT)); }
    2123             : 
    2124  2052988062 : INLINE int odd(long x) { return x & 1; }
    2125   116881651 : INLINE int both_odd(long x, long y) { return x & y & 1; }
    2126             : 
    2127             : INLINE int
    2128  8047723351 : isonstack(GEN x)
    2129  8047723351 : { return ((pari_sp)x >= pari_mainstack->bot
    2130  8047723351 :        && (pari_sp)x <  pari_mainstack->top); }
    2131             : 
    2132             : /* assume x != 0 and x t_REAL, return an approximation to log2(|x|) */
    2133             : INLINE double
    2134    92961347 : dbllog2r(GEN x)
    2135    92961347 : { return log2((double)(ulong)x[2]) + (double)(expo(x) - (BITS_IN_LONG-1)); }
    2136             : 
    2137             : INLINE GEN
    2138     2512240 : mul_content(GEN cx, GEN cy)
    2139             : {
    2140     2512240 :   if (!cx) return cy;
    2141      520054 :   if (!cy) return cx;
    2142      332827 :   return gmul(cx,cy);
    2143             : }
    2144             : INLINE GEN
    2145           0 : inv_content(GEN c) { return c? ginv(c): NULL; }
    2146             : INLINE GEN
    2147       57950 : div_content(GEN cx, GEN cy)
    2148             : {
    2149       57950 :   if (!cy) return cx;
    2150       56816 :   if (!cx) return ginv(cy);
    2151       25758 :   return gdiv(cx,cy);
    2152             : }
    2153             : INLINE GEN
    2154    10293926 : mul_denom(GEN dx, GEN dy)
    2155             : {
    2156    10293926 :   if (!dx) return dy;
    2157     1835896 :   if (!dy) return dx;
    2158     1368163 :   return mulii(dx,dy);
    2159             : }
    2160             : 
    2161             : /* POLYNOMIALS */
    2162             : INLINE GEN
    2163     1439404 : constant_coeff(GEN x) { return signe(x)? gel(x,2): gen_0; }
    2164             : INLINE GEN
    2165   168979493 : leading_coeff(GEN x) { return lg(x) == 2? gen_0: gel(x,lg(x)-1); }
    2166             : INLINE ulong
    2167      969165 : Flx_lead(GEN x) { return lg(x) == 2? 0: x[lg(x)-1]; }
    2168             : INLINE ulong
    2169      330286 : Flx_constant(GEN x) { return lg(x) == 2? 0: x[2]; }
    2170             : INLINE long
    2171  5330354391 : degpol(GEN x) { return lg(x)-3; }
    2172             : INLINE long
    2173  2618430416 : lgpol(GEN x) { return lg(x)-2; }
    2174             : INLINE long
    2175   341316842 : lgcols(GEN x) { return lg(gel(x,1)); }
    2176             : INLINE long
    2177   153659891 : nbrows(GEN x) { return lg(gel(x,1))-1; }
    2178             : INLINE GEN
    2179           0 : truecoef(GEN x, long n) { return polcoef(x,n,-1); }
    2180             : 
    2181             : INLINE GEN
    2182     2128025 : ZXQ_mul(GEN y, GEN x, GEN T) { return ZX_rem(ZX_mul(y, x), T); }
    2183             : INLINE GEN
    2184      950775 : ZXQ_sqr(GEN x, GEN T) { return ZX_rem(ZX_sqr(x), T); }
    2185             : 
    2186             : INLINE GEN
    2187   103468855 : RgX_copy(GEN x)
    2188   376960853 : { pari_APPLY_pol_normalized(gcopy(gel(x,i))); }
    2189             : /* have to use ulong to avoid silly warnings from gcc "assuming signed
    2190             :  * overflow does not occur" */
    2191             : INLINE GEN
    2192     2551519 : RgX_coeff(GEN x, long n)
    2193             : {
    2194     2551519 :   ulong l = lg(x);
    2195     2551519 :   return (n < 0 || ((ulong)n+3) > l)? gen_0: gel(x,n+2);
    2196             : }
    2197             : INLINE GEN
    2198      349345 : RgX_renormalize(GEN x) { return RgX_renormalize_lg(x, lg(x)); }
    2199             : INLINE GEN
    2200     7053359 : RgX_div(GEN x, GEN y) { return RgX_divrem(x,y,NULL); }
    2201             : INLINE GEN
    2202        1904 : RgXQX_div(GEN x, GEN y, GEN T) { return RgXQX_divrem(x,y,T,NULL); }
    2203             : INLINE GEN
    2204      125476 : RgXQX_rem(GEN x, GEN y, GEN T) { return RgXQX_divrem(x,y,T,ONLY_REM); }
    2205             : INLINE GEN
    2206     5437055 : FpX_div(GEN x, GEN y, GEN p) { return FpX_divrem(x,y,p, NULL); }
    2207             : INLINE GEN
    2208     1995667 : Flx_div(GEN x, GEN y, ulong p) { return Flx_divrem(x,y,p, NULL); }
    2209             : INLINE GEN
    2210    21395522 : Flx_div_pre(GEN x, GEN y, ulong p, ulong pi)
    2211    21395522 : { return Flx_divrem_pre(x,y,p,pi, NULL); }
    2212             : INLINE GEN
    2213     1552381 : F2x_div(GEN x, GEN y) { return F2x_divrem(x,y, NULL); }
    2214             : INLINE GEN
    2215           0 : FpV_FpC_mul(GEN x, GEN y, GEN p) { return FpV_dotproduct(x,y,p); }
    2216             : INLINE GEN
    2217   101696857 : pol0_Flx(long sv) { return mkvecsmall(sv); }
    2218             : INLINE GEN
    2219    54570600 : pol1_Flx(long sv) { return mkvecsmall2(sv, 1); }
    2220             : INLINE GEN
    2221    37590216 : polx_Flx(long sv) { return mkvecsmall3(sv, 0, 1); }
    2222             : INLINE GEN
    2223           0 : zero_zx(long sv) { return zero_Flx(sv); }
    2224             : INLINE GEN
    2225           0 : polx_zx(long sv) { return polx_Flx(sv); }
    2226             : INLINE GEN
    2227           0 : zx_shift(GEN x, long n) { return Flx_shift(x,n); }
    2228             : INLINE GEN
    2229       14049 : zx_renormalize(GEN x, long l) { return Flx_renormalize(x,l); }
    2230             : INLINE GEN
    2231        1350 : zero_F2x(long sv) { return zero_Flx(sv); }
    2232             : INLINE GEN
    2233    13186673 : pol0_F2x(long sv) { return pol0_Flx(sv); }
    2234             : INLINE GEN
    2235     3954137 : pol1_F2x(long sv) { return pol1_Flx(sv); }
    2236             : INLINE GEN
    2237     1070496 : polx_F2x(long sv) { return mkvecsmall2(sv, 2); }
    2238             : INLINE int
    2239     2873469 : F2x_equal1(GEN x) { return Flx_equal1(x); }
    2240             : INLINE int
    2241     4598280 : F2x_equal(GEN V, GEN W) { return Flx_equal(V,W); }
    2242             : INLINE GEN
    2243    59606511 : F2x_copy(GEN x) { return leafcopy(x); }
    2244             : INLINE GEN
    2245        4487 : F2v_copy(GEN x) { return leafcopy(x); }
    2246             : INLINE GEN
    2247     2545331 : Flv_copy(GEN x) { return leafcopy(x); }
    2248             : INLINE GEN
    2249   172063458 : Flx_copy(GEN x) { return leafcopy(x); }
    2250             : INLINE GEN
    2251     4366143 : vecsmall_copy(GEN x) { return leafcopy(x); }
    2252             : INLINE int
    2253     8318111 : Flx_equal1(GEN x) { return degpol(x)==0 && x[2] == 1; }
    2254             : INLINE int
    2255       12549 : ZX_equal1(GEN x) { return degpol(x)==0 && equali1(gel(x,2)); }
    2256             : INLINE int
    2257     7266145 : ZX_is_monic(GEN x) { return equali1(leading_coeff(x)); }
    2258             : 
    2259             : INLINE GEN
    2260   154331543 : ZX_renormalize(GEN x, long lx)    { return ZXX_renormalize(x,lx); }
    2261             : INLINE GEN
    2262   144996437 : FpX_renormalize(GEN x, long lx)   { return ZXX_renormalize(x,lx); }
    2263             : INLINE GEN
    2264      849896 : FpXX_renormalize(GEN x, long lx)  { return ZXX_renormalize(x,lx); }
    2265             : INLINE GEN
    2266     4693783 : FpXQX_renormalize(GEN x, long lx) { return ZXX_renormalize(x,lx); }
    2267             : INLINE GEN
    2268   114209830 : F2x_renormalize(GEN x, long lx)   { return Flx_renormalize(x,lx); }
    2269             : 
    2270             : INLINE GEN
    2271           0 : F2xX_shift(GEN a, long n, long vs) { return FlxX_shift(a, n, vs); }
    2272             : 
    2273             : INLINE GEN
    2274       37585 : F2v_to_F2x(GEN x, long sv) {
    2275       37585 :   GEN y = leafcopy(x);
    2276       37585 :   y[1] = sv; F2x_renormalize(y, lg(y)); return y;
    2277             : }
    2278             : 
    2279             : INLINE long
    2280         385 : sturm(GEN x) { return sturmpart(x, NULL, NULL); }
    2281             : 
    2282             : INLINE long
    2283        5796 : gval(GEN x, long v)
    2284        5796 : { pari_sp av = avma; return gc_long(av, gvaluation(x, pol_x(v))); }
    2285             : 
    2286             : INLINE void
    2287      480682 : RgX_shift_inplace_init(long v)
    2288      480682 : { if (v) (void)cgetg(v, t_VECSMALL); }
    2289             : /* shift polynomial in place. assume v free cells have been left before x */
    2290             : INLINE GEN
    2291      480682 : RgX_shift_inplace(GEN x, long v)
    2292             : {
    2293             :   long i, lx;
    2294             :   GEN z;
    2295      480682 :   if (!v) return x;
    2296      253169 :   lx = lg(x);
    2297      253169 :   if (lx == 2) return x;
    2298      253169 :   z = x + lx;
    2299             :   /* stackdummy's from normalizepol */
    2300      253169 :   while (lg(z) != v) z += lg(z);
    2301      253169 :   z += v;
    2302     4654514 :   for (i = lx-1; i >= 2; i--) gel(--z,0) = gel(x,i);
    2303      675895 :   for (i = 0;  i < v; i++) gel(--z,0) = gen_0;
    2304      253169 :   z -= 2;
    2305      253169 :   z[1] = x[1];
    2306      253169 :   z[0] = evaltyp(t_POL) | evallg(lx+v);
    2307      253169 :   stackdummy((pari_sp)z, (pari_sp)x); return z;
    2308             : }
    2309             : 
    2310             : 
    2311             : /* LINEAR ALGEBRA */
    2312             : INLINE GEN
    2313      502527 : zv_to_ZV(GEN x) { return vecsmall_to_vec(x); }
    2314             : INLINE GEN
    2315     7747345 : zc_to_ZC(GEN x) { return vecsmall_to_col(x); }
    2316             : INLINE GEN
    2317     3190968 : ZV_to_zv(GEN x) { return vec_to_vecsmall(x); }
    2318             : INLINE GEN
    2319           0 : zx_to_zv(GEN x, long N) { return Flx_to_Flv(x,N); }
    2320             : INLINE GEN
    2321      104146 : zv_to_zx(GEN x, long sv) { return Flv_to_Flx(x,sv); }
    2322             : INLINE GEN
    2323           0 : zm_to_zxV(GEN x, long sv) { return Flm_to_FlxV(x,sv); }
    2324             : INLINE GEN
    2325           0 : zero_zm(long x, long y) { return zero_Flm(x,y); }
    2326             : INLINE GEN
    2327    36150200 : zero_zv(long x) { return zero_Flv(x); }
    2328             : INLINE GEN
    2329         266 : zm_transpose(GEN x) { return Flm_transpose(x); }
    2330             : INLINE GEN
    2331           0 : zm_copy(GEN x) { return Flm_copy(x); }
    2332             : INLINE GEN
    2333     2183634 : zv_copy(GEN x) { return Flv_copy(x); }
    2334             : INLINE GEN
    2335           0 : zm_row(GEN x, long i) { return Flm_row(x,i); }
    2336             : 
    2337             : INLINE GEN
    2338    10191821 : ZC_hnfrem(GEN x, GEN y) { return ZC_hnfdivrem(x,y,NULL); }
    2339             : INLINE GEN
    2340      326773 : ZM_hnfrem(GEN x, GEN y) { return ZM_hnfdivrem(x,y,NULL); }
    2341             : INLINE GEN
    2342     6933424 : ZM_lll(GEN x, double D, long f) { return ZM_lll_norms(x,D,f,NULL); }
    2343             : INLINE void
    2344     9404898 : RgM_dimensions(GEN x, long *m, long *n) { *n = lg(x)-1; *m = *n? nbrows(x): 0; }
    2345             : INLINE GEN
    2346    21440427 : RgM_shallowcopy(GEN x)
    2347    93322866 : { pari_APPLY_same(leafcopy(gel(x,i))); }
    2348             : INLINE GEN
    2349      198008 : F2m_copy(GEN x) { return RgM_shallowcopy(x); }
    2350             : 
    2351             : INLINE GEN
    2352           0 : F3m_copy(GEN x) { return RgM_shallowcopy(x); }
    2353             : 
    2354             : INLINE GEN
    2355     6275279 : Flm_copy(GEN x) { return RgM_shallowcopy(x); }
    2356             : 
    2357             : /* divisibility: return 1 if y[i] | x[i] for all i, 0 otherwise. Assume
    2358             :  * x,y are ZV of the same length */
    2359             : INLINE int
    2360       23485 : ZV_dvd(GEN x, GEN y)
    2361             : {
    2362       23485 :   long i, l = lg(x);
    2363       37856 :   for (i=1; i < l; i++)
    2364       30464 :     if ( ! dvdii( gel(x,i), gel(y,i) ) ) return 0;
    2365        7392 :   return 1;
    2366             : }
    2367             : INLINE GEN
    2368      539090 : ZM_ZV_mod(GEN x, GEN y)
    2369     1537888 : { pari_APPLY_same(ZV_ZV_mod(gel(x,i), y)) }
    2370             : INLINE GEN
    2371     7322904 : ZV_ZV_mod(GEN x, GEN y)
    2372    18920474 : { pari_APPLY_same(modii(gel(x,i), gel(y,i))) }
    2373             : INLINE GEN
    2374           0 : vecmodii(GEN x, GEN y) { return ZV_ZV_mod(x,y); }
    2375             : INLINE GEN
    2376      174881 : vecmoduu(GEN x, GEN y) { pari_APPLY_ulong(((ulong*)x)[i] % ((ulong*)y)[i]) }
    2377             : 
    2378             : /* Fq */
    2379             : INLINE GEN
    2380     3106428 : Fq_red(GEN x, GEN T, GEN p)
    2381     3106428 : { return typ(x)==t_INT? Fp_red(x,p): FpXQ_red(x,T,p); }
    2382             : INLINE GEN
    2383       73792 : Fq_to_FpXQ(GEN x, GEN T, GEN p /*unused*/)
    2384             : {
    2385             :   (void) p;
    2386       73792 :   return typ(x)==t_INT ? scalarpol(x, get_FpX_var(T)): x;
    2387             : }
    2388             : INLINE GEN
    2389         756 : Rg_to_Fq(GEN x, GEN T, GEN p) { return T? Rg_to_FpXQ(x,T,p): Rg_to_Fp(x,p); }
    2390             : 
    2391             : INLINE GEN
    2392       14594 : gener_Fq_local(GEN T, GEN p, GEN L)
    2393           0 : { return T? gener_FpXQ_local(T,p, L)
    2394       14594 :           : pgener_Fp_local(p, L); }
    2395             : 
    2396             : INLINE GEN
    2397           0 : random_Fq(GEN T, GEN p)
    2398           0 : { return T ? random_FpX(get_FpX_degree(T), get_FpX_var(T), p): randomi(p); }
    2399             : 
    2400             : /* FpXQX */
    2401             : INLINE GEN
    2402        4526 : FpXQX_div(GEN x, GEN y, GEN T, GEN p) { return FpXQX_divrem(x, y, T, p, NULL); }
    2403             : INLINE GEN
    2404           0 : FlxqX_div(GEN x, GEN y, GEN T, ulong p) { return FlxqX_divrem(x, y, T, p, NULL); }
    2405             : INLINE GEN
    2406      165407 : FlxqX_div_pre(GEN x, GEN y, GEN T, ulong p, ulong pi) { return FlxqX_divrem_pre(x, y, T, p, pi, NULL); }
    2407             : INLINE GEN
    2408       33173 : F2xqX_div(GEN x, GEN y, GEN T) { return F2xqX_divrem(x, y, T, NULL); }
    2409             : 
    2410             : INLINE GEN
    2411       20587 : FpXY_Fq_evaly(GEN Q, GEN y, GEN T, GEN p, long vx)
    2412       20587 : { return T ? FpXY_FpXQ_evaly(Q, y, T, p, vx): FpXY_evaly(Q, y, p, vx); }
    2413             : 
    2414             : /* FqX */
    2415             : INLINE GEN
    2416       25354 : FqX_red(GEN z, GEN T, GEN p) { return T? FpXQX_red(z, T, p): FpX_red(z, p); }
    2417             : INLINE GEN
    2418      127694 : FqX_add(GEN x,GEN y,GEN T,GEN p) { return T? FpXX_add(x,y,p): FpX_add(x,y,p); }
    2419             : INLINE GEN
    2420       24956 : FqX_neg(GEN x,GEN T,GEN p) { return T? FpXX_neg(x,p): FpX_neg(x,p); }
    2421             : INLINE GEN
    2422       68607 : FqX_sub(GEN x,GEN y,GEN T,GEN p) { return T? FpXX_sub(x,y,p): FpX_sub(x,y,p); }
    2423             : INLINE GEN
    2424      567980 : FqX_Fp_mul(GEN P, GEN u, GEN T, GEN p)
    2425      567980 : { return T? FpXX_Fp_mul(P, u, p): FpX_Fp_mul(P, u, p); }
    2426             : INLINE GEN
    2427      427291 : FqX_Fq_mul(GEN P, GEN U, GEN T, GEN p)
    2428      427291 : { return typ(U)==t_INT ? FqX_Fp_mul(P, U, T, p): FpXQX_FpXQ_mul(P, U, T, p); }
    2429             : INLINE GEN
    2430      367095 : FqX_mul(GEN x, GEN y, GEN T, GEN p)
    2431      367095 : { return T? FpXQX_mul(x, y, T, p): FpX_mul(x, y, p); }
    2432             : INLINE GEN
    2433       21942 : FqX_mulu(GEN x, ulong y, GEN T, GEN p)
    2434       21942 : { return T? FpXX_mulu(x, y, p): FpX_mulu(x, y, p); }
    2435             : INLINE GEN
    2436       71855 : FqX_sqr(GEN x, GEN T, GEN p)
    2437       71855 : { return T? FpXQX_sqr(x, T, p): FpX_sqr(x, p); }
    2438             : INLINE GEN
    2439        1295 : FqX_powu(GEN x, ulong n, GEN T, GEN p)
    2440        1295 : { return T? FpXQX_powu(x, n, T, p): FpX_powu(x, n, p); }
    2441             : INLINE GEN
    2442       19411 : FqX_halve(GEN x, GEN T, GEN p)
    2443       19411 : { return T? FpXX_halve(x, p): FpX_halve(x, p); }
    2444             : INLINE GEN
    2445       38450 : FqX_div(GEN x, GEN y, GEN T, GEN p)
    2446       38450 : { return T? FpXQX_divrem(x,y,T,p,NULL): FpX_divrem(x,y,p,NULL); }
    2447             : INLINE GEN
    2448        6090 : FqX_get_red(GEN S, GEN T, GEN p)
    2449        6090 : { return T? FpXQX_get_red(S,T,p): FpX_get_red(S,p); }
    2450             : INLINE GEN
    2451       37743 : FqX_rem(GEN x, GEN y, GEN T, GEN p)
    2452       37743 : { return T? FpXQX_rem(x,y,T,p): FpX_rem(x,y,p); }
    2453             : INLINE GEN
    2454           0 : FqX_divrem(GEN x, GEN y, GEN T, GEN p, GEN *z)
    2455           0 : { return T? FpXQX_divrem(x,y,T,p,z): FpX_divrem(x,y,p,z); }
    2456             : INLINE GEN
    2457       69629 : FqX_div_by_X_x(GEN x, GEN y, GEN T, GEN p, GEN *z)
    2458       69629 : { return T? FpXQX_div_by_X_x(x,y,T,p,z): FpX_div_by_X_x(x,y,p,z); }
    2459             : INLINE GEN
    2460           0 : FqX_halfgcd(GEN P,GEN Q,GEN T,GEN p)
    2461           0 : {return T? FpXQX_halfgcd(P,Q,T,p): FpX_halfgcd(P,Q,p);}
    2462             : INLINE GEN
    2463        8106 : FqX_gcd(GEN P,GEN Q,GEN T,GEN p)
    2464        8106 : {return T? FpXQX_gcd(P,Q,T,p): FpX_gcd(P,Q,p);}
    2465             : INLINE GEN
    2466      442840 : FqX_extgcd(GEN P,GEN Q,GEN T,GEN p, GEN *U, GEN *V)
    2467      442840 : { return T? FpXQX_extgcd(P,Q,T,p,U,V): FpX_extgcd(P,Q,p,U,V); }
    2468             : INLINE GEN
    2469        4053 : FqX_normalize(GEN z, GEN T, GEN p)
    2470        4053 : { return T? FpXQX_normalize(z, T, p): FpX_normalize(z, p); }
    2471             : INLINE GEN
    2472       40061 : FqX_deriv(GEN f, GEN T, GEN p) { return T? FpXX_deriv(f, p): FpX_deriv(f, p); }
    2473             : INLINE long
    2474      683802 : FqX_is_squarefree(GEN P, GEN T, GEN p)
    2475      683802 : { return T ? FpXQX_is_squarefree(P, T, p): FpX_is_squarefree(P, p); }
    2476             : INLINE GEN
    2477           0 : FqX_integ(GEN f, GEN T, GEN p) { return T? FpXX_integ(f, p): FpX_integ(f, p); }
    2478             : INLINE GEN
    2479      140834 : FqX_factor(GEN f, GEN T, GEN p)
    2480      140834 : { return T?FpXQX_factor(f, T, p): FpX_factor(f, p); }
    2481             : INLINE GEN
    2482           7 : FqX_factor_squarefree(GEN f, GEN T, GEN p)
    2483           7 : { return T ? FpXQX_factor_squarefree(f, T, p): FpX_factor_squarefree(f, p); }
    2484             : INLINE GEN
    2485           7 : FqX_ddf(GEN f, GEN T, GEN p)
    2486           7 : { return T ? FpXQX_ddf(f, T, p): FpX_ddf(f, p); }
    2487             : INLINE GEN
    2488       47786 : FqX_degfact(GEN f, GEN T, GEN p)
    2489       47786 : { return T?FpXQX_degfact(f, T, p): FpX_degfact(f, p); }
    2490             : INLINE GEN
    2491        7273 : FqX_roots(GEN f, GEN T, GEN p)
    2492        7273 : { return T?FpXQX_roots(f, T, p): FpX_roots(f, p); }
    2493             : INLINE GEN
    2494         175 : FqX_to_mod(GEN f, GEN T, GEN p)
    2495         175 : { return T?FpXQX_to_mod(f, T, p): FpX_to_mod(f, p); }
    2496             : 
    2497             : /*FqXQ*/
    2498             : INLINE GEN
    2499           0 : FqXQ_add(GEN x, GEN y, GEN S/*unused*/, GEN T, GEN p)
    2500           0 : { (void)S; return T? FpXX_add(x,y,p): FpX_add(x,y,p); }
    2501             : INLINE GEN
    2502           0 : FqXQ_sub(GEN x, GEN y, GEN S/*unused*/, GEN T, GEN p)
    2503           0 : { (void)S; return T? FpXX_sub(x,y,p): FpX_sub(x,y,p); }
    2504             : INLINE GEN
    2505           0 : FqXQ_div(GEN x, GEN y, GEN S, GEN T, GEN p)
    2506           0 : { return T? FpXQXQ_div(x,y,S,T,p): FpXQ_div(x,y,S,p); }
    2507             : INLINE GEN
    2508           0 : FqXQ_inv(GEN x, GEN S, GEN T, GEN p)
    2509           0 : { return T? FpXQXQ_inv(x,S,T,p): FpXQ_inv(x,S,p); }
    2510             : INLINE GEN
    2511           0 : FqXQ_invsafe(GEN x, GEN S, GEN T, GEN p)
    2512           0 : { return T? FpXQXQ_invsafe(x,S,T,p): FpXQ_inv(x,S,p); }
    2513             : INLINE GEN
    2514       22766 : FqXQ_mul(GEN x, GEN y, GEN S, GEN T, GEN p)
    2515       22766 : { return T? FpXQXQ_mul(x,y,S,T,p): FpXQ_mul(x,y,S,p); }
    2516             : INLINE GEN
    2517           0 : FqXQ_sqr(GEN x, GEN S, GEN T, GEN p)
    2518           0 : { return T? FpXQXQ_sqr(x,S,T,p): FpXQ_sqr(x,S,p); }
    2519             : INLINE GEN
    2520           0 : FqXQ_pow(GEN x, GEN n, GEN S, GEN T, GEN p)
    2521           0 : { return T? FpXQXQ_pow(x,n,S,T,p): FpXQ_pow(x,n,S,p); }
    2522             : 
    2523             : /*FqXn*/
    2524             : INLINE GEN
    2525        6590 : FqXn_expint(GEN x, long n, GEN T, GEN p)
    2526        6590 : { return T? FpXQXn_expint(x,n,T,p): FpXn_expint(x,n,p); }
    2527             : INLINE GEN
    2528           0 : FqXn_exp(GEN x, long n, GEN T, GEN p)
    2529           0 : { return T? FpXQXn_exp(x,n,T,p): FpXn_exp(x,n,p); }
    2530             : INLINE GEN
    2531        7126 : FqXn_inv(GEN x, long n, GEN T, GEN p)
    2532        7126 : { return T? FpXQXn_inv(x,n,T,p): FpXn_inv(x,n,p); }
    2533             : INLINE GEN
    2534      263403 : FqXn_mul(GEN x, GEN y, long n, GEN T, GEN p)
    2535      263403 : { return T? FpXQXn_mul(x, y, n, T, p): FpXn_mul(x, y, n, p); }
    2536             : INLINE GEN
    2537           0 : FqXn_sqr(GEN x, long n, GEN T, GEN p)
    2538           0 : { return T? FpXQXn_sqr(x,n,T,p): FpXn_sqr(x,n,p); }
    2539             : 
    2540             : /*FpXQ*/
    2541             : INLINE GEN
    2542           0 : FpXQ_add(GEN x,GEN y,GEN T/*unused*/,GEN p)
    2543           0 : { (void)T; return FpX_add(x,y,p); }
    2544             : INLINE GEN
    2545           0 : FpXQ_sub(GEN x,GEN y,GEN T/*unused*/,GEN p)
    2546           0 : { (void)T; return FpX_sub(x,y,p); }
    2547             : 
    2548             : /*Flxq*/
    2549             : INLINE GEN
    2550           0 : Flxq_add(GEN x,GEN y,GEN T/*unused*/,ulong p)
    2551           0 : { (void)T; return Flx_add(x,y,p); }
    2552             : INLINE GEN
    2553           0 : Flxq_sub(GEN x,GEN y,GEN T/*unused*/,ulong p)
    2554           0 : { (void)T; return Flx_sub(x,y,p); }
    2555             : 
    2556             : /* F2x */
    2557             : 
    2558             : INLINE ulong
    2559   667530066 : F2x_coeff(GEN x,long v)
    2560             : {
    2561   667530066 :    ulong u=(ulong)x[2+divsBIL(v)];
    2562   667529923 :    return (u>>remsBIL(v))&1UL;
    2563             : }
    2564             : 
    2565             : INLINE void
    2566    12263289 : F2x_clear(GEN x,long v)
    2567             : {
    2568    12263289 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2569    12263247 :    *u&=~(1UL<<remsBIL(v));
    2570    12263227 : }
    2571             : 
    2572             : INLINE void
    2573   124446185 : F2x_set(GEN x,long v)
    2574             : {
    2575   124446185 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2576   124444656 :    *u|=1UL<<remsBIL(v);
    2577   124443679 : }
    2578             : 
    2579             : INLINE void
    2580     1553274 : F2x_flip(GEN x,long v)
    2581             : {
    2582     1553274 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2583     1553274 :    *u^=1UL<<remsBIL(v);
    2584     1553274 : }
    2585             : 
    2586             : /* F2v */
    2587             : 
    2588             : INLINE ulong
    2589   660967309 : F2v_coeff(GEN x,long v) { return F2x_coeff(x,v-1); }
    2590             : 
    2591             : INLINE void
    2592    12263294 : F2v_clear(GEN x,long v) { F2x_clear(x,v-1); }
    2593             : 
    2594             : INLINE void
    2595   101337123 : F2v_set(GEN x,long v)   { F2x_set(x,v-1); }
    2596             : 
    2597             : INLINE void
    2598     1553274 : F2v_flip(GEN x,long v) { F2x_flip(x,v-1); }
    2599             : 
    2600             : /* F2m */
    2601             : 
    2602             : INLINE ulong
    2603     8019135 : F2m_coeff(GEN x, long a, long b) { return F2v_coeff(gel(x,b), a); }
    2604             : 
    2605             : INLINE void
    2606           0 : F2m_clear(GEN x, long a, long b) { F2v_clear(gel(x,b), a); }
    2607             : 
    2608             : INLINE void
    2609         798 : F2m_set(GEN x, long a, long b) { F2v_set(gel(x,b), a); }
    2610             : 
    2611             : INLINE void
    2612     1553274 : F2m_flip(GEN x, long a, long b) { F2v_flip(gel(x,b), a); }
    2613             : 
    2614             : /* F3m */
    2615             : 
    2616             : INLINE ulong
    2617     3247859 : F3m_coeff(GEN x, long a, long b) { return F3v_coeff(gel(x,b), a); }
    2618             : 
    2619             : INLINE void
    2620           0 : F3m_set(GEN x, long a, long b, ulong c) { F3v_set(gel(x,b), a, c); }
    2621             : 
    2622             : /* ARITHMETIC */
    2623             : INLINE GEN
    2624        3885 : matpascal(long n) { return matqpascal(n, NULL); }
    2625             : INLINE long
    2626      458538 : Z_issquare(GEN x) { return Z_issquareall(x, NULL); }
    2627             : INLINE long
    2628          98 : Z_ispower(GEN x, ulong k) { return Z_ispowerall(x, k, NULL); }
    2629             : INLINE GEN
    2630     6590415 : sqrti(GEN x) { return sqrtremi(x,NULL); }
    2631             : INLINE GEN
    2632   123157930 : gaddgs(GEN y, long s) { return gaddsg(s,y); }
    2633             : INLINE int
    2634      785658 : gcmpgs(GEN y, long s) { return -gcmpsg(s,y); }
    2635             : INLINE int
    2636       29176 : gequalgs(GEN y, long s) { return gequalsg(s,y); }
    2637             : INLINE GEN
    2638           0 : gmaxsg(long s, GEN y) { return gmaxgs(y,s); }
    2639             : INLINE GEN
    2640           0 : gminsg(long s, GEN y) { return gmings(y,s); }
    2641             : INLINE GEN
    2642    21998398 : gmulgs(GEN y, long s) { return gmulsg(s,y); }
    2643             : INLINE GEN
    2644   124174680 : gmulgu(GEN y, ulong s) { return gmulug(s,y); }
    2645             : INLINE GEN
    2646     1707262 : gsubgs(GEN y, long s) { return gaddgs(y, -s); }
    2647             : INLINE GEN
    2648      529180 : gdivsg(long s, GEN y) { return gdiv(stoi(s), y); }
    2649             : 
    2650             : INLINE GEN
    2651    13509989 : gmax_shallow(GEN x, GEN y) { return gcmp(x,y)<0? y: x; }
    2652             : INLINE GEN
    2653      874938 : gmin_shallow(GEN x, GEN y) { return gcmp(x,y)<0? x: y; }
    2654             : 
    2655             : /* x t_COMPLEX */
    2656             : INLINE GEN
    2657    90768114 : cxnorm(GEN x) { return gadd(gsqr(gel(x,1)), gsqr(gel(x,2))); }
    2658             : /* q t_QUAD */
    2659             : INLINE GEN
    2660       69860 : quadnorm(GEN q)
    2661             : {
    2662       69860 :   GEN X = gel(q,1), b = gel(X,3), c = gel(X,2);
    2663       69860 :   GEN z, u = gel(q,3), v = gel(q,2);
    2664       69860 :   if (typ(u) == t_INT && typ(v) == t_INT) /* generic case */
    2665             :   {
    2666       69671 :     z = signe(b)? mulii(v, addii(u,v)): sqri(v);
    2667       69671 :     return addii(z, mulii(c, sqri(u)));
    2668             :   }
    2669             :   else
    2670             :   {
    2671         189 :     z = signe(b)? gmul(v, gadd(u,v)): gsqr(v);
    2672         189 :     return gadd(z, gmul(c, gsqr(u)));
    2673             :   }
    2674             : }
    2675             : /* x a t_QUAD, return the attached discriminant */
    2676             : INLINE GEN
    2677        1078 : quad_disc(GEN x)
    2678             : {
    2679        1078 :   GEN Q = gel(x,1), b = gel(Q,3), c = gel(Q,2), c4 = shifti(c,2);
    2680        1078 :   if (is_pm1(b)) return subsi(1, c4);
    2681         154 :   togglesign_safe(&c4); return c4;
    2682             : }
    2683             : INLINE GEN
    2684     4848289 : qfb_disc3(GEN x, GEN y, GEN z) { return subii(sqri(y), shifti(mulii(x,z),2)); }
    2685             : INLINE GEN
    2686    18470593 : qfb_disc(GEN x) { return gel(x,4); }
    2687             : 
    2688             : INLINE GEN
    2689     4137470 : sqrfrac(GEN x)
    2690             : {
    2691     4137470 :   GEN z = cgetg(3,t_FRAC);
    2692     4137468 :   gel(z,1) = sqri(gel(x,1));
    2693     4137436 :   gel(z,2) = sqri(gel(x,2)); return z;
    2694             : }
    2695             : 
    2696             : INLINE void
    2697    16753948 : normalize_frac(GEN z) {
    2698    16753948 :   if (signe(gel(z,2)) < 0) { togglesign(gel(z,1)); setabssign(gel(z,2)); }
    2699    16753948 : }
    2700             : 
    2701             : INLINE GEN
    2702    42892007 : powii(GEN x, GEN n)
    2703             : {
    2704    42892007 :   long ln = lgefint(n);
    2705    42892007 :   if (ln == 3) {
    2706             :     GEN z;
    2707    42869042 :     if (signe(n) > 0) return powiu(x, n[2]);
    2708       74807 :     z = cgetg(3, t_FRAC);
    2709       74829 :     gel(z,1) = gen_1;
    2710       74829 :     gel(z,2) = powiu(x, n[2]);
    2711       74829 :     return z;
    2712             :   }
    2713       22965 :   if (ln == 2) return gen_1; /* rare */
    2714             :   /* should never happen */
    2715           0 :   return powgi(x, n); /* overflow unless x = 0, 1, -1 */
    2716             : }
    2717             : INLINE GEN
    2718        1561 : powIs(long n) {
    2719        1561 :   switch(n & 3)
    2720             :   {
    2721          63 :     case 1: return mkcomplex(gen_0,gen_1);
    2722         385 :     case 2: return gen_m1;
    2723         707 :     case 3: return mkcomplex(gen_0,gen_m1);
    2724             :   }
    2725         406 :   return gen_1;
    2726             : }
    2727             : 
    2728             : /*******************************************************************/
    2729             : /*                                                                 */
    2730             : /*                             ASSIGNMENTS                         */
    2731             : /*                                                                 */
    2732             : /*******************************************************************/
    2733           0 : INLINE void mpexpz(GEN x, GEN z)
    2734           0 : { pari_sp av = avma; gaffect(mpexp(x), z); set_avma(av); }
    2735           0 : INLINE void mplogz(GEN x, GEN z)
    2736           0 : { pari_sp av = avma; gaffect(mplog(x), z); set_avma(av); }
    2737           0 : INLINE void mpcosz(GEN x, GEN z)
    2738           0 : { pari_sp av = avma; gaffect(mpcos(x), z); set_avma(av); }
    2739           0 : INLINE void mpsinz(GEN x, GEN z)
    2740           0 : { pari_sp av = avma; gaffect(mpsin(x), z); set_avma(av); }
    2741           0 : INLINE void gnegz(GEN x, GEN z)
    2742           0 : { pari_sp av = avma; gaffect(gneg(x), z); set_avma(av); }
    2743           0 : INLINE void gabsz(GEN x, long prec, GEN z)
    2744           0 : { pari_sp av = avma; gaffect(gabs(x,prec), z); set_avma(av); }
    2745           0 : INLINE void gaddz(GEN x, GEN y, GEN z)
    2746           0 : { pari_sp av = avma; gaffect(gadd(x,y), z); set_avma(av); }
    2747           0 : INLINE void gsubz(GEN x, GEN y, GEN z)
    2748           0 : { pari_sp av = avma; gaffect(gsub(x,y), z); set_avma(av); }
    2749           0 : INLINE void gmulz(GEN x, GEN y, GEN z)
    2750           0 : { pari_sp av = avma; gaffect(gmul(x,y), z); set_avma(av); }
    2751           0 : INLINE void gdivz(GEN x, GEN y, GEN z)
    2752           0 : { pari_sp av = avma; gaffect(gdiv(x,y), z); set_avma(av); }
    2753           0 : INLINE void gdiventz(GEN x, GEN y, GEN z)
    2754           0 : { pari_sp av = avma; gaffect(gdivent(x,y), z); set_avma(av); }
    2755           0 : INLINE void gmodz(GEN x, GEN y, GEN z)
    2756           0 : { pari_sp av = avma; gaffect(gmod(x,y), z); set_avma(av); }
    2757           0 : INLINE void gmul2nz(GEN x, long s, GEN z)
    2758           0 : { pari_sp av = avma; gaffect(gmul2n(x,s), z); set_avma(av); }
    2759           0 : INLINE void gshiftz(GEN x, long s, GEN z)
    2760           0 : { pari_sp av = avma; gaffect(gshift(x,s), z); set_avma(av); }
    2761             : 
    2762             : /*******************************************************************/
    2763             : /*                                                                 */
    2764             : /*                       ELLIPTIC CURVES                           */
    2765             : /*                                                                 */
    2766             : /*******************************************************************/
    2767     7116195 : INLINE GEN ell_get_a1(GEN e) { return gel(e,1); }
    2768     5709704 : INLINE GEN ell_get_a2(GEN e) { return gel(e,2); }
    2769     6912842 : INLINE GEN ell_get_a3(GEN e) { return gel(e,3); }
    2770     6522705 : INLINE GEN ell_get_a4(GEN e) { return gel(e,4); }
    2771     7961478 : INLINE GEN ell_get_a6(GEN e) { return gel(e,5); }
    2772     5432777 : INLINE GEN ell_get_b2(GEN e) { return gel(e,6); }
    2773     2135641 : INLINE GEN ell_get_b4(GEN e) { return gel(e,7); }
    2774     3055105 : INLINE GEN ell_get_b6(GEN e) { return gel(e,8); }
    2775     2608978 : INLINE GEN ell_get_b8(GEN e) { return gel(e,9); }
    2776     8021709 : INLINE GEN ell_get_c4(GEN e) { return gel(e,10); }
    2777     8850348 : INLINE GEN ell_get_c6(GEN e) { return gel(e,11); }
    2778    11279869 : INLINE GEN ell_get_disc(GEN e) { return gel(e,12); }
    2779     1295726 : INLINE GEN ell_get_j(GEN e) { return gel(e,13); }
    2780    11588331 : INLINE long ell_get_type(GEN e) { return mael(e,14,1); }
    2781     2036746 : INLINE GEN ellff_get_field(GEN x) { return gmael(x, 15, 1); }
    2782      800034 : INLINE GEN ellff_get_a4a6(GEN x)  { return gmael(x, 15, 2); }
    2783        1463 : INLINE GEN ellQp_get_zero(GEN x) { return gmael(x, 15, 1); }
    2784         308 : INLINE long ellQp_get_prec(GEN E) { return valp(ellQp_get_zero(E)); }
    2785        1134 : INLINE GEN ellQp_get_p(GEN E) { return padic_p(ellQp_get_zero(E)); }
    2786      232582 : INLINE long ellR_get_prec(GEN x) { return nbits2prec(mael3(x, 15, 1, 1)); }
    2787      371325 : INLINE long ellR_get_sign(GEN x) { return mael3(x, 15, 1, 2); }
    2788     2027603 : INLINE GEN ellnf_get_nf(GEN x) { return checknf_i(gmael(x,15,1)); }
    2789         126 : INLINE GEN ellnf_get_bnf(GEN x) { return checkbnf_i(gmael(x,15,1)); }
    2790             : 
    2791     4677492 : INLINE int checkell_i(GEN e) { return typ(e) == t_VEC && lg(e) == 17; }
    2792    51072998 : INLINE int ell_is_inf(GEN z) { return lg(z) == 2; }
    2793     1868493 : INLINE GEN ellinf(void) { return mkvec(gen_0); }
    2794             : 
    2795             : /*******************************************************************/
    2796             : /*                                                                 */
    2797             : /*                    ALGEBRAIC NUMBER THEORY                      */
    2798             : /*                                                                 */
    2799             : /*******************************************************************/
    2800    30052504 : INLINE GEN modpr_get_pr(GEN x)  { return gel(x,3); }
    2801     1888446 : INLINE GEN modpr_get_p(GEN x)  { return pr_get_p(modpr_get_pr(x)); }
    2802    13187471 : INLINE GEN modpr_get_T(GEN x)  { return lg(x) == 4? NULL: gel(x,4); }
    2803             : 
    2804    89368727 : INLINE GEN pr_get_p(GEN pr)  { return gel(pr,1); }
    2805    11508177 : INLINE GEN pr_get_gen(GEN pr){ return gel(pr,2); }
    2806             : /* .[2] instead of itos works: e and f are small positive integers */
    2807    15718247 : INLINE long pr_get_e(GEN pr) { return gel(pr,3)[2]; }
    2808    25341018 : INLINE long pr_get_f(GEN pr) { return gel(pr,4)[2]; }
    2809    47842516 : INLINE GEN pr_get_tau(GEN pr){ return gel(pr,5); }
    2810             : INLINE int
    2811    16399400 : pr_is_inert(GEN P) { return typ(pr_get_tau(P)) == t_INT; }
    2812             : INLINE GEN
    2813     1066910 : pr_norm(GEN pr) { return powiu(pr_get_p(pr), pr_get_f(pr)); }
    2814             : INLINE ulong
    2815      343931 : upr_norm(GEN pr) { return upowuu(pr_get_p(pr)[2], pr_get_f(pr)); }
    2816             : 
    2817             : /* assume nf a genuine nf */
    2818             : INLINE long
    2819     1167335 : nf_get_varn(GEN nf) { return varn(gel(nf,1)); }
    2820             : INLINE GEN
    2821    94431081 : nf_get_pol(GEN nf) { return gel(nf,1); }
    2822             : INLINE long
    2823    68810677 : nf_get_degree(GEN nf) { return degpol( nf_get_pol(nf) ); }
    2824             : INLINE long
    2825    22160779 : nf_get_r1(GEN nf) { GEN x = gel(nf,2); return itou(gel(x,1)); }
    2826             : INLINE long
    2827        4140 : nf_get_r2(GEN nf) { GEN x = gel(nf,2); return itou(gel(x,2)); }
    2828             : INLINE GEN
    2829      456897 : nf_get_disc(GEN nf) { return gel(nf,3); }
    2830             : INLINE GEN
    2831     3580215 : nf_get_index(GEN nf) { return gel(nf,4); }
    2832             : INLINE GEN
    2833    20766678 : nf_get_M(GEN nf) { return gmael(nf,5,1); }
    2834             : INLINE GEN
    2835      301274 : nf_get_G(GEN nf) { return gmael(nf,5,2); }
    2836             : INLINE GEN
    2837     1685995 : nf_get_roundG(GEN nf) { return gmael(nf,5,3); }
    2838             : INLINE GEN
    2839       22081 : nf_get_Tr(GEN nf) { return gmael(nf,5,4); }
    2840             : INLINE GEN
    2841        4438 : nf_get_diff(GEN nf) { return gmael(nf,5,5); }
    2842             : INLINE GEN
    2843       59381 : nf_get_ramified_primes(GEN nf) { return gmael(nf,5,8); }
    2844             : INLINE GEN
    2845     1531127 : nf_get_roots(GEN nf) { return gel(nf,6); }
    2846             : INLINE GEN
    2847        4382 : nf_get_zk(GEN nf)
    2848             : {
    2849        4382 :   GEN y = gel(nf,7), D = gel(y, 1);
    2850        4382 :   if (typ(D) == t_POL) D = gel(D, 2);
    2851        4382 :   if (!equali1(D)) y = gdiv(y, D);
    2852        4382 :   return y;
    2853             : }
    2854             : INLINE GEN
    2855     5021316 : nf_get_zkprimpart(GEN nf)
    2856             : {
    2857     5021316 :   GEN y = gel(nf,7);
    2858             :   /* test for old format of nf.zk: non normalized */
    2859     5021316 :   if (!equali1(gel(nf,4)) && gequal1(gel(y,1))) y = Q_remove_denom(y,NULL);
    2860     5021309 :   return y;
    2861             : }
    2862             : INLINE GEN
    2863     5067159 : nf_get_zkden(GEN nf)
    2864             : {
    2865     5067159 :   GEN y = gel(nf,7), D = gel(y,1);
    2866     5067159 :   if (typ(D) == t_POL) D = gel(D,2);
    2867             :   /* test for old format of nf.zk: non normalized */
    2868     5067159 :   if (!equali1(gel(nf,4)) && equali1(D)) D = Q_denom(y);
    2869     5067162 :   return D;
    2870             : }
    2871             : INLINE GEN
    2872     9487042 : nf_get_invzk(GEN nf) { return gel(nf,8); }
    2873             : INLINE void
    2874      516827 : nf_get_sign(GEN nf, long *r1, long *r2)
    2875             : {
    2876      516827 :   GEN x = gel(nf,2);
    2877      516827 :   *r1 = itou(gel(x,1));
    2878      516827 :   *r2 = itou(gel(x,2));
    2879      516827 : }
    2880             : 
    2881             : INLINE GEN
    2882     2521140 : cyc_get_expo(GEN c) { return lg(c) == 1? gen_1: gel(c,1); }
    2883             : INLINE GEN
    2884      391887 : abgrp_get_no(GEN x) { return gel(x,1); }
    2885             : INLINE GEN
    2886    11549156 : abgrp_get_cyc(GEN x) { return gel(x,2); }
    2887             : INLINE GEN
    2888     1653645 : abgrp_get_gen(GEN x) { return gel(x,3); }
    2889             : INLINE GEN
    2890     9425782 : bnf_get_nf(GEN bnf) { return gel(bnf,7); }
    2891             : INLINE GEN
    2892     5097423 : bnf_get_clgp(GEN bnf) { return gmael(bnf,8,1); }
    2893             : INLINE GEN
    2894        8358 : bnf_get_no(GEN bnf) { return abgrp_get_no(bnf_get_clgp(bnf)); }
    2895             : INLINE GEN
    2896     3509044 : bnf_get_cyc(GEN bnf) { return abgrp_get_cyc(bnf_get_clgp(bnf)); }
    2897             : INLINE GEN
    2898     1579856 : bnf_get_gen(GEN bnf)  { return abgrp_get_gen(bnf_get_clgp(bnf)); }
    2899             : INLINE GEN
    2900         641 : bnf_get_reg(GEN bnf) { return gmael(bnf,8,2); }
    2901             : INLINE GEN
    2902     2702040 : bnf_get_logfu(GEN bnf) { return gel(bnf,3); }
    2903             : INLINE GEN
    2904     1278295 : bnf_get_sunits(GEN bnf)
    2905     1278295 : { GEN s = gmael(bnf,8,3); return typ(s) == t_INT? NULL: s; }
    2906             : INLINE GEN
    2907      290535 : bnf_get_tuU(GEN bnf) { return gmael3(bnf,8,4,2); }
    2908             : INLINE long
    2909      265194 : bnf_get_tuN(GEN bnf) { return gmael3(bnf,8,4,1)[2]; }
    2910             : INLINE GEN
    2911      288187 : bnf_get_fu_nocheck(GEN bnf) { return gmael(bnf,8,5); }
    2912             : INLINE GEN
    2913       26293 : nfV_to_scalar_or_alg(GEN nf, GEN x)
    2914       63435 : { pari_APPLY_same(nf_to_scalar_or_alg(nf, gel(x,i))) }
    2915             : INLINE GEN
    2916       25852 : bnf_get_fu(GEN bnf) {
    2917       25852 :   GEN fu = bnf_build_units(bnf), nf = bnf_get_nf(bnf);
    2918       25852 :   if (typ(fu) == t_MAT) pari_err(e_MISC,"missing units in bnf");
    2919       25852 :   return nfV_to_scalar_or_alg(nf, vecslice(fu, 2, lg(fu)-1));
    2920             : }
    2921             : 
    2922             : INLINE GEN
    2923     3632291 : bnr_get_bnf(GEN bnr) { return gel(bnr,1); }
    2924             : INLINE GEN
    2925     1936927 : bnr_get_bid(GEN bnr) { return gel(bnr,2); }
    2926             : INLINE GEN
    2927      140998 : bnr_get_mod(GEN bnr) { return gmael(bnr,2,1); }
    2928             : INLINE GEN
    2929     1260065 : bnr_get_nf(GEN bnr) { return gmael(bnr,1,7); }
    2930             : INLINE GEN
    2931     2728627 : bnr_get_clgp(GEN bnr) { return gel(bnr,5); }
    2932             : INLINE GEN
    2933      314572 : bnr_get_no(GEN bnr) { return abgrp_get_no(bnr_get_clgp(bnr)); }
    2934             : INLINE GEN
    2935     2396450 : bnr_get_cyc(GEN bnr) { return abgrp_get_cyc(bnr_get_clgp(bnr)); }
    2936             : INLINE GEN
    2937          70 : bnr_get_gen_nocheck(GEN bnr) { return abgrp_get_gen(bnr_get_clgp(bnr)); }
    2938             : INLINE GEN
    2939        7847 : bnr_get_gen(GEN bnr) {
    2940        7847 :   GEN G = bnr_get_clgp(bnr);
    2941        7847 :   if (lg(G) !=  4)
    2942           0 :     pari_err(e_MISC,"missing bnr generators: please use bnrinit(,,1)");
    2943        7847 :   return gel(G,3);
    2944             : }
    2945             : 
    2946             : /* localstar, used in gchar */
    2947             : INLINE GEN
    2948       51955 : locs_get_cyc(GEN locs) { return gel(locs,1); }
    2949             : INLINE GEN
    2950      191695 : locs_get_Lsprk(GEN locs) { return gel(locs,2); }
    2951             : INLINE GEN
    2952        1260 : locs_get_Lgenfil(GEN locs) { return gel(locs,3); }
    2953             : INLINE GEN
    2954        8225 : locs_get_mod(GEN locs) { return gel(locs,4); }
    2955             : /* pr dividing the modulus N of locs, 0 <= i < v_pr(N)
    2956             :  * return a t_MAT whose columns are the logs
    2957             :  * of generators of U_i(pr)/U_{i+1}(pr). */
    2958             : INLINE GEN
    2959        1260 : locs_get_famod(GEN locs) { return gmael(locs,4,1); }
    2960             : INLINE GEN
    2961      207235 : locs_get_m_infty(GEN locs) { return gmael(locs,4,2); }
    2962             : 
    2963             : /* G a grossenchar group */
    2964             : INLINE GEN
    2965       32639 : gchar_get_basis(GEN gc)  { return  gel(gc, 1); }
    2966             : INLINE GEN
    2967      203105 : gchar_get_bnf(GEN gc)    { return  gel(gc, 2); }
    2968             : INLINE GEN
    2969      241501 : gchar_get_nf(GEN gc)    { return  gel(gc, 3); }
    2970             : INLINE GEN
    2971      279434 : gchar_get_zm(GEN gc)     { return  gel(gc, 4); }
    2972             : INLINE GEN
    2973        8225 : gchar_get_mod(GEN gc)    { return  locs_get_mod(gchar_get_zm(gc)); }
    2974             : INLINE GEN
    2975        4095 : gchar_get_modP(GEN gc)    { return gmael(gchar_get_mod(gc),1,1); }
    2976             : INLINE GEN
    2977       36865 : gchar_get_S(GEN gc)      { return  gel(gc, 5); }
    2978             : INLINE GEN
    2979      188468 : gchar_get_DLdata(GEN gc)   { return  gel(gc, 6); }
    2980             : INLINE GEN
    2981        1748 : gchar_get_sfu(GEN gc) { return  gel(gc, 7); }
    2982             : INLINE GEN
    2983       16168 : gchar_get_cyc(GEN gc)    { return  gel(gc, 9); }
    2984             : INLINE GEN
    2985           0 : gchar_get_hnf(GEN gc)    { return  gmael(gc, 10, 1); }
    2986             : INLINE GEN
    2987           0 : gchar_get_U(GEN gc)      { return  gmael(gc, 10, 2); }
    2988             : INLINE GEN
    2989       10969 : gchar_get_Ui(GEN gc)     { return  gmael(gc, 10, 3); }
    2990             : INLINE GEN
    2991        3321 : gchar_get_m0(GEN gc)     { return gel(gc, 11); }
    2992             : INLINE GEN
    2993        4267 : gchar_get_u0(GEN gc)     { return gel(gc, 12); }
    2994             : INLINE long
    2995       17416 : gchar_get_r1(GEN gc)     { return nf_get_r1(gchar_get_nf(gc)); }
    2996             : INLINE long
    2997         623 : gchar_get_r2(GEN gc)     { return nf_get_r2(gchar_get_nf(gc)); }
    2998             : INLINE GEN
    2999       50347 : gchar_get_loccyc(GEN gc) { return locs_get_cyc(gchar_get_zm(gc)); }
    3000             : INLINE long
    3001       37131 : gchar_get_nc(GEN gc)     { return lg(gchar_get_loccyc(gc))-1; }
    3002             : INLINE long
    3003       36865 : gchar_get_ns(GEN gc)     { return lg(gchar_get_S(gc))-1; }
    3004             : INLINE long
    3005        1841 : gchar_get_nm(GEN gc)     { return lg(gchar_get_basis(gc))-1; }
    3006             : INLINE long
    3007        4011 : gchar_get_evalprec(GEN gc)   { return  gmael(gc, 8, 1)[1]; }
    3008             : INLINE long
    3009       18732 : gchar_get_prec(GEN gc)   { return  gmael(gc, 8, 1)[2]; }
    3010             : INLINE long
    3011       13419 : gchar_get_nfprec(GEN gc) { return  gmael(gc, 8, 1)[3]; }
    3012             : INLINE void
    3013        1785 : gchar_set_evalprec(GEN gc, long prec) { gmael(gc, 8, 1)[1] = prec; }
    3014             : INLINE void
    3015        1202 : gchar_set_prec(GEN gc, long prec) { gmael(gc, 8, 1)[2] = prec; }
    3016             : INLINE void
    3017        1202 : gchar_copy_precs(GEN gc, GEN gc2)
    3018             : {
    3019        1202 :   gel(gc2, 8) = shallowcopy(gel(gc,8));
    3020        1202 :   gmael(gc2, 8, 1) = shallowcopy(gmael(gc, 8, 1));
    3021        1202 : }
    3022             : INLINE void
    3023        2950 : gchar_set_nfprec(GEN gc, long prec) { gmael(gc, 8, 1)[3] = prec; }
    3024             : INLINE long
    3025         322 : gchar_get_ntors(GEN gc)   { return  gmael(gc, 8, 2)[1]; }
    3026             : INLINE long
    3027         322 : gchar_get_nfree(GEN gc)   { return  gmael(gc, 8, 2)[2]; }
    3028             : INLINE long
    3029        2042 : gchar_get_nalg(GEN gc)   { return  gmael(gc, 8, 2)[3]; }
    3030             : INLINE void
    3031        1573 : gchar_set_basis(GEN gc, GEN m_inv)  { gel(gc, 1) = m_inv; }
    3032             : INLINE void
    3033        2077 : gchar_set_nf(GEN gc, GEN nf)      { gel(gc, 3) = nf; }
    3034             : INLINE void
    3035         623 : gchar_set_ntors(GEN gc, long n)    { gmael(gc, 8, 2)[1] = n; }
    3036             : INLINE void
    3037         623 : gchar_set_nfree(GEN gc, long n)    { gmael(gc, 8, 2)[2] = n; }
    3038             : INLINE void
    3039         623 : gchar_set_nalg(GEN gc, long n)    { gmael(gc, 8, 2)[3] = n; }
    3040             : INLINE void
    3041        1573 : gchar_set_cyc(GEN gc, GEN cyc)      { gel(gc, 9) = cyc; }
    3042             : INLINE void
    3043         623 : gchar_set_HUUi(GEN gc, GEN hnf, GEN U, GEN Ui) { gel(gc, 10) = mkvec3(hnf, U, Ui); }
    3044             : INLINE void
    3045         950 : gchar_set_m0(GEN gc, GEN m0)     { gel(gc, 11) = m0; }
    3046             : INLINE void
    3047        2093 : gchar_set_u0(GEN gc, GEN u0)     { gel(gc, 12) = u0; }
    3048             : 
    3049             : INLINE GEN
    3050     1386556 : bid_get_mod(GEN bid) { return gel(bid,1); }
    3051             : INLINE GEN
    3052       78295 : bid_get_ideal(GEN bid) { return gmael(bid,1,1); }
    3053             : INLINE GEN
    3054       35098 : bid_get_arch(GEN bid) { return gmael(bid,1,2); }
    3055             : INLINE GEN
    3056     5415498 : bid_get_grp(GEN bid) { return gel(bid,2); }
    3057             : INLINE GEN
    3058     2313944 : bid_get_fact(GEN bid) { return gmael(bid,3,1); }
    3059             : INLINE GEN
    3060     2025283 : bid_get_fact2(GEN bid) { return gmael(bid,3,2); }
    3061             : INLINE GEN
    3062     1990743 : bid_get_MOD(GEN bid) { GEN y = gel(bid,4); return lg(y) == 4? gel(y,3): NULL; }
    3063             : INLINE GEN
    3064     1991473 : bid_get_sprk(GEN bid) { return gmael(bid,4,1); }
    3065             : INLINE GEN
    3066       51226 : bid_get_sarch(GEN bid) { return gmael(bid,4,2); }
    3067             : INLINE GEN
    3068     2217789 : bid_get_archp(GEN bid) { return gmael3(bid,4,2,2); }
    3069             : INLINE GEN
    3070     3378355 : bid_get_U(GEN bid) { return gel(bid,5); }
    3071             : INLINE GEN
    3072           0 : bid_get_no(GEN bid) { return abgrp_get_no(bid_get_grp(bid)); }
    3073             : INLINE GEN
    3074     5361588 : bid_get_cyc(GEN bid) { return abgrp_get_cyc(bid_get_grp(bid)); }
    3075             : INLINE GEN
    3076           0 : bid_get_gen_nocheck(GEN bid)  { return abgrp_get_gen(bid_get_grp(bid)); }
    3077             : INLINE GEN
    3078       53333 : bid_get_gen(GEN bid) {
    3079       53333 :   GEN G = bid_get_grp(bid);
    3080       53333 :   if (lg(G) != 4) pari_err(e_MISC,"missing bid generators. Use idealstar(,,2)");
    3081       53333 :   return abgrp_get_gen(G);
    3082             : }
    3083             : 
    3084             : INLINE GEN
    3085    34544862 : znstar_get_N(GEN G) { return gmael(G,1,1); }
    3086             : INLINE GEN
    3087     7211010 : znstar_get_faN(GEN G) { return gel(G,3); }
    3088             : INLINE GEN
    3089          14 : znstar_get_no(GEN G) { return abgrp_get_no(gel(G,2)); }
    3090             : INLINE GEN
    3091      261976 : znstar_get_cyc(GEN G) { return abgrp_get_cyc(gel(G,2)); }
    3092             : INLINE GEN
    3093       16150 : znstar_get_gen(GEN G) { return abgrp_get_gen(gel(G,2)); }
    3094             : INLINE GEN
    3095     7824104 : znstar_get_conreycyc(GEN G) { return gmael(G,4,5); }
    3096             : INLINE GEN
    3097     3221821 : znstar_get_conreygen(GEN G) { return gmael(G,4,4); }
    3098             : INLINE GEN
    3099       46788 : znstar_get_Ui(GEN G) { return gmael(G,4,3); }
    3100             : INLINE GEN
    3101      176051 : znstar_get_U(GEN G) { return gel(G,5); }
    3102             : INLINE GEN
    3103     2820777 : znstar_get_pe(GEN G) { return gmael(G,4,1); }
    3104             : INLINE GEN
    3105       36112 : gal_get_pol(GEN gal) { return gel(gal,1); }
    3106             : INLINE GEN
    3107        6020 : gal_get_p(GEN gal) { return gmael(gal,2,1); }
    3108             : INLINE GEN
    3109          91 : gal_get_e(GEN gal) { return gmael(gal,2,2); }
    3110             : INLINE GEN
    3111       23772 : gal_get_mod(GEN gal) { return gmael(gal,2,3); }
    3112             : INLINE GEN
    3113       32528 : gal_get_roots(GEN gal) { return gel(gal,3); }
    3114             : INLINE GEN
    3115       27656 : gal_get_invvdm(GEN gal) { return gel(gal,4); }
    3116             : INLINE GEN
    3117       27650 : gal_get_den(GEN gal) { return gel(gal,5); }
    3118             : INLINE GEN
    3119       80170 : gal_get_group(GEN gal) { return gel(gal,6); }
    3120             : INLINE GEN
    3121       15435 : gal_get_gen(GEN gal) { return gel(gal,7); }
    3122             : INLINE GEN
    3123        6664 : gal_get_orders(GEN gal) { return gel(gal,8); }
    3124             : 
    3125             : /* assume rnf a genuine rnf */
    3126             : INLINE long
    3127     2506083 : rnf_get_degree(GEN rnf) { return degpol(rnf_get_pol(rnf)); }
    3128             : INLINE long
    3129       21217 : rnf_get_nfdegree(GEN rnf) { return degpol(nf_get_pol(rnf_get_nf(rnf))); }
    3130             : INLINE long
    3131     1392746 : rnf_get_absdegree(GEN rnf) { return degpol(gmael(rnf,11,1)); }
    3132             : INLINE GEN
    3133        1386 : rnf_get_idealdisc(GEN rnf) { return gmael(rnf,3,1); }
    3134             : INLINE GEN
    3135        1225 : rnf_get_k(GEN rnf) { return gmael(rnf,11,3); }
    3136             : INLINE GEN
    3137        1204 : rnf_get_alpha(GEN rnf) { return gmael(rnf, 11, 2); }
    3138             : INLINE GEN
    3139      733698 : rnf_get_nf(GEN rnf) { return gel(rnf,10); }
    3140             : INLINE GEN
    3141        6559 : rnf_get_nfzk(GEN rnf) { return gel(rnf,2); }
    3142             : INLINE GEN
    3143      314482 : rnf_get_polabs(GEN rnf) { return gmael(rnf,11,1); }
    3144             : INLINE GEN
    3145     2844933 : rnf_get_pol(GEN rnf) { return gel(rnf,1); }
    3146             : INLINE GEN
    3147         350 : rnf_get_disc(GEN rnf) { return gel(rnf,3); }
    3148             : INLINE GEN
    3149         105 : rnf_get_index(GEN rnf) { return gel(rnf,4); }
    3150             : INLINE GEN
    3151        2611 : rnf_get_ramified_primes(GEN rnf) { return gel(rnf,5); }
    3152             : INLINE long
    3153         574 : rnf_get_varn(GEN rnf) { return varn(gel(rnf,1)); }
    3154             : INLINE GEN
    3155      255354 : rnf_get_nfpol(GEN rnf) { return gmael(rnf,10,1); }
    3156             : INLINE long
    3157        4886 : rnf_get_nfvarn(GEN rnf) { return varn(gmael(rnf,10,1)); }
    3158             : INLINE GEN
    3159        4592 : rnf_get_zk(GEN rnf) { return gel(rnf,7); }
    3160             : INLINE GEN
    3161      135183 : rnf_get_map(GEN rnf) { return gel(rnf,11); }
    3162             : INLINE GEN
    3163        1225 : rnf_get_invzk(GEN rnf) { return gel(rnf,8); }
    3164             : 
    3165             : INLINE GEN
    3166      138519 : idealred(GEN nf, GEN id) { return idealred0(nf, id, NULL); }
    3167             : 
    3168             : INLINE GEN
    3169        5427 : idealchineseinit(GEN nf, GEN x)
    3170        5427 : { return idealchinese(nf,x,NULL); }
    3171             : 
    3172             : /*******************************************************************/
    3173             : /*                                                                 */
    3174             : /*                              CLOSURES                           */
    3175             : /*                                                                 */
    3176             : /*******************************************************************/
    3177   368052919 : INLINE long closure_arity(GEN C)          { return ((ulong)C[1])&ARITYBITS; }
    3178    40098206 : INLINE long closure_is_variadic(GEN C) { return !!(((ulong)C[1])&VARARGBITS); }
    3179   319336337 : INLINE const char *closure_codestr(GEN C)  { return GSTR(gel(C,2))-1; }
    3180           0 : INLINE GEN closure_get_code(GEN C)  { return gel(C,2); }
    3181   319310213 : INLINE GEN closure_get_oper(GEN C)  { return gel(C,3); }
    3182   319280756 : INLINE GEN closure_get_data(GEN C)  { return gel(C,4); }
    3183       13523 : INLINE GEN closure_get_dbg(GEN C)   { return gel(C,5); }
    3184       36855 : INLINE GEN closure_get_text(GEN C)  { return gel(C,6); }
    3185    13052221 : INLINE GEN closure_get_frame(GEN C) { return gel(C,7); }
    3186             : 
    3187             : /*******************************************************************/
    3188             : /*                                                                 */
    3189             : /*                               ERRORS                            */
    3190             : /*                                                                 */
    3191             : /*******************************************************************/
    3192             : INLINE long
    3193       62334 : err_get_num(GEN e) { return e[1]; }
    3194             : INLINE GEN
    3195         294 : err_get_compo(GEN e, long i) { return gel(e, i+1); }
    3196             : 
    3197             : INLINE void
    3198          14 : pari_err_BUG(const char *f) { pari_err(e_BUG,f); }
    3199             : INLINE void
    3200          21 : pari_err_CONSTPOL(const char *f) { pari_err(e_CONSTPOL, f); }
    3201             : INLINE void
    3202          84 : pari_err_COPRIME(const char *f, GEN x, GEN y) { pari_err(e_COPRIME, f,x,y); }
    3203             : INLINE void
    3204         718 : pari_err_DIM(const char *f) { pari_err(e_DIM, f); }
    3205             : INLINE void
    3206           0 : pari_err_FILE(const char *f, const char *g) { pari_err(e_FILE, f,g); }
    3207             : INLINE void
    3208          36 : pari_err_FILEDESC(const char *f, long n) { pari_err(e_FILEDESC, f,n); }
    3209             : INLINE void
    3210          98 : pari_err_FLAG(const char *f) { pari_err(e_FLAG,f); }
    3211             : INLINE void
    3212         539 : pari_err_IMPL(const char *f) { pari_err(e_IMPL,f); }
    3213             : INLINE void
    3214       20018 : pari_err_INV(const char *f, GEN x) { pari_err(e_INV,f,x); }
    3215             : INLINE void
    3216          63 : pari_err_IRREDPOL(const char *f, GEN x) { pari_err(e_IRREDPOL, f,x); }
    3217             : INLINE void
    3218        2771 : 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); }
    3219             : INLINE void
    3220         214 : pari_err_COMPONENT(const char *f, const char *op, GEN l, GEN x) { pari_err(e_COMPONENT, f,op,l,x); }
    3221             : INLINE void
    3222           0 : pari_err_MAXPRIME(ulong c) { pari_err(e_MAXPRIME, c); }
    3223             : INLINE void
    3224         406 : pari_err_OP(const char *f, GEN x, GEN y) { pari_err(e_OP, f,x,y); }
    3225             : INLINE void
    3226         156 : pari_err_OVERFLOW(const char *f) { pari_err(e_OVERFLOW, f); }
    3227             : INLINE void
    3228         238 : pari_err_PREC(const char *f) { pari_err(e_PREC,f); }
    3229             : INLINE void
    3230           0 : pari_err_PACKAGE(const char *f) { pari_err(e_PACKAGE,f); }
    3231             : INLINE void
    3232          98 : pari_err_PRIME(const char *f, GEN x) { pari_err(e_PRIME, f,x); }
    3233             : INLINE void
    3234        1316 : pari_err_MODULUS(const char *f, GEN x, GEN y) { pari_err(e_MODULUS, f,x,y); }
    3235             : INLINE void
    3236          63 : pari_err_ROOTS0(const char *f) { pari_err(e_ROOTS0, f); }
    3237             : INLINE void
    3238        7084 : pari_err_SQRTN(const char *f, GEN x) { pari_err(e_SQRTN, f,x); }
    3239             : INLINE void
    3240       15384 : pari_err_TYPE(const char *f, GEN x) { pari_err(e_TYPE, f,x); }
    3241             : INLINE void
    3242        3493 : pari_err_TYPE2(const char *f, GEN x, GEN y) { pari_err(e_TYPE2, f,x,y); }
    3243             : INLINE void
    3244         371 : pari_err_VAR(const char *f, GEN x, GEN y) { pari_err(e_VAR, f,x,y); }
    3245             : INLINE void
    3246         238 : pari_err_PRIORITY(const char *f, GEN x, const char *op, long v)
    3247         238 : { pari_err(e_PRIORITY, f,x,op,v); }
    3248             : 

Generated by: LCOV version 1.16