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 30005-fc14bb602a) Lines: 1424 1567 90.9 %
Date: 2025-02-18 09:22:46 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     8025238 : 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     3019855 : mkpolmod(GEN x, GEN y) { retmkpolmod(x,y); }
     190             : INLINE GEN
     191    34040875 : mkfrac(GEN x, GEN y) { retmkfrac(x,y); }
     192             : INLINE GEN
     193     1209535 : 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       19838 : Qtoss(GEN q, long *n, long *d)
     197             : {
     198       19838 :   if (typ(q) == t_INT) { *n = itos(q); *d = 1; }
     199        5796 :   else { *n = itos(gel(q,1)); *d = itou(gel(q,2)); }
     200       19838 : }
     201             : INLINE GEN
     202     1074073 : sstoQ(long n, long d)
     203             : {
     204             :   ulong r;
     205             :   long g, q;
     206     1074073 :   if (!n)
     207             :   {
     208       95095 :     if (!d) pari_err_INV("sstoQ",gen_0);
     209       95095 :     return gen_0;
     210             :   }
     211      978978 :   if (d < 0) { d = -d; n = -n; }
     212      978978 :   if (d == 1) return stoi(n);
     213      959665 :   r = labs(n);
     214      959665 :   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   158072611 : uutoQ(ulong n, ulong d)
     224             : {
     225             :   ulong r;
     226             :   long g, q;
     227   158072611 :   if (!n)
     228             :   {
     229       38108 :     if (!d) pari_err_INV("uutoQ",gen_0);
     230       38108 :     return gen_0;
     231             :   }
     232   158034503 :   if (d == 1) return utoipos(n);
     233   158023401 :   if (n == 1) retmkfrac(gen_1, utoipos(d));
     234   157934474 :   q = udivuu_rem(n,d,&r);
     235   157934474 :   if (!r) return utoipos(q);
     236     5179921 :   g = ugcd(d,r); /* gcd(n,d) */
     237     5179921 :   if (g != 1) { n /= g; d /= g; }
     238     5179921 :   retmkfrac(utoipos(n), utoipos(d));
     239             : }
     240             : 
     241             : INLINE GEN
     242     4844366 : mkfraccopy(GEN x, GEN y) { retmkfrac(icopy(x), icopy(y)); }
     243             : INLINE GEN
     244      698089 : mkrfrac(GEN x, GEN y) { GEN v = cgetg(3, t_RFRAC);
     245      698089 :   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    90194945 : mkcomplex(GEN x, GEN y) { retmkcomplex(x,y); }
     251             : INLINE GEN
     252     1269555 : gen_I(void) { return mkcomplex(gen_0, gen_1); }
     253             : INLINE GEN
     254      963395 : 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   129281770 : mkvecsmall(long x) { GEN v = cgetg(2, t_VECSMALL); v[1] = x; return v; }
     261             : INLINE GEN
     262   223876444 : mkvecsmall2(long x,long y) { GEN v = cgetg(3, t_VECSMALL);
     263   223901980 :   v[1]=x; v[2]=y; return v; }
     264             : INLINE GEN
     265   100399072 : mkvecsmall3(long x,long y,long z) { GEN v = cgetg(4, t_VECSMALL);
     266   100398612 :   v[1]=x; v[2]=y; v[3]=z; return v; }
     267             : INLINE GEN
     268    15482275 : mkvecsmall4(long x,long y,long z,long t) { GEN v = cgetg(5, t_VECSMALL);
     269    15483993 :   v[1]=x; v[2]=y; v[3]=z; v[4]=t; return v; }
     270             : INLINE GEN
     271      689652 : mkvecsmall5(long x,long y,long z,long t,long u) { GEN v = cgetg(6, t_VECSMALL);
     272      689650 :   v[1]=x; v[2]=y; v[3]=z; v[4]=t; v[5]=u; return v; }
     273             : 
     274             : INLINE GEN
     275    27802533 : mkqfb(GEN x, GEN y, GEN z, GEN d) { retmkqfb(x,y,z,d); }
     276             : /* vec */
     277             : INLINE GEN
     278    68068433 : mkvec(GEN x) { retmkvec(x); }
     279             : INLINE GEN
     280   182652351 : mkvec2(GEN x, GEN y) { retmkvec2(x,y); }
     281             : INLINE GEN
     282   116381200 : mkvec3(GEN x, GEN y, GEN z) { retmkvec3(x,y,z); }
     283             : INLINE GEN
     284     6640530 : mkvec4(GEN x, GEN y, GEN z, GEN t) { retmkvec4(x,y,z,t); }
     285             : INLINE GEN
     286    14493387 : mkvec5(GEN x, GEN y, GEN z, GEN t, GEN u) { retmkvec5(x,y,z,t,u); }
     287             : INLINE GEN
     288         161 : mkvecs(long x) { retmkvec(stoi(x)); }
     289             : INLINE GEN
     290      220133 : 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      114618 : mkvec2copy(GEN x, GEN y) {
     299      114618 :   GEN v = cgetg(3,t_VEC); gel(v,1) = gcopy(x); gel(v,2) = gcopy(y); return v; }
     300             : /* col */
     301             : INLINE GEN
     302    10184914 : mkcol(GEN x) { retmkcol(x); }
     303             : INLINE GEN
     304   156699457 : 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       33522 : mkcolcopy(GEN x) { GEN v = cgetg(2, t_COL); gel(v,1) = gcopy(x); return v; }
     323             : /* mat */
     324             : INLINE GEN
     325     4609614 : mkmat(GEN x) { retmkmat(x); }
     326             : INLINE GEN
     327    32550355 : 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      121186 : 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     1079859 : mkoo(void) { GEN v = cgetg(2, t_INFINITY); gel(v,1) = gen_1; return v; }
     340             : INLINE GEN
     341      106014 : mkmoo(void) { GEN v = cgetg(2, t_INFINITY); gel(v,1) = gen_m1; return v; }
     342             : INLINE long
     343     1198145 : 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    50649379 : mkmat22(GEN a, GEN b, GEN c, GEN d) { retmkmat2(mkcol2(a,c),mkcol2(b,d)); }
     348             : 
     349             : /* pol */
     350             : INLINE GEN
     351     3568029 : pol_x(long v) {
     352     3568029 :   GEN p = cgetg(4, t_POL);
     353     3568025 :   p[1] = evalsigne(1)|evalvarn(v);
     354     3568025 :   gel(p,2) = gen_0;
     355     3568025 :   gel(p,3) = gen_1; return p;
     356             : }
     357             : /* x^n, assume n >= 0 */
     358             : INLINE GEN
     359     2236202 : pol_xn(long n, long v) {
     360     2236202 :   long i, a = n+2;
     361     2236202 :   GEN p = cgetg(a+1, t_POL);
     362     2236207 :   p[1] = evalsigne(1)|evalvarn(v);
     363     5391568 :   for (i = 2; i < a; i++) gel(p,i) = gen_0;
     364     2236207 :   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     4461812 : pol_1(long v) {
     384     4461812 :   GEN p = cgetg(3, t_POL);
     385     4461809 :   p[1] = evalsigne(1)|evalvarn(v);
     386     4461809 :   gel(p,2) = gen_1; return p;
     387             : }
     388             : INLINE GEN
     389    82536561 : pol_0(long v)
     390             : {
     391    82536561 :   GEN x = cgetg(2,t_POL);
     392    82536557 :   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   234093594 : 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    39280148 : const_col(long n, GEN x) { retconst_col(n, x); }
     408             : INLINE GEN
     409    19061633 : const_vecsmall(long n, long c)
     410             : {
     411             :   long i;
     412    19061633 :   GEN V = cgetg(n+1,t_VECSMALL);
     413   753207861 :   for(i=1;i<=n;i++) V[i] = c;
     414    19062326 :   return V;
     415             : }
     416             : 
     417             : /***   ZERO   ***/
     418             : /* O(p^e) */
     419             : INLINE GEN
     420      855885 : 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    42302957 : zeropol(long v) { return pol_0(v); }
     443             : /* vector(n) */
     444             : INLINE GEN
     445   118901332 : zerocol(long n)
     446             : {
     447   118901332 :   GEN y = cgetg(n+1,t_COL);
     448   803564842 :   long i; for (i=1; i<=n; i++) gel(y,i) = gen_0;
     449   118903692 :   return y;
     450             : }
     451             : /* vectorv(n) */
     452             : INLINE GEN
     453    26634564 : zerovec(long n)
     454             : {
     455    26634564 :   GEN y = cgetg(n+1,t_VEC);
     456   391822476 :   long i; for (i=1; i<=n; i++) gel(y,i) = gen_0;
     457    26634566 :   return y;
     458             : }
     459             : /* matrix(m, n) */
     460             : INLINE GEN
     461      108942 : zeromat(long m, long n)
     462             : {
     463      108942 :   GEN y = cgetg(n+1,t_MAT);
     464      108941 :   GEN v = zerocol(m);
     465      401806 :   long i; for (i=1; i<=n; i++) gel(y,i) = v;
     466      108942 :   return y;
     467             : }
     468             : /* = zero_zx, sv is a evalvarn()*/
     469             : INLINE GEN
     470     1431944 : zero_Flx(long sv) { return pol0_Flx(sv); }
     471             : INLINE GEN
     472    58786169 : zero_Flv(long n)
     473             : {
     474    58786169 :   GEN y = cgetg(n+1,t_VECSMALL);
     475   947486057 :   long i; for (i=1; i<=n; i++) y[i] = 0;
     476    58786305 :   return y;
     477             : }
     478             : /* matrix(m, n) */
     479             : INLINE GEN
     480     2786979 : zero_Flm(long m, long n)
     481             : {
     482     2786979 :   GEN y = cgetg(n+1,t_MAT);
     483     2786975 :   GEN v = zero_Flv(m);
     484    17722786 :   long i; for (i=1; i<=n; i++) gel(y,i) = v;
     485     2786971 :   return y;
     486             : }
     487             : /* matrix(m, n) */
     488             : INLINE GEN
     489      232107 : zero_Flm_copy(long m, long n)
     490             : {
     491      232107 :   GEN y = cgetg(n+1,t_MAT);
     492     2397509 :   long i; for (i=1; i<=n; i++) gel(y,i) = zero_Flv(m);
     493      232113 :   return y;
     494             : }
     495             : 
     496             : INLINE GEN
     497     3633833 : zero_F2v(long m)
     498             : {
     499     3633833 :   long l = nbits2nlong(m);
     500     3633828 :   GEN v  = zero_Flv(l+1);
     501     3633800 :   v[1] = m;
     502     3633800 :   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      841614 : zero_F2m_copy(long m, long n)
     519             : {
     520             :   long i;
     521      841614 :   GEN M = cgetg(n+1, t_MAT);
     522     2010645 :   for (i = 1; i <= n; i++)
     523     1169036 :     gel(M,i)= zero_F2v(m);
     524      841609 :   return M;
     525             : }
     526             : 
     527             : /* matrix(m, n) */
     528             : INLINE GEN
     529    14032430 : zeromatcopy(long m, long n)
     530             : {
     531    14032430 :   GEN y = cgetg(n+1,t_MAT);
     532    71039390 :   long i; for (i=1; i<=n; i++) gel(y,i) = zerocol(m);
     533    14032475 :   return y;
     534             : }
     535             : 
     536             : INLINE GEN
     537       24429 : zerovec_block(long len)
     538             : {
     539             :   long i;
     540       24429 :   GEN blk = cgetg_block(len + 1, t_VEC);
     541      806157 :   for (i = 1; i <= len; ++i)
     542      781728 :     gel(blk, i) = gen_0;
     543       24429 :   return blk;
     544             : }
     545             : 
     546             : /* i-th vector in the standard basis */
     547             : INLINE GEN
     548     5684113 : col_ei(long n, long i) { GEN e = zerocol(n); gel(e,i) = gen_1; return e; }
     549             : INLINE GEN
     550     1711471 : 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      497064 : vecsmall_ei(long n, long i) { GEN e = zero_zv(n); e[i] = 1; return e; }
     555             : INLINE GEN
     556     1292390 : Rg_col_ei(GEN x, long n, long i) { GEN e = zerocol(n); gel(e,i) = x; return e; }
     557             : 
     558             : INLINE GEN
     559    25798808 : shallowcopy(GEN x)
     560    25798808 : { return typ(x) == t_MAT ? RgM_shallowcopy(x): leafcopy(x); }
     561             : 
     562             : /* routines for naive growarrays */
     563             : INLINE GEN
     564    11735013 : vectrunc_init(long l)
     565             : {
     566    11735013 :   GEN z = new_chunk(l);
     567    11734774 :   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   315042832 : lg_increase(GEN x) { x[0]++; }
     577             : INLINE void
     578    15262450 : 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   188498273 : vecsmalltrunc_init(long l)
     589             : {
     590   188498273 :   GEN z = new_chunk(l);
     591   188504421 :   z[0] = evaltyp(t_VECSMALL) | _evallg(1); return z;
     592             : }
     593             : INLINE void
     594    99971627 : 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     2709825 : hash_str(const char *str)
     603             : {
     604     2709825 :   ulong hash = 5381UL, c;
     605    28156342 :   while ( (c = (ulong)*str++) )
     606    25446517 :     hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
     607     2709825 :   return hash;
     608             : }
     609             : INLINE ulong
     610    18201388 : hash_str_len(const char *str, long len)
     611             : {
     612    18201388 :   ulong hash = 5381UL;
     613             :   long i;
     614   166366184 :   for (i = 0; i < len; i++)
     615             :   {
     616   148164796 :     ulong c = (ulong)*str++;
     617   148164796 :     hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
     618             :   }
     619    18201388 :   return hash;
     620             : }
     621             : 
     622             : /*******************************************************************/
     623             : /*                                                                 */
     624             : /*                        VEC / COL / VECSMALL                     */
     625             : /*                                                                 */
     626             : /*******************************************************************/
     627             : /* shallow*/
     628             : INLINE GEN
     629       11550 : vec_shorten(GEN v, long n)
     630             : {
     631       11550 :   GEN V = cgetg(n+1, t_VEC);
     632             :   long i;
     633       13006 :   for(i = 1; i <= n; i++) gel(V,i) = gel(v,i);
     634       11550 :   return V;
     635             : }
     636             : /* shallow*/
     637             : INLINE GEN
     638       18941 : vec_lengthen(GEN v, long n)
     639             : {
     640       18941 :   GEN V = cgetg(n+1, t_VEC);
     641       18941 :   long i, l = lg(v);
     642     1935639 :   for(i = 1; i < l; i++) gel(V,i) = gel(v,i);
     643       18941 :   return V;
     644             : }
     645             : /* shallow*/
     646             : INLINE GEN
     647     3432388 : vec_append(GEN V, GEN s)
     648             : {
     649     3432388 :   long i, l2 = lg(V);
     650     3432388 :   GEN res = cgetg(l2+1, typ(V));
     651    10737632 :   for (i = 1; i < l2; i++) gel(res, i) = gel(V,i);
     652     3432392 :   gel(res,l2) = s; return res;
     653             : }
     654             : /* shallow*/
     655             : INLINE GEN
     656      300942 : vec_prepend(GEN v, GEN s)
     657             : {
     658      300942 :   long i, l = lg(v);
     659      300942 :   GEN w = cgetg(l+1, typ(v));
     660      300945 :   gel(w,1) = s;
     661      769430 :   for (i = 2; i <= l; i++) gel(w,i) = gel(v,i-1);
     662      300945 :   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       72596 : vecsmall_shorten(GEN v, long n)
     674             : {
     675       72596 :   GEN V = cgetg(n+1,t_VECSMALL);
     676             :   long i;
     677      889707 :   for(i = 1; i <= n; i++) V[i] = v[i];
     678       72597 :   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     4016095 : vec_to_vecsmall(GEN x)
     691    18861117 : { pari_APPLY_long(itos(gel(x,i))) }
     692             : INLINE GEN
     693      511220 : vecsmall_to_vec(GEN x)
     694     7069327 : { 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     7762016 : vecsmall_to_col(GEN x)
     704    59564903 : { pari_APPLY_type(t_COL, stoi(x[i])) }
     705             : 
     706             : INLINE int
     707     7209171 : vecsmall_lexcmp(GEN x, GEN y)
     708             : {
     709             :   long lx,ly,l,i;
     710     7209171 :   lx = lg(x);
     711     7209171 :   ly = lg(y); l = minss(lx,ly);
     712    30649366 :   for (i=1; i<l; i++)
     713    29021896 :     if (x[i] != y[i]) return x[i]<y[i]? -1: 1;
     714     1627470 :   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      186798 : vecsmall_prepend(GEN V, long s)
     730             : {
     731      186798 :   long i, l2 = lg(V);
     732      186798 :   GEN res = cgetg(l2+1, typ(V));
     733      186798 :   res[1] = s;
     734      624943 :   for (i = 2; i <= l2; ++i) res[i] = V[i - 1];
     735      186798 :   return res;
     736             : }
     737             : 
     738             : INLINE GEN
     739     4065039 : vecsmall_append(GEN V, long s)
     740             : {
     741     4065039 :   long i, l2 = lg(V);
     742     4065039 :   GEN res = cgetg(l2+1, t_VECSMALL);
     743     5975261 :   for (i = 1; i < l2; ++i) res[i] = V[i];
     744     4065039 :   res[l2] = s; return res;
     745             : }
     746             : 
     747             : INLINE GEN
     748     1465404 : vecsmall_concat(GEN u, GEN v)
     749             : {
     750     1465404 :   long i, l1 = lg(u)-1, l2 = lg(v)-1;
     751     1465404 :   GEN res = cgetg(l1+l2+1, t_VECSMALL);
     752    11628998 :   for (i = 1; i <= l1; ++i) res[i]    = u[i];
     753    15225361 :   for (i = 1; i <= l2; ++i) res[i+l1] = v[i];
     754     1465404 :   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         123 :   for (i = 1; i < l; i++)
     773          78 :     if (v[i] == x) return i;
     774          45 :   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     1011287 : vecsmall_max(GEN x)
     796             : {
     797     1011287 :   long i, t = x[1], lx = lg(x);
     798     2825464 :   for (i=2; i<lx; i++)
     799     1814177 :     if (x[i] > t) t = x[i];
     800     1011287 :   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    22771191 : ZV_isscalar(GEN x)
     823             : {
     824    22771191 :   long l = lg(x);
     825    54275479 :   while (--l > 1)
     826    53881059 :     if (signe(gel(x, l))) return 0;
     827      394420 :   return 1;
     828             : }
     829             : INLINE int
     830    52379370 : QV_isscalar(GEN x)
     831             : {
     832    52379370 :   long lx = lg(x),i;
     833    68076488 :   for (i=2; i<lx; i++)
     834    64355321 :     if (!isintzero(gel(x, i))) return 0;
     835     3721167 :   return 1;
     836             : }
     837             : INLINE int
     838     1140352 : RgV_isscalar(GEN x)
     839             : {
     840     1140352 :   long lx = lg(x),i;
     841     1166553 :   for (i=2; i<lx; i++)
     842     1162841 :     if (!gequal0(gel(x, i))) return 0;
     843        3712 :   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    26879315 : 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       67889 : RgX_is_rational(GEN x)
     862             : {
     863             :   long i;
     864      309349 :   for (i = lg(x)-1; i > 1; i--)
     865      293421 :     if (!is_rational_t(typ(gel(x,i)))) return 0;
     866       15928 :   return 1;
     867             : }
     868             : INLINE int
     869    15301276 : RgX_is_ZX(GEN x)
     870             : {
     871             :   long i;
     872    65379851 :   for (i = lg(x)-1; i > 1; i--)
     873    50142963 :     if (typ(gel(x,i)) != t_INT) return 0;
     874    15236888 :   return 1;
     875             : }
     876             : INLINE int
     877      395945 : RgX_is_QX(GEN x)
     878             : {
     879      395945 :   long k = lg(x)-1;
     880     1483353 :   for ( ; k>1; k--)
     881     1087688 :     if (!is_rational_t(typ(gel(x,k)))) return 0;
     882      395665 :   return 1;
     883             : }
     884             : INLINE int
     885     3113552 : RgX_is_monomial(GEN x)
     886             : {
     887             :   long i;
     888     3113552 :   if (!signe(x)) return 0;
     889     7121576 :   for (i=lg(x)-2; i>1; i--)
     890     4723641 :     if (!isexactzero(gel(x,i))) return 0;
     891     2397935 :   return 1;
     892             : }
     893             : INLINE int
     894    31362761 : RgV_is_ZV(GEN x)
     895             : {
     896             :   long i;
     897   124680563 :   for (i = lg(x)-1; i > 0; i--)
     898    93350233 :     if (typ(gel(x,i)) != t_INT) return 0;
     899    31330330 :   return 1;
     900             : }
     901             : INLINE int
     902      140156 : RgV_is_QV(GEN x)
     903             : {
     904             :   long i;
     905      620023 :   for (i = lg(x)-1; i > 0; i--)
     906      482821 :     if (!is_rational_t(typ(gel(x,i)))) return 0;
     907      137202 :   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   697130461 : pari_stack_base(pari_stack *s) { return s->data; }
     927             : 
     928             : INLINE void
     929     5754002 : pari_stack_init(pari_stack *s, size_t size, void **data)
     930             : {
     931     5754002 :   s->data = data;
     932     5754002 :   *data = NULL;
     933     5754002 :   s->n = 0;
     934     5754002 :   s->alloc = 0;
     935     5754002 :   s->size = size;
     936     5754002 : }
     937             : 
     938             : INLINE void
     939   691829946 : pari_stack_alloc(pari_stack *s, long nb)
     940             : {
     941   691829946 :   void **sdat = pari_stack_base(s);
     942   691737578 :   long alloc = s->alloc;
     943   691737578 :   if (s->n+nb <= alloc) return;
     944     2142432 :   if (!alloc)
     945     2046455 :     alloc = nb;
     946             :   else
     947             :   {
     948      196479 :     while (s->n+nb > alloc) alloc <<= 1;
     949             :   }
     950     2142432 :   pari_realloc_ip(sdat,alloc*s->size);
     951     2144274 :   s->alloc = alloc;
     952             : }
     953             : 
     954             : INLINE long
     955   598789590 : pari_stack_new(pari_stack *s) { pari_stack_alloc(s, 1); return s->n++; }
     956             : 
     957             : INLINE void
     958     5335407 : pari_stack_delete(pari_stack *s)
     959             : {
     960     5335407 :   void **sdat = pari_stack_base(s);
     961     5325824 :   if (*sdat) pari_free(*sdat);
     962     5346563 : }
     963             : 
     964             : INLINE void
     965        5788 : pari_stack_pushp(pari_stack *s, void *u)
     966             : {
     967        5788 :   long n = pari_stack_new(s);
     968        5788 :   void **sdat =(void**) *pari_stack_base(s);
     969        5788 :   sdat[n] = u;
     970        5788 : }
     971             : 
     972             : /*******************************************************************/
     973             : /*                                                                 */
     974             : /*                            EXTRACT                              */
     975             : /*                                                                 */
     976             : /*******************************************************************/
     977             : INLINE GEN
     978   642360493 : vecslice(GEN A, long y1, long y2)
     979             : {
     980   642360493 :   long i,lB = y2 - y1 + 2;
     981   642360493 :   GEN B = cgetg(lB, typ(A));
     982  2858657959 :   for (i=1; i<lB; i++) B[i] = A[y1-1+i];
     983   642353042 :   return B;
     984             : }
     985             : INLINE GEN
     986     2649050 : vecslicepermute(GEN A, GEN p, long y1, long y2)
     987             : {
     988     2649050 :   long i,lB = y2 - y1 + 2;
     989     2649050 :   GEN B = cgetg(lB, typ(A));
     990    29982181 :   for (i=1; i<lB; i++) B[i] = A[p[y1-1+i]];
     991     2649035 :   return B;
     992             : }
     993             : /* rowslice(rowpermute(A,p), x1, x2) */
     994             : INLINE GEN
     995      182825 : rowslicepermute(GEN x, GEN p, long j1, long j2)
     996      772142 : { pari_APPLY_same(vecslicepermute(gel(x,i),p,j1,j2)) }
     997             : 
     998             : INLINE GEN
     999    78449315 : rowslice(GEN x, long j1, long j2)
    1000   658344306 : { pari_APPLY_same(vecslice(gel(x,i), j1, j2)) }
    1001             : 
    1002             : INLINE GEN
    1003    16613014 : matslice(GEN A, long x1, long x2, long y1, long y2)
    1004    16613014 : { 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      354714 : vecsplice(GEN a, long j)
    1014             : {
    1015      354714 :   long i, k, l = lg(a);
    1016             :   GEN b;
    1017      354714 :   if (l == 1) pari_err(e_MISC, "incorrect component in vecsplice");
    1018      354714 :   b = cgetg(l-1, typ(a));
    1019     1503221 :   for (i = k = 1; i < l; i++)
    1020     1148508 :     if (i != j) gel(b, k++) = gel(a,i);
    1021      354713 :   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      762864 : row(GEN x, long j)
    1036     6687584 : { pari_APPLY_type(t_VEC, gcoeff(x, j, i)) }
    1037             : INLINE GEN
    1038     8757799 : Flm_row(GEN x, long j)
    1039   232252740 : { 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    78052642 : vecsmallpermute(GEN A, GEN p) { return perm_mul(A, p); }
    1086             : 
    1087             : INLINE GEN
    1088    19846902 : vecpermute(GEN A, GEN x)
    1089   112527216 : { pari_APPLY_type(typ(A), gel(A, x[i])) }
    1090             : 
    1091             : INLINE GEN
    1092     6937796 : veclast(GEN A) { return gel(A, lg(A)-1); }
    1093             : 
    1094             : INLINE GEN
    1095    14431796 : rowpermute(GEN x, GEN p)
    1096   100895459 : { 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     3155926 : identity_zv(long n)
    1106             : {
    1107     3155926 :   GEN v = cgetg(n+1, t_VECSMALL);
    1108             :   long i;
    1109    32251070 :   for (i = 1; i <= n; i++) v[i] = i;
    1110     3155925 :   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     3131580 : 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    80247691 : perm_mul(GEN s, GEN x)
    1138  1014859932 : { 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     2780864 : perm_inv(GEN x)
    1147             : {
    1148             :   long i, lx;
    1149     2780864 :   GEN y = cgetg_copy(x, &lx);
    1150    39084125 :   for (i=1; i<lx; i++) y[ x[i] ] = i;
    1151     2780861 :   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   490894085 : pari_free(void *pointer)
    1165             : {
    1166   490894085 :   BLOCK_SIGINT_START;
    1167   490941383 :   free(pointer);
    1168   490941383 :   BLOCK_SIGINT_END;
    1169   490935601 : }
    1170             : INLINE void*
    1171   721236302 : pari_malloc(size_t size)
    1172             : {
    1173   721236302 :   if (size)
    1174             :   {
    1175             :     char *tmp;
    1176   721236705 :     BLOCK_SIGINT_START;
    1177   721289313 :     tmp = (char*)malloc(size);
    1178   721289313 :     BLOCK_SIGINT_END;
    1179   721291084 :     if (!tmp) pari_err(e_MEM);
    1180   721299877 :     return tmp;
    1181             :   }
    1182           0 :   return NULL;
    1183             : }
    1184             : INLINE void*
    1185        1869 : pari_realloc(void *pointer, size_t size)
    1186             : {
    1187             :   char *tmp;
    1188             : 
    1189        1869 :   BLOCK_SIGINT_START;
    1190        1869 :   if (!pointer) tmp = (char *) malloc(size);
    1191        1869 :   else tmp = (char *) realloc(pointer,size);
    1192        1869 :   BLOCK_SIGINT_END;
    1193        1869 :   if (!tmp) pari_err(e_MEM);
    1194        1869 :   return tmp;
    1195             : }
    1196             : INLINE void
    1197     2147101 : pari_realloc_ip(void **pointer, size_t size)
    1198             : {
    1199             :   char *tmp;
    1200     2147101 :   BLOCK_SIGINT_START;
    1201     2146984 :   if (!*pointer) tmp = (char *) malloc(size);
    1202      100788 :   else tmp = (char *) realloc(*pointer,size);
    1203     2146984 :   if (!tmp) pari_err(e_MEM);
    1204     2146984 :   *pointer = tmp;
    1205     2146984 :   BLOCK_SIGINT_END;
    1206     2146837 : }
    1207             : 
    1208             : INLINE void*
    1209       47076 : pari_calloc(size_t size)
    1210             : {
    1211       47076 :   void *t = pari_malloc(size);
    1212       47076 :   memset(t, 0, size); return t;
    1213             : }
    1214             : INLINE GEN
    1215       10096 : cgetalloc(size_t l, long t)
    1216             : { /* evallg may raise e_OVERFLOW, which would leak x */
    1217       10096 :   ulong x0 = evaltyp(t) | evallg(l);
    1218       10096 :   GEN x = (GEN)pari_malloc(l * sizeof(long));
    1219       10096 :   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  7851757489 : icopy_avma(GEN x, pari_sp av)
    1230             : {
    1231  7851757489 :   long i = lgefint(x), lx = i;
    1232  7851757489 :   GEN y = ((GEN)av) - i;
    1233 57729630178 :   while (--i > 0) y[i] = x[i];
    1234  7851757489 :   y[0] = evaltyp(t_INT)|evallg(lx);
    1235  7854973957 :   return y;
    1236             : }
    1237             : /* copy leaf x as if we had set_avma(av) */
    1238             : INLINE GEN
    1239   547439685 : leafcopy_avma(GEN x, pari_sp av)
    1240             : {
    1241   547439685 :   long i = lg(x);
    1242   547439685 :   GEN y = ((GEN)av) - i;
    1243  2975263763 :   while (--i > 0) y[i] = x[i];
    1244   547439685 :   y[0] = x[0] & (~CLONEBIT);
    1245   547439685 :   return y;
    1246             : }
    1247             : INLINE GEN
    1248  1076156044 : gerepileuptoleaf(pari_sp av, GEN x)
    1249             : {
    1250             :   long lx;
    1251             :   GEN q;
    1252             : 
    1253  1076156044 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1254  1074850845 :   lx = lg(x);
    1255  1074850845 :   q = ((GEN)av) - lx;
    1256  1074850845 :   set_avma((pari_sp)q);
    1257 10848865793 :   while (--lx >= 0) q[lx] = x[lx];
    1258  1074566219 :   return q;
    1259             : }
    1260             : INLINE GEN
    1261  3990755934 : gerepileuptoint(pari_sp av, GEN x)
    1262             : {
    1263  3990755934 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1264  3555074251 :   set_avma((pari_sp)icopy_avma(x, av));
    1265  3558645939 :   return (GEN)avma;
    1266             : }
    1267             : INLINE GEN
    1268  1832910663 : gerepileupto(pari_sp av, GEN x)
    1269             : {
    1270  1832910663 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1271  1669155309 :   switch(typ(x))
    1272             :   { /* non-default = !is_recursive_t(tq) */
    1273   480835643 :     case t_INT: return gerepileuptoint(av, x);
    1274   338418130 :     case t_REAL:
    1275             :     case t_STR:
    1276   338418130 :     case t_VECSMALL: return gerepileuptoleaf(av,x);
    1277   849903517 :     default:
    1278             :       /* NB: x+i --> ((long)x) + i*sizeof(long) */
    1279   849903517 :       return gerepile(av, (pari_sp) (x+lg(x)), x);
    1280             :   }
    1281             : }
    1282             : 
    1283             : /* gerepileupto(av, gcopy(x)) */
    1284             : INLINE GEN
    1285   227664568 : gerepilecopy(pari_sp av, GEN x)
    1286             : {
    1287   227664568 :   if (is_recursive_t(typ(x)))
    1288             :   {
    1289   208160863 :     GENbin *p = copy_bin(x);
    1290   208180385 :     set_avma(av); return bin_copy(p);
    1291             :   }
    1292             :   else
    1293             :   {
    1294    19503121 :     set_avma(av);
    1295    19503278 :     if (x < (GEN)av) {
    1296    19295494 :       if (x < (GEN)pari_mainstack->bot) new_chunk(lg(x));
    1297    19295499 :       x = leafcopy_avma(x, av);
    1298    19295532 :       set_avma((pari_sp)x);
    1299             :     } else
    1300      207787 :       x = leafcopy(x);
    1301    19503326 :     return x;
    1302             :   }
    1303             : }
    1304             : 
    1305             : INLINE void
    1306    47884485 : guncloneNULL(GEN x) { if (x) gunclone(x); }
    1307             : INLINE void
    1308     1371530 : 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      984985 : gerepilemany(pari_sp av, GEN* gptr[], int n)
    1315             : {
    1316             :   int i;
    1317     3913358 :   for (i=0; i<n; i++) *gptr[i] = (GEN)copy_bin(*gptr[i]);
    1318      984872 :   set_avma(av);
    1319     3913886 :   for (i=0; i<n; i++) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1320      985117 : }
    1321             : 
    1322             : INLINE void
    1323    19178159 : gerepileall(pari_sp av, int n, ...)
    1324             : {
    1325             :   int i;
    1326    19178159 :   va_list a; va_start(a, n);
    1327    19178159 :   if (n < 10)
    1328             :   {
    1329             :     GEN *gptr[10];
    1330    58156819 :     for (i=0; i<n; i++)
    1331    38977834 :     { gptr[i] = va_arg(a,GEN*); *gptr[i] = (GEN)copy_bin(*gptr[i]); }
    1332    19178985 :     set_avma(av);
    1333    58157870 :     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    19179522 :   va_end(a);
    1346    19179522 : }
    1347             : 
    1348             : /* assume 1 <= n < 10 */
    1349             : INLINE GEN
    1350    86227674 : gc_all(pari_sp av, int n, ...)
    1351             : {
    1352             :   int i;
    1353             :   GEN *v[10];
    1354    86227674 :   va_list a; va_start(a, n);
    1355   289705791 :   for (i=0; i<n; i++) { v[i] = va_arg(a,GEN*); *v[i] = (GEN)copy_bin(*v[i]); }
    1356    86227941 :   set_avma(av);
    1357   289706409 :   for (i=0; i<n; i++) *v[i] = bin_copy((GENbin*)*v[i]);
    1358    86228065 :   return *v[0];
    1359             : }
    1360             : 
    1361             : INLINE void
    1362     2200355 : gerepilecoeffs(pari_sp av, GEN x, int n)
    1363             : {
    1364             :   int i;
    1365    26205004 :   for (i=0; i<n; i++) gel(x,i) = (GEN)copy_bin(gel(x,i));
    1366     2200924 :   set_avma(av);
    1367    26206123 :   for (i=0; i<n; i++) gel(x,i) = bin_copy((GENbin*)x[i]);
    1368     2200519 : }
    1369             : 
    1370             : /* p from copy_bin. Copy p->x back to stack, then destroy p */
    1371             : INLINE GEN
    1372   477617244 : bin_copy(GENbin *p)
    1373             : {
    1374             :   GEN x, y, base;
    1375             :   long dx, len;
    1376             : 
    1377   477617244 :   x   = p->x; if (!x) { pari_free(p); return gen_0; }
    1378   448568662 :   len = p->len;
    1379   448568662 :   base= p->base; dx = x - base;
    1380   448568662 :   y = (GEN)memcpy((void*)new_chunk(len), (void*)GENbinbase(p), len*sizeof(long));
    1381   448562019 :   y += dx;
    1382   448562019 :   p->rebase(y, ((ulong)y-(ulong)x));
    1383   448565516 :   pari_free(p); return y;
    1384             : }
    1385             : 
    1386             : INLINE GEN
    1387   926184449 : GENbinbase(GENbin *p) { return (GEN)(p + 1); }
    1388             : 
    1389             : INLINE void
    1390   117721061 : cgiv(GEN x)
    1391             : {
    1392   117721061 :   pari_sp av = (pari_sp)(x+lg(x));
    1393   117721061 :   if (isonstack((GEN)av)) set_avma(av);
    1394   117735132 : }
    1395             : 
    1396             : INLINE void
    1397     1886974 : killblock(GEN x) { gunclone(x); }
    1398             : 
    1399             : INLINE int
    1400   291184394 : 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    17935384 : cxcompotor(GEN z, long prec)
    1410             : {
    1411    17935384 :   switch(typ(z))
    1412             :   {
    1413    11783125 :     case t_INT:  return itor(z, prec);
    1414      293174 :     case t_FRAC: return fractor(z, prec);
    1415     5859308 :     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     8951032 : cxtofp(GEN x, long prec)
    1422     8951032 : { retmkcomplex(cxcompotor(gel(x,1),prec), cxcompotor(gel(x,2),prec)); }
    1423             : 
    1424             : INLINE GEN
    1425      384632 : cxtoreal(GEN q)
    1426      384632 : { return (typ(q) == t_COMPLEX && gequal0(gel(q,2)))? gel(q,1): q; }
    1427             : 
    1428             : INLINE double
    1429    60621255 : gtodouble(GEN x)
    1430             : {
    1431    60621255 :   if (typ(x)!=t_REAL) {
    1432     8161091 :     pari_sp av = avma;
    1433     8161091 :     x = gtofp(x, DEFAULTPREC);
    1434     8160521 :     if (typ(x)!=t_REAL) pari_err_TYPE("gtodouble [t_REAL expected]", x);
    1435     8160521 :     set_avma(av);
    1436             :   }
    1437    60620578 :   return rtodbl(x);
    1438             : }
    1439             : 
    1440             : INLINE int
    1441     2971837 : gisdouble(GEN x, double *g)
    1442             : {
    1443     2971837 :   if (typ(x)!=t_REAL) {
    1444       41923 :     pari_sp av = avma;
    1445       41923 :     x = gtofp(x, DEFAULTPREC);
    1446       41923 :     if (typ(x)!=t_REAL) pari_err_TYPE("gisdouble [t_REAL expected]", x);
    1447       41923 :     set_avma(av);
    1448             :   }
    1449     2971838 :   if (expo(x) >= 0x3ff) return 0;
    1450     2971838 :   *g = rtodbl(x); return 1;
    1451             : }
    1452             : 
    1453             : INLINE long
    1454    85800843 : gtos(GEN x) {
    1455    85800843 :   if (typ(x) != t_INT) pari_err_TYPE("gtos [integer expected]",x);
    1456    85800829 :   return itos(x);
    1457             : }
    1458             : 
    1459             : INLINE ulong
    1460      102638 : gtou(GEN x) {
    1461      102638 :   if (typ(x) != t_INT || signe(x)<0)
    1462           7 :     pari_err_TYPE("gtou [integer >=0 expected]",x);
    1463      102631 :   return itou(x);
    1464             : }
    1465             : 
    1466             : INLINE GEN
    1467    45575930 : absfrac(GEN x)
    1468             : {
    1469    45575930 :   GEN y = cgetg(3, t_FRAC);
    1470    45575971 :   gel(y,1) = absi(gel(x,1));
    1471    45576006 :   gel(y,2) = icopy(gel(x,2)); return y;
    1472             : }
    1473             : INLINE GEN
    1474       27254 : absfrac_shallow(GEN x)
    1475       27254 : { return signe(gel(x,1))>0? x: mkfrac(negi(gel(x,1)), gel(x,2)); }
    1476             : INLINE GEN
    1477     7922114 : Q_abs(GEN x) { return (typ(x) == t_INT)? absi(x): absfrac(x); }
    1478             : INLINE GEN
    1479      118421 : Q_abs_shallow(GEN x)
    1480      118421 : { 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   252459467 : gtofp(GEN z, long prec)
    1491             : {
    1492   252459467 :   switch(typ(z))
    1493             :   {
    1494   213726500 :     case t_INT:  return itor(z, prec);
    1495     4097405 :     case t_FRAC: return fractor(z, prec);
    1496    25944810 :     case t_REAL: return rtor(z, prec);
    1497     8697935 :     case t_COMPLEX: {
    1498     8697935 :       GEN a = gel(z,1), b = gel(z,2);
    1499     8697935 :       if (isintzero(b)) return cxcompotor(a, prec);
    1500     8697919 :       if (isintzero(a)) {
    1501        9103 :         GEN y = cgetg(3, t_COMPLEX);
    1502        9103 :         b = cxcompotor(b, prec);
    1503        9103 :         gel(y,1) = real_0_bit(expo(b) - prec);
    1504        9103 :         gel(y,2) = b; return y;
    1505             :       }
    1506     8688774 :       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     7132561 : RgX_gtofp(GEN x, long prec)
    1531    37210857 : { pari_APPLY_pol_normalized(gtofp(gel(x,i), prec)); }
    1532             : 
    1533             : INLINE GEN
    1534    33738298 : RgC_gtofp(GEN x, long prec)
    1535   217411109 : { 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     8183566 : RgM_gtofp(GEN x, long prec)
    1543    41291324 : { 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       60610 : RgX_fpnorml2(GEN x, long prec)
    1555             : {
    1556       60610 :   pari_sp av = avma;
    1557       60610 :   return gerepileupto(av, gnorml2(RgX_gtofp(x, prec)));
    1558             : }
    1559             : INLINE GEN
    1560      619428 : RgC_fpnorml2(GEN x, long prec)
    1561             : {
    1562      619428 :   pari_sp av = avma;
    1563      619428 :   return gerepileupto(av, gnorml2(RgC_gtofp(x, prec)));
    1564             : }
    1565             : INLINE GEN
    1566       22534 : RgM_fpnorml2(GEN x, long prec)
    1567             : {
    1568       22534 :   pari_sp av = avma;
    1569       22534 :   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      239589 : affc_fixlg(GEN x, GEN res)
    1588             : {
    1589      239589 :   if (typ(x) == t_COMPLEX)
    1590             :   {
    1591      206871 :     affrr_fixlg(gel(x,1), gel(res,1));
    1592      206871 :     affrr_fixlg(gel(x,2), gel(res,2));
    1593             :   }
    1594             :   else
    1595             :   {
    1596       32718 :     set_avma((pari_sp)(res+3));
    1597       32718 :     res = cgetr(realprec(gel(res,1)));
    1598       32719 :     affrr_fixlg(x, res);
    1599             :   }
    1600      239591 :   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       41087 : ndec2nlong(long x) { return 1 + (long)((x)*(LOG2_10/BITS_IN_LONG)); }
    1613             : INLINE long
    1614       32831 : ndec2prec(long x) { return ndec2nlong(x) << TWOPOTBITS_IN_LONG; }
    1615             : INLINE long
    1616        8256 : 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    12591451 : nbits2nlong(long x) {
    1622    12591451 :   return (long)(((ulong)x+BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1623             : }
    1624             : 
    1625             : INLINE long
    1626  1474871461 : nbits2extraprec(long x) {
    1627  1474871461 :   return (((ulong)x+BITS_IN_LONG-1)>>TWOPOTBITS_IN_LONG) << TWOPOTBITS_IN_LONG;
    1628             : }
    1629             : 
    1630             : INLINE long
    1631   185704561 : nbits2prec(long x) {
    1632   185704561 :   return (((ulong)x+BITS_IN_LONG-1)>>TWOPOTBITS_IN_LONG) << TWOPOTBITS_IN_LONG;
    1633             : }
    1634             : 
    1635             : INLINE long
    1636  4459646831 : prec2lg(long x) {
    1637  4459646831 :   return (long)(((ulong)x+3*BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1638             : }
    1639             : /* ceil(x / sizeof(long)) */
    1640             : INLINE long
    1641   120860127 : nchar2nlong(long x) {
    1642   120860127 :   return (long)(((ulong)x+sizeof(long)-1) >> (TWOPOTBITS_IN_LONG-3L));
    1643             : }
    1644             : INLINE long
    1645   104294207 : prec2nbits(long x) { return x; }
    1646             : INLINE double
    1647     3175075 : bit_accuracy_mul(long x, double y) { return (x-2) * (BITS_IN_LONG*y); }
    1648             : INLINE double
    1649      570916 : prec2nbits_mul(long x, double y) { return x * y; }
    1650             : INLINE long
    1651   141596466 : bit_prec(GEN x) { return realprec(x); }
    1652             : INLINE long
    1653  3126166208 : bit_accuracy(long x) { return (x-2) * BITS_IN_LONG; }
    1654             : INLINE long
    1655        9750 : prec2ndec(long x) { return (long)(x * LOG10_2); }
    1656             : INLINE long
    1657         214 : nbits2ndec(long x) { return prec2ndec(x); }
    1658             : INLINE long
    1659      475486 : precdbl(long x) {return x << 1;}
    1660             : INLINE long
    1661  8070346539 : divsBIL(long n) { return n >> TWOPOTBITS_IN_LONG; }
    1662             : INLINE long
    1663  7980732158 : 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    79918365 : Fp_red(GEN a, GEN m) { return modii(a, m); }
    1674             : INLINE GEN
    1675   173798856 : Fp_add(GEN a, GEN b, GEN m)
    1676             : {
    1677   173798856 :   pari_sp av=avma;
    1678   173798856 :   GEN p = addii(a,b);
    1679   173249226 :   long s = signe(p);
    1680   173249226 :   if (!s) return p; /* = gen_0 */
    1681   160360482 :   if (s > 0) /* general case */
    1682             :   {
    1683   160104479 :     GEN t = subii(p, m);
    1684   160009649 :     s = signe(t);
    1685   160009649 :     if (!s) return gc_const(av, gen_0);
    1686   151721382 :     if (s < 0) return gc_const((pari_sp)p, p);
    1687    72440711 :     if (cmpii(t, m) < 0) return gerepileuptoint(av, t); /* general case ! */
    1688     3296435 :     p = remii(t, m);
    1689             :   }
    1690             :   else
    1691      261528 :     p = modii(p, m);
    1692     3558048 :   return gerepileuptoint(av, p);
    1693             : }
    1694             : INLINE GEN
    1695    20984059 : Fp_double(GEN x, GEN N)
    1696             : {
    1697    20984059 :   GEN z = shifti(x, 1);
    1698    20633368 :   return cmpii(z, N) >= 0? subii(z, N): z;
    1699             : }
    1700             : INLINE GEN
    1701   203463517 : Fp_sub(GEN a, GEN b, GEN m)
    1702             : {
    1703   203463517 :   pari_sp av=avma;
    1704   203463517 :   GEN p = subii(a,b);
    1705   201924545 :   long s = signe(p);
    1706   201924545 :   if (!s) return p; /* = gen_0 */
    1707   186038295 :   if (s > 0)
    1708             :   {
    1709    93289738 :     if (cmpii(p, m) < 0) return p; /* general case ! */
    1710     1452411 :     p = remii(p, m);
    1711             :   }
    1712             :   else
    1713             :   {
    1714    92748557 :     GEN t = addii(p, m);
    1715    94275581 :     if (!s) return gc_const(av, gen_0);
    1716    94274308 :     if (s > 0) return gerepileuptoint(av, t); /* general case ! */
    1717    94274308 :     p = modii(t, m);
    1718             :   }
    1719    96038924 :   return gerepileuptoint(av, p);
    1720             : }
    1721             : INLINE GEN
    1722    28806479 : Fp_neg(GEN b, GEN m)
    1723             : {
    1724    28806479 :   pari_sp av = avma;
    1725    28806479 :   long s = signe(b);
    1726             :   GEN p;
    1727    28806479 :   if (!s) return gen_0;
    1728    24374004 :   if (s > 0)
    1729             :   {
    1730    23245423 :     p = subii(m, b);
    1731    23245106 :     if (signe(p) >= 0) return p; /* general case ! */
    1732      386776 :     p = modii(p, m);
    1733             :   } else
    1734     1129178 :     p = remii(negi(b), m);
    1735     1516160 :   return gerepileuptoint(av, p);
    1736             : }
    1737             : 
    1738             : INLINE GEN
    1739      252299 : Fp_halve(GEN a, GEN p)
    1740             : {
    1741      252299 :   if (mpodd(a)) a = addii(a,p);
    1742      252299 :   return shifti(a,-1);
    1743             : }
    1744             : 
    1745             : /* assume 0 <= u < p and ps2 = p>>1 */
    1746             : INLINE GEN
    1747    75647408 : Fp_center(GEN u, GEN p, GEN ps2)
    1748    75647408 : { return abscmpii(u,ps2)<=0? icopy(u): subii(u,p); }
    1749             : /* same without copy */
    1750             : INLINE GEN
    1751    14165781 : Fp_center_i(GEN u, GEN p, GEN ps2)
    1752    14165781 : { return abscmpii(u,ps2)<=0? u: subii(u,p); }
    1753             : 
    1754             : /* x + y*z mod p */
    1755             : INLINE GEN
    1756    11298187 : Fp_addmul(GEN x, GEN y, GEN z, GEN p)
    1757             : {
    1758             :   pari_sp av;
    1759    11298187 :   if (!signe(y) || !signe(z)) return Fp_red(x, p);
    1760    10951834 :   if (!signe(x)) return Fp_mul(z,y, p);
    1761     9951854 :   av = avma;
    1762     9951854 :   return gerepileuptoint(av, modii(addii(x, mulii(y,z)), p));
    1763             : }
    1764             : 
    1765             : INLINE GEN
    1766   200036748 : Fp_mul(GEN a, GEN b, GEN m)
    1767             : {
    1768   200036748 :   pari_sp av=avma;
    1769             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1770   200036748 :   (void)new_chunk(lg(a)+lg(b)+(lg(m)<<1));
    1771   200103642 :   p = mulii(a,b);
    1772   199929742 :   set_avma(av); return modii(p,m);
    1773             : }
    1774             : INLINE GEN
    1775    64070650 : Fp_sqr(GEN a, GEN m)
    1776             : {
    1777    64070650 :   pari_sp av=avma;
    1778             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1779    64070650 :   (void)new_chunk((lg(a)+lg(m))<<1);
    1780    64421725 :   p = sqri(a);
    1781    62677889 :   set_avma(av); return remii(p,m); /*Use remii: p >= 0 */
    1782             : }
    1783             : INLINE GEN
    1784    67786246 : Fp_mulu(GEN a, ulong b, GEN m)
    1785             : {
    1786    67786246 :   long l = lgefint(m);
    1787    67786246 :   if (l == 3)
    1788             :   {
    1789    46133867 :     ulong mm = m[2];
    1790    46133867 :     return utoi( Fl_mul(umodiu(a, mm), b, mm) );
    1791             :   } else {
    1792    21652379 :     pari_sp av = avma;
    1793             :     GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1794    21652379 :     (void)new_chunk(lg(a)+1+(l<<1));
    1795    21624041 :     p = muliu(a,b);
    1796    21419429 :     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    23213811 : Fp_inv(GEN a, GEN m)
    1824             : {
    1825             :   GEN res;
    1826    23213811 :   if (! invmod(a,m,&res)) pari_err_INV("Fp_inv", mkintmod(res,m));
    1827    23213527 :   return res;
    1828             : }
    1829             : INLINE GEN
    1830     1098655 : Fp_invsafe(GEN a, GEN m)
    1831             : {
    1832             :   GEN res;
    1833     1098655 :   if (! invmod(a,m,&res)) return NULL;
    1834     1098606 :   return res;
    1835             : }
    1836             : INLINE GEN
    1837    14988533 : Fp_div(GEN a, GEN b, GEN m)
    1838             : {
    1839    14988533 :   pari_sp av = avma;
    1840             :   GEN p;
    1841    14988533 :   if (lgefint(b) == 3)
    1842             :   {
    1843    13843500 :     a = Fp_divu(a, b[2], m);
    1844    13844946 :     if (signe(b) < 0) a = Fp_neg(a, m);
    1845    13844955 :     return a;
    1846             :   }
    1847             :   /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1848     1145033 :   (void)new_chunk(lg(a)+(lg(m)<<1));
    1849     1145035 :   p = mulii(a, Fp_inv(b,m));
    1850     1145035 :   set_avma(av); return modii(p,m);
    1851             : }
    1852             : INLINE GEN
    1853    15087784 : Fp_divu(GEN x, ulong a, GEN p)
    1854             : {
    1855    15087784 :   pari_sp av = avma;
    1856             :   ulong b;
    1857    15087784 :   if (lgefint(p) == 3)
    1858             :   {
    1859    14554457 :     ulong pp = p[2], xp = umodiu(x, pp);
    1860    14555268 :     return xp? utoipos(Fl_div(xp, a % pp, pp)): gen_0;
    1861             :   }
    1862      533327 :   x = Fp_red(x, p);
    1863      533330 :   b = Fl_neg(Fl_div(umodiu(x,a), umodiu(p,a), a), a); /* x + pb = 0 (mod a) */
    1864      533330 :   return gerepileuptoint(av, diviuexact(addmuliu(x, p, b), a));
    1865             : }
    1866             : 
    1867             : INLINE GEN
    1868     1095042 : Flx_mulu(GEN x, ulong a, ulong p) { return Flx_Fl_mul(x,a%p,p); }
    1869             : 
    1870             : INLINE GEN
    1871     2498398 : get_F2x_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1872             : 
    1873             : INLINE long
    1874     2532923 : get_F2x_var(GEN T) { return typ(T)==t_VEC? mael(T,2,1): T[1]; }
    1875             : 
    1876             : INLINE long
    1877     1929009 : 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    25431761 : get_Flx_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1890             : 
    1891             : INLINE long
    1892    67692244 : get_Flx_var(GEN T) { return typ(T)==t_VEC? mael(T,2,1): T[1]; }
    1893             : 
    1894             : INLINE long
    1895    82064916 : 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      264970 : get_FlxqX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1902             : 
    1903             : INLINE long
    1904      318193 : get_FlxqX_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1905             : 
    1906             : INLINE GEN
    1907     3392226 : get_FpX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1908             : 
    1909             : INLINE long
    1910     7241110 : get_FpX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1911             : 
    1912             : INLINE long
    1913     6005685 : 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       51621 : get_FpXQX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1920             : 
    1921             : INLINE long
    1922        3586 : 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    32772656 : submulii(GEN x, GEN y, GEN z)
    1932             : {
    1933    32772656 :   long lx = lgefint(x), ly, lz;
    1934             :   pari_sp av;
    1935             :   GEN t;
    1936    32772656 :   if (lx == 2) { t = mulii(z,y); togglesign(t); return t; }
    1937    30267181 :   ly = lgefint(y);
    1938    30267181 :   if (ly == 2) return icopy(x);
    1939    28999749 :   lz = lgefint(z);
    1940    28999749 :   av = avma; (void)new_chunk(lx+ly+lz); /* HACK */
    1941    28999749 :   t = mulii(z, y);
    1942    28999749 :   set_avma(av); return subii(x,t);
    1943             : }
    1944             : /* y*z - x */
    1945             : INLINE GEN
    1946     3863369 : mulsubii(GEN y, GEN z, GEN x)
    1947             : {
    1948     3863369 :   long lx = lgefint(x), ly, lz;
    1949             :   pari_sp av;
    1950             :   GEN t;
    1951     3863369 :   if (lx == 2) return mulii(z,y);
    1952     2438525 :   ly = lgefint(y);
    1953     2438525 :   if (ly == 2) return negi(x);
    1954     2160412 :   lz = lgefint(z);
    1955     2160412 :   av = avma; (void)new_chunk(lx+ly+lz); /* HACK */
    1956     2160438 :   t = mulii(z, y);
    1957     2160413 :   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      541398 : addmuliu(GEN x, GEN y, ulong u)
    1975             : {
    1976             :   pari_sp av;
    1977      541398 :   long ly = lgefint(y);
    1978      541398 :   if (ly == 2) return icopy(x);
    1979      541398 :   av = avma;
    1980      541398 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1981      541398 :   y = mului(u,y);
    1982      541399 :   set_avma(av); return addii(x, y);
    1983             : }
    1984             : /* x - u*y */
    1985             : INLINE GEN
    1986    59546910 : submuliu_inplace(GEN x, GEN y, ulong u)
    1987             : {
    1988             :   pari_sp av;
    1989    59546910 :   long ly = lgefint(y);
    1990    59546910 :   if (ly == 2) return x;
    1991    38027640 :   av = avma;
    1992    38027640 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1993    38031987 :   y = mului(u,y);
    1994    38031776 :   set_avma(av); return subii(x, y);
    1995             : }
    1996             : /* x + u*y */
    1997             : INLINE GEN
    1998    59003105 : addmuliu_inplace(GEN x, GEN y, ulong u)
    1999             : {
    2000             :   pari_sp av;
    2001    59003105 :   long ly = lgefint(y);
    2002    59003105 :   if (ly == 2) return x;
    2003    37932990 :   av = avma;
    2004    37932990 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    2005    37937304 :   y = mului(u,y);
    2006    37937140 :   set_avma(av); return addii(x, y);
    2007             : }
    2008             : /* ux + vy */
    2009             : INLINE GEN
    2010    38088321 : lincombii(GEN u, GEN v, GEN x, GEN y)
    2011             : {
    2012    38088321 :   long lx = lgefint(x), ly;
    2013             :   GEN p1, p2;
    2014             :   pari_sp av;
    2015    38088321 :   if (lx == 2) return mulii(v,y);
    2016    23961528 :   ly = lgefint(y);
    2017    23961528 :   if (ly == 2) return mulii(u,x);
    2018    21276567 :   av = avma; (void)new_chunk(lx+ly+lgefint(u)+lgefint(v)); /* HACK */
    2019    21279711 :   p1 = mulii(u,x);
    2020    21278370 :   p2 = mulii(v,y);
    2021    21278065 :   set_avma(av); return addii(p1,p2);
    2022             : }
    2023             : 
    2024             : /*******************************************************************/
    2025             : /*                                                                 */
    2026             : /*                          GEN SUBTYPES                           */
    2027             : /*                                                                 */
    2028             : /*******************************************************************/
    2029             : 
    2030             : INLINE int
    2031  4809641636 : 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     9575961 : is_intreal_t(long t) { return (t <= t_REAL); }
    2036             : INLINE int
    2037   656038357 : is_matvec_t(long t) { return (t >= t_VEC && t <= t_MAT); }
    2038             : INLINE int
    2039    90582654 : 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     5017360 : is_rational_t(long t) { return (t == t_INT || t == t_FRAC); }
    2044             : INLINE int
    2045    62561340 : is_real_t(long t) { return (t == t_INT || t == t_REAL || t == t_FRAC); }
    2046             : INLINE int
    2047  9119144070 : is_recursive_t(long t) { return lontyp[t]; }
    2048             : INLINE int
    2049   361254820 : is_scalar_t(long t) { return (t < t_POL); }
    2050             : INLINE int
    2051    43393233 : is_vec_t(long t) { return (t == t_VEC || t == t_COL); }
    2052             : 
    2053             : INLINE int
    2054    68052805 : qfb_is_qfi(GEN q) { return signe(gel(q,4)) < 0; }
    2055             : 
    2056             : /*******************************************************************/
    2057             : /*                                                                 */
    2058             : /*                         TRANSCENDENTAL                          */
    2059             : /*                                                                 */
    2060             : /*******************************************************************/
    2061             : INLINE GEN
    2062    79927518 : sqrtr(GEN x) {
    2063    79927518 :   long s = signe(x);
    2064    79927518 :   if (s == 0) return real_0_bit(expo(x) >> 1);
    2065    79894403 :   if (s >= 0) return sqrtr_abs(x);
    2066      433606 :   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     2794100 : sqrtnr(GEN x, long n) {
    2081     2794100 :   long s = signe(x);
    2082             :   GEN r;
    2083     2794100 :   if (s == 0) return real_0_bit(expo(x) / n);
    2084     2794100 :   r = sqrtnr_abs(x, n);
    2085     2794113 :   if (s < 0) pari_err_IMPL("sqrtnr for x < 0");
    2086     2794112 :   return r;
    2087             : }
    2088             : INLINE long
    2089      752242 : logint(GEN B, GEN y) { return logintall(B,y,NULL); }
    2090             : INLINE ulong
    2091     1723379 : ulogint(ulong B, ulong y)
    2092             : {
    2093             :   ulong r;
    2094             :   long e;
    2095     1723379 :   if (y == 2) return expu(B);
    2096     1675393 :   r = y;
    2097     5063875 :   for (e=1;; e++)
    2098             :   { /* here, r = y^e, r2 = y^(e-1) */
    2099     5063875 :     if (r >= B) return r == B? e: e-1;
    2100     3389992 :     r = umuluu_or_0(y, r);
    2101     3390023 :     if (!r) return e;
    2102             :   }
    2103             : }
    2104             : 
    2105             : /*******************************************************************/
    2106             : /*                                                                 */
    2107             : /*                         MISCELLANEOUS                           */
    2108             : /*                                                                 */
    2109             : /*******************************************************************/
    2110     9575840 : INLINE int ismpzero(GEN x) { return is_intreal_t(typ(x)) && !signe(x); }
    2111  2797330486 : INLINE int isintzero(GEN x) { return typ(x) == t_INT && !signe(x); }
    2112    17007588 : INLINE int isint1(GEN x) { return typ(x)==t_INT && equali1(x); }
    2113     5702656 : INLINE int isintm1(GEN x){ return typ(x)==t_INT && equalim1(x);}
    2114  1212968663 : INLINE int equali1(GEN n)
    2115  1212968663 : { return (ulong) n[1] == (evallgefint(3UL) | evalsigne(1)) && n[2] == 1; }
    2116   139008323 : INLINE int equalim1(GEN n)
    2117   139008323 : { return (ulong) n[1] == (evallgefint(3UL) | evalsigne(-1)) && n[2] == 1; }
    2118             : /* works only for POSITIVE integers */
    2119  2189876918 : INLINE int is_pm1(GEN n)
    2120  2189876918 : { return lgefint(n) == 3 && n[2] == 1; }
    2121   557170077 : INLINE int is_bigint(GEN n)
    2122   557170077 : { long l = lgefint(n); return l > 3 || (l == 3 && (n[2] & HIGHBIT)); }
    2123             : 
    2124  2026313299 : INLINE int odd(long x) { return x & 1; }
    2125   116946405 : INLINE int both_odd(long x, long y) { return x & y & 1; }
    2126             : 
    2127             : INLINE int
    2128  7965851785 : isonstack(GEN x)
    2129  7965851785 : { return ((pari_sp)x >= pari_mainstack->bot
    2130  7965851785 :        && (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    92936758 : dbllog2r(GEN x)
    2135    92936758 : { return log2((double)(ulong)x[2]) + (double)(expo(x) - (BITS_IN_LONG-1)); }
    2136             : 
    2137             : INLINE GEN
    2138     2514735 : mul_content(GEN cx, GEN cy)
    2139             : {
    2140     2514735 :   if (!cx) return cy;
    2141      520763 :   if (!cy) return cx;
    2142      332964 :   return gmul(cx,cy);
    2143             : }
    2144             : INLINE GEN
    2145           0 : inv_content(GEN c) { return c? ginv(c): NULL; }
    2146             : INLINE GEN
    2147       57990 : div_content(GEN cx, GEN cy)
    2148             : {
    2149       57990 :   if (!cy) return cx;
    2150       56856 :   if (!cx) return ginv(cy);
    2151       25795 :   return gdiv(cx,cy);
    2152             : }
    2153             : INLINE GEN
    2154    10300180 : mul_denom(GEN dx, GEN dy)
    2155             : {
    2156    10300180 :   if (!dx) return dy;
    2157     1836212 :   if (!dy) return dx;
    2158     1368371 :   return mulii(dx,dy);
    2159             : }
    2160             : 
    2161             : /* POLYNOMIALS */
    2162             : INLINE GEN
    2163     1439828 : constant_coeff(GEN x) { return signe(x)? gel(x,2): gen_0; }
    2164             : INLINE GEN
    2165   169109962 : leading_coeff(GEN x) { return lg(x) == 2? gen_0: gel(x,lg(x)-1); }
    2166             : INLINE ulong
    2167      968933 : Flx_lead(GEN x) { return lg(x) == 2? 0: x[lg(x)-1]; }
    2168             : INLINE ulong
    2169      330388 : Flx_constant(GEN x) { return lg(x) == 2? 0: x[2]; }
    2170             : INLINE long
    2171  5342975441 : degpol(GEN x) { return lg(x)-3; }
    2172             : INLINE long
    2173  2626910406 : lgpol(GEN x) { return lg(x)-2; }
    2174             : INLINE long
    2175   341566811 : lgcols(GEN x) { return lg(gel(x,1)); }
    2176             : INLINE long
    2177   153813825 : 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     2128418 : ZXQ_mul(GEN y, GEN x, GEN T) { return ZX_rem(ZX_mul(y, x), T); }
    2183             : INLINE GEN
    2184      951138 : ZXQ_sqr(GEN x, GEN T) { return ZX_rem(ZX_sqr(x), T); }
    2185             : 
    2186             : INLINE GEN
    2187   103474401 : RgX_copy(GEN x)
    2188   376975764 : { 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     7053519 : 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      125497 : RgXQX_rem(GEN x, GEN y, GEN T) { return RgXQX_divrem(x,y,T,ONLY_REM); }
    2205             : INLINE GEN
    2206     5440717 : FpX_div(GEN x, GEN y, GEN p) { return FpX_divrem(x,y,p, NULL); }
    2207             : INLINE GEN
    2208     1996024 : Flx_div(GEN x, GEN y, ulong p) { return Flx_divrem(x,y,p, NULL); }
    2209             : INLINE GEN
    2210    21460590 : Flx_div_pre(GEN x, GEN y, ulong p, ulong pi)
    2211    21460590 : { return Flx_divrem_pre(x,y,p,pi, NULL); }
    2212             : INLINE GEN
    2213     1566236 : 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   101807655 : pol0_Flx(long sv) { return mkvecsmall(sv); }
    2218             : INLINE GEN
    2219    54626886 : pol1_Flx(long sv) { return mkvecsmall2(sv, 1); }
    2220             : INLINE GEN
    2221    37668393 : 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    13233905 : pol0_F2x(long sv) { return pol0_Flx(sv); }
    2234             : INLINE GEN
    2235     3953483 : pol1_F2x(long sv) { return pol1_Flx(sv); }
    2236             : INLINE GEN
    2237     1076080 : polx_F2x(long sv) { return mkvecsmall2(sv, 2); }
    2238             : INLINE int
    2239     2872207 : F2x_equal1(GEN x) { return Flx_equal1(x); }
    2240             : INLINE int
    2241     4653204 : F2x_equal(GEN V, GEN W) { return Flx_equal(V,W); }
    2242             : INLINE GEN
    2243    60402141 : F2x_copy(GEN x) { return leafcopy(x); }
    2244             : INLINE GEN
    2245        4487 : F2v_copy(GEN x) { return leafcopy(x); }
    2246             : INLINE GEN
    2247     2545781 : Flv_copy(GEN x) { return leafcopy(x); }
    2248             : INLINE GEN
    2249   172268008 : Flx_copy(GEN x) { return leafcopy(x); }
    2250             : INLINE GEN
    2251     4370368 : vecsmall_copy(GEN x) { return leafcopy(x); }
    2252             : INLINE int
    2253     8319425 : Flx_equal1(GEN x) { return degpol(x)==0 && x[2] == 1; }
    2254             : INLINE int
    2255       12633 : ZX_equal1(GEN x) { return degpol(x)==0 && equali1(gel(x,2)); }
    2256             : INLINE int
    2257     7268099 : ZX_is_monic(GEN x) { return equali1(leading_coeff(x)); }
    2258             : 
    2259             : INLINE GEN
    2260   154324608 : ZX_renormalize(GEN x, long lx)    { return ZXX_renormalize(x,lx); }
    2261             : INLINE GEN
    2262   145095638 : FpX_renormalize(GEN x, long lx)   { return ZXX_renormalize(x,lx); }
    2263             : INLINE GEN
    2264      849899 : FpXX_renormalize(GEN x, long lx)  { return ZXX_renormalize(x,lx); }
    2265             : INLINE GEN
    2266     4695314 : FpXQX_renormalize(GEN x, long lx) { return ZXX_renormalize(x,lx); }
    2267             : INLINE GEN
    2268   115101126 : 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       37865 : F2v_to_F2x(GEN x, long sv) {
    2275       37865 :   GEN y = leafcopy(x);
    2276       37865 :   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      480509 : RgX_shift_inplace_init(long v)
    2288      480509 : { 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      480509 : RgX_shift_inplace(GEN x, long v)
    2292             : {
    2293             :   long i, lx;
    2294             :   GEN z;
    2295      480509 :   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      502659 : zv_to_ZV(GEN x) { return vecsmall_to_vec(x); }
    2314             : INLINE GEN
    2315     7747834 : zc_to_ZC(GEN x) { return vecsmall_to_col(x); }
    2316             : INLINE GEN
    2317     3190952 : 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    36184078 : 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     2183260 : 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    10692183 : ZC_hnfrem(GEN x, GEN y) { return ZC_hnfdivrem(x,y,NULL); }
    2339             : INLINE GEN
    2340      326812 : ZM_hnfrem(GEN x, GEN y) { return ZM_hnfdivrem(x,y,NULL); }
    2341             : INLINE GEN
    2342     6937193 : ZM_lll(GEN x, double D, long f) { return ZM_lll_norms(x,D,f,NULL); }
    2343             : INLINE void
    2344     9402895 : RgM_dimensions(GEN x, long *m, long *n) { *n = lg(x)-1; *m = *n? nbrows(x): 0; }
    2345             : INLINE GEN
    2346    21451183 : RgM_shallowcopy(GEN x)
    2347    93405494 : { pari_APPLY_same(leafcopy(gel(x,i))); }
    2348             : INLINE GEN
    2349      198567 : 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     6280935 : 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      539185 : ZM_ZV_mod(GEN x, GEN y)
    2369     1538061 : { pari_APPLY_same(ZV_ZV_mod(gel(x,i), y)) }
    2370             : INLINE GEN
    2371     7323197 : ZV_ZV_mod(GEN x, GEN y)
    2372    18922070 : { 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     3106123 : Fq_red(GEN x, GEN T, GEN p)
    2381     3106123 : { 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       14602 : gener_Fq_local(GEN T, GEN p, GEN L)
    2393           0 : { return T? gener_FpXQ_local(T,p, L)
    2394       14602 :           : 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      165383 : 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      568918 : FqX_Fp_mul(GEN P, GEN u, GEN T, GEN p)
    2425      568918 : { return T? FpXX_Fp_mul(P, u, p): FpX_Fp_mul(P, u, p); }
    2426             : INLINE GEN
    2427      427291 : FqX_Fq_mul(GEN P, GEN U, GEN T, GEN p)
    2428      427291 : { return typ(U)==t_INT ? FqX_Fp_mul(P, U, T, p): FpXQX_FpXQ_mul(P, U, T, p); }
    2429             : INLINE GEN
    2430      367212 : FqX_mul(GEN x, GEN y, GEN T, GEN p)
    2431      367212 : { 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       38414 : FqX_div(GEN x, GEN y, GEN T, GEN p)
    2446       38414 : { 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       71939 : FqX_div_by_X_x(GEN x, GEN y, GEN T, GEN p, GEN *z)
    2458       71939 : { 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      691866 : FqX_gcd(GEN P,GEN Q,GEN T,GEN p)
    2464      691866 : {return T? FpXQX_gcd(P,Q,T,p): FpX_gcd(P,Q,p);}
    2465             : INLINE GEN
    2466      443270 : FqX_extgcd(GEN P,GEN Q,GEN T,GEN p, GEN *U, GEN *V)
    2467      443270 : { return T? FpXQX_extgcd(P,Q,T,p,U,V): FpX_extgcd(P,Q,p,U,V); }
    2468             : INLINE GEN
    2469        4032 : FqX_normalize(GEN z, GEN T, GEN p)
    2470        4032 : { 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      140974 : FqX_factor(GEN f, GEN T, GEN p)
    2477      140974 : { 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   667574011 : F2x_coeff(GEN x,long v)
    2557             : {
    2558   667574011 :    ulong u=(ulong)x[2+divsBIL(v)];
    2559   667573691 :    return (u>>remsBIL(v))&1UL;
    2560             : }
    2561             : 
    2562             : INLINE void
    2563    12280110 : F2x_clear(GEN x,long v)
    2564             : {
    2565    12280110 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2566    12280065 :    *u&=~(1UL<<remsBIL(v));
    2567    12280042 : }
    2568             : 
    2569             : INLINE void
    2570   124634739 : F2x_set(GEN x,long v)
    2571             : {
    2572   124634739 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2573   124630704 :    *u|=1UL<<remsBIL(v);
    2574   124631671 : }
    2575             : 
    2576             : INLINE void
    2577     1553944 : F2x_flip(GEN x,long v)
    2578             : {
    2579     1553944 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2580     1553944 :    *u^=1UL<<remsBIL(v);
    2581     1553944 : }
    2582             : 
    2583             : /* F2v */
    2584             : 
    2585             : INLINE ulong
    2586   661059730 : F2v_coeff(GEN x,long v) { return F2x_coeff(x,v-1); }
    2587             : 
    2588             : INLINE void
    2589    12280123 : F2v_clear(GEN x,long v) { F2x_clear(x,v-1); }
    2590             : 
    2591             : INLINE void
    2592   101346857 : F2v_set(GEN x,long v)   { F2x_set(x,v-1); }
    2593             : 
    2594             : INLINE void
    2595     1553944 : F2v_flip(GEN x,long v) { F2x_flip(x,v-1); }
    2596             : 
    2597             : /* F2m */
    2598             : 
    2599             : INLINE ulong
    2600     8033376 : 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     1553944 : F2m_flip(GEN x, long a, long b) { F2v_flip(gel(x,b), a); }
    2610             : 
    2611             : /* F3m */
    2612             : 
    2613             : INLINE ulong
    2614     3240628 : 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      458607 : 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     6591387 : sqrti(GEN x) { return sqrtremi(x,NULL); }
    2628             : INLINE GEN
    2629   123138367 : gaddgs(GEN y, long s) { return gaddsg(s,y); }
    2630             : INLINE int
    2631      780379 : 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    22347687 : gmulgs(GEN y, long s) { return gmulsg(s,y); }
    2640             : INLINE GEN
    2641   124174659 : gmulgu(GEN y, ulong s) { return gmulug(s,y); }
    2642             : INLINE GEN
    2643     1692556 : gsubgs(GEN y, long s) { return gaddgs(y, -s); }
    2644             : INLINE GEN
    2645      528371 : gdivsg(long s, GEN y) { return gdiv(stoi(s), y); }
    2646             : 
    2647             : INLINE GEN
    2648    13509971 : gmax_shallow(GEN x, GEN y) { return gcmp(x,y)<0? y: x; }
    2649             : INLINE GEN
    2650      876179 : gmin_shallow(GEN x, GEN y) { return gcmp(x,y)<0? x: y; }
    2651             : 
    2652             : /* x t_COMPLEX */
    2653             : INLINE GEN
    2654    90802305 : 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     4850203 : qfb_disc3(GEN x, GEN y, GEN z) { return subii(sqri(y), shifti(mulii(x,z),2)); }
    2682             : INLINE GEN
    2683    18474970 : qfb_disc(GEN x) { return gel(x,4); }
    2684             : 
    2685             : INLINE GEN
    2686     4135849 : sqrfrac(GEN x)
    2687             : {
    2688     4135849 :   GEN z = cgetg(3,t_FRAC);
    2689     4135847 :   gel(z,1) = sqri(gel(x,1));
    2690     4135824 :   gel(z,2) = sqri(gel(x,2)); return z;
    2691             : }
    2692             : 
    2693             : INLINE void
    2694    16754122 : normalize_frac(GEN z) {
    2695    16754122 :   if (signe(gel(z,2)) < 0) { togglesign(gel(z,1)); setabssign(gel(z,2)); }
    2696    16754122 : }
    2697             : 
    2698             : INLINE GEN
    2699    42913879 : powii(GEN x, GEN n)
    2700             : {
    2701    42913879 :   long ln = lgefint(n);
    2702    42913879 :   if (ln == 3) {
    2703             :     GEN z;
    2704    42890931 :     if (signe(n) > 0) return powiu(x, n[2]);
    2705       74810 :     z = cgetg(3, t_FRAC);
    2706       74825 :     gel(z,1) = gen_1;
    2707       74825 :     gel(z,2) = powiu(x, n[2]);
    2708       74823 :     return z;
    2709             :   }
    2710       22948 :   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     7116195 : INLINE GEN ell_get_a1(GEN e) { return gel(e,1); }
    2765     5709699 : INLINE GEN ell_get_a2(GEN e) { return gel(e,2); }
    2766     6912842 : INLINE GEN ell_get_a3(GEN e) { return gel(e,3); }
    2767     6522700 : INLINE GEN ell_get_a4(GEN e) { return gel(e,4); }
    2768     7961473 : INLINE GEN ell_get_a6(GEN e) { return gel(e,5); }
    2769     5432782 : 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     8021727 : INLINE GEN ell_get_c4(GEN e) { return gel(e,10); }
    2774     8850368 : INLINE GEN ell_get_c6(GEN e) { return gel(e,11); }
    2775    11279870 : 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    11588371 : INLINE long ell_get_type(GEN e) { return mael(e,14,1); }
    2778     2036736 : INLINE GEN ellff_get_field(GEN x) { return gmael(x, 15, 1); }
    2779      800034 : 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     2027603 : 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     4677488 : INLINE int checkell_i(GEN e) { return typ(e) == t_VEC && lg(e) == 17; }
    2789    51365180 : INLINE int ell_is_inf(GEN z) { return lg(z) == 2; }
    2790     1875768 : INLINE GEN ellinf(void) { return mkvec(gen_0); }
    2791             : 
    2792             : /*******************************************************************/
    2793             : /*                                                                 */
    2794             : /*                    ALGEBRAIC NUMBER THEORY                      */
    2795             : /*                                                                 */
    2796             : /*******************************************************************/
    2797    30054958 : 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    13188190 : INLINE GEN modpr_get_T(GEN x)  { return lg(x) == 4? NULL: gel(x,4); }
    2800             : 
    2801    89397417 : INLINE GEN pr_get_p(GEN pr)  { return gel(pr,1); }
    2802    11517886 : 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    15726675 : INLINE long pr_get_e(GEN pr) { return gel(pr,3)[2]; }
    2805    25357162 : INLINE long pr_get_f(GEN pr) { return gel(pr,4)[2]; }
    2806    47864250 : INLINE GEN pr_get_tau(GEN pr){ return gel(pr,5); }
    2807             : INLINE int
    2808    16405300 : pr_is_inert(GEN P) { return typ(pr_get_tau(P)) == t_INT; }
    2809             : INLINE GEN
    2810     1067670 : pr_norm(GEN pr) { return powiu(pr_get_p(pr), pr_get_f(pr)); }
    2811             : INLINE ulong
    2812      343931 : 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     1167403 : nf_get_varn(GEN nf) { return varn(gel(nf,1)); }
    2817             : INLINE GEN
    2818    94477544 : nf_get_pol(GEN nf) { return gel(nf,1); }
    2819             : INLINE long
    2820    68840272 : nf_get_degree(GEN nf) { return degpol( nf_get_pol(nf) ); }
    2821             : INLINE long
    2822    22172435 : 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      457800 : nf_get_disc(GEN nf) { return gel(nf,3); }
    2827             : INLINE GEN
    2828     3582805 : nf_get_index(GEN nf) { return gel(nf,4); }
    2829             : INLINE GEN
    2830    20779157 : nf_get_M(GEN nf) { return gmael(nf,5,1); }
    2831             : INLINE GEN
    2832      301779 : nf_get_G(GEN nf) { return gmael(nf,5,2); }
    2833             : INLINE GEN
    2834     1686960 : nf_get_roundG(GEN nf) { return gmael(nf,5,3); }
    2835             : INLINE GEN
    2836       22082 : 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     1532505 : 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     5025881 : nf_get_zkprimpart(GEN nf)
    2853             : {
    2854     5025881 :   GEN y = gel(nf,7);
    2855             :   /* test for old format of nf.zk: non normalized */
    2856     5025881 :   if (!equali1(gel(nf,4)) && gequal1(gel(y,1))) y = Q_remove_denom(y,NULL);
    2857     5025870 :   return y;
    2858             : }
    2859             : INLINE GEN
    2860     5071750 : nf_get_zkden(GEN nf)
    2861             : {
    2862     5071750 :   GEN y = gel(nf,7), D = gel(y,1);
    2863     5071750 :   if (typ(D) == t_POL) D = gel(D,2);
    2864             :   /* test for old format of nf.zk: non normalized */
    2865     5071750 :   if (!equali1(gel(nf,4)) && equali1(D)) D = Q_denom(y);
    2866     5071741 :   return D;
    2867             : }
    2868             : INLINE GEN
    2869     9493081 : nf_get_invzk(GEN nf) { return gel(nf,8); }
    2870             : INLINE void
    2871      516870 : nf_get_sign(GEN nf, long *r1, long *r2)
    2872             : {
    2873      516870 :   GEN x = gel(nf,2);
    2874      516870 :   *r1 = itou(gel(x,1));
    2875      516870 :   *r2 = itou(gel(x,2));
    2876      516870 : }
    2877             : 
    2878             : INLINE GEN
    2879     2521972 : cyc_get_expo(GEN c) { return lg(c) == 1? gen_1: gel(c,1); }
    2880             : INLINE GEN
    2881      392012 : abgrp_get_no(GEN x) { return gel(x,1); }
    2882             : INLINE GEN
    2883    11550141 : abgrp_get_cyc(GEN x) { return gel(x,2); }
    2884             : INLINE GEN
    2885     1653906 : abgrp_get_gen(GEN x) { return gel(x,3); }
    2886             : INLINE GEN
    2887     9426929 : bnf_get_nf(GEN bnf) { return gel(bnf,7); }
    2888             : INLINE GEN
    2889     5098134 : 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     3509475 : bnf_get_cyc(GEN bnf) { return abgrp_get_cyc(bnf_get_clgp(bnf)); }
    2894             : INLINE GEN
    2895     1580120 : 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     2702370 : bnf_get_logfu(GEN bnf) { return gel(bnf,3); }
    2900             : INLINE GEN
    2901     1278530 : bnf_get_sunits(GEN bnf)
    2902     1278530 : { GEN s = gmael(bnf,8,3); return typ(s) == t_INT? NULL: s; }
    2903             : INLINE GEN
    2904      290540 : bnf_get_tuU(GEN bnf) { return gmael3(bnf,8,4,2); }
    2905             : INLINE long
    2906      265199 : bnf_get_tuN(GEN bnf) { return gmael3(bnf,8,4,1)[2]; }
    2907             : INLINE GEN
    2908      288195 : 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     3632609 : bnr_get_bnf(GEN bnr) { return gel(bnr,1); }
    2921             : INLINE GEN
    2922     1937120 : bnr_get_bid(GEN bnr) { return gel(bnr,2); }
    2923             : INLINE GEN
    2924      141127 : bnr_get_mod(GEN bnr) { return gmael(bnr,2,1); }
    2925             : INLINE GEN
    2926     1260192 : bnr_get_nf(GEN bnr) { return gmael(bnr,1,7); }
    2927             : INLINE GEN
    2928     2728937 : bnr_get_clgp(GEN bnr) { return gel(bnr,5); }
    2929             : INLINE GEN
    2930      314614 : bnr_get_no(GEN bnr) { return abgrp_get_no(bnr_get_clgp(bnr)); }
    2931             : INLINE GEN
    2932     2396704 : 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     1386618 : 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       35098 : bid_get_arch(GEN bid) { return gmael(bid,1,2); }
    3052             : INLINE GEN
    3053     5415792 : bid_get_grp(GEN bid) { return gel(bid,2); }
    3054             : INLINE GEN
    3055     2314077 : bid_get_fact(GEN bid) { return gmael(bid,3,1); }
    3056             : INLINE GEN
    3057     2025387 : bid_get_fact2(GEN bid) { return gmael(bid,3,2); }
    3058             : INLINE GEN
    3059     1990848 : bid_get_MOD(GEN bid) { GEN y = gel(bid,4); return lg(y) == 4? gel(y,3): NULL; }
    3060             : INLINE GEN
    3061     1991579 : 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     2217875 : bid_get_archp(GEN bid) { return gmael3(bid,4,2,2); }
    3066             : INLINE GEN
    3067     3378524 : 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     5361884 : 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       53326 : bid_get_gen(GEN bid) {
    3076       53326 :   GEN G = bid_get_grp(bid);
    3077       53326 :   if (lg(G) != 4) pari_err(e_MISC,"missing bid generators. Use idealstar(,,2)");
    3078       53326 :   return abgrp_get_gen(G);
    3079             : }
    3080             : 
    3081             : INLINE GEN
    3082    34543777 : znstar_get_N(GEN G) { return gmael(G,1,1); }
    3083             : INLINE GEN
    3084     7210394 : 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     7823726 : 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       36154 : 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       32570 : gal_get_roots(GEN gal) { return gel(gal,3); }
    3111             : INLINE GEN
    3112       27677 : 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       80190 : 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     2507249 : 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     1393227 : 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      734423 : 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      315053 : rnf_get_polabs(GEN rnf) { return gmael(rnf,11,1); }
    3141             : INLINE GEN
    3142     2846441 : 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      255696 : 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      135229 : 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      138615 : idealred(GEN nf, GEN id) { return idealred0(nf, id, NULL); }
    3164             : 
    3165             : INLINE GEN
    3166        5455 : idealchineseinit(GEN nf, GEN x)
    3167        5455 : { return idealchinese(nf,x,NULL); }
    3168             : 
    3169             : /*******************************************************************/
    3170             : /*                                                                 */
    3171             : /*                              CLOSURES                           */
    3172             : /*                                                                 */
    3173             : /*******************************************************************/
    3174   361260405 : INLINE long closure_arity(GEN C)          { return ((ulong)C[1])&ARITYBITS; }
    3175    40099519 : INLINE long closure_is_variadic(GEN C) { return !!(((ulong)C[1])&VARARGBITS); }
    3176   312515453 : 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   312499728 : INLINE GEN closure_get_oper(GEN C)  { return gel(C,3); }
    3179   312481274 : INLINE GEN closure_get_data(GEN C)  { return gel(C,4); }
    3180       13502 : INLINE GEN closure_get_dbg(GEN C)   { return gel(C,5); }
    3181       36806 : INLINE GEN closure_get_text(GEN C)  { return gel(C,6); }
    3182    13054133 : INLINE GEN closure_get_frame(GEN C) { return gel(C,7); }
    3183             : 
    3184             : /*******************************************************************/
    3185             : /*                                                                 */
    3186             : /*                               ERRORS                            */
    3187             : /*                                                                 */
    3188             : /*******************************************************************/
    3189             : INLINE long
    3190       62291 : 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        2764 : 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