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 30060-c7c2f950fd) Lines: 1424 1567 90.9 %
Date: 2025-03-09 09:23:40 Functions: 647 718 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     8025461 : 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     3018854 : mkpolmod(GEN x, GEN y) { retmkpolmod(x,y); }
     190             : INLINE GEN
     191    41019902 : 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       19908 : Qtoss(GEN q, long *n, long *d)
     197             : {
     198       19908 :   if (typ(q) == t_INT) { *n = itos(q); *d = 1; }
     199        5796 :   else { *n = itos(gel(q,1)); *d = itou(gel(q,2)); }
     200       19908 : }
     201             : INLINE GEN
     202     1074129 : sstoQ(long n, long d)
     203             : {
     204             :   ulong r;
     205             :   long g, q;
     206     1074129 :   if (!n)
     207             :   {
     208       95095 :     if (!d) pari_err_INV("sstoQ",gen_0);
     209       95095 :     return gen_0;
     210             :   }
     211      979034 :   if (d < 0) { d = -d; n = -n; }
     212      979034 :   if (d == 1) return stoi(n);
     213      959721 :   r = labs(n);
     214      959721 :   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   158072695 : uutoQ(ulong n, ulong d)
     224             : {
     225             :   ulong r;
     226             :   long g, q;
     227   158072695 :   if (!n)
     228             :   {
     229       38108 :     if (!d) pari_err_INV("uutoQ",gen_0);
     230       38108 :     return gen_0;
     231             :   }
     232   158034587 :   if (d == 1) return utoipos(n);
     233   158023485 :   if (n == 1) retmkfrac(gen_1, utoipos(d));
     234   157934502 :   q = udivuu_rem(n,d,&r);
     235   157934502 :   if (!r) return utoipos(q);
     236     5179949 :   g = ugcd(d,r); /* gcd(n,d) */
     237     5179949 :   if (g != 1) { n /= g; d /= g; }
     238     5179949 :   retmkfrac(utoipos(n), utoipos(d));
     239             : }
     240             : 
     241             : INLINE GEN
     242     4844476 : mkfraccopy(GEN x, GEN y) { retmkfrac(icopy(x), icopy(y)); }
     243             : INLINE GEN
     244      698130 : mkrfrac(GEN x, GEN y) { GEN v = cgetg(3, t_RFRAC);
     245      698130 :   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    90164191 : mkcomplex(GEN x, GEN y) { retmkcomplex(x,y); }
     251             : INLINE GEN
     252     1269388 : gen_I(void) { return mkcomplex(gen_0, gen_1); }
     253             : INLINE GEN
     254      968281 : 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   129273643 : mkvecsmall(long x) { GEN v = cgetg(2, t_VECSMALL); v[1] = x; return v; }
     261             : INLINE GEN
     262   223853526 : mkvecsmall2(long x,long y) { GEN v = cgetg(3, t_VECSMALL);
     263   223870857 :   v[1]=x; v[2]=y; return v; }
     264             : INLINE GEN
     265   100377416 : mkvecsmall3(long x,long y,long z) { GEN v = cgetg(4, t_VECSMALL);
     266   100372656 :   v[1]=x; v[2]=y; v[3]=z; return v; }
     267             : INLINE GEN
     268    15476846 : mkvecsmall4(long x,long y,long z,long t) { GEN v = cgetg(5, t_VECSMALL);
     269    15478924 :   v[1]=x; v[2]=y; v[3]=z; v[4]=t; return v; }
     270             : INLINE GEN
     271      689645 : mkvecsmall5(long x,long y,long z,long t,long u) { GEN v = cgetg(6, t_VECSMALL);
     272      689642 :   v[1]=x; v[2]=y; v[3]=z; v[4]=t; v[5]=u; return v; }
     273             : 
     274             : INLINE GEN
     275    27800045 : mkqfb(GEN x, GEN y, GEN z, GEN d) { retmkqfb(x,y,z,d); }
     276             : /* vec */
     277             : INLINE GEN
     278    68035843 : mkvec(GEN x) { retmkvec(x); }
     279             : INLINE GEN
     280   183313802 : mkvec2(GEN x, GEN y) { retmkvec2(x,y); }
     281             : INLINE GEN
     282   115967069 : mkvec3(GEN x, GEN y, GEN z) { retmkvec3(x,y,z); }
     283             : INLINE GEN
     284     6642455 : mkvec4(GEN x, GEN y, GEN z, GEN t) { retmkvec4(x,y,z,t); }
     285             : INLINE GEN
     286    14487862 : 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      220130 : 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      114598 : mkvec2copy(GEN x, GEN y) {
     299      114598 :   GEN v = cgetg(3,t_VEC); gel(v,1) = gcopy(x); gel(v,2) = gcopy(y); return v; }
     300             : /* col */
     301             : INLINE GEN
     302    10182857 : mkcol(GEN x) { retmkcol(x); }
     303             : INLINE GEN
     304   156673466 : 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      232379 : 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     4415292 : 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       33510 : mkcolcopy(GEN x) { GEN v = cgetg(2, t_COL); gel(v,1) = gcopy(x); return v; }
     323             : /* mat */
     324             : INLINE GEN
     325     4610818 : mkmat(GEN x) { retmkmat(x); }
     326             : INLINE GEN
     327    32589728 : 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      121147 : 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     1077646 : mkoo(void) { GEN v = cgetg(2, t_INFINITY); gel(v,1) = gen_1; return v; }
     340             : INLINE GEN
     341      106010 : mkmoo(void) { GEN v = cgetg(2, t_INFINITY); gel(v,1) = gen_m1; return v; }
     342             : INLINE long
     343     1195922 : inf_get_sign(GEN x) { return signe(gel(x,1)); }
     344             : INLINE GEN
     345      207452 : mkmat22s(long a, long b, long c, long d) {retmkmat2(mkcol2s(a,c),mkcol2s(b,d));}
     346             : INLINE GEN
     347    50606616 : mkmat22(GEN a, GEN b, GEN c, GEN d) { retmkmat2(mkcol2(a,c),mkcol2(b,d)); }
     348             : 
     349             : /* pol */
     350             : INLINE GEN
     351     3564612 : pol_x(long v) {
     352     3564612 :   GEN p = cgetg(4, t_POL);
     353     3564613 :   p[1] = evalsigne(1)|evalvarn(v);
     354     3564613 :   gel(p,2) = gen_0;
     355     3564613 :   gel(p,3) = gen_1; return p;
     356             : }
     357             : /* x^n, assume n >= 0 */
     358             : INLINE GEN
     359     2236289 : pol_xn(long n, long v) {
     360     2236289 :   long i, a = n+2;
     361     2236289 :   GEN p = cgetg(a+1, t_POL);
     362     2236291 :   p[1] = evalsigne(1)|evalvarn(v);
     363     5391577 :   for (i = 2; i < a; i++) gel(p,i) = gen_0;
     364     2236291 :   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     4462815 : pol_1(long v) {
     384     4462815 :   GEN p = cgetg(3, t_POL);
     385     4462804 :   p[1] = evalsigne(1)|evalvarn(v);
     386     4462804 :   gel(p,2) = gen_1; return p;
     387             : }
     388             : INLINE GEN
     389    82484543 : pol_0(long v)
     390             : {
     391    82484543 :   GEN x = cgetg(2,t_POL);
     392    82484537 :   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   234087099 : 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    39273033 : const_col(long n, GEN x) { retconst_col(n, x); }
     408             : INLINE GEN
     409    19063701 : const_vecsmall(long n, long c)
     410             : {
     411             :   long i;
     412    19063701 :   GEN V = cgetg(n+1,t_VECSMALL);
     413   754483419 :   for(i=1;i<=n;i++) V[i] = c;
     414    19064481 :   return V;
     415             : }
     416             : 
     417             : /***   ZERO   ***/
     418             : /* O(p^e) */
     419             : INLINE GEN
     420      855950 : 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    42303362 : zeropol(long v) { return pol_0(v); }
     443             : /* vector(n) */
     444             : INLINE GEN
     445   118848224 : zerocol(long n)
     446             : {
     447   118848224 :   GEN y = cgetg(n+1,t_COL);
     448   803982947 :   long i; for (i=1; i<=n; i++) gel(y,i) = gen_0;
     449   118849441 :   return y;
     450             : }
     451             : /* vectorv(n) */
     452             : INLINE GEN
     453    26630285 : zerovec(long n)
     454             : {
     455    26630285 :   GEN y = cgetg(n+1,t_VEC);
     456   391603005 :   long i; for (i=1; i<=n; i++) gel(y,i) = gen_0;
     457    26630272 :   return y;
     458             : }
     459             : /* matrix(m, n) */
     460             : INLINE GEN
     461      109097 : zeromat(long m, long n)
     462             : {
     463      109097 :   GEN y = cgetg(n+1,t_MAT);
     464      109096 :   GEN v = zerocol(m);
     465      403383 :   long i; for (i=1; i<=n; i++) gel(y,i) = v;
     466      109097 :   return y;
     467             : }
     468             : /* = zero_zx, sv is a evalvarn()*/
     469             : INLINE GEN
     470     1426097 : zero_Flx(long sv) { return pol0_Flx(sv); }
     471             : INLINE GEN
     472    58772599 : zero_Flv(long n)
     473             : {
     474    58772599 :   GEN y = cgetg(n+1,t_VECSMALL);
     475   948496525 :   long i; for (i=1; i<=n; i++) y[i] = 0;
     476    58772776 :   return y;
     477             : }
     478             : /* matrix(m, n) */
     479             : INLINE GEN
     480     2783078 : zero_Flm(long m, long n)
     481             : {
     482     2783078 :   GEN y = cgetg(n+1,t_MAT);
     483     2783062 :   GEN v = zero_Flv(m);
     484    17701101 :   long i; for (i=1; i<=n; i++) gel(y,i) = v;
     485     2783066 :   return y;
     486             : }
     487             : /* matrix(m, n) */
     488             : INLINE GEN
     489      232433 : zero_Flm_copy(long m, long n)
     490             : {
     491      232433 :   GEN y = cgetg(n+1,t_MAT);
     492     2403412 :   long i; for (i=1; i<=n; i++) gel(y,i) = zero_Flv(m);
     493      232431 :   return y;
     494             : }
     495             : 
     496             : INLINE GEN
     497     3629249 : zero_F2v(long m)
     498             : {
     499     3629249 :   long l = nbits2nlong(m);
     500     3629241 :   GEN v  = zero_Flv(l+1);
     501     3629204 :   v[1] = m;
     502     3629204 :   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      840382 : zero_F2m_copy(long m, long n)
     519             : {
     520             :   long i;
     521      840382 :   GEN M = cgetg(n+1, t_MAT);
     522     2007657 :   for (i = 1; i <= n; i++)
     523     1167284 :     gel(M,i)= zero_F2v(m);
     524      840373 :   return M;
     525             : }
     526             : 
     527             : /* matrix(m, n) */
     528             : INLINE GEN
     529    14027269 : zeromatcopy(long m, long n)
     530             : {
     531    14027269 :   GEN y = cgetg(n+1,t_MAT);
     532    71003524 :   long i; for (i=1; i<=n; i++) gel(y,i) = zerocol(m);
     533    14027287 :   return y;
     534             : }
     535             : 
     536             : INLINE GEN
     537       24411 : zerovec_block(long len)
     538             : {
     539             :   long i;
     540       24411 :   GEN blk = cgetg_block(len + 1, t_VEC);
     541      805563 :   for (i = 1; i <= len; ++i)
     542      781152 :     gel(blk, i) = gen_0;
     543       24411 :   return blk;
     544             : }
     545             : 
     546             : /* i-th vector in the standard basis */
     547             : INLINE GEN
     548     5681076 : col_ei(long n, long i) { GEN e = zerocol(n); gel(e,i) = gen_1; return e; }
     549             : INLINE GEN
     550     1711562 : 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      494366 : vecsmall_ei(long n, long i) { GEN e = zero_zv(n); e[i] = 1; return e; }
     555             : INLINE GEN
     556     1294220 : Rg_col_ei(GEN x, long n, long i) { GEN e = zerocol(n); gel(e,i) = x; return e; }
     557             : 
     558             : INLINE GEN
     559    25875176 : shallowcopy(GEN x)
     560    25875176 : { return typ(x) == t_MAT ? RgM_shallowcopy(x): leafcopy(x); }
     561             : 
     562             : /* routines for naive growarrays */
     563             : INLINE GEN
     564    11736164 : vectrunc_init(long l)
     565             : {
     566    11736164 :   GEN z = new_chunk(l);
     567    11735973 :   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   317012351 : lg_increase(GEN x) { x[0]++; }
     577             : INLINE void
     578    15261310 : vectrunc_append(GEN x, GEN t) { gel(x, lg(x)) = t; lg_increase(x); }
     579             : INLINE void
     580       10864 : vectrunc_append_batch(GEN x, GEN y)
     581             : {
     582       10864 :   long i, l = lg(x), ly = lg(y);
     583       10864 :   GEN z = x + l-1;
     584       36358 :   for (i = 1; i < ly; i++) gel(z,i) = gel(y,i);
     585       10864 :   setlg(x, l+ly-1);
     586       10864 : }
     587             : INLINE GEN
     588   189449466 : vecsmalltrunc_init(long l)
     589             : {
     590   189449466 :   GEN z = new_chunk(l);
     591   189470226 :   z[0] = evaltyp(t_VECSMALL) | _evallg(1); return z;
     592             : }
     593             : INLINE void
     594    99780020 : 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    18206026 : hash_str_len(const char *str, long len)
     611             : {
     612    18206026 :   ulong hash = 5381UL;
     613             :   long i;
     614   166388304 :   for (i = 0; i < len; i++)
     615             :   {
     616   148182278 :     ulong c = (ulong)*str++;
     617   148182278 :     hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
     618             :   }
     619    18206026 :   return hash;
     620             : }
     621             : 
     622             : /*******************************************************************/
     623             : /*                                                                 */
     624             : /*                        VEC / COL / VECSMALL                     */
     625             : /*                                                                 */
     626             : /*******************************************************************/
     627             : /* shallow*/
     628             : INLINE GEN
     629       11549 : vec_shorten(GEN v, long n)
     630             : {
     631       11549 :   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     3432266 : vec_append(GEN V, GEN s)
     648             : {
     649     3432266 :   long i, l2 = lg(V);
     650     3432266 :   GEN res = cgetg(l2+1, typ(V));
     651    10737328 :   for (i = 1; i < l2; i++) gel(res, i) = gel(V,i);
     652     3432267 :   gel(res,l2) = s; return res;
     653             : }
     654             : /* shallow*/
     655             : INLINE GEN
     656      300960 : vec_prepend(GEN v, GEN s)
     657             : {
     658      300960 :   long i, l = lg(v);
     659      300960 :   GEN w = cgetg(l+1, typ(v));
     660      300965 :   gel(w,1) = s;
     661      769570 :   for (i = 2; i <= l; i++) gel(w,i) = gel(v,i-1);
     662      300965 :   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       72915 : vecsmall_shorten(GEN v, long n)
     674             : {
     675       72915 :   GEN V = cgetg(n+1,t_VECSMALL);
     676             :   long i;
     677      892873 :   for(i = 1; i <= n; i++) V[i] = v[i];
     678       72917 :   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     4016088 : vec_to_vecsmall(GEN x)
     691    18861036 : { pari_APPLY_long(itos(gel(x,i))) }
     692             : INLINE GEN
     693      511214 : vecsmall_to_vec(GEN x)
     694     7069315 : { 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     7761335 : vecsmall_to_col(GEN x)
     704    59563381 : { pari_APPLY_type(t_COL, stoi(x[i])) }
     705             : 
     706             : INLINE int
     707     7209169 : vecsmall_lexcmp(GEN x, GEN y)
     708             : {
     709             :   long lx,ly,l,i;
     710     7209169 :   lx = lg(x);
     711     7209169 :   ly = lg(y); l = minss(lx,ly);
     712    30649362 :   for (i=1; i<l; i++)
     713    29021894 :     if (x[i] != y[i]) return x[i]<y[i]? -1: 1;
     714     1627468 :   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      186795 : vecsmall_prepend(GEN V, long s)
     730             : {
     731      186795 :   long i, l2 = lg(V);
     732      186795 :   GEN res = cgetg(l2+1, typ(V));
     733      186795 :   res[1] = s;
     734      624937 :   for (i = 2; i <= l2; ++i) res[i] = V[i - 1];
     735      186795 :   return res;
     736             : }
     737             : 
     738             : INLINE GEN
     739     4065065 : vecsmall_append(GEN V, long s)
     740             : {
     741     4065065 :   long i, l2 = lg(V);
     742     4065065 :   GEN res = cgetg(l2+1, t_VECSMALL);
     743     5975412 :   for (i = 1; i < l2; ++i) res[i] = V[i];
     744     4065065 :   res[l2] = s; return res;
     745             : }
     746             : 
     747             : INLINE GEN
     748     1464230 : vecsmall_concat(GEN u, GEN v)
     749             : {
     750     1464230 :   long i, l1 = lg(u)-1, l2 = lg(v)-1;
     751     1464230 :   GEN res = cgetg(l1+l2+1, t_VECSMALL);
     752    11617463 :   for (i = 1; i <= l1; ++i) res[i]    = u[i];
     753    15218625 :   for (i = 1; i <= l2; ++i) res[i+l1] = v[i];
     754     1464230 :   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     1011303 : vecsmall_max(GEN x)
     796             : {
     797     1011303 :   long i, t = x[1], lx = lg(x);
     798     2825450 :   for (i=2; i<lx; i++)
     799     1814147 :     if (x[i] > t) t = x[i];
     800     1011303 :   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    22767669 : ZV_isscalar(GEN x)
     823             : {
     824    22767669 :   long l = lg(x);
     825    54273087 :   while (--l > 1)
     826    53878633 :     if (signe(gel(x, l))) return 0;
     827      394454 :   return 1;
     828             : }
     829             : INLINE int
     830    52366423 : QV_isscalar(GEN x)
     831             : {
     832    52366423 :   long lx = lg(x),i;
     833    68056301 :   for (i=2; i<lx; i++)
     834    64338941 :     if (!isintzero(gel(x, i))) return 0;
     835     3717360 :   return 1;
     836             : }
     837             : INLINE int
     838     1140224 : RgV_isscalar(GEN x)
     839             : {
     840     1140224 :   long lx = lg(x),i;
     841     1166406 :   for (i=2; i<lx; i++)
     842     1162692 :     if (!gequal0(gel(x, i))) return 0;
     843        3714 :   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    26877647 : 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       67890 : RgX_is_rational(GEN x)
     862             : {
     863             :   long i;
     864      309363 :   for (i = lg(x)-1; i > 1; i--)
     865      293430 :     if (!is_rational_t(typ(gel(x,i)))) return 0;
     866       15933 :   return 1;
     867             : }
     868             : INLINE int
     869    15295520 : RgX_is_ZX(GEN x)
     870             : {
     871             :   long i;
     872    65359344 :   for (i = lg(x)-1; i > 1; i--)
     873    50128199 :     if (typ(gel(x,i)) != t_INT) return 0;
     874    15231145 :   return 1;
     875             : }
     876             : INLINE int
     877      395657 : RgX_is_QX(GEN x)
     878             : {
     879      395657 :   long k = lg(x)-1;
     880     1482519 :   for ( ; k>1; k--)
     881     1087142 :     if (!is_rational_t(typ(gel(x,k)))) return 0;
     882      395377 :   return 1;
     883             : }
     884             : INLINE int
     885     3111013 : RgX_is_monomial(GEN x)
     886             : {
     887             :   long i;
     888     3111013 :   if (!signe(x)) return 0;
     889     7119002 :   for (i=lg(x)-2; i>1; i--)
     890     4721103 :     if (!isexactzero(gel(x,i))) return 0;
     891     2397899 :   return 1;
     892             : }
     893             : INLINE int
     894    31363540 : RgV_is_ZV(GEN x)
     895             : {
     896             :   long i;
     897   124678469 :   for (i = lg(x)-1; i > 0; i--)
     898    93347360 :     if (typ(gel(x,i)) != t_INT) return 0;
     899    31331109 :   return 1;
     900             : }
     901             : INLINE int
     902      140160 : RgV_is_QV(GEN x)
     903             : {
     904             :   long i;
     905      620034 :   for (i = lg(x)-1; i > 0; i--)
     906      482828 :     if (!is_rational_t(typ(gel(x,i)))) return 0;
     907      137206 :   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   704053364 : pari_stack_base(pari_stack *s) { return s->data; }
     927             : 
     928             : INLINE void
     929     5751771 : pari_stack_init(pari_stack *s, size_t size, void **data)
     930             : {
     931     5751771 :   s->data = data;
     932     5751771 :   *data = NULL;
     933     5751771 :   s->n = 0;
     934     5751771 :   s->alloc = 0;
     935     5751771 :   s->size = size;
     936     5751771 : }
     937             : 
     938             : INLINE void
     939   698715363 : pari_stack_alloc(pari_stack *s, long nb)
     940             : {
     941   698715363 :   void **sdat = pari_stack_base(s);
     942   698649505 :   long alloc = s->alloc;
     943   698649505 :   if (s->n+nb <= alloc) return;
     944     2141413 :   if (!alloc)
     945     2045257 :     alloc = nb;
     946             :   else
     947             :   {
     948      196915 :     while (s->n+nb > alloc) alloc <<= 1;
     949             :   }
     950     2141413 :   pari_realloc_ip(sdat,alloc*s->size);
     951     2143336 :   s->alloc = alloc;
     952             : }
     953             : 
     954             : INLINE long
     955   605689539 : pari_stack_new(pari_stack *s) { pari_stack_alloc(s, 1); return s->n++; }
     956             : 
     957             : INLINE void
     958     5356817 : pari_stack_delete(pari_stack *s)
     959             : {
     960     5356817 :   void **sdat = pari_stack_base(s);
     961     5350471 :   if (*sdat) pari_free(*sdat);
     962     5366847 : }
     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   641087427 : vecslice(GEN A, long y1, long y2)
     979             : {
     980   641087427 :   long i,lB = y2 - y1 + 2;
     981   641087427 :   GEN B = cgetg(lB, typ(A));
     982  2854427141 :   for (i=1; i<lB; i++) B[i] = A[y1-1+i];
     983   641067465 :   return B;
     984             : }
     985             : INLINE GEN
     986     2644556 : vecslicepermute(GEN A, GEN p, long y1, long y2)
     987             : {
     988     2644556 :   long i,lB = y2 - y1 + 2;
     989     2644556 :   GEN B = cgetg(lB, typ(A));
     990    29927580 :   for (i=1; i<lB; i++) B[i] = A[p[y1-1+i]];
     991     2644554 :   return B;
     992             : }
     993             : /* rowslice(rowpermute(A,p), x1, x2) */
     994             : INLINE GEN
     995      182517 : rowslicepermute(GEN x, GEN p, long j1, long j2)
     996      770731 : { pari_APPLY_same(vecslicepermute(gel(x,i),p,j1,j2)) }
     997             : 
     998             : INLINE GEN
     999    78316820 : rowslice(GEN x, long j1, long j2)
    1000   657013556 : { pari_APPLY_same(vecslice(gel(x,i), j1, j2)) }
    1001             : 
    1002             : INLINE GEN
    1003    16596751 : matslice(GEN A, long x1, long x2, long y1, long y2)
    1004    16596751 : { 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      354698 : vecsplice(GEN a, long j)
    1014             : {
    1015      354698 :   long i, k, l = lg(a);
    1016             :   GEN b;
    1017      354698 :   if (l == 1) pari_err(e_MISC, "incorrect component in vecsplice");
    1018      354698 :   b = cgetg(l-1, typ(a));
    1019     1503161 :   for (i = k = 1; i < l; i++)
    1020     1148463 :     if (i != j) gel(b, k++) = gel(a,i);
    1021      354698 :   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      762867 : row(GEN x, long j)
    1036     6687647 : { pari_APPLY_type(t_VEC, gcoeff(x, j, i)) }
    1037             : INLINE GEN
    1038     8741478 : Flm_row(GEN x, long j)
    1039   231872907 : { 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      697025 : vecreverse(GEN A)
    1056             : {
    1057             :   long i, l;
    1058      697025 :   GEN B = cgetg_copy(A, &l);
    1059     2407755 :   for (i=1; i<l; i++) gel(B, i) = gel(A, l-i);
    1060      697025 :   return B;
    1061             : }
    1062             : 
    1063             : INLINE GEN
    1064        3073 : vecsmall_reverse(GEN A)
    1065             : {
    1066             :   long i, l;
    1067        3073 :   GEN B = cgetg_copy(A, &l);
    1068       12761 :   for (i=1; i<l; i++) B[i] = A[l-i];
    1069        3073 :   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    77951219 : vecsmallpermute(GEN A, GEN p) { return perm_mul(A, p); }
    1086             : 
    1087             : INLINE GEN
    1088    19832250 : vecpermute(GEN A, GEN x)
    1089   112461276 : { pari_APPLY_type(typ(A), gel(A, x[i])) }
    1090             : 
    1091             : INLINE GEN
    1092     6933261 : veclast(GEN A) { return gel(A, lg(A)-1); }
    1093             : 
    1094             : INLINE GEN
    1095    14414657 : rowpermute(GEN x, GEN p)
    1096   100757967 : { 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     3149552 : identity_zv(long n)
    1106             : {
    1107     3149552 :   GEN v = cgetg(n+1, t_VECSMALL);
    1108             :   long i;
    1109    32213448 :   for (i = 1; i <= n; i++) v[i] = i;
    1110     3149511 :   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     3125209 : 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    80145971 : perm_mul(GEN s, GEN x)
    1138  1014050480 : { 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     2778526 : perm_inv(GEN x)
    1147             : {
    1148             :   long i, lx;
    1149     2778526 :   GEN y = cgetg_copy(x, &lx);
    1150    39056567 :   for (i=1; i<lx; i++) y[ x[i] ] = i;
    1151     2778517 :   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   490907785 : pari_free(void *pointer)
    1165             : {
    1166   490907785 :   BLOCK_SIGINT_START;
    1167   490959772 :   free(pointer);
    1168   490959772 :   BLOCK_SIGINT_END;
    1169   490955910 : }
    1170             : INLINE void*
    1171   721250879 : pari_malloc(size_t size)
    1172             : {
    1173   721250879 :   if (size)
    1174             :   {
    1175             :     char *tmp;
    1176   721252201 :     BLOCK_SIGINT_START;
    1177   721309885 :     tmp = (char*)malloc(size);
    1178   721309885 :     BLOCK_SIGINT_END;
    1179   721305173 :     if (!tmp) pari_err(e_MEM);
    1180   721312081 :     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     2145721 : pari_realloc_ip(void **pointer, size_t size)
    1198             : {
    1199             :   char *tmp;
    1200     2145721 :   BLOCK_SIGINT_START;
    1201     2146046 :   if (!*pointer) tmp = (char *) malloc(size);
    1202      101118 :   else tmp = (char *) realloc(*pointer,size);
    1203     2146046 :   if (!tmp) pari_err(e_MEM);
    1204     2146046 :   *pointer = tmp;
    1205     2146046 :   BLOCK_SIGINT_END;
    1206     2145757 : }
    1207             : 
    1208             : INLINE void*
    1209       47349 : pari_calloc(size_t size)
    1210             : {
    1211       47349 :   void *t = pari_malloc(size);
    1212       47349 :   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  7896137295 : icopy_avma(GEN x, pari_sp av)
    1230             : {
    1231  7896137295 :   long i = lgefint(x), lx = i;
    1232  7896137295 :   GEN y = ((GEN)av) - i;
    1233 57873532430 :   while (--i > 0) y[i] = x[i];
    1234  7896137295 :   y[0] = evaltyp(t_INT)|evallg(lx);
    1235  7899540382 :   return y;
    1236             : }
    1237             : /* copy leaf x as if we had set_avma(av) */
    1238             : INLINE GEN
    1239   549096361 : leafcopy_avma(GEN x, pari_sp av)
    1240             : {
    1241   549096361 :   long i = lg(x);
    1242   549096361 :   GEN y = ((GEN)av) - i;
    1243  2985844891 :   while (--i > 0) y[i] = x[i];
    1244   549096361 :   y[0] = x[0] & (~CLONEBIT);
    1245   549096361 :   return y;
    1246             : }
    1247             : INLINE GEN
    1248  1074481522 : gerepileuptoleaf(pari_sp av, GEN x)
    1249             : {
    1250             :   long lx;
    1251             :   GEN q;
    1252             : 
    1253  1074481522 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1254  1073237329 :   lx = lg(x);
    1255  1073237329 :   q = ((GEN)av) - lx;
    1256  1073237329 :   set_avma((pari_sp)q);
    1257 10826939163 :   while (--lx >= 0) q[lx] = x[lx];
    1258  1072834069 :   return q;
    1259             : }
    1260             : INLINE GEN
    1261  4036162137 : gerepileuptoint(pari_sp av, GEN x)
    1262             : {
    1263  4036162137 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1264  3601018901 :   set_avma((pari_sp)icopy_avma(x, av));
    1265  3604841313 :   return (GEN)avma;
    1266             : }
    1267             : INLINE GEN
    1268  1861036326 : gerepileupto(pari_sp av, GEN x)
    1269             : {
    1270  1861036326 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1271  1677891144 :   switch(typ(x))
    1272             :   { /* non-default = !is_recursive_t(tq) */
    1273   480742569 :     case t_INT: return gerepileuptoint(av, x);
    1274   338309221 :     case t_REAL:
    1275             :     case t_STR:
    1276   338309221 :     case t_VECSMALL: return gerepileuptoleaf(av,x);
    1277   858841413 :     default:
    1278             :       /* NB: x+i --> ((long)x) + i*sizeof(long) */
    1279   858841413 :       return gerepile(av, (pari_sp) (x+lg(x)), x);
    1280             :   }
    1281             : }
    1282             : 
    1283             : /* gerepileupto(av, gcopy(x)) */
    1284             : INLINE GEN
    1285   227568293 : gerepilecopy(pari_sp av, GEN x)
    1286             : {
    1287   227568293 :   if (is_recursive_t(typ(x)))
    1288             :   {
    1289   208070963 :     GENbin *p = copy_bin(x);
    1290   208093921 :     set_avma(av); return bin_copy(p);
    1291             :   }
    1292             :   else
    1293             :   {
    1294    19496929 :     set_avma(av);
    1295    19497104 :     if (x < (GEN)av) {
    1296    19289326 :       if (x < (GEN)pari_mainstack->bot) new_chunk(lg(x));
    1297    19289335 :       x = leafcopy_avma(x, av);
    1298    19289363 :       set_avma((pari_sp)x);
    1299             :     } else
    1300      207780 :       x = leafcopy(x);
    1301    19497129 :     return x;
    1302             :   }
    1303             : }
    1304             : 
    1305             : INLINE void
    1306    47901672 : guncloneNULL(GEN x) { if (x) gunclone(x); }
    1307             : INLINE void
    1308     1379570 : 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      985012 : gerepilemany(pari_sp av, GEN* gptr[], int n)
    1315             : {
    1316             :   int i;
    1317     3913209 :   for (i=0; i<n; i++) *gptr[i] = (GEN)copy_bin(*gptr[i]);
    1318      984736 :   set_avma(av);
    1319     3913848 :   for (i=0; i<n; i++) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1320      985183 : }
    1321             : 
    1322             : INLINE void
    1323    19233280 : gerepileall(pari_sp av, int n, ...)
    1324             : {
    1325             :   int i;
    1326    19233280 :   va_list a; va_start(a, n);
    1327    19233280 :   if (n < 10)
    1328             :   {
    1329             :     GEN *gptr[10];
    1330    58322229 :     for (i=0; i<n; i++)
    1331    39087591 :     { gptr[i] = va_arg(a,GEN*); *gptr[i] = (GEN)copy_bin(*gptr[i]); }
    1332    19234638 :     set_avma(av);
    1333    58324110 :     for (--i; i>=0; i--) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1334             : 
    1335             :   }
    1336             :   else
    1337             :   {
    1338           0 :     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    19235446 :   va_end(a);
    1346    19235446 : }
    1347             : 
    1348             : /* assume 1 <= n < 10 */
    1349             : INLINE GEN
    1350    86214414 : gc_all(pari_sp av, int n, ...)
    1351             : {
    1352             :   int i;
    1353             :   GEN *v[10];
    1354    86214414 :   va_list a; va_start(a, n);
    1355   289661534 :   for (i=0; i<n; i++) { v[i] = va_arg(a,GEN*); *v[i] = (GEN)copy_bin(*v[i]); }
    1356    86214991 :   set_avma(av);
    1357   289662945 :   for (i=0; i<n; i++) *v[i] = bin_copy((GENbin*)*v[i]);
    1358    86215416 :   return *v[0];
    1359             : }
    1360             : 
    1361             : INLINE void
    1362     2202054 : gerepilecoeffs(pari_sp av, GEN x, int n)
    1363             : {
    1364             :   int i;
    1365    26223087 :   for (i=0; i<n; i++) gel(x,i) = (GEN)copy_bin(gel(x,i));
    1366     2202434 :   set_avma(av);
    1367    26224391 :   for (i=0; i<n; i++) gel(x,i) = bin_copy((GENbin*)x[i]);
    1368     2202200 : }
    1369             : 
    1370             : /* p from copy_bin. Copy p->x back to stack, then destroy p */
    1371             : INLINE GEN
    1372   477626923 : bin_copy(GENbin *p)
    1373             : {
    1374             :   GEN x, y, base;
    1375             :   long dx, len;
    1376             : 
    1377   477626923 :   x   = p->x; if (!x) { pari_free(p); return gen_0; }
    1378   448578371 :   len = p->len;
    1379   448578371 :   base= p->base; dx = x - base;
    1380   448578371 :   y = (GEN)memcpy((void*)new_chunk(len), (void*)GENbinbase(p), len*sizeof(long));
    1381   448568953 :   y += dx;
    1382   448568953 :   p->rebase(y, ((ulong)y-(ulong)x));
    1383   448569041 :   pari_free(p); return y;
    1384             : }
    1385             : 
    1386             : INLINE GEN
    1387   926201670 : GENbinbase(GENbin *p) { return (GEN)(p + 1); }
    1388             : 
    1389             : INLINE void
    1390   117645179 : cgiv(GEN x)
    1391             : {
    1392   117645179 :   pari_sp av = (pari_sp)(x+lg(x));
    1393   117645179 :   if (isonstack((GEN)av)) set_avma(av);
    1394   117661219 : }
    1395             : 
    1396             : INLINE void
    1397     1890222 : killblock(GEN x) { gunclone(x); }
    1398             : 
    1399             : INLINE int
    1400   291107641 : 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    17940758 : cxcompotor(GEN z, long prec)
    1410             : {
    1411    17940758 :   switch(typ(z))
    1412             :   {
    1413    11787613 :     case t_INT:  return itor(z, prec);
    1414      293286 :     case t_FRAC: return fractor(z, prec);
    1415     5860177 :     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     8953700 : cxtofp(GEN x, long prec)
    1422     8953700 : { retmkcomplex(cxcompotor(gel(x,1),prec), cxcompotor(gel(x,2),prec)); }
    1423             : 
    1424             : INLINE GEN
    1425      389532 : cxtoreal(GEN q)
    1426      389532 : { return (typ(q) == t_COMPLEX && gequal0(gel(q,2)))? gel(q,1): q; }
    1427             : 
    1428             : INLINE double
    1429    60619242 : gtodouble(GEN x)
    1430             : {
    1431    60619242 :   if (typ(x)!=t_REAL) {
    1432     8161102 :     pari_sp av = avma;
    1433     8161102 :     x = gtofp(x, DEFAULTPREC);
    1434     8160577 :     if (typ(x)!=t_REAL) pari_err_TYPE("gtodouble [t_REAL expected]", x);
    1435     8160577 :     set_avma(av);
    1436             :   }
    1437    60618585 :   return rtodbl(x);
    1438             : }
    1439             : 
    1440             : INLINE int
    1441     2968508 : gisdouble(GEN x, double *g)
    1442             : {
    1443     2968508 :   if (typ(x)!=t_REAL) {
    1444       41913 :     pari_sp av = avma;
    1445       41913 :     x = gtofp(x, DEFAULTPREC);
    1446       41912 :     if (typ(x)!=t_REAL) pari_err_TYPE("gisdouble [t_REAL expected]", x);
    1447       41912 :     set_avma(av);
    1448             :   }
    1449     2968507 :   if (expo(x) >= 0x3ff) return 0;
    1450     2968507 :   *g = rtodbl(x); return 1;
    1451             : }
    1452             : 
    1453             : INLINE long
    1454    85801817 : gtos(GEN x) {
    1455    85801817 :   if (typ(x) != t_INT) pari_err_TYPE("gtos [integer expected]",x);
    1456    85801803 :   return itos(x);
    1457             : }
    1458             : 
    1459             : INLINE ulong
    1460      102627 : gtou(GEN x) {
    1461      102627 :   if (typ(x) != t_INT || signe(x)<0)
    1462           7 :     pari_err_TYPE("gtou [integer >=0 expected]",x);
    1463      102620 :   return itou(x);
    1464             : }
    1465             : 
    1466             : INLINE GEN
    1467    45563472 : absfrac(GEN x)
    1468             : {
    1469    45563472 :   GEN y = cgetg(3, t_FRAC);
    1470    45563493 :   gel(y,1) = absi(gel(x,1));
    1471    45563507 :   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     7912596 : Q_abs(GEN x) { return (typ(x) == t_INT)? absi(x): absfrac(x); }
    1478             : INLINE GEN
    1479      118534 : Q_abs_shallow(GEN x)
    1480      118534 : { 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   252490691 : gtofp(GEN z, long prec)
    1491             : {
    1492   252490691 :   switch(typ(z))
    1493             :   {
    1494   213749682 :     case t_INT:  return itor(z, prec);
    1495     4097531 :     case t_FRAC: return fractor(z, prec);
    1496    25950318 :     case t_REAL: return rtor(z, prec);
    1497     8700662 :     case t_COMPLEX: {
    1498     8700662 :       GEN a = gel(z,1), b = gel(z,2);
    1499     8700662 :       if (isintzero(b)) return cxcompotor(a, prec);
    1500     8700655 :       if (isintzero(a)) {
    1501        9204 :         GEN y = cgetg(3, t_COMPLEX);
    1502        9204 :         b = cxcompotor(b, prec);
    1503        9204 :         gel(y,1) = real_0_bit(expo(b) - prec);
    1504        9204 :         gel(y,2) = b; return y;
    1505             :       }
    1506     8691427 :       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     7133410 : RgX_gtofp(GEN x, long prec)
    1531    37213992 : { pari_APPLY_pol_normalized(gtofp(gel(x,i), prec)); }
    1532             : 
    1533             : INLINE GEN
    1534    33714808 : RgC_gtofp(GEN x, long prec)
    1535   217410348 : { 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     8179822 : RgM_gtofp(GEN x, long prec)
    1543    41264094 : { 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       60613 : RgX_fpnorml2(GEN x, long prec)
    1555             : {
    1556       60613 :   pari_sp av = avma;
    1557       60613 :   return gerepileupto(av, gnorml2(RgX_gtofp(x, prec)));
    1558             : }
    1559             : INLINE GEN
    1560      619432 : RgC_fpnorml2(GEN x, long prec)
    1561             : {
    1562      619432 :   pari_sp av = avma;
    1563      619432 :   return gerepileupto(av, gnorml2(RgC_gtofp(x, prec)));
    1564             : }
    1565             : INLINE GEN
    1566       22536 : RgM_fpnorml2(GEN x, long prec)
    1567             : {
    1568       22536 :   pari_sp av = avma;
    1569       22536 :   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      244492 : affc_fixlg(GEN x, GEN res)
    1588             : {
    1589      244492 :   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       37614 :     set_avma((pari_sp)(res+3));
    1597       37614 :     res = cgetr(realprec(gel(res,1)));
    1598       37614 :     affrr_fixlg(x, res);
    1599             :   }
    1600      244492 :   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       41479 : ndec2nlong(long x) { return 1 + (long)((x)*(LOG2_10/BITS_IN_LONG)); }
    1613             : INLINE long
    1614       33209 : 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    12572907 : nbits2nlong(long x) {
    1622    12572907 :   return (long)(((ulong)x+BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1623             : }
    1624             : 
    1625             : INLINE long
    1626  1477344507 : nbits2extraprec(long x) {
    1627  1477344507 :   return (((ulong)x+BITS_IN_LONG-1)>>TWOPOTBITS_IN_LONG) << TWOPOTBITS_IN_LONG;
    1628             : }
    1629             : 
    1630             : INLINE long
    1631   185641726 : nbits2prec(long x) {
    1632   185641726 :   return (((ulong)x+BITS_IN_LONG-1)>>TWOPOTBITS_IN_LONG) << TWOPOTBITS_IN_LONG;
    1633             : }
    1634             : 
    1635             : INLINE long
    1636  4460635663 : prec2lg(long x) {
    1637  4460635663 :   return (long)(((ulong)x+3*BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1638             : }
    1639             : /* ceil(x / sizeof(long)) */
    1640             : INLINE long
    1641   120832948 : nchar2nlong(long x) {
    1642   120832948 :   return (long)(((ulong)x+sizeof(long)-1) >> (TWOPOTBITS_IN_LONG-3L));
    1643             : }
    1644             : INLINE long
    1645   104451123 : prec2nbits(long x) { return x; }
    1646             : INLINE double
    1647     3175228 : bit_accuracy_mul(long x, double y) { return (x-2) * (BITS_IN_LONG*y); }
    1648             : INLINE double
    1649      575819 : prec2nbits_mul(long x, double y) { return x * y; }
    1650             : INLINE long
    1651   141525712 : bit_prec(GEN x) { return realprec(x); }
    1652             : INLINE long
    1653  3125799206 : 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      475401 : precdbl(long x) {return x << 1;}
    1660             : INLINE long
    1661  8072551275 : divsBIL(long n) { return n >> TWOPOTBITS_IN_LONG; }
    1662             : INLINE long
    1663  7982476455 : 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    80444173 : Fp_red(GEN a, GEN m) { return modii(a, m); }
    1674             : INLINE GEN
    1675   173306259 : Fp_add(GEN a, GEN b, GEN m)
    1676             : {
    1677   173306259 :   pari_sp av=avma;
    1678   173306259 :   GEN p = addii(a,b);
    1679   172798083 :   long s = signe(p);
    1680   172798083 :   if (!s) return p; /* = gen_0 */
    1681   159977114 :   if (s > 0) /* general case */
    1682             :   {
    1683   159720430 :     GEN t = subii(p, m);
    1684   159603147 :     s = signe(t);
    1685   159603147 :     if (!s) return gc_const(av, gen_0);
    1686   151293010 :     if (s < 0) return gc_const((pari_sp)p, p);
    1687    72263345 :     if (cmpii(t, m) < 0) return gerepileuptoint(av, t); /* general case ! */
    1688     3289280 :     p = remii(t, m);
    1689             :   }
    1690             :   else
    1691      260353 :     p = modii(p, m);
    1692     3549711 :   return gerepileuptoint(av, p);
    1693             : }
    1694             : INLINE GEN
    1695    21084565 : Fp_double(GEN x, GEN N)
    1696             : {
    1697    21084565 :   GEN z = shifti(x, 1);
    1698    20763094 :   return cmpii(z, N) >= 0? subii(z, N): z;
    1699             : }
    1700             : INLINE GEN
    1701   202996932 : Fp_sub(GEN a, GEN b, GEN m)
    1702             : {
    1703   202996932 :   pari_sp av=avma;
    1704   202996932 :   GEN p = subii(a,b);
    1705   201499831 :   long s = signe(p);
    1706   201499831 :   if (!s) return p; /* = gen_0 */
    1707   185825656 :   if (s > 0)
    1708             :   {
    1709    93150703 :     if (cmpii(p, m) < 0) return p; /* general case ! */
    1710     1449437 :     p = remii(p, m);
    1711             :   }
    1712             :   else
    1713             :   {
    1714    92674953 :     GEN t = addii(p, m);
    1715    94165105 :     if (!s) return gc_const(av, gen_0);
    1716    94161920 :     if (s > 0) return gerepileuptoint(av, t); /* general case ! */
    1717    94161920 :     p = modii(t, m);
    1718             :   }
    1719    95901431 :   return gerepileuptoint(av, p);
    1720             : }
    1721             : INLINE GEN
    1722    28824489 : Fp_neg(GEN b, GEN m)
    1723             : {
    1724    28824489 :   pari_sp av = avma;
    1725    28824489 :   long s = signe(b);
    1726             :   GEN p;
    1727    28824489 :   if (!s) return gen_0;
    1728    24389988 :   if (s > 0)
    1729             :   {
    1730    23263725 :     p = subii(m, b);
    1731    23263292 :     if (signe(p) >= 0) return p; /* general case ! */
    1732      387003 :     p = modii(p, m);
    1733             :   } else
    1734     1126707 :     p = remii(negi(b), m);
    1735     1513930 :   return gerepileuptoint(av, p);
    1736             : }
    1737             : 
    1738             : INLINE GEN
    1739      246928 : Fp_halve(GEN a, GEN p)
    1740             : {
    1741      246928 :   if (mpodd(a)) a = addii(a,p);
    1742      246928 :   return shifti(a,-1);
    1743             : }
    1744             : 
    1745             : /* assume 0 <= u < p and ps2 = p>>1 */
    1746             : INLINE GEN
    1747    75596565 : Fp_center(GEN u, GEN p, GEN ps2)
    1748    75596565 : { return abscmpii(u,ps2)<=0? icopy(u): subii(u,p); }
    1749             : /* same without copy */
    1750             : INLINE GEN
    1751    14117714 : Fp_center_i(GEN u, GEN p, GEN ps2)
    1752    14117714 : { return abscmpii(u,ps2)<=0? u: subii(u,p); }
    1753             : 
    1754             : /* x + y*z mod p */
    1755             : INLINE GEN
    1756    11251686 : Fp_addmul(GEN x, GEN y, GEN z, GEN p)
    1757             : {
    1758             :   pari_sp av;
    1759    11251686 :   if (!signe(y) || !signe(z)) return Fp_red(x, p);
    1760    10906636 :   if (!signe(x)) return Fp_mul(z,y, p);
    1761     9908152 :   av = avma;
    1762     9908152 :   return gerepileuptoint(av, modii(addii(x, mulii(y,z)), p));
    1763             : }
    1764             : 
    1765             : INLINE GEN
    1766   199537675 : Fp_mul(GEN a, GEN b, GEN m)
    1767             : {
    1768   199537675 :   pari_sp av=avma;
    1769             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1770   199537675 :   (void)new_chunk(lg(a)+lg(b)+(lg(m)<<1));
    1771   199611301 :   p = mulii(a,b);
    1772   199447748 :   set_avma(av); return modii(p,m);
    1773             : }
    1774             : INLINE GEN
    1775    63883493 : Fp_sqr(GEN a, GEN m)
    1776             : {
    1777    63883493 :   pari_sp av=avma;
    1778             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1779    63883493 :   (void)new_chunk((lg(a)+lg(m))<<1);
    1780    64261009 :   p = sqri(a);
    1781    62586228 :   set_avma(av); return remii(p,m); /*Use remii: p >= 0 */
    1782             : }
    1783             : INLINE GEN
    1784    67464813 : Fp_mulu(GEN a, ulong b, GEN m)
    1785             : {
    1786    67464813 :   long l = lgefint(m);
    1787    67464813 :   if (l == 3)
    1788             :   {
    1789    45875904 :     ulong mm = m[2];
    1790    45875904 :     return utoi( Fl_mul(umodiu(a, mm), b, mm) );
    1791             :   } else {
    1792    21588909 :     pari_sp av = avma;
    1793             :     GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1794    21588909 :     (void)new_chunk(lg(a)+1+(l<<1));
    1795    21562233 :     p = muliu(a,b);
    1796    21348044 :     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    23212813 : Fp_inv(GEN a, GEN m)
    1824             : {
    1825             :   GEN res;
    1826    23212813 :   if (! invmod(a,m,&res)) pari_err_INV("Fp_inv", mkintmod(res,m));
    1827    23212570 :   return res;
    1828             : }
    1829             : INLINE GEN
    1830     1100037 : Fp_invsafe(GEN a, GEN m)
    1831             : {
    1832             :   GEN res;
    1833     1100037 :   if (! invmod(a,m,&res)) return NULL;
    1834     1099995 :   return res;
    1835             : }
    1836             : INLINE GEN
    1837    14986899 : Fp_div(GEN a, GEN b, GEN m)
    1838             : {
    1839    14986899 :   pari_sp av = avma;
    1840             :   GEN p;
    1841    14986899 :   if (lgefint(b) == 3)
    1842             :   {
    1843    13842295 :     a = Fp_divu(a, b[2], m);
    1844    13843747 :     if (signe(b) < 0) a = Fp_neg(a, m);
    1845    13843758 :     return a;
    1846             :   }
    1847             :   /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1848     1144604 :   (void)new_chunk(lg(a)+(lg(m)<<1));
    1849     1144608 :   p = mulii(a, Fp_inv(b,m));
    1850     1144608 :   set_avma(av); return modii(p,m);
    1851             : }
    1852             : INLINE GEN
    1853    15086578 : Fp_divu(GEN x, ulong a, GEN p)
    1854             : {
    1855    15086578 :   pari_sp av = avma;
    1856             :   ulong b;
    1857    15086578 :   if (lgefint(p) == 3)
    1858             :   {
    1859    14553607 :     ulong pp = p[2], xp = umodiu(x, pp);
    1860    14554406 :     return xp? utoipos(Fl_div(xp, a % pp, pp)): gen_0;
    1861             :   }
    1862      532971 :   x = Fp_red(x, p);
    1863      532979 :   b = Fl_neg(Fl_div(umodiu(x,a), umodiu(p,a), a), a); /* x + pb = 0 (mod a) */
    1864      532981 :   return gerepileuptoint(av, diviuexact(addmuliu(x, p, b), a));
    1865             : }
    1866             : 
    1867             : INLINE GEN
    1868     1094856 : Flx_mulu(GEN x, ulong a, ulong p) { return Flx_Fl_mul(x,a%p,p); }
    1869             : 
    1870             : INLINE GEN
    1871     2499118 : get_F2x_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1872             : 
    1873             : INLINE long
    1874     2532759 : get_F2x_var(GEN T) { return typ(T)==t_VEC? mael(T,2,1): T[1]; }
    1875             : 
    1876             : INLINE long
    1877     1929142 : 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    25425526 : get_Flx_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1890             : 
    1891             : INLINE long
    1892    67686131 : get_Flx_var(GEN T) { return typ(T)==t_VEC? mael(T,2,1): T[1]; }
    1893             : 
    1894             : INLINE long
    1895    81934973 : 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     3393215 : get_FpX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1908             : 
    1909             : INLINE long
    1910     7237986 : get_FpX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1911             : 
    1912             : INLINE long
    1913     6006225 : 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    32802391 : submulii(GEN x, GEN y, GEN z)
    1932             : {
    1933    32802391 :   long lx = lgefint(x), ly, lz;
    1934             :   pari_sp av;
    1935             :   GEN t;
    1936    32802391 :   if (lx == 2) { t = mulii(z,y); togglesign(t); return t; }
    1937    30269887 :   ly = lgefint(y);
    1938    30269887 :   if (ly == 2) return icopy(x);
    1939    29001635 :   lz = lgefint(z);
    1940    29001635 :   av = avma; (void)new_chunk(lx+ly+lz); /* HACK */
    1941    29001635 :   t = mulii(z, y);
    1942    29001635 :   set_avma(av); return subii(x,t);
    1943             : }
    1944             : /* y*z - x */
    1945             : INLINE GEN
    1946     3848770 : mulsubii(GEN y, GEN z, GEN x)
    1947             : {
    1948     3848770 :   long lx = lgefint(x), ly, lz;
    1949             :   pari_sp av;
    1950             :   GEN t;
    1951     3848770 :   if (lx == 2) return mulii(z,y);
    1952     2429602 :   ly = lgefint(y);
    1953     2429602 :   if (ly == 2) return negi(x);
    1954     2152056 :   lz = lgefint(z);
    1955     2152056 :   av = avma; (void)new_chunk(lx+ly+lz); /* HACK */
    1956     2152095 :   t = mulii(z, y);
    1957     2152067 :   set_avma(av); return subii(t,x);
    1958             : }
    1959             : 
    1960             : /* x - u*y */
    1961             : INLINE GEN
    1962        7693 : submuliu(GEN x, GEN y, ulong u)
    1963             : {
    1964             :   pari_sp av;
    1965        7693 :   long ly = lgefint(y);
    1966        7693 :   if (ly == 2) return icopy(x);
    1967        7693 :   av = avma;
    1968        7693 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1969        7693 :   y = mului(u,y);
    1970        7693 :   set_avma(av); return subii(x, y);
    1971             : }
    1972             : /* x + u*y */
    1973             : INLINE GEN
    1974      541049 : addmuliu(GEN x, GEN y, ulong u)
    1975             : {
    1976             :   pari_sp av;
    1977      541049 :   long ly = lgefint(y);
    1978      541049 :   if (ly == 2) return icopy(x);
    1979      541049 :   av = avma;
    1980      541049 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1981      541049 :   y = mului(u,y);
    1982      541048 :   set_avma(av); return addii(x, y);
    1983             : }
    1984             : /* x - u*y */
    1985             : INLINE GEN
    1986    59990228 : submuliu_inplace(GEN x, GEN y, ulong u)
    1987             : {
    1988             :   pari_sp av;
    1989    59990228 :   long ly = lgefint(y);
    1990    59990228 :   if (ly == 2) return x;
    1991    38019033 :   av = avma;
    1992    38019033 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1993    38024090 :   y = mului(u,y);
    1994    38023864 :   set_avma(av); return subii(x, y);
    1995             : }
    1996             : /* x + u*y */
    1997             : INLINE GEN
    1998    59489521 : addmuliu_inplace(GEN x, GEN y, ulong u)
    1999             : {
    2000             :   pari_sp av;
    2001    59489521 :   long ly = lgefint(y);
    2002    59489521 :   if (ly == 2) return x;
    2003    37927533 :   av = avma;
    2004    37927533 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    2005    37931928 :   y = mului(u,y);
    2006    37931779 :   set_avma(av); return addii(x, y);
    2007             : }
    2008             : /* ux + vy */
    2009             : INLINE GEN
    2010    37847364 : lincombii(GEN u, GEN v, GEN x, GEN y)
    2011             : {
    2012    37847364 :   long lx = lgefint(x), ly;
    2013             :   GEN p1, p2;
    2014             :   pari_sp av;
    2015    37847364 :   if (lx == 2) return mulii(v,y);
    2016    23797488 :   ly = lgefint(y);
    2017    23797488 :   if (ly == 2) return mulii(u,x);
    2018    21114446 :   av = avma; (void)new_chunk(lx+ly+lgefint(u)+lgefint(v)); /* HACK */
    2019    21117622 :   p1 = mulii(u,x);
    2020    21116448 :   p2 = mulii(v,y);
    2021    21116305 :   set_avma(av); return addii(p1,p2);
    2022             : }
    2023             : 
    2024             : /*******************************************************************/
    2025             : /*                                                                 */
    2026             : /*                          GEN SUBTYPES                           */
    2027             : /*                                                                 */
    2028             : /*******************************************************************/
    2029             : 
    2030             : INLINE int
    2031  4884415568 : 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     9576209 : is_intreal_t(long t) { return (t <= t_REAL); }
    2036             : INLINE int
    2037   655817813 : is_matvec_t(long t) { return (t >= t_VEC && t <= t_MAT); }
    2038             : INLINE int
    2039    90578600 : 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     5016259 : is_rational_t(long t) { return (t == t_INT || t == t_FRAC); }
    2044             : INLINE int
    2045    62561553 : is_real_t(long t) { return (t == t_INT || t == t_REAL || t == t_FRAC); }
    2046             : INLINE int
    2047  9169019504 : is_recursive_t(long t) { return lontyp[t]; }
    2048             : INLINE int
    2049   368237160 : is_scalar_t(long t) { return (t < t_POL); }
    2050             : INLINE int
    2051    43394344 : is_vec_t(long t) { return (t == t_VEC || t == t_COL); }
    2052             : 
    2053             : INLINE int
    2054    68048659 : qfb_is_qfi(GEN q) { return signe(gel(q,4)) < 0; }
    2055             : 
    2056             : /*******************************************************************/
    2057             : /*                                                                 */
    2058             : /*                         TRANSCENDENTAL                          */
    2059             : /*                                                                 */
    2060             : /*******************************************************************/
    2061             : INLINE GEN
    2062    79927360 : sqrtr(GEN x) {
    2063    79927360 :   long s = signe(x);
    2064    79927360 :   if (s == 0) return real_0_bit(expo(x) >> 1);
    2065    79894245 :   if (s >= 0) return sqrtr_abs(x);
    2066      433451 :   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     2795783 : sqrtnr(GEN x, long n) {
    2081     2795783 :   long s = signe(x);
    2082             :   GEN r;
    2083     2795783 :   if (s == 0) return real_0_bit(expo(x) / n);
    2084     2795783 :   r = sqrtnr_abs(x, n);
    2085     2795779 :   if (s < 0) pari_err_IMPL("sqrtnr for x < 0");
    2086     2795779 :   return r;
    2087             : }
    2088             : INLINE long
    2089      752227 : logint(GEN B, GEN y) { return logintall(B,y,NULL); }
    2090             : INLINE ulong
    2091     1733829 : ulogint(ulong B, ulong y)
    2092             : {
    2093             :   ulong r;
    2094             :   long e;
    2095     1733829 :   if (y == 2) return expu(B);
    2096     1685815 :   r = y;
    2097     5099687 :   for (e=1;; e++)
    2098             :   { /* here, r = y^e, r2 = y^(e-1) */
    2099     5099687 :     if (r >= B) return r == B? e: e-1;
    2100     3415228 :     r = umuluu_or_0(y, r);
    2101     3415305 :     if (!r) return e;
    2102             :   }
    2103             : }
    2104             : 
    2105             : /*******************************************************************/
    2106             : /*                                                                 */
    2107             : /*                         MISCELLANEOUS                           */
    2108             : /*                                                                 */
    2109             : /*******************************************************************/
    2110     9576105 : INLINE int ismpzero(GEN x) { return is_intreal_t(typ(x)) && !signe(x); }
    2111  2800445653 : INLINE int isintzero(GEN x) { return typ(x) == t_INT && !signe(x); }
    2112    17006323 : INLINE int isint1(GEN x) { return typ(x)==t_INT && equali1(x); }
    2113     5702018 : INLINE int isintm1(GEN x){ return typ(x)==t_INT && equalim1(x);}
    2114  1276182562 : INLINE int equali1(GEN n)
    2115  1276182562 : { return (ulong) n[1] == (evallgefint(3UL) | evalsigne(1)) && n[2] == 1; }
    2116   139008423 : INLINE int equalim1(GEN n)
    2117   139008423 : { return (ulong) n[1] == (evallgefint(3UL) | evalsigne(-1)) && n[2] == 1; }
    2118             : /* works only for POSITIVE integers */
    2119  2188215327 : INLINE int is_pm1(GEN n)
    2120  2188215327 : { return lgefint(n) == 3 && n[2] == 1; }
    2121   557478882 : INLINE int is_bigint(GEN n)
    2122   557478882 : { long l = lgefint(n); return l > 3 || (l == 3 && (n[2] & HIGHBIT)); }
    2123             : 
    2124  2055888253 : INLINE int odd(long x) { return x & 1; }
    2125   116735111 : INLINE int both_odd(long x, long y) { return x & y & 1; }
    2126             : 
    2127             : INLINE int
    2128  8051053866 : isonstack(GEN x)
    2129  8051053866 : { return ((pari_sp)x >= pari_mainstack->bot
    2130  8051053866 :        && (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    92973732 : dbllog2r(GEN x)
    2135    92973732 : { return log2((double)(ulong)x[2]) + (double)(expo(x) - (BITS_IN_LONG-1)); }
    2136             : 
    2137             : INLINE GEN
    2138     2513138 : mul_content(GEN cx, GEN cy)
    2139             : {
    2140     2513138 :   if (!cx) return cy;
    2141      520420 :   if (!cy) return cx;
    2142      332956 :   return gmul(cx,cy);
    2143             : }
    2144             : INLINE GEN
    2145           0 : inv_content(GEN c) { return c? ginv(c): NULL; }
    2146             : INLINE GEN
    2147       58000 : div_content(GEN cx, GEN cy)
    2148             : {
    2149       58000 :   if (!cy) return cx;
    2150       56866 :   if (!cx) return ginv(cy);
    2151       25802 :   return gdiv(cx,cy);
    2152             : }
    2153             : INLINE GEN
    2154    10295643 : mul_denom(GEN dx, GEN dy)
    2155             : {
    2156    10295643 :   if (!dx) return dy;
    2157     1836346 :   if (!dy) return dx;
    2158     1368493 :   return mulii(dx,dy);
    2159             : }
    2160             : 
    2161             : /* POLYNOMIALS */
    2162             : INLINE GEN
    2163     1439472 : constant_coeff(GEN x) { return signe(x)? gel(x,2): gen_0; }
    2164             : INLINE GEN
    2165   169106006 : leading_coeff(GEN x) { return lg(x) == 2? gen_0: gel(x,lg(x)-1); }
    2166             : INLINE ulong
    2167      969902 : Flx_lead(GEN x) { return lg(x) == 2? 0: x[lg(x)-1]; }
    2168             : INLINE ulong
    2169      330361 : Flx_constant(GEN x) { return lg(x) == 2? 0: x[2]; }
    2170             : INLINE long
    2171  5337487517 : degpol(GEN x) { return lg(x)-3; }
    2172             : INLINE long
    2173  2624962596 : lgpol(GEN x) { return lg(x)-2; }
    2174             : INLINE long
    2175   341355562 : lgcols(GEN x) { return lg(gel(x,1)); }
    2176             : INLINE long
    2177   153706437 : 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     2128202 : ZXQ_mul(GEN y, GEN x, GEN T) { return ZX_rem(ZX_mul(y, x), T); }
    2183             : INLINE GEN
    2184      951167 : ZXQ_sqr(GEN x, GEN T) { return ZX_rem(ZX_sqr(x), T); }
    2185             : 
    2186             : INLINE GEN
    2187   103470116 : RgX_copy(GEN x)
    2188   376963577 : { 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     2551365 : RgX_coeff(GEN x, long n)
    2193             : {
    2194     2551365 :   ulong l = lg(x);
    2195     2551365 :   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     7054214 : 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     5438169 : FpX_div(GEN x, GEN y, GEN p) { return FpX_divrem(x,y,p, NULL); }
    2207             : INLINE GEN
    2208     1996142 : Flx_div(GEN x, GEN y, ulong p) { return Flx_divrem(x,y,p, NULL); }
    2209             : INLINE GEN
    2210    21458249 : Flx_div_pre(GEN x, GEN y, ulong p, ulong pi)
    2211    21458249 : { return Flx_divrem_pre(x,y,p,pi, NULL); }
    2212             : INLINE GEN
    2213     1566782 : 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   101808205 : pol0_Flx(long sv) { return mkvecsmall(sv); }
    2218             : INLINE GEN
    2219    54623747 : pol1_Flx(long sv) { return mkvecsmall2(sv, 1); }
    2220             : INLINE GEN
    2221    37659303 : 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    13243538 : pol0_F2x(long sv) { return pol0_Flx(sv); }
    2234             : INLINE GEN
    2235     3954895 : pol1_F2x(long sv) { return pol1_Flx(sv); }
    2236             : INLINE GEN
    2237     1075975 : polx_F2x(long sv) { return mkvecsmall2(sv, 2); }
    2238             : INLINE int
    2239     2873718 : F2x_equal1(GEN x) { return Flx_equal1(x); }
    2240             : INLINE int
    2241     4659855 : F2x_equal(GEN V, GEN W) { return Flx_equal(V,W); }
    2242             : INLINE GEN
    2243    60379084 : F2x_copy(GEN x) { return leafcopy(x); }
    2244             : INLINE GEN
    2245        4487 : F2v_copy(GEN x) { return leafcopy(x); }
    2246             : INLINE GEN
    2247     2545081 : Flv_copy(GEN x) { return leafcopy(x); }
    2248             : INLINE GEN
    2249   172214370 : Flx_copy(GEN x) { return leafcopy(x); }
    2250             : INLINE GEN
    2251     4367755 : vecsmall_copy(GEN x) { return leafcopy(x); }
    2252             : INLINE int
    2253     8319343 : Flx_equal1(GEN x) { return degpol(x)==0 && x[2] == 1; }
    2254             : INLINE int
    2255       12609 : ZX_equal1(GEN x) { return degpol(x)==0 && equali1(gel(x,2)); }
    2256             : INLINE int
    2257     7267577 : ZX_is_monic(GEN x) { return equali1(leading_coeff(x)); }
    2258             : 
    2259             : INLINE GEN
    2260   154380775 : ZX_renormalize(GEN x, long lx)    { return ZXX_renormalize(x,lx); }
    2261             : INLINE GEN
    2262   145123881 : 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     4693707 : FpXQX_renormalize(GEN x, long lx) { return ZXX_renormalize(x,lx); }
    2267             : INLINE GEN
    2268   115174435 : 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       37801 : F2v_to_F2x(GEN x, long sv) {
    2275       37801 :   GEN y = leafcopy(x);
    2276       37801 :   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      480681 : RgX_shift_inplace_init(long v)
    2288      480681 : { 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      480681 : RgX_shift_inplace(GEN x, long v)
    2292             : {
    2293             :   long i, lx;
    2294             :   GEN z;
    2295      480681 :   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      502653 : zv_to_ZV(GEN x) { return vecsmall_to_vec(x); }
    2314             : INLINE GEN
    2315     7747153 : zc_to_ZC(GEN x) { return vecsmall_to_col(x); }
    2316             : INLINE GEN
    2317     3190959 : 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    36171432 : 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     2183401 : 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    10193715 : ZC_hnfrem(GEN x, GEN y) { return ZC_hnfdivrem(x,y,NULL); }
    2339             : INLINE GEN
    2340      326836 : ZM_hnfrem(GEN x, GEN y) { return ZM_hnfdivrem(x,y,NULL); }
    2341             : INLINE GEN
    2342     6934769 : ZM_lll(GEN x, double D, long f) { return ZM_lll_norms(x,D,f,NULL); }
    2343             : INLINE void
    2344     9406032 : RgM_dimensions(GEN x, long *m, long *n) { *n = lg(x)-1; *m = *n? nbrows(x): 0; }
    2345             : INLINE GEN
    2346    21444607 : RgM_shallowcopy(GEN x)
    2347    93341880 : { pari_APPLY_same(leafcopy(gel(x,i))); }
    2348             : INLINE GEN
    2349      198153 : 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     6276342 : 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      539228 : ZM_ZV_mod(GEN x, GEN y)
    2369     1538201 : { pari_APPLY_same(ZV_ZV_mod(gel(x,i), y)) }
    2370             : INLINE GEN
    2371     7323127 : ZV_ZV_mod(GEN x, GEN y)
    2372    18921179 : { 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     3106322 : Fq_red(GEN x, GEN T, GEN p)
    2381     3106322 : { 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       14595 : gener_Fq_local(GEN T, GEN p, GEN L)
    2393           0 : { return T? gener_FpXQ_local(T,p, L)
    2394       14595 :           : 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      165416 : 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      568809 : FqX_Fp_mul(GEN P, GEN u, GEN T, GEN p)
    2425      568809 : { return T? FpXX_Fp_mul(P, u, p): FpX_Fp_mul(P, u, p); }
    2426             : INLINE GEN
    2427      427292 : FqX_Fq_mul(GEN P, GEN U, GEN T, GEN p)
    2428      427292 : { return typ(U)==t_INT ? FqX_Fp_mul(P, U, T, p): FpXQX_FpXQ_mul(P, U, T, p); }
    2429             : INLINE GEN
    2430      367208 : FqX_mul(GEN x, GEN y, GEN T, GEN p)
    2431      367208 : { 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       38448 : FqX_div(GEN x, GEN y, GEN T, GEN p)
    2446       38448 : { 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      691908 : FqX_gcd(GEN P,GEN Q,GEN T,GEN p)
    2464      691908 : {return T? FpXQX_gcd(P,Q,T,p): FpX_gcd(P,Q,p);}
    2465             : INLINE GEN
    2466      443265 : FqX_extgcd(GEN P,GEN Q,GEN T,GEN p, GEN *U, GEN *V)
    2467      443265 : { 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      723863 : FqX_deriv(GEN f, GEN T, GEN p) { return T? FpXX_deriv(f, p): FpX_deriv(f, p); }
    2473             : INLINE GEN
    2474           0 : FqX_integ(GEN f, GEN T, GEN p) { return T? FpXX_integ(f, p): FpX_integ(f, p); }
    2475             : INLINE GEN
    2476      140995 : FqX_factor(GEN f, GEN T, GEN p)
    2477      140995 : { return T?FpXQX_factor(f, T, p): FpX_factor(f, p); }
    2478             : INLINE GEN
    2479           7 : FqX_factor_squarefree(GEN f, GEN T, GEN p)
    2480           7 : { return T ? FpXQX_factor_squarefree(f, T, p): FpX_factor_squarefree(f, p); }
    2481             : INLINE GEN
    2482           7 : FqX_ddf(GEN f, GEN T, GEN p)
    2483           7 : { return T ? FpXQX_ddf(f, T, p): FpX_ddf(f, p); }
    2484             : INLINE GEN
    2485       47786 : FqX_degfact(GEN f, GEN T, GEN p)
    2486       47786 : { return T?FpXQX_degfact(f, T, p): FpX_degfact(f, p); }
    2487             : INLINE GEN
    2488        7273 : FqX_roots(GEN f, GEN T, GEN p)
    2489        7273 : { return T?FpXQX_roots(f, T, p): FpX_roots(f, p); }
    2490             : INLINE GEN
    2491         175 : FqX_to_mod(GEN f, GEN T, GEN p)
    2492         175 : { return T?FpXQX_to_mod(f, T, p): FpX_to_mod(f, p); }
    2493             : 
    2494             : /*FqXQ*/
    2495             : INLINE GEN
    2496           0 : FqXQ_add(GEN x, GEN y, GEN S/*unused*/, GEN T, GEN p)
    2497           0 : { (void)S; return T? FpXX_add(x,y,p): FpX_add(x,y,p); }
    2498             : INLINE GEN
    2499           0 : FqXQ_sub(GEN x, GEN y, GEN S/*unused*/, GEN T, GEN p)
    2500           0 : { (void)S; return T? FpXX_sub(x,y,p): FpX_sub(x,y,p); }
    2501             : INLINE GEN
    2502           0 : FqXQ_div(GEN x, GEN y, GEN S, GEN T, GEN p)
    2503           0 : { return T? FpXQXQ_div(x,y,S,T,p): FpXQ_div(x,y,S,p); }
    2504             : INLINE GEN
    2505           0 : FqXQ_inv(GEN x, GEN S, GEN T, GEN p)
    2506           0 : { return T? FpXQXQ_inv(x,S,T,p): FpXQ_inv(x,S,p); }
    2507             : INLINE GEN
    2508           0 : FqXQ_invsafe(GEN x, GEN S, GEN T, GEN p)
    2509           0 : { return T? FpXQXQ_invsafe(x,S,T,p): FpXQ_inv(x,S,p); }
    2510             : INLINE GEN
    2511       22766 : FqXQ_mul(GEN x, GEN y, GEN S, GEN T, GEN p)
    2512       22766 : { return T? FpXQXQ_mul(x,y,S,T,p): FpXQ_mul(x,y,S,p); }
    2513             : INLINE GEN
    2514           0 : FqXQ_sqr(GEN x, GEN S, GEN T, GEN p)
    2515           0 : { return T? FpXQXQ_sqr(x,S,T,p): FpXQ_sqr(x,S,p); }
    2516             : INLINE GEN
    2517           0 : FqXQ_pow(GEN x, GEN n, GEN S, GEN T, GEN p)
    2518           0 : { return T? FpXQXQ_pow(x,n,S,T,p): FpXQ_pow(x,n,S,p); }
    2519             : 
    2520             : /*FqXn*/
    2521             : INLINE GEN
    2522        6590 : FqXn_expint(GEN x, long n, GEN T, GEN p)
    2523        6590 : { return T? FpXQXn_expint(x,n,T,p): FpXn_expint(x,n,p); }
    2524             : INLINE GEN
    2525           0 : FqXn_exp(GEN x, long n, GEN T, GEN p)
    2526           0 : { return T? FpXQXn_exp(x,n,T,p): FpXn_exp(x,n,p); }
    2527             : INLINE GEN
    2528        7126 : FqXn_inv(GEN x, long n, GEN T, GEN p)
    2529        7126 : { return T? FpXQXn_inv(x,n,T,p): FpXn_inv(x,n,p); }
    2530             : INLINE GEN
    2531      263403 : FqXn_mul(GEN x, GEN y, long n, GEN T, GEN p)
    2532      263403 : { return T? FpXQXn_mul(x, y, n, T, p): FpXn_mul(x, y, n, p); }
    2533             : INLINE GEN
    2534           0 : FqXn_sqr(GEN x, long n, GEN T, GEN p)
    2535           0 : { return T? FpXQXn_sqr(x,n,T,p): FpXn_sqr(x,n,p); }
    2536             : 
    2537             : /*FpXQ*/
    2538             : INLINE GEN
    2539           0 : FpXQ_add(GEN x,GEN y,GEN T/*unused*/,GEN p)
    2540           0 : { (void)T; return FpX_add(x,y,p); }
    2541             : INLINE GEN
    2542           0 : FpXQ_sub(GEN x,GEN y,GEN T/*unused*/,GEN p)
    2543           0 : { (void)T; return FpX_sub(x,y,p); }
    2544             : 
    2545             : /*Flxq*/
    2546             : INLINE GEN
    2547           0 : Flxq_add(GEN x,GEN y,GEN T/*unused*/,ulong p)
    2548           0 : { (void)T; return Flx_add(x,y,p); }
    2549             : INLINE GEN
    2550           0 : Flxq_sub(GEN x,GEN y,GEN T/*unused*/,ulong p)
    2551           0 : { (void)T; return Flx_sub(x,y,p); }
    2552             : 
    2553             : /* F2x */
    2554             : 
    2555             : INLINE ulong
    2556   667610580 : F2x_coeff(GEN x,long v)
    2557             : {
    2558   667610580 :    ulong u=(ulong)x[2+divsBIL(v)];
    2559   667610236 :    return (u>>remsBIL(v))&1UL;
    2560             : }
    2561             : 
    2562             : INLINE void
    2563    12269467 : F2x_clear(GEN x,long v)
    2564             : {
    2565    12269467 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2566    12269410 :    *u&=~(1UL<<remsBIL(v));
    2567    12269404 : }
    2568             : 
    2569             : INLINE void
    2570   124695526 : F2x_set(GEN x,long v)
    2571             : {
    2572   124695526 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2573   124691844 :    *u|=1UL<<remsBIL(v);
    2574   124692344 : }
    2575             : 
    2576             : INLINE void
    2577     1554195 : F2x_flip(GEN x,long v)
    2578             : {
    2579     1554195 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2580     1554195 :    *u^=1UL<<remsBIL(v);
    2581     1554195 : }
    2582             : 
    2583             : /* F2v */
    2584             : 
    2585             : INLINE ulong
    2586   661002253 : F2v_coeff(GEN x,long v) { return F2x_coeff(x,v-1); }
    2587             : 
    2588             : INLINE void
    2589    12269465 : F2v_clear(GEN x,long v) { F2x_clear(x,v-1); }
    2590             : 
    2591             : INLINE void
    2592   101342811 : F2v_set(GEN x,long v)   { F2x_set(x,v-1); }
    2593             : 
    2594             : INLINE void
    2595     1554195 : F2v_flip(GEN x,long v) { F2x_flip(x,v-1); }
    2596             : 
    2597             : /* F2m */
    2598             : 
    2599             : INLINE ulong
    2600     8023145 : F2m_coeff(GEN x, long a, long b) { return F2v_coeff(gel(x,b), a); }
    2601             : 
    2602             : INLINE void
    2603           0 : F2m_clear(GEN x, long a, long b) { F2v_clear(gel(x,b), a); }
    2604             : 
    2605             : INLINE void
    2606         798 : F2m_set(GEN x, long a, long b) { F2v_set(gel(x,b), a); }
    2607             : 
    2608             : INLINE void
    2609     1554195 : F2m_flip(GEN x, long a, long b) { F2v_flip(gel(x,b), a); }
    2610             : 
    2611             : /* F3m */
    2612             : 
    2613             : INLINE ulong
    2614     3247493 : F3m_coeff(GEN x, long a, long b) { return F3v_coeff(gel(x,b), a); }
    2615             : 
    2616             : INLINE void
    2617           0 : F3m_set(GEN x, long a, long b, ulong c) { F3v_set(gel(x,b), a, c); }
    2618             : 
    2619             : /* ARITHMETIC */
    2620             : INLINE GEN
    2621        3885 : matpascal(long n) { return matqpascal(n, NULL); }
    2622             : INLINE long
    2623      458608 : Z_issquare(GEN x) { return Z_issquareall(x, NULL); }
    2624             : INLINE long
    2625          98 : Z_ispower(GEN x, ulong k) { return Z_ispowerall(x, k, NULL); }
    2626             : INLINE GEN
    2627     6591484 : sqrti(GEN x) { return sqrtremi(x,NULL); }
    2628             : INLINE GEN
    2629   123157976 : gaddgs(GEN y, long s) { return gaddsg(s,y); }
    2630             : INLINE int
    2631      785659 : gcmpgs(GEN y, long s) { return -gcmpsg(s,y); }
    2632             : INLINE int
    2633       29176 : gequalgs(GEN y, long s) { return gequalsg(s,y); }
    2634             : INLINE GEN
    2635           0 : gmaxsg(long s, GEN y) { return gmaxgs(y,s); }
    2636             : INLINE GEN
    2637           0 : gminsg(long s, GEN y) { return gmings(y,s); }
    2638             : INLINE GEN
    2639    22005944 : gmulgs(GEN y, long s) { return gmulsg(s,y); }
    2640             : INLINE GEN
    2641   124174680 : gmulgu(GEN y, ulong s) { return gmulug(s,y); }
    2642             : INLINE GEN
    2643     1707305 : gsubgs(GEN y, long s) { return gaddgs(y, -s); }
    2644             : INLINE GEN
    2645      528436 : gdivsg(long s, GEN y) { return gdiv(stoi(s), y); }
    2646             : 
    2647             : INLINE GEN
    2648    13510030 : gmax_shallow(GEN x, GEN y) { return gcmp(x,y)<0? y: x; }
    2649             : INLINE GEN
    2650      875137 : gmin_shallow(GEN x, GEN y) { return gcmp(x,y)<0? x: y; }
    2651             : 
    2652             : /* x t_COMPLEX */
    2653             : INLINE GEN
    2654    90785007 : cxnorm(GEN x) { return gadd(gsqr(gel(x,1)), gsqr(gel(x,2))); }
    2655             : /* q t_QUAD */
    2656             : INLINE GEN
    2657       69860 : quadnorm(GEN q)
    2658             : {
    2659       69860 :   GEN X = gel(q,1), b = gel(X,3), c = gel(X,2);
    2660       69860 :   GEN z, u = gel(q,3), v = gel(q,2);
    2661       69860 :   if (typ(u) == t_INT && typ(v) == t_INT) /* generic case */
    2662             :   {
    2663       69671 :     z = signe(b)? mulii(v, addii(u,v)): sqri(v);
    2664       69671 :     return addii(z, mulii(c, sqri(u)));
    2665             :   }
    2666             :   else
    2667             :   {
    2668         189 :     z = signe(b)? gmul(v, gadd(u,v)): gsqr(v);
    2669         189 :     return gadd(z, gmul(c, gsqr(u)));
    2670             :   }
    2671             : }
    2672             : /* x a t_QUAD, return the attached discriminant */
    2673             : INLINE GEN
    2674        1078 : quad_disc(GEN x)
    2675             : {
    2676        1078 :   GEN Q = gel(x,1), b = gel(Q,3), c = gel(Q,2), c4 = shifti(c,2);
    2677        1078 :   if (is_pm1(b)) return subsi(1, c4);
    2678         154 :   togglesign_safe(&c4); return c4;
    2679             : }
    2680             : INLINE GEN
    2681     4848968 : qfb_disc3(GEN x, GEN y, GEN z) { return subii(sqri(y), shifti(mulii(x,z),2)); }
    2682             : INLINE GEN
    2683    18474990 : qfb_disc(GEN x) { return gel(x,4); }
    2684             : 
    2685             : INLINE GEN
    2686     4137427 : sqrfrac(GEN x)
    2687             : {
    2688     4137427 :   GEN z = cgetg(3,t_FRAC);
    2689     4137426 :   gel(z,1) = sqri(gel(x,1));
    2690     4137399 :   gel(z,2) = sqri(gel(x,2)); return z;
    2691             : }
    2692             : 
    2693             : INLINE void
    2694    16754157 : normalize_frac(GEN z) {
    2695    16754157 :   if (signe(gel(z,2)) < 0) { togglesign(gel(z,1)); setabssign(gel(z,2)); }
    2696    16754157 : }
    2697             : 
    2698             : INLINE GEN
    2699    42911887 : powii(GEN x, GEN n)
    2700             : {
    2701    42911887 :   long ln = lgefint(n);
    2702    42911887 :   if (ln == 3) {
    2703             :     GEN z;
    2704    42888920 :     if (signe(n) > 0) return powiu(x, n[2]);
    2705       74821 :     z = cgetg(3, t_FRAC);
    2706       74834 :     gel(z,1) = gen_1;
    2707       74834 :     gel(z,2) = powiu(x, n[2]);
    2708       74834 :     return z;
    2709             :   }
    2710       22967 :   if (ln == 2) return gen_1; /* rare */
    2711             :   /* should never happen */
    2712           0 :   return powgi(x, n); /* overflow unless x = 0, 1, -1 */
    2713             : }
    2714             : INLINE GEN
    2715        1561 : powIs(long n) {
    2716        1561 :   switch(n & 3)
    2717             :   {
    2718          63 :     case 1: return mkcomplex(gen_0,gen_1);
    2719         385 :     case 2: return gen_m1;
    2720         707 :     case 3: return mkcomplex(gen_0,gen_m1);
    2721             :   }
    2722         406 :   return gen_1;
    2723             : }
    2724             : 
    2725             : /*******************************************************************/
    2726             : /*                                                                 */
    2727             : /*                             ASSIGNMENTS                         */
    2728             : /*                                                                 */
    2729             : /*******************************************************************/
    2730           0 : INLINE void mpexpz(GEN x, GEN z)
    2731           0 : { pari_sp av = avma; gaffect(mpexp(x), z); set_avma(av); }
    2732           0 : INLINE void mplogz(GEN x, GEN z)
    2733           0 : { pari_sp av = avma; gaffect(mplog(x), z); set_avma(av); }
    2734           0 : INLINE void mpcosz(GEN x, GEN z)
    2735           0 : { pari_sp av = avma; gaffect(mpcos(x), z); set_avma(av); }
    2736           0 : INLINE void mpsinz(GEN x, GEN z)
    2737           0 : { pari_sp av = avma; gaffect(mpsin(x), z); set_avma(av); }
    2738           0 : INLINE void gnegz(GEN x, GEN z)
    2739           0 : { pari_sp av = avma; gaffect(gneg(x), z); set_avma(av); }
    2740           0 : INLINE void gabsz(GEN x, long prec, GEN z)
    2741           0 : { pari_sp av = avma; gaffect(gabs(x,prec), z); set_avma(av); }
    2742           0 : INLINE void gaddz(GEN x, GEN y, GEN z)
    2743           0 : { pari_sp av = avma; gaffect(gadd(x,y), z); set_avma(av); }
    2744           0 : INLINE void gsubz(GEN x, GEN y, GEN z)
    2745           0 : { pari_sp av = avma; gaffect(gsub(x,y), z); set_avma(av); }
    2746           0 : INLINE void gmulz(GEN x, GEN y, GEN z)
    2747           0 : { pari_sp av = avma; gaffect(gmul(x,y), z); set_avma(av); }
    2748           0 : INLINE void gdivz(GEN x, GEN y, GEN z)
    2749           0 : { pari_sp av = avma; gaffect(gdiv(x,y), z); set_avma(av); }
    2750           0 : INLINE void gdiventz(GEN x, GEN y, GEN z)
    2751           0 : { pari_sp av = avma; gaffect(gdivent(x,y), z); set_avma(av); }
    2752           0 : INLINE void gmodz(GEN x, GEN y, GEN z)
    2753           0 : { pari_sp av = avma; gaffect(gmod(x,y), z); set_avma(av); }
    2754           0 : INLINE void gmul2nz(GEN x, long s, GEN z)
    2755           0 : { pari_sp av = avma; gaffect(gmul2n(x,s), z); set_avma(av); }
    2756           0 : INLINE void gshiftz(GEN x, long s, GEN z)
    2757           0 : { pari_sp av = avma; gaffect(gshift(x,s), z); set_avma(av); }
    2758             : 
    2759             : /*******************************************************************/
    2760             : /*                                                                 */
    2761             : /*                       ELLIPTIC CURVES                           */
    2762             : /*                                                                 */
    2763             : /*******************************************************************/
    2764     7116192 : INLINE GEN ell_get_a1(GEN e) { return gel(e,1); }
    2765     5709708 : INLINE GEN ell_get_a2(GEN e) { return gel(e,2); }
    2766     6912839 : INLINE GEN ell_get_a3(GEN e) { return gel(e,3); }
    2767     6522709 : INLINE GEN ell_get_a4(GEN e) { return gel(e,4); }
    2768     7961482 : INLINE GEN ell_get_a6(GEN e) { return gel(e,5); }
    2769     5432770 : INLINE GEN ell_get_b2(GEN e) { return gel(e,6); }
    2770     2135641 : INLINE GEN ell_get_b4(GEN e) { return gel(e,7); }
    2771     3055105 : INLINE GEN ell_get_b6(GEN e) { return gel(e,8); }
    2772     2608978 : INLINE GEN ell_get_b8(GEN e) { return gel(e,9); }
    2773     8021674 : INLINE GEN ell_get_c4(GEN e) { return gel(e,10); }
    2774     8850302 : INLINE GEN ell_get_c6(GEN e) { return gel(e,11); }
    2775    11279875 : INLINE GEN ell_get_disc(GEN e) { return gel(e,12); }
    2776     1295726 : INLINE GEN ell_get_j(GEN e) { return gel(e,13); }
    2777    11588238 : INLINE long ell_get_type(GEN e) { return mael(e,14,1); }
    2778     2036753 : INLINE GEN ellff_get_field(GEN x) { return gmael(x, 15, 1); }
    2779      800033 : INLINE GEN ellff_get_a4a6(GEN x)  { return gmael(x, 15, 2); }
    2780        1463 : INLINE GEN ellQp_get_zero(GEN x) { return gmael(x, 15, 1); }
    2781         308 : INLINE long ellQp_get_prec(GEN E) { return valp(ellQp_get_zero(E)); }
    2782        1134 : INLINE GEN ellQp_get_p(GEN E) { return padic_p(ellQp_get_zero(E)); }
    2783      232582 : INLINE long ellR_get_prec(GEN x) { return nbits2prec(mael3(x, 15, 1, 1)); }
    2784      371325 : INLINE long ellR_get_sign(GEN x) { return mael3(x, 15, 1, 2); }
    2785     2027575 : INLINE GEN ellnf_get_nf(GEN x) { return checknf_i(gmael(x,15,1)); }
    2786         126 : INLINE GEN ellnf_get_bnf(GEN x) { return checkbnf_i(gmael(x,15,1)); }
    2787             : 
    2788     4677450 : INLINE int checkell_i(GEN e) { return typ(e) == t_VEC && lg(e) == 17; }
    2789    51353460 : INLINE int ell_is_inf(GEN z) { return lg(z) == 2; }
    2790     1868498 : INLINE GEN ellinf(void) { return mkvec(gen_0); }
    2791             : 
    2792             : /*******************************************************************/
    2793             : /*                                                                 */
    2794             : /*                    ALGEBRAIC NUMBER THEORY                      */
    2795             : /*                                                                 */
    2796             : /*******************************************************************/
    2797    30053203 : INLINE GEN modpr_get_pr(GEN x)  { return gel(x,3); }
    2798     1888768 : INLINE GEN modpr_get_p(GEN x)  { return pr_get_p(modpr_get_pr(x)); }
    2799    13187803 : INLINE GEN modpr_get_T(GEN x)  { return lg(x) == 4? NULL: gel(x,4); }
    2800             : 
    2801    89386225 : INLINE GEN pr_get_p(GEN pr)  { return gel(pr,1); }
    2802    11510805 : INLINE GEN pr_get_gen(GEN pr){ return gel(pr,2); }
    2803             : /* .[2] instead of itos works: e and f are small positive integers */
    2804    15721777 : INLINE long pr_get_e(GEN pr) { return gel(pr,3)[2]; }
    2805    25349368 : INLINE long pr_get_f(GEN pr) { return gel(pr,4)[2]; }
    2806    47856618 : INLINE GEN pr_get_tau(GEN pr){ return gel(pr,5); }
    2807             : INLINE int
    2808    16404061 : pr_is_inert(GEN P) { return typ(pr_get_tau(P)) == t_INT; }
    2809             : INLINE GEN
    2810     1067461 : pr_norm(GEN pr) { return powiu(pr_get_p(pr), pr_get_f(pr)); }
    2811             : INLINE ulong
    2812      343929 : upr_norm(GEN pr) { return upowuu(pr_get_p(pr)[2], pr_get_f(pr)); }
    2813             : 
    2814             : /* assume nf a genuine nf */
    2815             : INLINE long
    2816     1167447 : nf_get_varn(GEN nf) { return varn(gel(nf,1)); }
    2817             : INLINE GEN
    2818    94444774 : nf_get_pol(GEN nf) { return gel(nf,1); }
    2819             : INLINE long
    2820    68819438 : nf_get_degree(GEN nf) { return degpol( nf_get_pol(nf) ); }
    2821             : INLINE long
    2822    22167193 : nf_get_r1(GEN nf) { GEN x = gel(nf,2); return itou(gel(x,1)); }
    2823             : INLINE long
    2824        4140 : nf_get_r2(GEN nf) { GEN x = gel(nf,2); return itou(gel(x,2)); }
    2825             : INLINE GEN
    2826      457383 : nf_get_disc(GEN nf) { return gel(nf,3); }
    2827             : INLINE GEN
    2828     3581154 : nf_get_index(GEN nf) { return gel(nf,4); }
    2829             : INLINE GEN
    2830    20772836 : nf_get_M(GEN nf) { return gmael(nf,5,1); }
    2831             : INLINE GEN
    2832      301717 : nf_get_G(GEN nf) { return gmael(nf,5,2); }
    2833             : INLINE GEN
    2834     1686226 : nf_get_roundG(GEN nf) { return gmael(nf,5,3); }
    2835             : INLINE GEN
    2836       22084 : nf_get_Tr(GEN nf) { return gmael(nf,5,4); }
    2837             : INLINE GEN
    2838        4459 : nf_get_diff(GEN nf) { return gmael(nf,5,5); }
    2839             : INLINE GEN
    2840       59584 : nf_get_ramified_primes(GEN nf) { return gmael(nf,5,8); }
    2841             : INLINE GEN
    2842     1531920 : nf_get_roots(GEN nf) { return gel(nf,6); }
    2843             : INLINE GEN
    2844        4382 : nf_get_zk(GEN nf)
    2845             : {
    2846        4382 :   GEN y = gel(nf,7), D = gel(y, 1);
    2847        4382 :   if (typ(D) == t_POL) D = gel(D, 2);
    2848        4382 :   if (!equali1(D)) y = gdiv(y, D);
    2849        4382 :   return y;
    2850             : }
    2851             : INLINE GEN
    2852     5022303 : nf_get_zkprimpart(GEN nf)
    2853             : {
    2854     5022303 :   GEN y = gel(nf,7);
    2855             :   /* test for old format of nf.zk: non normalized */
    2856     5022303 :   if (!equali1(gel(nf,4)) && gequal1(gel(y,1))) y = Q_remove_denom(y,NULL);
    2857     5022290 :   return y;
    2858             : }
    2859             : INLINE GEN
    2860     5068147 : nf_get_zkden(GEN nf)
    2861             : {
    2862     5068147 :   GEN y = gel(nf,7), D = gel(y,1);
    2863     5068147 :   if (typ(D) == t_POL) D = gel(D,2);
    2864             :   /* test for old format of nf.zk: non normalized */
    2865     5068147 :   if (!equali1(gel(nf,4)) && equali1(D)) D = Q_denom(y);
    2866     5068127 :   return D;
    2867             : }
    2868             : INLINE GEN
    2869     9489087 : nf_get_invzk(GEN nf) { return gel(nf,8); }
    2870             : INLINE void
    2871      516868 : nf_get_sign(GEN nf, long *r1, long *r2)
    2872             : {
    2873      516868 :   GEN x = gel(nf,2);
    2874      516868 :   *r1 = itou(gel(x,1));
    2875      516868 :   *r2 = itou(gel(x,2));
    2876      516868 : }
    2877             : 
    2878             : INLINE GEN
    2879     2521232 : cyc_get_expo(GEN c) { return lg(c) == 1? gen_1: gel(c,1); }
    2880             : INLINE GEN
    2881      392004 : abgrp_get_no(GEN x) { return gel(x,1); }
    2882             : INLINE GEN
    2883    11549572 : abgrp_get_cyc(GEN x) { return gel(x,2); }
    2884             : INLINE GEN
    2885     1653783 : abgrp_get_gen(GEN x) { return gel(x,3); }
    2886             : INLINE GEN
    2887     9426340 : bnf_get_nf(GEN bnf) { return gel(bnf,7); }
    2888             : INLINE GEN
    2889     5097763 : bnf_get_clgp(GEN bnf) { return gmael(bnf,8,1); }
    2890             : INLINE GEN
    2891        8379 : bnf_get_no(GEN bnf) { return abgrp_get_no(bnf_get_clgp(bnf)); }
    2892             : INLINE GEN
    2893     3509230 : bnf_get_cyc(GEN bnf) { return abgrp_get_cyc(bnf_get_clgp(bnf)); }
    2894             : INLINE GEN
    2895     1579994 : bnf_get_gen(GEN bnf)  { return abgrp_get_gen(bnf_get_clgp(bnf)); }
    2896             : INLINE GEN
    2897         641 : bnf_get_reg(GEN bnf) { return gmael(bnf,8,2); }
    2898             : INLINE GEN
    2899     2702141 : bnf_get_logfu(GEN bnf) { return gel(bnf,3); }
    2900             : INLINE GEN
    2901     1278398 : bnf_get_sunits(GEN bnf)
    2902     1278398 : { GEN s = gmael(bnf,8,3); return typ(s) == t_INT? NULL: s; }
    2903             : INLINE GEN
    2904      290549 : bnf_get_tuU(GEN bnf) { return gmael3(bnf,8,4,2); }
    2905             : INLINE long
    2906      265206 : bnf_get_tuN(GEN bnf) { return gmael3(bnf,8,4,1)[2]; }
    2907             : INLINE GEN
    2908      288199 : bnf_get_fu_nocheck(GEN bnf) { return gmael(bnf,8,5); }
    2909             : INLINE GEN
    2910       26293 : nfV_to_scalar_or_alg(GEN nf, GEN x)
    2911       63435 : { pari_APPLY_same(nf_to_scalar_or_alg(nf, gel(x,i))) }
    2912             : INLINE GEN
    2913       25852 : bnf_get_fu(GEN bnf) {
    2914       25852 :   GEN fu = bnf_build_units(bnf), nf = bnf_get_nf(bnf);
    2915       25852 :   if (typ(fu) == t_MAT) pari_err(e_MISC,"missing units in bnf");
    2916       25852 :   return nfV_to_scalar_or_alg(nf, vecslice(fu, 2, lg(fu)-1));
    2917             : }
    2918             : 
    2919             : INLINE GEN
    2920     3632368 : bnr_get_bnf(GEN bnr) { return gel(bnr,1); }
    2921             : INLINE GEN
    2922     1937009 : bnr_get_bid(GEN bnr) { return gel(bnr,2); }
    2923             : INLINE GEN
    2924      141124 : bnr_get_mod(GEN bnr) { return gmael(bnr,2,1); }
    2925             : INLINE GEN
    2926     1260194 : bnr_get_nf(GEN bnr) { return gmael(bnr,1,7); }
    2927             : INLINE GEN
    2928     2728816 : bnr_get_clgp(GEN bnr) { return gel(bnr,5); }
    2929             : INLINE GEN
    2930      314608 : bnr_get_no(GEN bnr) { return abgrp_get_no(bnr_get_clgp(bnr)); }
    2931             : INLINE GEN
    2932     2396592 : bnr_get_cyc(GEN bnr) { return abgrp_get_cyc(bnr_get_clgp(bnr)); }
    2933             : INLINE GEN
    2934          70 : bnr_get_gen_nocheck(GEN bnr) { return abgrp_get_gen(bnr_get_clgp(bnr)); }
    2935             : INLINE GEN
    2936        7847 : bnr_get_gen(GEN bnr) {
    2937        7847 :   GEN G = bnr_get_clgp(bnr);
    2938        7847 :   if (lg(G) !=  4)
    2939           0 :     pari_err(e_MISC,"missing bnr generators: please use bnrinit(,,1)");
    2940        7847 :   return gel(G,3);
    2941             : }
    2942             : 
    2943             : /* localstar, used in gchar */
    2944             : INLINE GEN
    2945       51955 : locs_get_cyc(GEN locs) { return gel(locs,1); }
    2946             : INLINE GEN
    2947      191695 : locs_get_Lsprk(GEN locs) { return gel(locs,2); }
    2948             : INLINE GEN
    2949        1260 : locs_get_Lgenfil(GEN locs) { return gel(locs,3); }
    2950             : INLINE GEN
    2951        8225 : locs_get_mod(GEN locs) { return gel(locs,4); }
    2952             : /* pr dividing the modulus N of locs, 0 <= i < v_pr(N)
    2953             :  * return a t_MAT whose columns are the logs
    2954             :  * of generators of U_i(pr)/U_{i+1}(pr). */
    2955             : INLINE GEN
    2956        1260 : locs_get_famod(GEN locs) { return gmael(locs,4,1); }
    2957             : INLINE GEN
    2958      207235 : locs_get_m_infty(GEN locs) { return gmael(locs,4,2); }
    2959             : 
    2960             : /* G a grossenchar group */
    2961             : INLINE GEN
    2962       32639 : gchar_get_basis(GEN gc)  { return  gel(gc, 1); }
    2963             : INLINE GEN
    2964      203105 : gchar_get_bnf(GEN gc)    { return  gel(gc, 2); }
    2965             : INLINE GEN
    2966      241501 : gchar_get_nf(GEN gc)    { return  gel(gc, 3); }
    2967             : INLINE GEN
    2968      279434 : gchar_get_zm(GEN gc)     { return  gel(gc, 4); }
    2969             : INLINE GEN
    2970        8225 : gchar_get_mod(GEN gc)    { return  locs_get_mod(gchar_get_zm(gc)); }
    2971             : INLINE GEN
    2972        4095 : gchar_get_modP(GEN gc)    { return gmael(gchar_get_mod(gc),1,1); }
    2973             : INLINE GEN
    2974       36865 : gchar_get_S(GEN gc)      { return  gel(gc, 5); }
    2975             : INLINE GEN
    2976      188468 : gchar_get_DLdata(GEN gc)   { return  gel(gc, 6); }
    2977             : INLINE GEN
    2978        1748 : gchar_get_sfu(GEN gc) { return  gel(gc, 7); }
    2979             : INLINE GEN
    2980       16168 : gchar_get_cyc(GEN gc)    { return  gel(gc, 9); }
    2981             : INLINE GEN
    2982           0 : gchar_get_hnf(GEN gc)    { return  gmael(gc, 10, 1); }
    2983             : INLINE GEN
    2984           0 : gchar_get_U(GEN gc)      { return  gmael(gc, 10, 2); }
    2985             : INLINE GEN
    2986       10969 : gchar_get_Ui(GEN gc)     { return  gmael(gc, 10, 3); }
    2987             : INLINE GEN
    2988        3321 : gchar_get_m0(GEN gc)     { return gel(gc, 11); }
    2989             : INLINE GEN
    2990        4267 : gchar_get_u0(GEN gc)     { return gel(gc, 12); }
    2991             : INLINE long
    2992       17416 : gchar_get_r1(GEN gc)     { return nf_get_r1(gchar_get_nf(gc)); }
    2993             : INLINE long
    2994         623 : gchar_get_r2(GEN gc)     { return nf_get_r2(gchar_get_nf(gc)); }
    2995             : INLINE GEN
    2996       50347 : gchar_get_loccyc(GEN gc) { return locs_get_cyc(gchar_get_zm(gc)); }
    2997             : INLINE long
    2998       37131 : gchar_get_nc(GEN gc)     { return lg(gchar_get_loccyc(gc))-1; }
    2999             : INLINE long
    3000       36865 : gchar_get_ns(GEN gc)     { return lg(gchar_get_S(gc))-1; }
    3001             : INLINE long
    3002        1841 : gchar_get_nm(GEN gc)     { return lg(gchar_get_basis(gc))-1; }
    3003             : INLINE long
    3004        4011 : gchar_get_evalprec(GEN gc)   { return  gmael(gc, 8, 1)[1]; }
    3005             : INLINE long
    3006       18732 : gchar_get_prec(GEN gc)   { return  gmael(gc, 8, 1)[2]; }
    3007             : INLINE long
    3008       13419 : gchar_get_nfprec(GEN gc) { return  gmael(gc, 8, 1)[3]; }
    3009             : INLINE void
    3010        1785 : gchar_set_evalprec(GEN gc, long prec) { gmael(gc, 8, 1)[1] = prec; }
    3011             : INLINE void
    3012        1202 : gchar_set_prec(GEN gc, long prec) { gmael(gc, 8, 1)[2] = prec; }
    3013             : INLINE void
    3014        1202 : gchar_copy_precs(GEN gc, GEN gc2)
    3015             : {
    3016        1202 :   gel(gc2, 8) = shallowcopy(gel(gc,8));
    3017        1202 :   gmael(gc2, 8, 1) = shallowcopy(gmael(gc, 8, 1));
    3018        1202 : }
    3019             : INLINE void
    3020        2950 : gchar_set_nfprec(GEN gc, long prec) { gmael(gc, 8, 1)[3] = prec; }
    3021             : INLINE long
    3022         322 : gchar_get_ntors(GEN gc)   { return  gmael(gc, 8, 2)[1]; }
    3023             : INLINE long
    3024         322 : gchar_get_nfree(GEN gc)   { return  gmael(gc, 8, 2)[2]; }
    3025             : INLINE long
    3026        2042 : gchar_get_nalg(GEN gc)   { return  gmael(gc, 8, 2)[3]; }
    3027             : INLINE void
    3028        1573 : gchar_set_basis(GEN gc, GEN m_inv)  { gel(gc, 1) = m_inv; }
    3029             : INLINE void
    3030        2077 : gchar_set_nf(GEN gc, GEN nf)      { gel(gc, 3) = nf; }
    3031             : INLINE void
    3032         623 : gchar_set_ntors(GEN gc, long n)    { gmael(gc, 8, 2)[1] = n; }
    3033             : INLINE void
    3034         623 : gchar_set_nfree(GEN gc, long n)    { gmael(gc, 8, 2)[2] = n; }
    3035             : INLINE void
    3036         623 : gchar_set_nalg(GEN gc, long n)    { gmael(gc, 8, 2)[3] = n; }
    3037             : INLINE void
    3038        1573 : gchar_set_cyc(GEN gc, GEN cyc)      { gel(gc, 9) = cyc; }
    3039             : INLINE void
    3040         623 : gchar_set_HUUi(GEN gc, GEN hnf, GEN U, GEN Ui) { gel(gc, 10) = mkvec3(hnf, U, Ui); }
    3041             : INLINE void
    3042         950 : gchar_set_m0(GEN gc, GEN m0)     { gel(gc, 11) = m0; }
    3043             : INLINE void
    3044        2093 : gchar_set_u0(GEN gc, GEN u0)     { gel(gc, 12) = u0; }
    3045             : 
    3046             : INLINE GEN
    3047     1386556 : bid_get_mod(GEN bid) { return gel(bid,1); }
    3048             : INLINE GEN
    3049       78295 : bid_get_ideal(GEN bid) { return gmael(bid,1,1); }
    3050             : INLINE GEN
    3051       35097 : bid_get_arch(GEN bid) { return gmael(bid,1,2); }
    3052             : INLINE GEN
    3053     5415591 : bid_get_grp(GEN bid) { return gel(bid,2); }
    3054             : INLINE GEN
    3055     2314048 : bid_get_fact(GEN bid) { return gmael(bid,3,1); }
    3056             : INLINE GEN
    3057     2025336 : bid_get_fact2(GEN bid) { return gmael(bid,3,2); }
    3058             : INLINE GEN
    3059     1990801 : bid_get_MOD(GEN bid) { GEN y = gel(bid,4); return lg(y) == 4? gel(y,3): NULL; }
    3060             : INLINE GEN
    3061     1991530 : bid_get_sprk(GEN bid) { return gmael(bid,4,1); }
    3062             : INLINE GEN
    3063       51226 : bid_get_sarch(GEN bid) { return gmael(bid,4,2); }
    3064             : INLINE GEN
    3065     2217855 : bid_get_archp(GEN bid) { return gmael3(bid,4,2,2); }
    3066             : INLINE GEN
    3067     3378409 : bid_get_U(GEN bid) { return gel(bid,5); }
    3068             : INLINE GEN
    3069           0 : bid_get_no(GEN bid) { return abgrp_get_no(bid_get_grp(bid)); }
    3070             : INLINE GEN
    3071     5361677 : bid_get_cyc(GEN bid) { return abgrp_get_cyc(bid_get_grp(bid)); }
    3072             : INLINE GEN
    3073           0 : bid_get_gen_nocheck(GEN bid)  { return abgrp_get_gen(bid_get_grp(bid)); }
    3074             : INLINE GEN
    3075       53333 : bid_get_gen(GEN bid) {
    3076       53333 :   GEN G = bid_get_grp(bid);
    3077       53333 :   if (lg(G) != 4) pari_err(e_MISC,"missing bid generators. Use idealstar(,,2)");
    3078       53333 :   return abgrp_get_gen(G);
    3079             : }
    3080             : 
    3081             : INLINE GEN
    3082    34544232 : znstar_get_N(GEN G) { return gmael(G,1,1); }
    3083             : INLINE GEN
    3084     7211094 : znstar_get_faN(GEN G) { return gel(G,3); }
    3085             : INLINE GEN
    3086          14 : znstar_get_no(GEN G) { return abgrp_get_no(gel(G,2)); }
    3087             : INLINE GEN
    3088      261948 : znstar_get_cyc(GEN G) { return abgrp_get_cyc(gel(G,2)); }
    3089             : INLINE GEN
    3090       16150 : znstar_get_gen(GEN G) { return abgrp_get_gen(gel(G,2)); }
    3091             : INLINE GEN
    3092     7824202 : znstar_get_conreycyc(GEN G) { return gmael(G,4,5); }
    3093             : INLINE GEN
    3094     3221793 : znstar_get_conreygen(GEN G) { return gmael(G,4,4); }
    3095             : INLINE GEN
    3096       46788 : znstar_get_Ui(GEN G) { return gmael(G,4,3); }
    3097             : INLINE GEN
    3098      176051 : znstar_get_U(GEN G) { return gel(G,5); }
    3099             : INLINE GEN
    3100     2820763 : znstar_get_pe(GEN G) { return gmael(G,4,1); }
    3101             : INLINE GEN
    3102       36155 : gal_get_pol(GEN gal) { return gel(gal,1); }
    3103             : INLINE GEN
    3104        6041 : gal_get_p(GEN gal) { return gmael(gal,2,1); }
    3105             : INLINE GEN
    3106          91 : gal_get_e(GEN gal) { return gmael(gal,2,2); }
    3107             : INLINE GEN
    3108       23793 : gal_get_mod(GEN gal) { return gmael(gal,2,3); }
    3109             : INLINE GEN
    3110       32571 : gal_get_roots(GEN gal) { return gel(gal,3); }
    3111             : INLINE GEN
    3112       27678 : gal_get_invvdm(GEN gal) { return gel(gal,4); }
    3113             : INLINE GEN
    3114       27671 : gal_get_den(GEN gal) { return gel(gal,5); }
    3115             : INLINE GEN
    3116       80192 : gal_get_group(GEN gal) { return gel(gal,6); }
    3117             : INLINE GEN
    3118       15456 : gal_get_gen(GEN gal) { return gel(gal,7); }
    3119             : INLINE GEN
    3120        6664 : gal_get_orders(GEN gal) { return gel(gal,8); }
    3121             : 
    3122             : /* assume rnf a genuine rnf */
    3123             : INLINE long
    3124     2506083 : rnf_get_degree(GEN rnf) { return degpol(rnf_get_pol(rnf)); }
    3125             : INLINE long
    3126       21217 : rnf_get_nfdegree(GEN rnf) { return degpol(nf_get_pol(rnf_get_nf(rnf))); }
    3127             : INLINE long
    3128     1392746 : rnf_get_absdegree(GEN rnf) { return degpol(gmael(rnf,11,1)); }
    3129             : INLINE GEN
    3130        1386 : rnf_get_idealdisc(GEN rnf) { return gmael(rnf,3,1); }
    3131             : INLINE GEN
    3132        1225 : rnf_get_k(GEN rnf) { return gmael(rnf,11,3); }
    3133             : INLINE GEN
    3134        1204 : rnf_get_alpha(GEN rnf) { return gmael(rnf, 11, 2); }
    3135             : INLINE GEN
    3136      733698 : rnf_get_nf(GEN rnf) { return gel(rnf,10); }
    3137             : INLINE GEN
    3138        6559 : rnf_get_nfzk(GEN rnf) { return gel(rnf,2); }
    3139             : INLINE GEN
    3140      314482 : rnf_get_polabs(GEN rnf) { return gmael(rnf,11,1); }
    3141             : INLINE GEN
    3142     2844933 : rnf_get_pol(GEN rnf) { return gel(rnf,1); }
    3143             : INLINE GEN
    3144         350 : rnf_get_disc(GEN rnf) { return gel(rnf,3); }
    3145             : INLINE GEN
    3146         105 : rnf_get_index(GEN rnf) { return gel(rnf,4); }
    3147             : INLINE GEN
    3148        2611 : rnf_get_ramified_primes(GEN rnf) { return gel(rnf,5); }
    3149             : INLINE long
    3150         574 : rnf_get_varn(GEN rnf) { return varn(gel(rnf,1)); }
    3151             : INLINE GEN
    3152      255354 : rnf_get_nfpol(GEN rnf) { return gmael(rnf,10,1); }
    3153             : INLINE long
    3154        4886 : rnf_get_nfvarn(GEN rnf) { return varn(gmael(rnf,10,1)); }
    3155             : INLINE GEN
    3156        4592 : rnf_get_zk(GEN rnf) { return gel(rnf,7); }
    3157             : INLINE GEN
    3158      135183 : rnf_get_map(GEN rnf) { return gel(rnf,11); }
    3159             : INLINE GEN
    3160        1225 : rnf_get_invzk(GEN rnf) { return gel(rnf,8); }
    3161             : 
    3162             : INLINE GEN
    3163      138609 : idealred(GEN nf, GEN id) { return idealred0(nf, id, NULL); }
    3164             : 
    3165             : INLINE GEN
    3166        5427 : idealchineseinit(GEN nf, GEN x)
    3167        5427 : { return idealchinese(nf,x,NULL); }
    3168             : 
    3169             : /*******************************************************************/
    3170             : /*                                                                 */
    3171             : /*                              CLOSURES                           */
    3172             : /*                                                                 */
    3173             : /*******************************************************************/
    3174   368109791 : INLINE long closure_arity(GEN C)          { return ((ulong)C[1])&ARITYBITS; }
    3175    40101643 : INLINE long closure_is_variadic(GEN C) { return !!(((ulong)C[1])&VARARGBITS); }
    3176   319375256 : INLINE const char *closure_codestr(GEN C)  { return GSTR(gel(C,2))-1; }
    3177           0 : INLINE GEN closure_get_code(GEN C)  { return gel(C,2); }
    3178   319353052 : INLINE GEN closure_get_oper(GEN C)  { return gel(C,3); }
    3179   319330901 : INLINE GEN closure_get_data(GEN C)  { return gel(C,4); }
    3180       13516 : INLINE GEN closure_get_dbg(GEN C)   { return gel(C,5); }
    3181       36841 : INLINE GEN closure_get_text(GEN C)  { return gel(C,6); }
    3182    13055330 : INLINE GEN closure_get_frame(GEN C) { return gel(C,7); }
    3183             : 
    3184             : /*******************************************************************/
    3185             : /*                                                                 */
    3186             : /*                               ERRORS                            */
    3187             : /*                                                                 */
    3188             : /*******************************************************************/
    3189             : INLINE long
    3190       62320 : err_get_num(GEN e) { return e[1]; }
    3191             : INLINE GEN
    3192         294 : err_get_compo(GEN e, long i) { return gel(e, i+1); }
    3193             : 
    3194             : INLINE void
    3195          14 : pari_err_BUG(const char *f) { pari_err(e_BUG,f); }
    3196             : INLINE void
    3197          21 : pari_err_CONSTPOL(const char *f) { pari_err(e_CONSTPOL, f); }
    3198             : INLINE void
    3199          84 : pari_err_COPRIME(const char *f, GEN x, GEN y) { pari_err(e_COPRIME, f,x,y); }
    3200             : INLINE void
    3201         718 : pari_err_DIM(const char *f) { pari_err(e_DIM, f); }
    3202             : INLINE void
    3203           0 : pari_err_FILE(const char *f, const char *g) { pari_err(e_FILE, f,g); }
    3204             : INLINE void
    3205          36 : pari_err_FILEDESC(const char *f, long n) { pari_err(e_FILEDESC, f,n); }
    3206             : INLINE void
    3207          98 : pari_err_FLAG(const char *f) { pari_err(e_FLAG,f); }
    3208             : INLINE void
    3209         539 : pari_err_IMPL(const char *f) { pari_err(e_IMPL,f); }
    3210             : INLINE void
    3211       20018 : pari_err_INV(const char *f, GEN x) { pari_err(e_INV,f,x); }
    3212             : INLINE void
    3213          63 : pari_err_IRREDPOL(const char *f, GEN x) { pari_err(e_IRREDPOL, f,x); }
    3214             : INLINE void
    3215        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); }
    3216             : INLINE void
    3217         214 : pari_err_COMPONENT(const char *f, const char *op, GEN l, GEN x) { pari_err(e_COMPONENT, f,op,l,x); }
    3218             : INLINE void
    3219           0 : pari_err_MAXPRIME(ulong c) { pari_err(e_MAXPRIME, c); }
    3220             : INLINE void
    3221         406 : pari_err_OP(const char *f, GEN x, GEN y) { pari_err(e_OP, f,x,y); }
    3222             : INLINE void
    3223         156 : pari_err_OVERFLOW(const char *f) { pari_err(e_OVERFLOW, f); }
    3224             : INLINE void
    3225         238 : pari_err_PREC(const char *f) { pari_err(e_PREC,f); }
    3226             : INLINE void
    3227           0 : pari_err_PACKAGE(const char *f) { pari_err(e_PACKAGE,f); }
    3228             : INLINE void
    3229          98 : pari_err_PRIME(const char *f, GEN x) { pari_err(e_PRIME, f,x); }
    3230             : INLINE void
    3231        1316 : pari_err_MODULUS(const char *f, GEN x, GEN y) { pari_err(e_MODULUS, f,x,y); }
    3232             : INLINE void
    3233          63 : pari_err_ROOTS0(const char *f) { pari_err(e_ROOTS0, f); }
    3234             : INLINE void
    3235        7084 : pari_err_SQRTN(const char *f, GEN x) { pari_err(e_SQRTN, f,x); }
    3236             : INLINE void
    3237       15377 : pari_err_TYPE(const char *f, GEN x) { pari_err(e_TYPE, f,x); }
    3238             : INLINE void
    3239        3493 : pari_err_TYPE2(const char *f, GEN x, GEN y) { pari_err(e_TYPE2, f,x,y); }
    3240             : INLINE void
    3241         371 : pari_err_VAR(const char *f, GEN x, GEN y) { pari_err(e_VAR, f,x,y); }
    3242             : INLINE void
    3243         238 : pari_err_PRIORITY(const char *f, GEN x, const char *op, long v)
    3244         238 : { pari_err(e_PRIORITY, f,x,op,v); }
    3245             : 

Generated by: LCOV version 1.16