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.16.1 lcov report (development 28403-bea3a26501) Lines: 1436 1576 91.1 %
Date: 2023-03-30 07:42:39 Functions: 643 712 90.3 %
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 retmkqfb(x,y,z,d)\
      80             :   do { GEN _v = cgetg(5, t_QFB);\
      81             :        gel(_v,1) = (x);\
      82             :        gel(_v,2) = (y);\
      83             :        gel(_v,3) = (z);\
      84             :        gel(_v,4) = (d); return _v; } while(0)
      85             : #define retmkquad(x,y,z)\
      86             :   do { GEN _v = cgetg(4, t_QUAD);\
      87             :        gel(_v,1) = (x);\
      88             :        gel(_v,2) = (y);\
      89             :        gel(_v,3) = (z); return _v; } while(0)
      90             : #define retmkvec4(x,y,z,t)\
      91             :   do { GEN _v = cgetg(5, t_VEC);\
      92             :        gel(_v,1) = (x);\
      93             :        gel(_v,2) = (y);\
      94             :        gel(_v,3) = (z);\
      95             :        gel(_v,4) = (t); return _v; } while(0)
      96             : #define retmkvec5(x,y,z,t,u)\
      97             :   do { GEN _v = cgetg(6, t_VEC);\
      98             :        gel(_v,1) = (x);\
      99             :        gel(_v,2) = (y);\
     100             :        gel(_v,3) = (z);\
     101             :        gel(_v,4) = (t);\
     102             :        gel(_v,5) = (u); return _v; } while(0)
     103             : #define retmkcol(x)\
     104             :   do { GEN _v = cgetg(2, t_COL);\
     105             :        gel(_v,1) = (x); return _v; } while(0)
     106             : #define retmkcol2(x,y)\
     107             :   do { GEN _v = cgetg(3, t_COL);\
     108             :        gel(_v,1) = (x);\
     109             :        gel(_v,2) = (y); return _v; } while(0)
     110             : #define retmkcol3(x,y,z)\
     111             :   do { GEN _v = cgetg(4, t_COL);\
     112             :        gel(_v,1) = (x);\
     113             :        gel(_v,2) = (y);\
     114             :        gel(_v,3) = (z); return _v; } while(0)
     115             : #define retmkcol4(x,y,z,t)\
     116             :   do { GEN _v = cgetg(5, t_COL);\
     117             :        gel(_v,1) = (x);\
     118             :        gel(_v,2) = (y);\
     119             :        gel(_v,3) = (z);\
     120             :        gel(_v,4) = (t); return _v; } while(0)
     121             : #define retmkcol5(x,y,z,t,u)\
     122             :   do { GEN _v = cgetg(6, t_COL);\
     123             :        gel(_v,1) = (x);\
     124             :        gel(_v,2) = (y);\
     125             :        gel(_v,3) = (z);\
     126             :        gel(_v,4) = (t);\
     127             :        gel(_v,5) = (u); return _v; } while(0)
     128             : #define retmkcol6(x,y,z,t,u,v)\
     129             :   do { GEN _v = cgetg(7, t_COL);\
     130             :        gel(_v,1) = (x);\
     131             :        gel(_v,2) = (y);\
     132             :        gel(_v,3) = (z);\
     133             :        gel(_v,4) = (t);\
     134             :        gel(_v,5) = (u);\
     135             :        gel(_v,6) = (v); return _v; } while(0)
     136             : #define retmkmat(x)\
     137             :   do { GEN _v = cgetg(2, t_MAT);\
     138             :        gel(_v,1) = (x); return _v; } while(0)
     139             : #define retmkmat2(x,y)\
     140             :   do { GEN _v = cgetg(3, t_MAT);\
     141             :        gel(_v,1) = (x);\
     142             :        gel(_v,2) = (y); return _v; } while(0)
     143             : #define retmkmat3(x,y,z)\
     144             :   do { GEN _v = cgetg(4, t_MAT);\
     145             :        gel(_v,1) = (x);\
     146             :        gel(_v,2) = (y);\
     147             :        gel(_v,3) = (z); return _v; } while(0)
     148             : #define retmkmat4(x,y,z,t)\
     149             :   do { GEN _v = cgetg(5, t_MAT);\
     150             :        gel(_v,1) = (x);\
     151             :        gel(_v,2) = (y);\
     152             :        gel(_v,3) = (z);\
     153             :        gel(_v,4) = (t); return _v; } while(0)
     154             : #define retmkmat5(x,y,z,t,u)\
     155             :   do { GEN _v = cgetg(6, t_MAT);\
     156             :        gel(_v,1) = (x);\
     157             :        gel(_v,2) = (y);\
     158             :        gel(_v,3) = (z);\
     159             :        gel(_v,4) = (t);\
     160             :        gel(_v,5) = (u); return _v; } while(0)
     161             : 
     162             : INLINE GEN
     163     6838012 : mkintmod(GEN x, GEN y) { retmkintmod(x,y); }
     164             : INLINE GEN
     165        1813 : mkintmodu(ulong x, ulong y) {
     166        1813 :   GEN v = cgetg(3,t_INTMOD);
     167        1813 :   gel(v,1) = utoipos(y);
     168        1813 :   gel(v,2) = utoi(x); return v;
     169             : }
     170             : INLINE GEN
     171     2591049 : mkpolmod(GEN x, GEN y) { retmkpolmod(x,y); }
     172             : INLINE GEN
     173    30807951 : mkfrac(GEN x, GEN y) { retmkfrac(x,y); }
     174             : INLINE GEN
     175     1205620 : mkfracss(long x, long y) { retmkfrac(stoi(x),utoipos(y)); }
     176             : /* q = n/d a t_FRAC or t_INT; recover (n,d) */
     177             : INLINE void
     178       18501 : Qtoss(GEN q, long *n, long *d)
     179             : {
     180       18501 :   if (typ(q) == t_INT) { *n = itos(q); *d = 1; }
     181        5691 :   else { *n = itos(gel(q,1)); *d = itou(gel(q,2)); }
     182       18501 : }
     183             : INLINE GEN
     184      769706 : sstoQ(long n, long d)
     185             : {
     186             :   ulong r;
     187             :   long g, q;
     188      769706 :   if (!n)
     189             :   {
     190       92281 :     if (!d) pari_err_INV("sstoQ",gen_0);
     191       92281 :     return gen_0;
     192             :   }
     193      677425 :   if (d < 0) { d = -d; n = -n; }
     194      677425 :   if (d == 1) return stoi(n);
     195      664426 :   r = labs(n);
     196      664426 :   if (r == 1) retmkfrac(n > 0? gen_1: gen_m1, utoipos(d));
     197      630357 :   q = udivuu_rem(r, d, &r);
     198      630357 :   if (!r) return n > 0? utoipos(q): utoineg(q);
     199      575652 :   g = ugcd(d,r); /* gcd(n,d) */
     200      575652 :   if (g != 1) { n /= g; d /= g; }
     201      575652 :   retmkfrac(stoi(n), utoipos(d));
     202             : }
     203             : 
     204             : INLINE GEN
     205   157849961 : uutoQ(ulong n, ulong d)
     206             : {
     207             :   ulong r;
     208             :   long g, q;
     209   157849961 :   if (!n)
     210             :   {
     211        9438 :     if (!d) pari_err_INV("uutoQ",gen_0);
     212        9438 :     return gen_0;
     213             :   }
     214   157840523 :   if (d == 1) return utoipos(n);
     215   157829428 :   if (n == 1) retmkfrac(gen_1, utoipos(d));
     216   157742131 :   q = udivuu_rem(n,d,&r);
     217   157742131 :   if (!r) return utoipos(q);
     218     5116511 :   g = ugcd(d,r); /* gcd(n,d) */
     219     5116511 :   if (g != 1) { n /= g; d /= g; }
     220     5116511 :   retmkfrac(utoipos(n), utoipos(d));
     221             : }
     222             : 
     223             : INLINE GEN
     224     3832135 : mkfraccopy(GEN x, GEN y) { retmkfrac(icopy(x), icopy(y)); }
     225             : INLINE GEN
     226      697571 : mkrfrac(GEN x, GEN y) { GEN v = cgetg(3, t_RFRAC);
     227      697571 :   gel(v,1) = x; gel(v,2) = y; return v; }
     228             : INLINE GEN
     229           7 : mkrfraccopy(GEN x, GEN y) { GEN v = cgetg(3, t_RFRAC);
     230           7 :   gel(v,1) = gcopy(x); gel(v,2) = gcopy(y); return v; }
     231             : INLINE GEN
     232    75871256 : mkcomplex(GEN x, GEN y) { retmkcomplex(x,y); }
     233             : INLINE GEN
     234      832781 : gen_I(void) { return mkcomplex(gen_0, gen_1); }
     235             : INLINE GEN
     236      744005 : cgetc(long l) { retmkcomplex(cgetr(l), cgetr(l)); }
     237             : INLINE GEN
     238       69132 : mkquad(GEN n, GEN x, GEN y) { GEN v = cgetg(4, t_QUAD);
     239       69132 :   gel(v,1) = n; gel(v,2) = x; gel(v,3) = y; return v; }
     240             : /* vecsmall */
     241             : INLINE GEN
     242   122725240 : mkvecsmall(long x) { GEN v = cgetg(2, t_VECSMALL); v[1] = x; return v; }
     243             : INLINE GEN
     244   196903744 : mkvecsmall2(long x,long y) { GEN v = cgetg(3, t_VECSMALL);
     245   196880856 :   v[1]=x; v[2]=y; return v; }
     246             : INLINE GEN
     247    91740497 : mkvecsmall3(long x,long y,long z) { GEN v = cgetg(4, t_VECSMALL);
     248    91729543 :   v[1]=x; v[2]=y; v[3]=z; return v; }
     249             : INLINE GEN
     250    14598125 : mkvecsmall4(long x,long y,long z,long t) { GEN v = cgetg(5, t_VECSMALL);
     251    14584817 :   v[1]=x; v[2]=y; v[3]=z; v[4]=t; return v; }
     252             : INLINE GEN
     253      621803 : mkvecsmall5(long x,long y,long z,long t,long u) { GEN v = cgetg(6, t_VECSMALL);
     254      621803 :   v[1]=x; v[2]=y; v[3]=z; v[4]=t; v[5]=u; return v; }
     255             : 
     256             : INLINE GEN
     257    16870576 : mkqfb(GEN x, GEN y, GEN z, GEN d) { retmkqfb(x,y,z,d); }
     258             : /* vec */
     259             : INLINE GEN
     260    60848820 : mkvec(GEN x) { retmkvec(x); }
     261             : INLINE GEN
     262   151722926 : mkvec2(GEN x, GEN y) { retmkvec2(x,y); }
     263             : INLINE GEN
     264    96111779 : mkvec3(GEN x, GEN y, GEN z) { retmkvec3(x,y,z); }
     265             : INLINE GEN
     266     5963268 : mkvec4(GEN x, GEN y, GEN z, GEN t) { retmkvec4(x,y,z,t); }
     267             : INLINE GEN
     268    15621019 : mkvec5(GEN x, GEN y, GEN z, GEN t, GEN u) { retmkvec5(x,y,z,t,u); }
     269             : INLINE GEN
     270         154 : mkvecs(long x) { retmkvec(stoi(x)); }
     271             : INLINE GEN
     272      213181 : mkvec2s(long x, long y) { retmkvec2(stoi(x),stoi(y)); }
     273             : INLINE GEN
     274      488650 : mkvec3s(long x, long y, long z) { retmkvec3(stoi(x),stoi(y),stoi(z)); }
     275             : INLINE GEN
     276          21 : mkvec4s(long x, long y, long z, long t) { retmkvec4(stoi(x),stoi(y),stoi(z),stoi(t)); }
     277             : INLINE GEN
     278       35896 : mkveccopy(GEN x) { GEN v = cgetg(2, t_VEC); gel(v,1) = gcopy(x); return v; }
     279             : INLINE GEN
     280      122272 : mkvec2copy(GEN x, GEN y) {
     281      122272 :   GEN v = cgetg(3,t_VEC); gel(v,1) = gcopy(x); gel(v,2) = gcopy(y); return v; }
     282             : /* col */
     283             : INLINE GEN
     284     8811661 : mkcol(GEN x) { retmkcol(x); }
     285             : INLINE GEN
     286    69756479 : mkcol2(GEN x, GEN y) { retmkcol2(x,y); }
     287             : INLINE GEN
     288       86407 : mkcol3(GEN x, GEN y, GEN z) { retmkcol3(x,y,z); }
     289             : INLINE GEN
     290      102935 : mkcol4(GEN x, GEN y, GEN z, GEN t) { retmkcol4(x,y,z,t); }
     291             : INLINE GEN
     292         100 : mkcol5(GEN x, GEN y, GEN z, GEN t, GEN u) { retmkcol5(x,y,z,t,u); }
     293             : INLINE GEN
     294       12586 : mkcol6(GEN x, GEN y, GEN z, GEN t, GEN u, GEN v) { retmkcol6(x,y,z,t,u,v); }
     295             : INLINE GEN
     296       40411 : mkcols(long x) { retmkcol(stoi(x)); }
     297             : INLINE GEN
     298     2761682 : mkcol2s(long x, long y) { retmkcol2(stoi(x),stoi(y)); }
     299             : INLINE GEN
     300         301 : mkcol3s(long x, long y, long z) { retmkcol3(stoi(x),stoi(y),stoi(z)); }
     301             : INLINE GEN
     302           0 : mkcol4s(long x, long y, long z, long t) { retmkcol4(stoi(x),stoi(y),stoi(z),stoi(t)); }
     303             : INLINE GEN
     304       29173 : mkcolcopy(GEN x) { GEN v = cgetg(2, t_COL); gel(v,1) = gcopy(x); return v; }
     305             : /* mat */
     306             : INLINE GEN
     307     4391110 : mkmat(GEN x) { retmkmat(x); }
     308             : INLINE GEN
     309    38974976 : mkmat2(GEN x, GEN y) { retmkmat2(x,y); }
     310             : INLINE GEN
     311       16772 : mkmat3(GEN x, GEN y, GEN z) { retmkmat3(x,y,z); }
     312             : INLINE GEN
     313           0 : mkmat4(GEN x, GEN y, GEN z, GEN t) { retmkmat4(x,y,z,t); }
     314             : INLINE GEN
     315           0 : mkmat5(GEN x, GEN y, GEN z, GEN t, GEN u) { retmkmat5(x,y,z,t,u); }
     316             : INLINE GEN
     317      117732 : mkmatcopy(GEN x) { GEN v = cgetg(2, t_MAT); gel(v,1) = gcopy(x); return v; }
     318             : INLINE GEN
     319           0 : mkerr(long x) { GEN v = cgetg(2, t_ERROR); v[1] = x; return v; }
     320             : INLINE GEN
     321      200018 : mkoo(void) { GEN v = cgetg(2, t_INFINITY); gel(v,1) = gen_1; return v; }
     322             : INLINE GEN
     323      103116 : mkmoo(void) { GEN v = cgetg(2, t_INFINITY); gel(v,1) = gen_m1; return v; }
     324             : INLINE long
     325      315325 : inf_get_sign(GEN x) { return signe(gel(x,1)); }
     326             : INLINE GEN
     327       12495 : mkmat22s(long a, long b, long c, long d) {retmkmat2(mkcol2s(a,c),mkcol2s(b,d));}
     328             : INLINE GEN
     329    10526350 : mkmat22(GEN a, GEN b, GEN c, GEN d) { retmkmat2(mkcol2(a,c),mkcol2(b,d)); }
     330             : 
     331             : /* pol */
     332             : INLINE GEN
     333     2498241 : pol_x(long v) {
     334     2498241 :   GEN p = cgetg(4, t_POL);
     335     2498262 :   p[1] = evalsigne(1)|evalvarn(v);
     336     2498262 :   gel(p,2) = gen_0;
     337     2498262 :   gel(p,3) = gen_1; return p;
     338             : }
     339             : /* x^n, assume n >= 0 */
     340             : INLINE GEN
     341     2153900 : pol_xn(long n, long v) {
     342     2153900 :   long i, a = n+2;
     343     2153900 :   GEN p = cgetg(a+1, t_POL);
     344     2153901 :   p[1] = evalsigne(1)|evalvarn(v);
     345     5009108 :   for (i = 2; i < a; i++) gel(p,i) = gen_0;
     346     2153901 :   gel(p,a) = gen_1; return p;
     347             : }
     348             : /* x^n, no assumption on n */
     349             : INLINE GEN
     350         294 : pol_xnall(long n, long v)
     351             : {
     352         294 :   if (n < 0) retmkrfrac(gen_1, pol_xn(-n,v));
     353         287 :   return pol_xn(n, v);
     354             : }
     355             : /* x^n, assume n >= 0 */
     356             : INLINE GEN
     357         371 : polxn_Flx(long n, long sv) {
     358         371 :   long i, a = n+2;
     359         371 :   GEN p = cgetg(a+1, t_VECSMALL);
     360         371 :   p[1] = sv;
     361        1806 :   for (i = 2; i < a; i++) p[i] = 0;
     362         371 :   p[a] = 1; return p;
     363             : }
     364             : INLINE GEN
     365     4298087 : pol_1(long v) {
     366     4298087 :   GEN p = cgetg(3, t_POL);
     367     4298067 :   p[1] = evalsigne(1)|evalvarn(v);
     368     4298067 :   gel(p,2) = gen_1; return p;
     369             : }
     370             : INLINE GEN
     371    34512378 : pol_0(long v)
     372             : {
     373    34512378 :   GEN x = cgetg(2,t_POL);
     374    34512362 :   x[1] = evalvarn(v); return x;
     375             : }
     376             : #define retconst_vec(n,x)\
     377             :   do { long _i, _n = (n);\
     378             :        GEN _v = cgetg(_n+1, t_VEC), _x = (x);\
     379             :        for (_i = 1; _i <= _n; _i++) gel(_v,_i) = _x;\
     380             :        return _v; } while(0)
     381             : INLINE GEN
     382   218139728 : const_vec(long n, GEN x) { retconst_vec(n, x); }
     383             : #define retconst_col(n,x)\
     384             :   do { long _i, _n = (n);\
     385             :        GEN _v = cgetg(_n+1, t_COL), _x = (x);\
     386             :        for (_i = 1; _i <= _n; _i++) gel(_v,_i) = _x;\
     387             :        return _v; } while(0)
     388             : INLINE GEN
     389    37143459 : const_col(long n, GEN x) { retconst_col(n, x); }
     390             : INLINE GEN
     391    17403094 : const_vecsmall(long n, long c)
     392             : {
     393             :   long i;
     394    17403094 :   GEN V = cgetg(n+1,t_VECSMALL);
     395   629395595 :   for(i=1;i<=n;i++) V[i] = c;
     396    17403442 :   return V;
     397             : }
     398             : 
     399             : /***   ZERO   ***/
     400             : /* O(p^e) */
     401             : INLINE GEN
     402      850419 : zeropadic(GEN p, long e)
     403             : {
     404      850419 :   GEN y = cgetg(5,t_PADIC);
     405      850382 :   gel(y,4) = gen_0;
     406      850382 :   gel(y,3) = gen_1;
     407      850382 :   gel(y,2) = icopy(p);
     408      850365 :   y[1] = evalvalp(e) | _evalprecp(0);
     409      850343 :   return y;
     410             : }
     411             : INLINE GEN
     412       10219 : zeropadic_shallow(GEN p, long e)
     413             : {
     414       10219 :   GEN y = cgetg(5,t_PADIC);
     415       10219 :   gel(y,4) = gen_0;
     416       10219 :   gel(y,3) = gen_1;
     417       10219 :   gel(y,2) = p;
     418       10219 :   y[1] = evalvalp(e) | _evalprecp(0);
     419       10219 :   return y;
     420             : }
     421             : /* O(pol_x(v)^e) */
     422             : INLINE GEN
     423      136346 : zeroser(long v, long e)
     424             : {
     425      136346 :   GEN x = cgetg(2, t_SER);
     426      136346 :   x[1] = evalvalser(e) | evalvarn(v); return x;
     427             : }
     428             : INLINE int
     429     9971266 : ser_isexactzero(GEN x)
     430             : {
     431     9971266 :   if (!signe(x)) switch(lg(x))
     432             :   {
     433      131180 :     case 2: return 1;
     434        3899 :     case 3: return isexactzero(gel(x,2));
     435             :   }
     436     9836187 :   return 0;
     437             : }
     438             : /* 0 * pol_x(v) */
     439             : INLINE GEN
     440    14657034 : zeropol(long v) { return pol_0(v); }
     441             : /* vector(n) */
     442             : INLINE GEN
     443    75337438 : zerocol(long n)
     444             : {
     445    75337438 :   GEN y = cgetg(n+1,t_COL);
     446   541018579 :   long i; for (i=1; i<=n; i++) gel(y,i) = gen_0;
     447    75337779 :   return y;
     448             : }
     449             : /* vectorv(n) */
     450             : INLINE GEN
     451    24693988 : zerovec(long n)
     452             : {
     453    24693988 :   GEN y = cgetg(n+1,t_VEC);
     454   336774071 :   long i; for (i=1; i<=n; i++) gel(y,i) = gen_0;
     455    24693974 :   return y;
     456             : }
     457             : /* matrix(m, n) */
     458             : INLINE GEN
     459       91949 : zeromat(long m, long n)
     460             : {
     461       91949 :   GEN y = cgetg(n+1,t_MAT);
     462       91947 :   GEN v = zerocol(m);
     463      297977 :   long i; for (i=1; i<=n; i++) gel(y,i) = v;
     464       91953 :   return y;
     465             : }
     466             : /* = zero_zx, sv is a evalvarn()*/
     467             : INLINE GEN
     468     1329838 : zero_Flx(long sv) { return pol0_Flx(sv); }
     469             : INLINE GEN
     470    54580806 : zero_Flv(long n)
     471             : {
     472    54580806 :   GEN y = cgetg(n+1,t_VECSMALL);
     473  1063633469 :   long i; for (i=1; i<=n; i++) y[i] = 0;
     474    54581381 :   return y;
     475             : }
     476             : /* matrix(m, n) */
     477             : INLINE GEN
     478     2048566 : zero_Flm(long m, long n)
     479             : {
     480     2048566 :   GEN y = cgetg(n+1,t_MAT);
     481     2048546 :   GEN v = zero_Flv(m);
     482    13256881 :   long i; for (i=1; i<=n; i++) gel(y,i) = v;
     483     2048566 :   return y;
     484             : }
     485             : /* matrix(m, n) */
     486             : INLINE GEN
     487      222480 : zero_Flm_copy(long m, long n)
     488             : {
     489      222480 :   GEN y = cgetg(n+1,t_MAT);
     490     2278871 :   long i; for (i=1; i<=n; i++) gel(y,i) = zero_Flv(m);
     491      222478 :   return y;
     492             : }
     493             : 
     494             : INLINE GEN
     495     3463932 : zero_F2v(long m)
     496             : {
     497     3463932 :   long l = nbits2nlong(m);
     498     3463917 :   GEN v  = zero_Flv(l+1);
     499     3463903 :   v[1] = m;
     500     3463903 :   return v;
     501             : }
     502             : 
     503             : INLINE GEN
     504           0 : zero_F2m(long m, long n)
     505             : {
     506             :   long i;
     507           0 :   GEN M = cgetg(n+1, t_MAT);
     508           0 :   GEN v = zero_F2v(m);
     509           0 :   for (i = 1; i <= n; i++)
     510           0 :     gel(M,i) = v;
     511           0 :   return M;
     512             : }
     513             : 
     514             : 
     515             : INLINE GEN
     516      835464 : zero_F2m_copy(long m, long n)
     517             : {
     518             :   long i;
     519      835464 :   GEN M = cgetg(n+1, t_MAT);
     520     1979736 :   for (i = 1; i <= n; i++)
     521     1144269 :     gel(M,i)= zero_F2v(m);
     522      835467 :   return M;
     523             : }
     524             : 
     525             : /* matrix(m, n) */
     526             : INLINE GEN
     527     6196389 : zeromatcopy(long m, long n)
     528             : {
     529     6196389 :   GEN y = cgetg(n+1,t_MAT);
     530    28916565 :   long i; for (i=1; i<=n; i++) gel(y,i) = zerocol(m);
     531     6196406 :   return y;
     532             : }
     533             : 
     534             : INLINE GEN
     535       18256 : zerovec_block(long len)
     536             : {
     537             :   long i;
     538       18256 :   GEN blk = cgetg_block(len + 1, t_VEC);
     539      602448 :   for (i = 1; i <= len; ++i)
     540      584192 :     gel(blk, i) = gen_0;
     541       18256 :   return blk;
     542             : }
     543             : 
     544             : /* i-th vector in the standard basis */
     545             : INLINE GEN
     546     5030583 : col_ei(long n, long i) { GEN e = zerocol(n); gel(e,i) = gen_1; return e; }
     547             : INLINE GEN
     548     1691391 : vec_ei(long n, long i) { GEN e = zerovec(n); gel(e,i) = gen_1; return e; }
     549             : INLINE GEN
     550          42 : F2v_ei(long n, long i) { GEN e = zero_F2v(n); F2v_set(e,i); return e; }
     551             : INLINE GEN
     552       49369 : vecsmall_ei(long n, long i) { GEN e = zero_zv(n); e[i] = 1; return e; }
     553             : INLINE GEN
     554     1182398 : Rg_col_ei(GEN x, long n, long i) { GEN e = zerocol(n); gel(e,i) = x; return e; }
     555             : 
     556             : INLINE GEN
     557    19192856 : shallowcopy(GEN x)
     558    19192856 : { return typ(x) == t_MAT ? RgM_shallowcopy(x): leafcopy(x); }
     559             : 
     560             : /* routines for naive growarrays */
     561             : INLINE GEN
     562    11118869 : vectrunc_init(long l)
     563             : {
     564    11118869 :   GEN z = new_chunk(l);
     565    11118786 :   z[0] = evaltyp(t_VEC) | _evallg(1); return z;
     566             : }
     567             : INLINE GEN
     568      348914 : coltrunc_init(long l)
     569             : {
     570      348914 :   GEN z = new_chunk(l);
     571      348914 :   z[0] = evaltyp(t_COL) | _evallg(1); return z;
     572             : }
     573             : INLINE void
     574   291332988 : lg_increase(GEN x) { x[0]++; }
     575             : INLINE void
     576    13880640 : vectrunc_append(GEN x, GEN t) { gel(x, lg(x)) = t; lg_increase(x); }
     577             : INLINE void
     578       10864 : vectrunc_append_batch(GEN x, GEN y)
     579             : {
     580       10864 :   long i, l = lg(x), ly = lg(y);
     581       10864 :   GEN z = x + l-1;
     582       36358 :   for (i = 1; i < ly; i++) gel(z,i) = gel(y,i);
     583       10864 :   setlg(x, l+ly-1);
     584       10864 : }
     585             : INLINE GEN
     586   134949844 : vecsmalltrunc_init(long l)
     587             : {
     588   134949844 :   GEN z = new_chunk(l);
     589   134862703 :   z[0] = evaltyp(t_VECSMALL) | _evallg(1); return z;
     590             : }
     591             : INLINE void
     592    61230576 : vecsmalltrunc_append(GEN x, long t) { x[ lg(x) ] = t; lg_increase(x); }
     593             : 
     594             : /*******************************************************************/
     595             : /*                                                                 */
     596             : /*                    STRING HASH FUNCTIONS                        */
     597             : /*                                                                 */
     598             : /*******************************************************************/
     599             : INLINE ulong
     600     2537761 : hash_str(const char *str)
     601             : {
     602     2537761 :   ulong hash = 5381UL, c;
     603    26201644 :   while ( (c = (ulong)*str++) )
     604    23663883 :     hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
     605     2537761 :   return hash;
     606             : }
     607             : INLINE ulong
     608    15187039 : hash_str_len(const char *str, long len)
     609             : {
     610    15187039 :   ulong hash = 5381UL;
     611             :   long i;
     612   121542171 :   for (i = 0; i < len; i++)
     613             :   {
     614   106355132 :     ulong c = (ulong)*str++;
     615   106355132 :     hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
     616             :   }
     617    15187039 :   return hash;
     618             : }
     619             : 
     620             : /*******************************************************************/
     621             : /*                                                                 */
     622             : /*                        VEC / COL / VECSMALL                     */
     623             : /*                                                                 */
     624             : /*******************************************************************/
     625             : /* shallow*/
     626             : INLINE GEN
     627       11555 : vec_shorten(GEN v, long n)
     628             : {
     629       11555 :   GEN V = cgetg(n+1, t_VEC);
     630             :   long i;
     631       13011 :   for(i = 1; i <= n; i++) gel(V,i) = gel(v,i);
     632       11555 :   return V;
     633             : }
     634             : /* shallow*/
     635             : INLINE GEN
     636       18874 : vec_lengthen(GEN v, long n)
     637             : {
     638       18874 :   GEN V = cgetg(n+1, t_VEC);
     639       18874 :   long i, l = lg(v);
     640     1938394 :   for(i = 1; i < l; i++) gel(V,i) = gel(v,i);
     641       18874 :   return V;
     642             : }
     643             : /* shallow*/
     644             : INLINE GEN
     645     3422068 : vec_append(GEN V, GEN s)
     646             : {
     647     3422068 :   long i, l2 = lg(V);
     648     3422068 :   GEN res = cgetg(l2+1, typ(V));
     649    10714193 :   for (i = 1; i < l2; i++) gel(res, i) = gel(V,i);
     650     3422043 :   gel(res,l2) = s; return res;
     651             : }
     652             : /* shallow*/
     653             : INLINE GEN
     654      272419 : vec_prepend(GEN v, GEN s)
     655             : {
     656      272419 :   long i, l = lg(v);
     657      272419 :   GEN w = cgetg(l+1, typ(v));
     658      272418 :   gel(w,1) = s;
     659      578570 :   for (i = 2; i <= l; i++) gel(w,i) = gel(v,i-1);
     660      272418 :   return w;
     661             : }
     662             : /* shallow*/
     663             : INLINE GEN
     664           0 : vec_setconst(GEN v, GEN x)
     665             : {
     666           0 :   long i, l = lg(v);
     667           0 :   for (i = 1; i < l; i++) gel(v,i) = x;
     668           0 :   return v;
     669             : }
     670             : INLINE GEN
     671       68216 : vecsmall_shorten(GEN v, long n)
     672             : {
     673       68216 :   GEN V = cgetg(n+1,t_VECSMALL);
     674             :   long i;
     675      834465 :   for(i = 1; i <= n; i++) V[i] = v[i];
     676       68217 :   return V;
     677             : }
     678             : INLINE GEN
     679         490 : vecsmall_lengthen(GEN v, long n)
     680             : {
     681         490 :   long i, l = lg(v);
     682         490 :   GEN V = cgetg(n+1,t_VECSMALL);
     683       25095 :   for(i = 1; i < l; i++) V[i] = v[i];
     684         490 :   return V;
     685             : }
     686             : 
     687             : INLINE GEN
     688     4239473 : vec_to_vecsmall(GEN x)
     689    19628429 : { pari_APPLY_long(itos(gel(x,i))) }
     690             : INLINE GEN
     691      499480 : vecsmall_to_vec(GEN x)
     692     5559031 : { pari_APPLY_type(t_VEC, stoi(x[i])) }
     693             : INLINE GEN
     694        2464 : vecsmall_to_vec_inplace(GEN z)
     695             : {
     696        2464 :   long i, l = lg(z);
     697       77014 :   for (i=1; i<l; i++) gel(z,i) = stoi(z[i]);
     698        2464 :   settyp(z, t_VEC); return z;
     699             : }
     700             : INLINE GEN
     701     7650776 : vecsmall_to_col(GEN x)
     702    58480745 : { pari_APPLY_type(t_COL, stoi(x[i])) }
     703             : 
     704             : INLINE int
     705     7071987 : vecsmall_lexcmp(GEN x, GEN y)
     706             : {
     707             :   long lx,ly,l,i;
     708     7071987 :   lx = lg(x);
     709     7071987 :   ly = lg(y); l = minss(lx,ly);
     710    30507805 :   for (i=1; i<l; i++)
     711    28880950 :     if (x[i] != y[i]) return x[i]<y[i]? -1: 1;
     712     1626855 :   if (lx == ly) return 0;
     713       30578 :   return (lx < ly)? -1 : 1;
     714             : }
     715             : 
     716             : INLINE int
     717   108088071 : vecsmall_prefixcmp(GEN x, GEN y)
     718             : {
     719   108088071 :   long i, lx = lg(x), ly = lg(y), l = minss(lx,ly);
     720   542691324 :   for (i=1; i<l; i++)
     721   519806035 :     if (x[i] != y[i]) return x[i]<y[i]? -1: 1;
     722    22885289 :   return 0;
     723             : }
     724             : 
     725             : /*Can be used on t_VEC, but coeffs not gcopy-ed*/
     726             : INLINE GEN
     727      183616 : vecsmall_prepend(GEN V, long s)
     728             : {
     729      183616 :   long i, l2 = lg(V);
     730      183616 :   GEN res = cgetg(l2+1, typ(V));
     731      183616 :   res[1] = s;
     732      615412 :   for (i = 2; i <= l2; ++i) res[i] = V[i - 1];
     733      183616 :   return res;
     734             : }
     735             : 
     736             : INLINE GEN
     737     3951679 : vecsmall_append(GEN V, long s)
     738             : {
     739     3951679 :   long i, l2 = lg(V);
     740     3951679 :   GEN res = cgetg(l2+1, t_VECSMALL);
     741     5844699 :   for (i = 1; i < l2; ++i) res[i] = V[i];
     742     3951679 :   res[l2] = s; return res;
     743             : }
     744             : 
     745             : INLINE GEN
     746     1449907 : vecsmall_concat(GEN u, GEN v)
     747             : {
     748     1449907 :   long i, l1 = lg(u)-1, l2 = lg(v)-1;
     749     1449907 :   GEN res = cgetg(l1+l2+1, t_VECSMALL);
     750    11494732 :   for (i = 1; i <= l1; ++i) res[i]    = u[i];
     751    14754351 :   for (i = 1; i <= l2; ++i) res[i+l1] = v[i];
     752     1449908 :   return res;
     753             : }
     754             : 
     755             : /* return the number of indices where u and v are equal */
     756             : INLINE long
     757           0 : vecsmall_coincidence(GEN u, GEN v)
     758             : {
     759           0 :   long i, s = 0, l = minss(lg(u),lg(v));
     760           0 :   for(i=1; i<l; i++)
     761           0 :     if(u[i] == v[i]) s++;
     762           0 :   return s;
     763             : }
     764             : 
     765             : /* returns the first index i<=n such that x=v[i] if it exists, 0 otherwise */
     766             : INLINE long
     767          42 : vecsmall_isin(GEN v, long x)
     768             : {
     769          42 :   long i, l = lg(v);
     770          62 :   for (i = 1; i < l; i++)
     771          40 :     if (v[i] == x) return i;
     772          22 :   return 0;
     773             : }
     774             : 
     775             : INLINE long
     776          84 : vecsmall_pack(GEN V, long base, long mod)
     777             : {
     778          84 :   long i, s = 0;
     779         273 :   for(i=1; i<lg(V); i++) s = (base*s + V[i]) % mod;
     780          84 :   return s;
     781             : }
     782             : 
     783             : INLINE long
     784          14 : vecsmall_indexmax(GEN x)
     785             : {
     786          14 :   long i, i0 = 1, t = x[1], lx = lg(x);
     787          56 :   for (i=2; i<lx; i++)
     788          42 :     if (x[i] > t) t = x[i0=i];
     789          14 :   return i0;
     790             : }
     791             : 
     792             : INLINE long
     793      838873 : vecsmall_max(GEN x)
     794             : {
     795      838873 :   long i, t = x[1], lx = lg(x);
     796     2278701 :   for (i=2; i<lx; i++)
     797     1439828 :     if (x[i] > t) t = x[i];
     798      838873 :   return t;
     799             : }
     800             : 
     801             : INLINE long
     802          14 : vecsmall_indexmin(GEN x)
     803             : {
     804          14 :   long i, i0 = 1, t = x[1], lx =lg(x);
     805          56 :   for (i=2; i<lx; i++)
     806          42 :     if (x[i] < t) t = x[i0=i];
     807          14 :   return i0;
     808             : }
     809             : 
     810             : INLINE long
     811        1442 : vecsmall_min(GEN x)
     812             : {
     813        1442 :   long i, t = x[1], lx =lg(x);
     814       10094 :   for (i=2; i<lx; i++)
     815        8652 :     if (x[i] < t) t = x[i];
     816        1442 :   return t;
     817             : }
     818             : 
     819             : INLINE int
     820    36440005 : ZV_isscalar(GEN x)
     821             : {
     822    36440005 :   long l = lg(x);
     823    61431877 :   while (--l > 1)
     824    60982614 :     if (signe(gel(x, l))) return 0;
     825      449263 :   return 1;
     826             : }
     827             : INLINE int
     828    41968178 : QV_isscalar(GEN x)
     829             : {
     830    41968178 :   long lx = lg(x),i;
     831    49366618 :   for (i=2; i<lx; i++)
     832    47090559 :     if (!isintzero(gel(x, i))) return 0;
     833     2276059 :   return 1;
     834             : }
     835             : INLINE int
     836        8007 : RgV_isscalar(GEN x)
     837             : {
     838        8007 :   long lx = lg(x),i;
     839        9251 :   for (i=2; i<lx; i++)
     840        9209 :     if (!gequal0(gel(x, i))) return 0;
     841          42 :   return 1;
     842             : }
     843             : INLINE int
     844           0 : RgX_isscalar(GEN x)
     845             : {
     846             :   long i;
     847           0 :   for (i=lg(x)-1; i>2; i--)
     848           0 :     if (!gequal0(gel(x, i))) return 0;
     849           0 :   return 1;
     850             : }
     851             : INLINE long
     852    25102307 : RgX_equal_var(GEN x, GEN y) { return varn(x) == varn(y) && RgX_equal(x,y); }
     853             : INLINE GEN
     854         140 : RgX_to_RgV(GEN x, long N) { x = RgX_to_RgC(x, N); settyp(x, t_VEC); return x; }
     855             : 
     856             : INLINE int
     857       64043 : RgX_is_rational(GEN x)
     858             : {
     859             :   long i;
     860      297770 :   for (i = lg(x)-1; i > 1; i--)
     861      282598 :     if (!is_rational_t(typ(gel(x,i)))) return 0;
     862       15172 :   return 1;
     863             : }
     864             : INLINE int
     865    12941263 : RgX_is_ZX(GEN x)
     866             : {
     867             :   long i;
     868    53667028 :   for (i = lg(x)-1; i > 1; i--)
     869    40783537 :     if (typ(gel(x,i)) != t_INT) return 0;
     870    12883491 :   return 1;
     871             : }
     872             : INLINE int
     873      338132 : RgX_is_QX(GEN x)
     874             : {
     875      338132 :   long k = lg(x)-1;
     876     1253665 :   for ( ; k>1; k--)
     877      915799 :     if (!is_rational_t(typ(gel(x,k)))) return 0;
     878      337866 :   return 1;
     879             : }
     880             : INLINE int
     881     2990041 : RgX_is_monomial(GEN x)
     882             : {
     883             :   long i;
     884     2990041 :   if (!signe(x)) return 0;
     885     6913147 :   for (i=lg(x)-2; i>1; i--)
     886     4513258 :     if (!isexactzero(gel(x,i))) return 0;
     887     2399889 :   return 1;
     888             : }
     889             : INLINE int
     890    30908919 : RgV_is_ZV(GEN x)
     891             : {
     892             :   long i;
     893   122732429 :   for (i = lg(x)-1; i > 0; i--)
     894    91852910 :     if (typ(gel(x,i)) != t_INT) return 0;
     895    30879519 :   return 1;
     896             : }
     897             : INLINE int
     898      110559 : RgV_is_QV(GEN x)
     899             : {
     900             :   long i;
     901      529254 :   for (i = lg(x)-1; i > 0; i--)
     902      421648 :     if (!is_rational_t(typ(gel(x,i)))) return 0;
     903      107606 :   return 1;
     904             : }
     905             : INLINE long
     906      109067 : RgV_isin_i(GEN v, GEN x, long n)
     907             : {
     908             :   long i;
     909     1031380 :   for (i = 1; i <= n; i++)
     910     1025591 :     if (gequal(gel(v,i), x)) return i;
     911        5789 :   return 0;
     912             : }
     913             : INLINE long
     914      109067 : RgV_isin(GEN v, GEN x) { return RgV_isin_i(v, x, lg(v)-1); }
     915             : 
     916             : /********************************************************************/
     917             : /**                                                                **/
     918             : /**            Dynamic arrays implementation                       **/
     919             : /**                                                                **/
     920             : /********************************************************************/
     921             : INLINE void **
     922   640650159 : pari_stack_base(pari_stack *s) { return s->data; }
     923             : 
     924             : INLINE void
     925     4162788 : pari_stack_init(pari_stack *s, size_t size, void **data)
     926             : {
     927     4162788 :   s->data = data;
     928     4162788 :   *data = NULL;
     929     4162788 :   s->n = 0;
     930     4162788 :   s->alloc = 0;
     931     4162788 :   s->size = size;
     932     4162788 : }
     933             : 
     934             : INLINE void
     935   636850381 : pari_stack_alloc(pari_stack *s, long nb)
     936             : {
     937   636850381 :   void **sdat = pari_stack_base(s);
     938   636730039 :   long alloc = s->alloc;
     939   636730039 :   if (s->n+nb <= alloc) return;
     940     1584515 :   if (!alloc)
     941     1487011 :     alloc = nb;
     942             :   else
     943             :   {
     944      198473 :     while (s->n+nb > alloc) alloc <<= 1;
     945             :   }
     946     1584515 :   pari_realloc_ip(sdat,alloc*s->size);
     947     1588759 :   s->alloc = alloc;
     948             : }
     949             : 
     950             : INLINE long
     951   549158697 : pari_stack_new(pari_stack *s) { pari_stack_alloc(s, 1); return s->n++; }
     952             : 
     953             : INLINE void
     954     3840059 : pari_stack_delete(pari_stack *s)
     955             : {
     956     3840059 :   void **sdat = pari_stack_base(s);
     957     3831529 :   if (*sdat) pari_free(*sdat);
     958     3855186 : }
     959             : 
     960             : INLINE void
     961        5578 : pari_stack_pushp(pari_stack *s, void *u)
     962             : {
     963        5578 :   long n = pari_stack_new(s);
     964        5578 :   void **sdat =(void**) *pari_stack_base(s);
     965        5578 :   sdat[n] = u;
     966        5578 : }
     967             : 
     968             : /*******************************************************************/
     969             : /*                                                                 */
     970             : /*                            EXTRACT                              */
     971             : /*                                                                 */
     972             : /*******************************************************************/
     973             : INLINE GEN
     974   543915558 : vecslice(GEN A, long y1, long y2)
     975             : {
     976   543915558 :   long i,lB = y2 - y1 + 2;
     977   543915558 :   GEN B = cgetg(lB, typ(A));
     978  2447477886 :   for (i=1; i<lB; i++) B[i] = A[y1-1+i];
     979   543893499 :   return B;
     980             : }
     981             : INLINE GEN
     982     1927633 : vecslicepermute(GEN A, GEN p, long y1, long y2)
     983             : {
     984     1927633 :   long i,lB = y2 - y1 + 2;
     985     1927633 :   GEN B = cgetg(lB, typ(A));
     986    30392857 :   for (i=1; i<lB; i++) B[i] = A[p[y1-1+i]];
     987     1927622 :   return B;
     988             : }
     989             : /* rowslice(rowpermute(A,p), x1, x2) */
     990             : INLINE GEN
     991      167184 : rowslicepermute(GEN x, GEN p, long j1, long j2)
     992      727868 : { pari_APPLY_same(vecslicepermute(gel(x,i),p,j1,j2)) }
     993             : 
     994             : INLINE GEN
     995    57821867 : rowslice(GEN x, long j1, long j2)
     996   555580573 : { pari_APPLY_same(vecslice(gel(x,i), j1, j2)) }
     997             : 
     998             : INLINE GEN
     999     8765295 : matslice(GEN A, long x1, long x2, long y1, long y2)
    1000     8765295 : { return rowslice(vecslice(A, y1, y2), x1, x2); }
    1001             : 
    1002             : /* shallow, remove coeff of index j */
    1003             : INLINE GEN
    1004         210 : rowsplice(GEN x, long j)
    1005        1036 : { pari_APPLY_same(vecsplice(gel(x,i), j)) }
    1006             : 
    1007             : /* shallow, remove coeff of index j */
    1008             : INLINE GEN
    1009      354212 : vecsplice(GEN a, long j)
    1010             : {
    1011      354212 :   long i, k, l = lg(a);
    1012             :   GEN b;
    1013      354212 :   if (l == 1) pari_err(e_MISC, "incorrect component in vecsplice");
    1014      354212 :   b = cgetg(l-1, typ(a));
    1015     1499634 :   for (i = k = 1; i < l; i++)
    1016     1145422 :     if (i != j) gel(b, k++) = gel(a,i);
    1017      354212 :   return b;
    1018             : }
    1019             : /* shallow */
    1020             : INLINE GEN
    1021        1036 : RgM_minor(GEN a, long i, long j)
    1022             : {
    1023        1036 :   GEN b = vecsplice(a, j);
    1024        1036 :   long k, l = lg(b);
    1025        4242 :   for (k = 1; k < l; k++) gel(b,k) = vecsplice(gel(b,k), i);
    1026        1036 :   return b;
    1027             : }
    1028             : 
    1029             : /* A[x0,] */
    1030             : INLINE GEN
    1031      474466 : row(GEN x, long j)
    1032     4403991 : { pari_APPLY_type(t_VEC, gcoeff(x, j, i)) }
    1033             : INLINE GEN
    1034     7870620 : Flm_row(GEN x, long j)
    1035   206119227 : { pari_APPLY_ulong((ulong)coeff(x, j, i)) }
    1036             : /* A[x0,] */
    1037             : INLINE GEN
    1038      204988 : rowcopy(GEN x, long j)
    1039     2105509 : { pari_APPLY_type(t_VEC, gcopy(gcoeff(x, j, i))) }
    1040             : /* A[x0, x1..x2] */
    1041             : INLINE GEN
    1042         987 : row_i(GEN A, long x0, long x1, long x2)
    1043             : {
    1044         987 :   long i, lB = x2 - x1 + 2;
    1045         987 :   GEN B  = cgetg(lB, t_VEC);
    1046        2989 :   for (i=x1; i<=x2; i++) gel(B, i) = gcoeff(A, x0, i);
    1047         987 :   return B;
    1048             : }
    1049             : 
    1050             : INLINE GEN
    1051      397131 : vecreverse(GEN A)
    1052             : {
    1053             :   long i, l;
    1054      397131 :   GEN B = cgetg_copy(A, &l);
    1055     1173977 :   for (i=1; i<l; i++) gel(B, i) = gel(A, l-i);
    1056      397131 :   return B;
    1057             : }
    1058             : 
    1059             : INLINE GEN
    1060        3003 : vecsmall_reverse(GEN A)
    1061             : {
    1062             :   long i, l;
    1063        3003 :   GEN B = cgetg_copy(A, &l);
    1064       12523 :   for (i=1; i<l; i++) B[i] = A[l-i];
    1065        3003 :   return B;
    1066             : }
    1067             : 
    1068             : INLINE void
    1069        2549 : vecreverse_inplace(GEN y)
    1070             : {
    1071        2549 :   long l = lg(y), lim = l>>1, i;
    1072        8179 :   for (i = 1; i <= lim; i++)
    1073             :   {
    1074        5630 :     GEN z = gel(y,i);
    1075        5630 :     gel(y,i)    = gel(y,l-i);
    1076        5630 :     gel(y,l-i) = z;
    1077             :   }
    1078        2549 : }
    1079             : 
    1080             : INLINE GEN
    1081    65253602 : vecsmallpermute(GEN A, GEN p) { return perm_mul(A, p); }
    1082             : 
    1083             : INLINE GEN
    1084    12657221 : vecpermute(GEN A, GEN x)
    1085    99215398 : { pari_APPLY_type(typ(A), gel(A, x[i])) }
    1086             : 
    1087             : INLINE GEN
    1088     8544241 : rowpermute(GEN x, GEN p)
    1089    75952996 : { pari_APPLY_same(typ(gel(x,i)) == t_VECSMALL ? vecsmallpermute(gel(x, i), p)
    1090             :                                               : vecpermute(gel(x, i), p))
    1091             : }
    1092             : /*******************************************************************/
    1093             : /*                                                                 */
    1094             : /*                          PERMUTATIONS                           */
    1095             : /*                                                                 */
    1096             : /*******************************************************************/
    1097             : INLINE GEN
    1098     1985510 : identity_zv(long n)
    1099             : {
    1100     1985510 :   GEN v = cgetg(n+1, t_VECSMALL);
    1101             :   long i;
    1102    24414953 :   for (i = 1; i <= n; i++) v[i] = i;
    1103     1985487 :   return v;
    1104             : }
    1105             : INLINE GEN
    1106        4249 : identity_ZV(long n)
    1107             : {
    1108        4249 :   GEN v = cgetg(n+1, t_VEC);
    1109             :   long i;
    1110       51569 :   for (i = 1; i <= n; i++) gel(v,i) = utoipos(i);
    1111        4249 :   return v;
    1112             : }
    1113             : /* identity permutation */
    1114             : INLINE GEN
    1115     1961185 : identity_perm(long n) { return identity_zv(n); }
    1116             : 
    1117             : /* assume d <= n */
    1118             : INLINE GEN
    1119       98483 : cyclic_perm(long n, long d)
    1120             : {
    1121       98483 :   GEN perm = cgetg(n+1, t_VECSMALL);
    1122             :   long i;
    1123      504098 :   for (i = 1; i <= n-d; i++) perm[i] = i+d;
    1124      225029 :   for (     ; i <= n;   i++) perm[i] = i-n+d;
    1125       98483 :   return perm;
    1126             : }
    1127             : 
    1128             : /* Multiply (compose) two permutations */
    1129             : INLINE GEN
    1130    67220511 : perm_mul(GEN s, GEN x)
    1131   895413052 : { pari_APPLY_long(s[x[i]]) }
    1132             : 
    1133             : INLINE GEN
    1134         728 : perm_sqr(GEN x)
    1135       18284 : { pari_APPLY_long(x[x[i]]) }
    1136             : 
    1137             : /* Compute the inverse (reciprocal) of a permutation. */
    1138             : INLINE GEN
    1139     2325886 : perm_inv(GEN x)
    1140             : {
    1141             :   long i, lx;
    1142     2325886 :   GEN y = cgetg_copy(x, &lx);
    1143    31924149 :   for (i=1; i<lx; i++) y[ x[i] ] = i;
    1144     2325880 :   return y;
    1145             : }
    1146             : /* Return s*t*s^-1 */
    1147             : INLINE GEN
    1148      418299 : perm_conj(GEN s, GEN t)
    1149             : {
    1150             :   long i, l;
    1151      418299 :   GEN v = cgetg_copy(s, &l);
    1152     6857893 :   for (i = 1; i < l; i++) v[ s[i] ] = s[ t[i] ];
    1153      418299 :   return v;
    1154             : }
    1155             : 
    1156             : INLINE void
    1157   378854496 : pari_free(void *pointer)
    1158             : {
    1159   378854496 :   BLOCK_SIGINT_START;
    1160   378907574 :   free(pointer);
    1161   378907574 :   BLOCK_SIGINT_END;
    1162   378900792 : }
    1163             : INLINE void*
    1164   604761341 : pari_malloc(size_t size)
    1165             : {
    1166   604761341 :   if (size)
    1167             :   {
    1168             :     char *tmp;
    1169   604762506 :     BLOCK_SIGINT_START;
    1170   604812896 :     tmp = (char*)malloc(size);
    1171   604812896 :     BLOCK_SIGINT_END;
    1172   604804420 :     if (!tmp) pari_err(e_MEM);
    1173   604806051 :     return tmp;
    1174             :   }
    1175           0 :   return NULL;
    1176             : }
    1177             : INLINE void*
    1178        1799 : pari_realloc(void *pointer, size_t size)
    1179             : {
    1180             :   char *tmp;
    1181             : 
    1182        1799 :   BLOCK_SIGINT_START;
    1183        1799 :   if (!pointer) tmp = (char *) malloc(size);
    1184        1799 :   else tmp = (char *) realloc(pointer,size);
    1185        1799 :   BLOCK_SIGINT_END;
    1186        1799 :   if (!tmp) pari_err(e_MEM);
    1187        1799 :   return tmp;
    1188             : }
    1189             : INLINE void
    1190     1589722 : pari_realloc_ip(void **pointer, size_t size)
    1191             : {
    1192             :   char *tmp;
    1193     1589722 :   BLOCK_SIGINT_START;
    1194     1589641 :   if (!*pointer) tmp = (char *) malloc(size);
    1195      103011 :   else tmp = (char *) realloc(*pointer,size);
    1196     1589641 :   if (!tmp) pari_err(e_MEM);
    1197     1589641 :   *pointer = tmp;
    1198     1589641 :   BLOCK_SIGINT_END;
    1199     1589073 : }
    1200             : 
    1201             : INLINE void*
    1202       44563 : pari_calloc(size_t size)
    1203             : {
    1204       44563 :   void *t = pari_malloc(size);
    1205       44563 :   memset(t, 0, size); return t;
    1206             : }
    1207             : INLINE GEN
    1208        8031 : cgetalloc(size_t l, long t)
    1209             : { /* evallg may raise e_OVERFLOW, which would leak x */
    1210        8031 :   ulong x0 = evaltyp(t) | evallg(l);
    1211        8031 :   GEN x = (GEN)pari_malloc(l * sizeof(long));
    1212        8031 :   x[0] = x0; return x;
    1213             : }
    1214             : 
    1215             : /*******************************************************************/
    1216             : /*                                                                 */
    1217             : /*                       GARBAGE COLLECTION                        */
    1218             : /*                                                                 */
    1219             : /*******************************************************************/
    1220             : /* copy integer x as if we had set_avma(av) */
    1221             : INLINE GEN
    1222  6859558423 : icopy_avma(GEN x, pari_sp av)
    1223             : {
    1224  6859558423 :   long i = lgefint(x), lx = i;
    1225  6859558423 :   GEN y = ((GEN)av) - i;
    1226 46896693273 :   while (--i > 0) y[i] = x[i];
    1227  6859558423 :   y[0] = evaltyp(t_INT)|evallg(lx);
    1228  6863674048 :   return y;
    1229             : }
    1230             : /* copy leaf x as if we had set_avma(av) */
    1231             : INLINE GEN
    1232   440347521 : leafcopy_avma(GEN x, pari_sp av)
    1233             : {
    1234   440347521 :   long i = lg(x);
    1235   440347521 :   GEN y = ((GEN)av) - i;
    1236  2769949276 :   while (--i > 0) y[i] = x[i];
    1237   440347521 :   y[0] = x[0] & (~CLONEBIT);
    1238   440347521 :   return y;
    1239             : }
    1240             : INLINE GEN
    1241  1038930419 : gerepileuptoleaf(pari_sp av, GEN x)
    1242             : {
    1243             :   long lx;
    1244             :   GEN q;
    1245             : 
    1246  1038930419 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1247  1038067798 :   lx = lg(x);
    1248  1038067798 :   q = ((GEN)av) - lx;
    1249  1038067798 :   set_avma((pari_sp)q);
    1250 10622050043 :   while (--lx >= 0) q[lx] = x[lx];
    1251  1037882803 :   return q;
    1252             : }
    1253             : INLINE GEN
    1254  3098602808 : gerepileuptoint(pari_sp av, GEN x)
    1255             : {
    1256  3098602808 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1257  2742010480 :   set_avma((pari_sp)icopy_avma(x, av));
    1258  2745284768 :   return (GEN)avma;
    1259             : }
    1260             : INLINE GEN
    1261  1536741605 : gerepileupto(pari_sp av, GEN x)
    1262             : {
    1263  1536741605 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1264  1354398383 :   switch(typ(x))
    1265             :   { /* non-default = !is_recursive_t(tq) */
    1266   369920259 :     case t_INT: return gerepileuptoint(av, x);
    1267   329888655 :     case t_REAL:
    1268             :     case t_STR:
    1269   329888655 :     case t_VECSMALL: return gerepileuptoleaf(av,x);
    1270   654589469 :     default:
    1271             :       /* NB: x+i --> ((long)x) + i*sizeof(long) */
    1272   654589469 :       return gerepile(av, (pari_sp) (x+lg(x)), x);
    1273             :   }
    1274             : }
    1275             : 
    1276             : /* gerepileupto(av, gcopy(x)) */
    1277             : INLINE GEN
    1278   150283528 : gerepilecopy(pari_sp av, GEN x)
    1279             : {
    1280   150283528 :   if (is_recursive_t(typ(x)))
    1281             :   {
    1282   143163904 :     GENbin *p = copy_bin(x);
    1283   143180895 :     set_avma(av); return bin_copy(p);
    1284             :   }
    1285             :   else
    1286             :   {
    1287     7119362 :     set_avma(av);
    1288     7119410 :     if (x < (GEN)av) {
    1289     5352214 :       if (x < (GEN)pari_mainstack->bot) new_chunk(lg(x));
    1290     5352213 :       x = leafcopy_avma(x, av);
    1291     5352242 :       set_avma((pari_sp)x);
    1292             :     } else
    1293     1767199 :       x = leafcopy(x);
    1294     7119439 :     return x;
    1295             :   }
    1296             : }
    1297             : 
    1298             : INLINE void
    1299    44281734 : guncloneNULL(GEN x) { if (x) gunclone(x); }
    1300             : INLINE void
    1301     1004541 : guncloneNULL_deep(GEN x) { if (x) gunclone_deep(x); }
    1302             : 
    1303             : /* Takes an array of pointers to GENs, of length n. Copies all
    1304             :  * objects to contiguous locations and cleans up the stack between
    1305             :  * av and avma. */
    1306             : INLINE void
    1307      970879 : gerepilemany(pari_sp av, GEN* gptr[], int n)
    1308             : {
    1309             :   int i;
    1310     3874889 :   for (i=0; i<n; i++) *gptr[i] = (GEN)copy_bin(*gptr[i]);
    1311      970454 :   set_avma(av);
    1312     3875673 :   for (i=0; i<n; i++) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1313      971118 : }
    1314             : 
    1315             : INLINE void
    1316    11684815 : gerepileall(pari_sp av, int n, ...)
    1317             : {
    1318             :   int i;
    1319    11684815 :   va_list a; va_start(a, n);
    1320    11684815 :   if (n < 10)
    1321             :   {
    1322             :     GEN *gptr[10];
    1323    35302191 :     for (i=0; i<n; i++)
    1324    23617032 :     { gptr[i] = va_arg(a,GEN*); *gptr[i] = (GEN)copy_bin(*gptr[i]); }
    1325    11685159 :     set_avma(av);
    1326    35302639 :     for (--i; i>=0; i--) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1327             : 
    1328             :   }
    1329             :   else
    1330             :   {
    1331           0 :     GEN **gptr = (GEN**)  pari_malloc(n*sizeof(GEN*));
    1332           0 :     for (i=0; i<n; i++)
    1333           0 :     { gptr[i] = va_arg(a,GEN*); *gptr[i] = (GEN)copy_bin(*gptr[i]); }
    1334           0 :     set_avma(av);
    1335           0 :     for (--i; i>=0; i--) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1336           0 :     pari_free(gptr);
    1337             :   }
    1338    11685552 :   va_end(a);
    1339    11685552 : }
    1340             : 
    1341             : /* assume 1 <= n < 10 */
    1342             : INLINE GEN
    1343    71326233 : gc_all(pari_sp av, int n, ...)
    1344             : {
    1345             :   int i;
    1346             :   GEN *v[10];
    1347    71326233 :   va_list a; va_start(a, n);
    1348   243680211 :   for (i=0; i<n; i++) { v[i] = va_arg(a,GEN*); *v[i] = (GEN)copy_bin(*v[i]); }
    1349    71326579 :   set_avma(av);
    1350   243681041 :   for (i=0; i<n; i++) *v[i] = bin_copy((GENbin*)*v[i]);
    1351    71326903 :   return *v[0];
    1352             : }
    1353             : 
    1354             : INLINE void
    1355     2212058 : gerepilecoeffs(pari_sp av, GEN x, int n)
    1356             : {
    1357             :   int i;
    1358    26765779 :   for (i=0; i<n; i++) gel(x,i) = (GEN)copy_bin(gel(x,i));
    1359     2212773 :   set_avma(av);
    1360    26767349 :   for (i=0; i<n; i++) gel(x,i) = bin_copy((GENbin*)x[i]);
    1361     2212229 : }
    1362             : 
    1363             : /* p from copy_bin. Copy p->x back to stack, then destroy p */
    1364             : INLINE GEN
    1365   366653042 : bin_copy(GENbin *p)
    1366             : {
    1367             :   GEN x, y, base;
    1368             :   long dx, len;
    1369             : 
    1370   366653042 :   x   = p->x; if (!x) { pari_free(p); return gen_0; }
    1371   339263691 :   len = p->len;
    1372   339263691 :   base= p->base; dx = x - base;
    1373   339263691 :   y = (GEN)memcpy((void*)new_chunk(len), (void*)GENbinbase(p), len*sizeof(long));
    1374   339257863 :   y += dx;
    1375   339257863 :   p->rebase(y, ((ulong)y-(ulong)x));
    1376   339262529 :   pari_free(p); return y;
    1377             : }
    1378             : 
    1379             : INLINE GEN
    1380   705901722 : GENbinbase(GENbin *p) { return (GEN)(p + 1); }
    1381             : 
    1382             : INLINE void
    1383   115809897 : cgiv(GEN x)
    1384             : {
    1385   115809897 :   pari_sp av = (pari_sp)(x+lg(x));
    1386   115809897 :   if (isonstack((GEN)av)) set_avma(av);
    1387   115812364 : }
    1388             : 
    1389             : INLINE void
    1390     1585397 : killblock(GEN x) { gunclone(x); }
    1391             : 
    1392             : INLINE int
    1393   282516148 : is_universal_constant(GEN x) { return (x >= gen_0 && x <= ghalf); }
    1394             : 
    1395             : /*******************************************************************/
    1396             : /*                                                                 */
    1397             : /*                    CONVERSION / ASSIGNMENT                      */
    1398             : /*                                                                 */
    1399             : /*******************************************************************/
    1400             : /* z is a type which may be a t_COMPLEX component (not a t_QUAD) */
    1401             : INLINE GEN
    1402    17878228 : cxcompotor(GEN z, long prec)
    1403             : {
    1404    17878228 :   switch(typ(z))
    1405             :   {
    1406    11255654 :     case t_INT:  return itor(z, prec);
    1407      289877 :     case t_FRAC: return fractor(z, prec);
    1408     6332985 :     case t_REAL: return rtor(z, prec);
    1409           0 :     default: pari_err_TYPE("cxcompotor",z);
    1410             :              return NULL; /* LCOV_EXCL_LINE */
    1411             :   }
    1412             : }
    1413             : INLINE GEN
    1414     8923668 : cxtofp(GEN x, long prec)
    1415     8923668 : { retmkcomplex(cxcompotor(gel(x,1),prec), cxcompotor(gel(x,2),prec)); }
    1416             : 
    1417             : INLINE GEN
    1418      275719 : cxtoreal(GEN q)
    1419      275719 : { return (typ(q) == t_COMPLEX && gequal0(gel(q,2)))? gel(q,1): q; }
    1420             : 
    1421             : INLINE double
    1422    57333441 : gtodouble(GEN x)
    1423             : {
    1424    57333441 :   if (typ(x)!=t_REAL) {
    1425     6375702 :     pari_sp av = avma;
    1426     6375702 :     x = gtofp(x, DEFAULTPREC);
    1427     6374980 :     if (typ(x)!=t_REAL) pari_err_TYPE("gtodouble [t_REAL expected]", x);
    1428     6374980 :     set_avma(av);
    1429             :   }
    1430    57332592 :   return rtodbl(x);
    1431             : }
    1432             : 
    1433             : INLINE int
    1434     8949212 : gisdouble(GEN x, double *g)
    1435             : {
    1436     8949212 :   if (typ(x)!=t_REAL) {
    1437      146851 :     pari_sp av = avma;
    1438      146851 :     x = gtofp(x, DEFAULTPREC);
    1439      146850 :     if (typ(x)!=t_REAL) pari_err_TYPE("gisdouble [t_REAL expected]", x);
    1440      146850 :     set_avma(av);
    1441             :   }
    1442     8949209 :   if (expo(x) >= 0x3ff) return 0;
    1443     8949209 :   *g = rtodbl(x); return 1;
    1444             : }
    1445             : 
    1446             : INLINE long
    1447    85674071 : gtos(GEN x) {
    1448    85674071 :   if (typ(x) != t_INT) pari_err_TYPE("gtos [integer expected]",x);
    1449    85674064 :   return itos(x);
    1450             : }
    1451             : 
    1452             : INLINE ulong
    1453      102983 : gtou(GEN x) {
    1454      102983 :   if (typ(x) != t_INT || signe(x)<0)
    1455           7 :     pari_err_TYPE("gtou [integer >=0 expected]",x);
    1456      102976 :   return itou(x);
    1457             : }
    1458             : 
    1459             : INLINE GEN
    1460    42106159 : absfrac(GEN x)
    1461             : {
    1462    42106159 :   GEN y = cgetg(3, t_FRAC);
    1463    42106201 :   gel(y,1) = absi(gel(x,1));
    1464    42106263 :   gel(y,2) = icopy(gel(x,2)); return y;
    1465             : }
    1466             : INLINE GEN
    1467       46408 : absfrac_shallow(GEN x)
    1468       46408 : { return signe(gel(x,1))>0? x: mkfrac(negi(gel(x,1)), gel(x,2)); }
    1469             : INLINE GEN
    1470     7156779 : Q_abs(GEN x) { return (typ(x) == t_INT)? absi(x): absfrac(x); }
    1471             : INLINE GEN
    1472      168782 : Q_abs_shallow(GEN x)
    1473      168782 : { return (typ(x) == t_INT)? absi_shallow(x): absfrac_shallow(x); }
    1474             : INLINE GEN
    1475       12754 : R_abs_shallow(GEN x)
    1476       12754 : { return (typ(x) == t_FRAC)? absfrac_shallow(x): mpabs_shallow(x); }
    1477             : INLINE GEN
    1478           0 : R_abs(GEN x)
    1479           0 : { return (typ(x) == t_FRAC)? absfrac(x): mpabs(x); }
    1480             : 
    1481             : /* Force z to be of type real/complex with floating point components */
    1482             : INLINE GEN
    1483    76963643 : gtofp(GEN z, long prec)
    1484             : {
    1485    76963643 :   switch(typ(z))
    1486             :   {
    1487    44020966 :     case t_INT:  return itor(z, prec);
    1488     4092815 :     case t_FRAC: return fractor(z, prec);
    1489    20193433 :     case t_REAL: return rtor(z, prec);
    1490     8663818 :     case t_COMPLEX: {
    1491     8663818 :       GEN a = gel(z,1), b = gel(z,2);
    1492     8663818 :       if (isintzero(b)) return cxcompotor(a, prec);
    1493     8663876 :       if (isintzero(a)) {
    1494        8884 :         GEN y = cgetg(3, t_COMPLEX);
    1495        8884 :         b = cxcompotor(b, prec);
    1496        8884 :         gel(y,1) = real_0_bit(expo(b) - prec2nbits(prec));
    1497        8884 :         gel(y,2) = b; return y;
    1498             :       }
    1499     8654972 :       return cxtofp(z, prec);
    1500             :     }
    1501           0 :     case t_QUAD: return quadtofp(z, prec);
    1502           0 :     default: pari_err_TYPE("gtofp",z);
    1503             :              return NULL; /* LCOV_EXCL_LINE */
    1504             :   }
    1505             : }
    1506             : /* Force z to be of type real / int */
    1507             : INLINE GEN
    1508       22428 : gtomp(GEN z, long prec)
    1509             : {
    1510       22428 :   switch(typ(z))
    1511             :   {
    1512          42 :     case t_INT:  return z;
    1513       22386 :     case t_FRAC: return fractor(z, prec);
    1514           0 :     case t_REAL: return rtor(z, prec);
    1515           0 :     case t_QUAD: z = quadtofp(z, prec);
    1516           0 :                  if (typ(z) == t_REAL) return z;
    1517           0 :     default: pari_err_TYPE("gtomp",z);
    1518             :              return NULL; /* LCOV_EXCL_LINE */
    1519             :   }
    1520             : }
    1521             : 
    1522             : INLINE GEN
    1523     4723724 : RgX_gtofp(GEN x, long prec)
    1524             : {
    1525             :   long l;
    1526     4723724 :   GEN y = cgetg_copy(x, &l);
    1527    26751416 :   while (--l > 1) gel(y,l) = gtofp(gel(x,l), prec);
    1528     4721797 :   y[1] = x[1]; return y;
    1529             : }
    1530             : INLINE GEN
    1531     3132350 : RgC_gtofp(GEN x, long prec)
    1532    25629649 : { pari_APPLY_type(t_COL, gtofp(gel(x,i), prec)) }
    1533             : 
    1534             : INLINE GEN
    1535          56 : RgV_gtofp(GEN x, long prec)
    1536        4781 : { pari_APPLY_type(t_VEC, gtofp(gel(x,i), prec)) }
    1537             : 
    1538             : INLINE GEN
    1539      585500 : RgM_gtofp(GEN x, long prec)
    1540     3090885 : { pari_APPLY_same(RgC_gtofp(gel(x,i), prec)) }
    1541             : 
    1542             : INLINE GEN
    1543         574 : RgC_gtomp(GEN x, long prec)
    1544       23002 : { pari_APPLY_type(t_COL, gtomp(gel(x,i), prec)) }
    1545             : 
    1546             : INLINE GEN
    1547          21 : RgM_gtomp(GEN x, long prec)
    1548         595 : { pari_APPLY_same(RgC_gtomp(gel(x,i), prec)) }
    1549             : 
    1550             : INLINE GEN
    1551       57823 : RgX_fpnorml2(GEN x, long prec)
    1552             : {
    1553       57823 :   pari_sp av = avma;
    1554       57823 :   return gerepileupto(av, gnorml2(RgX_gtofp(x, prec)));
    1555             : }
    1556             : INLINE GEN
    1557      616073 : RgC_fpnorml2(GEN x, long prec)
    1558             : {
    1559      616073 :   pari_sp av = avma;
    1560      616073 :   return gerepileupto(av, gnorml2(RgC_gtofp(x, prec)));
    1561             : }
    1562             : INLINE GEN
    1563       18995 : RgM_fpnorml2(GEN x, long prec)
    1564             : {
    1565       18995 :   pari_sp av = avma;
    1566       18995 :   return gerepileupto(av, gnorml2(RgM_gtofp(x, prec)));
    1567             : }
    1568             : 
    1569             : /* y a t_REAL */
    1570             : INLINE void
    1571      216244 : affgr(GEN x, GEN y)
    1572             : {
    1573             :   pari_sp av;
    1574      216244 :   switch(typ(x)) {
    1575        5992 :     case t_INT:  affir(x,y); break;
    1576      210252 :     case t_REAL: affrr(x,y); break;
    1577           0 :     case t_FRAC: rdiviiz(gel(x,1),gel(x,2), y); break;
    1578           0 :     case t_QUAD: av = avma; affgr(quadtofp(x,realprec(y)), y); set_avma(av); break;
    1579           0 :     default: pari_err_TYPE2("=",x,y);
    1580             :   }
    1581      216244 : }
    1582             : 
    1583             : INLINE GEN
    1584      245268 : affc_fixlg(GEN x, GEN res)
    1585             : {
    1586      245268 :   if (typ(x) == t_COMPLEX)
    1587             :   {
    1588      212863 :     affrr_fixlg(gel(x,1), gel(res,1));
    1589      212863 :     affrr_fixlg(gel(x,2), gel(res,2));
    1590             :   }
    1591             :   else
    1592             :   {
    1593       32405 :     set_avma((pari_sp)(res+3));
    1594       32405 :     res = cgetr(realprec(gel(res,1)));
    1595       32406 :     affrr_fixlg(x, res);
    1596             :   }
    1597      245270 :   return res;
    1598             : }
    1599             : 
    1600             : INLINE GEN
    1601           0 : trunc_safe(GEN x) { long e; return gcvtoi(x,&e); }
    1602             : 
    1603             : /*******************************************************************/
    1604             : /*                                                                 */
    1605             : /*                          LENGTH CONVERSIONS                     */
    1606             : /*                                                                 */
    1607             : /*******************************************************************/
    1608             : INLINE long
    1609       40365 : ndec2nlong(long x) { return 1 + (long)((x)*(LOG2_10/BITS_IN_LONG)); }
    1610             : INLINE long
    1611       31998 : ndec2prec(long x) { return 2 + ndec2nlong(x); }
    1612             : INLINE long
    1613        8367 : ndec2nbits(long x) { return ndec2nlong(x) << TWOPOTBITS_IN_LONG; }
    1614             : /* Fast implementation of ceil(x / (8*sizeof(long))); typecast to (ulong)
    1615             :  * to avoid overflow. Faster than 1 + ((x-1)>>TWOPOTBITS_IN_LONG)) :
    1616             :  *   addl, shrl instead of subl, sarl, addl */
    1617             : INLINE long
    1618    11895588 : nbits2nlong(long x) {
    1619    11895588 :   return (long)(((ulong)x+BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1620             : }
    1621             : 
    1622             : INLINE long
    1623   563289950 : nbits2extraprec(long x) {
    1624   563289950 :   return (long)(((ulong)x+BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1625             : }
    1626             : 
    1627             : /* Fast implementation of 2 + nbits2nlong(x) */
    1628             : INLINE long
    1629   187813274 : nbits2prec(long x) {
    1630   187813274 :   return (long)(((ulong)x+3*BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1631             : }
    1632             : INLINE long
    1633   289683447 : nbits2lg(long x) {
    1634   289683447 :   return (long)(((ulong)x+3*BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1635             : }
    1636             : /* ceil(x / sizeof(long)) */
    1637             : INLINE long
    1638   103158530 : nchar2nlong(long x) {
    1639   103158530 :   return (long)(((ulong)x+sizeof(long)-1) >> (TWOPOTBITS_IN_LONG-3L));
    1640             : }
    1641             : INLINE long
    1642  2383549424 : prec2nbits(long x) { return (x-2) * BITS_IN_LONG; }
    1643             : INLINE double
    1644     2873065 : bit_accuracy_mul(long x, double y) { return (x-2) * (BITS_IN_LONG*y); }
    1645             : INLINE double
    1646      614623 : prec2nbits_mul(long x, double y) { return (x-2) * (BITS_IN_LONG*y); }
    1647             : INLINE long
    1648   105137283 : bit_prec(GEN x) { return prec2nbits(realprec(x)); }
    1649             : INLINE long
    1650  2128776743 : bit_accuracy(long x) { return prec2nbits(x); }
    1651             : INLINE long
    1652       10180 : prec2ndec(long x) { return (long)prec2nbits_mul(x, LOG10_2); }
    1653             : INLINE long
    1654         228 : nbits2ndec(long x) { return (long)(x * LOG10_2); }
    1655             : INLINE long
    1656        4858 : precdbl(long x) {return (x - 1) << 1;}
    1657             : INLINE long
    1658  6584617488 : divsBIL(long n) { return n >> TWOPOTBITS_IN_LONG; }
    1659             : INLINE long
    1660  6468645866 : remsBIL(long n) { return n & (BITS_IN_LONG-1); }
    1661             : 
    1662             : /*********************************************************************/
    1663             : /**                                                                 **/
    1664             : /**                      OPERATIONS MODULO m                        **/
    1665             : /**                                                                 **/
    1666             : /*********************************************************************/
    1667             : /* Assume m > 0, more efficient if 0 <= a, b < m */
    1668             : 
    1669             : INLINE GEN
    1670    46165159 : Fp_red(GEN a, GEN m) { return modii(a, m); }
    1671             : INLINE GEN
    1672   138056550 : Fp_add(GEN a, GEN b, GEN m)
    1673             : {
    1674   138056550 :   pari_sp av=avma;
    1675   138056550 :   GEN p = addii(a,b);
    1676   136469198 :   long s = signe(p);
    1677   136469198 :   if (!s) return p; /* = gen_0 */
    1678   125554049 :   if (s > 0) /* general case */
    1679             :   {
    1680   125589459 :     GEN t = subii(p, m);
    1681   125191936 :     s = signe(t);
    1682   125191936 :     if (!s) return gc_const(av, gen_0);
    1683   117684988 :     if (s < 0) return gc_const((pari_sp)p, p);
    1684    59122517 :     if (cmpii(t, m) < 0) return gerepileuptoint(av, t); /* general case ! */
    1685     3240310 :     p = remii(t, m);
    1686             :   }
    1687             :   else
    1688      257424 :     p = modii(p, m);
    1689     3497843 :   return gerepileuptoint(av, p);
    1690             : }
    1691             : INLINE GEN
    1692   141177194 : Fp_sub(GEN a, GEN b, GEN m)
    1693             : {
    1694   141177194 :   pari_sp av=avma;
    1695   141177194 :   GEN p = subii(a,b);
    1696   138636965 :   long s = signe(p);
    1697   138636965 :   if (!s) return p; /* = gen_0 */
    1698   126880766 :   if (s > 0)
    1699             :   {
    1700    56914873 :     if (cmpii(p, m) < 0) return p; /* general case ! */
    1701     1317955 :     p = remii(p, m);
    1702             :   }
    1703             :   else
    1704             :   {
    1705    69965893 :     GEN t = addii(p, m);
    1706    71716822 :     if (!s) return gc_const(av, gen_0);
    1707    71785773 :     if (s > 0) return gerepileuptoint(av, t); /* general case ! */
    1708    71785773 :     p = modii(t, m);
    1709             :   }
    1710    73418764 :   return gerepileuptoint(av, p);
    1711             : }
    1712             : INLINE GEN
    1713    22453362 : Fp_neg(GEN b, GEN m)
    1714             : {
    1715    22453362 :   pari_sp av = avma;
    1716    22453362 :   long s = signe(b);
    1717             :   GEN p;
    1718    22453362 :   if (!s) return gen_0;
    1719    18474270 :   if (s > 0)
    1720             :   {
    1721    17360424 :     p = subii(m, b);
    1722    17358160 :     if (signe(p) >= 0) return p; /* general case ! */
    1723      382900 :     p = modii(p, m);
    1724             :   } else
    1725     1114740 :     p = remii(negi(b), m);
    1726     1497847 :   return gerepileuptoint(av, p);
    1727             : }
    1728             : 
    1729             : INLINE GEN
    1730       83332 : Fp_halve(GEN a, GEN p)
    1731             : {
    1732       83332 :   if (mpodd(a)) a = addii(a,p);
    1733       83332 :   return shifti(a,-1);
    1734             : }
    1735             : 
    1736             : /* assume 0 <= u < p and ps2 = p>>1 */
    1737             : INLINE GEN
    1738    59758270 : Fp_center(GEN u, GEN p, GEN ps2)
    1739    59758270 : { return abscmpii(u,ps2)<=0? icopy(u): subii(u,p); }
    1740             : /* same without copy */
    1741             : INLINE GEN
    1742    12887966 : Fp_center_i(GEN u, GEN p, GEN ps2)
    1743    12887966 : { return abscmpii(u,ps2)<=0? u: subii(u,p); }
    1744             : 
    1745             : /* x + y*z mod p */
    1746             : INLINE GEN
    1747    11113971 : Fp_addmul(GEN x, GEN y, GEN z, GEN p)
    1748             : {
    1749             :   pari_sp av;
    1750    11113971 :   if (!signe(y) || !signe(z)) return Fp_red(x, p);
    1751    10784131 :   if (!signe(x)) return Fp_mul(z,y, p);
    1752     9784777 :   av = avma;
    1753     9784777 :   return gerepileuptoint(av, modii(addii(x, mulii(y,z)), p));
    1754             : }
    1755             : 
    1756             : INLINE GEN
    1757   176230394 : Fp_mul(GEN a, GEN b, GEN m)
    1758             : {
    1759   176230394 :   pari_sp av=avma;
    1760             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1761   176230394 :   (void)new_chunk(lg(a)+lg(b)+(lg(m)<<1));
    1762   176213207 :   p = mulii(a,b);
    1763   176207658 :   set_avma(av); return modii(p,m);
    1764             : }
    1765             : INLINE GEN
    1766    67199121 : Fp_sqr(GEN a, GEN m)
    1767             : {
    1768    67199121 :   pari_sp av=avma;
    1769             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1770    67199121 :   (void)new_chunk((lg(a)+lg(m))<<1);
    1771    66915294 :   p = sqri(a);
    1772    64520111 :   set_avma(av); return remii(p,m); /*Use remii: p >= 0 */
    1773             : }
    1774             : INLINE GEN
    1775    82056475 : Fp_mulu(GEN a, ulong b, GEN m)
    1776             : {
    1777    82056475 :   long l = lgefint(m);
    1778    82056475 :   if (l == 3)
    1779             :   {
    1780    45601454 :     ulong mm = m[2];
    1781    45601454 :     return utoi( Fl_mul(umodiu(a, mm), b, mm) );
    1782             :   } else {
    1783    36455021 :     pari_sp av = avma;
    1784             :     GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1785    36455021 :     (void)new_chunk(lg(a)+1+(l<<1));
    1786    36346908 :     p = muliu(a,b);
    1787    34530380 :     set_avma(av); return modii(p,m);
    1788             :   }
    1789             : }
    1790             : INLINE GEN
    1791       17962 : Fp_muls(GEN a, long b, GEN m)
    1792             : {
    1793       17962 :   long l = lgefint(m);
    1794       17962 :   if (l == 3)
    1795             :   {
    1796        3578 :     ulong mm = m[2];
    1797        3578 :     if (b < 0)
    1798             :     {
    1799        3578 :       ulong t = Fl_mul(umodiu(a, mm), -b, mm);
    1800        3578 :       return t? utoipos(mm - t): gen_0;
    1801             :     }
    1802             :     else
    1803           0 :       return utoi( Fl_mul(umodiu(a, mm), b, mm) );
    1804             :   } else {
    1805       14384 :     pari_sp av = avma;
    1806             :     GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1807       14384 :     (void)new_chunk(lg(a)+1+(l<<1));
    1808       14384 :     p = mulis(a,b);
    1809       14384 :     set_avma(av); return modii(p,m);
    1810             :   }
    1811             : }
    1812             : 
    1813             : INLINE GEN
    1814    26497101 : Fp_inv(GEN a, GEN m)
    1815             : {
    1816             :   GEN res;
    1817    26497101 :   if (! invmod(a,m,&res)) pari_err_INV("Fp_inv", mkintmod(res,m));
    1818    26496638 :   return res;
    1819             : }
    1820             : INLINE GEN
    1821     1116048 : Fp_invsafe(GEN a, GEN m)
    1822             : {
    1823             :   GEN res;
    1824     1116048 :   if (! invmod(a,m,&res)) return NULL;
    1825     1115951 :   return res;
    1826             : }
    1827             : INLINE GEN
    1828     1462472 : Fp_div(GEN a, GEN b, GEN m)
    1829             : {
    1830     1462472 :   pari_sp av = avma;
    1831             :   GEN p;
    1832     1462472 :   if (lgefint(b) == 3)
    1833             :   {
    1834      489908 :     a = Fp_divu(a, b[2], m);
    1835      489908 :     if (signe(b) < 0) a = Fp_neg(a, m);
    1836      489908 :     return a;
    1837             :   }
    1838             :   /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1839      972564 :   (void)new_chunk(lg(a)+(lg(m)<<1));
    1840      972564 :   p = mulii(a, Fp_inv(b,m));
    1841      972564 :   set_avma(av); return modii(p,m);
    1842             : }
    1843             : INLINE GEN
    1844     1738004 : Fp_divu(GEN x, ulong a, GEN p)
    1845             : {
    1846     1738004 :   pari_sp av = avma;
    1847             :   ulong b;
    1848     1738004 :   if (lgefint(p) == 3)
    1849             :   {
    1850     1356873 :     ulong pp = p[2], xp = umodiu(x, pp);
    1851     1356873 :     return xp? utoipos(Fl_div(xp, a % pp, pp)): gen_0;
    1852             :   }
    1853      381131 :   x = Fp_red(x, p);
    1854      381131 :   b = Fl_neg(Fl_div(umodiu(x,a), umodiu(p,a), a), a); /* x + pb = 0 (mod a) */
    1855      381133 :   return gerepileuptoint(av, diviuexact(addmuliu(x, p, b), a));
    1856             : }
    1857             : 
    1858             : INLINE GEN
    1859     1064063 : Flx_mulu(GEN x, ulong a, ulong p) { return Flx_Fl_mul(x,a%p,p); }
    1860             : 
    1861             : INLINE GEN
    1862     2520467 : get_F2x_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1863             : 
    1864             : INLINE long
    1865     2472420 : get_F2x_var(GEN T) { return typ(T)==t_VEC? mael(T,2,1): T[1]; }
    1866             : 
    1867             : INLINE long
    1868     1928472 : get_F2x_degree(GEN T) { return typ(T)==t_VEC? F2x_degree(gel(T,2)): F2x_degree(T); }
    1869             : 
    1870             : INLINE GEN
    1871         427 : get_F2xqX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1872             : 
    1873             : INLINE long
    1874      373702 : get_F2xqX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1875             : 
    1876             : INLINE long
    1877      200312 : get_F2xqX_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1878             : 
    1879             : INLINE GEN
    1880    24476150 : get_Flx_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1881             : 
    1882             : INLINE long
    1883    64959119 : get_Flx_var(GEN T) { return typ(T)==t_VEC? mael(T,2,1): T[1]; }
    1884             : 
    1885             : INLINE long
    1886    83909346 : get_Flx_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1887             : 
    1888             : INLINE GEN
    1889        7987 : get_FlxqX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1890             : 
    1891             : INLINE long
    1892      245905 : get_FlxqX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1893             : 
    1894             : INLINE long
    1895      298332 : get_FlxqX_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1896             : 
    1897             : INLINE GEN
    1898     3380593 : get_FpX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1899             : 
    1900             : INLINE long
    1901     6738482 : get_FpX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1902             : 
    1903             : INLINE long
    1904     5570889 : get_FpX_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1905             : 
    1906             : INLINE GEN
    1907      146583 : get_FpXQX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1908             : 
    1909             : INLINE long
    1910       51890 : get_FpXQX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1911             : 
    1912             : INLINE long
    1913        3551 : get_FpXQX_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1914             : 
    1915             : /*******************************************************************/
    1916             : /*                                                                 */
    1917             : /*                        ADDMULII / SUBMULII                      */
    1918             : /*                                                                 */
    1919             : /*******************************************************************/
    1920             : /* x - y*z */
    1921             : INLINE GEN
    1922    43762194 : submulii(GEN x, GEN y, GEN z)
    1923             : {
    1924    43762194 :   long lx = lgefint(x), ly, lz;
    1925             :   pari_sp av;
    1926             :   GEN t;
    1927    43762194 :   if (lx == 2) { t = mulii(z,y); togglesign(t); return t; }
    1928    38617904 :   ly = lgefint(y);
    1929    38617904 :   if (ly == 2) return icopy(x);
    1930    36535558 :   lz = lgefint(z);
    1931    36535558 :   av = avma; (void)new_chunk(lx+ly+lz); /* HACK */
    1932    36535558 :   t = mulii(z, y);
    1933    36535558 :   set_avma(av); return subii(x,t);
    1934             : }
    1935             : /* y*z - x */
    1936             : INLINE GEN
    1937     3452724 : mulsubii(GEN y, GEN z, GEN x)
    1938             : {
    1939     3452724 :   long lx = lgefint(x), ly, lz;
    1940             :   pari_sp av;
    1941             :   GEN t;
    1942     3452724 :   if (lx == 2) return mulii(z,y);
    1943     2222691 :   ly = lgefint(y);
    1944     2222691 :   if (ly == 2) return negi(x);
    1945     2023941 :   lz = lgefint(z);
    1946     2023941 :   av = avma; (void)new_chunk(lx+ly+lz); /* HACK */
    1947     2023995 :   t = mulii(z, y);
    1948     2023942 :   set_avma(av); return subii(t,x);
    1949             : }
    1950             : 
    1951             : /* x - u*y */
    1952             : INLINE GEN
    1953        7693 : submuliu(GEN x, GEN y, ulong u)
    1954             : {
    1955             :   pari_sp av;
    1956        7693 :   long ly = lgefint(y);
    1957        7693 :   if (ly == 2) return icopy(x);
    1958        7693 :   av = avma;
    1959        7693 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1960        7693 :   y = mului(u,y);
    1961        7693 :   set_avma(av); return subii(x, y);
    1962             : }
    1963             : /* x + u*y */
    1964             : INLINE GEN
    1965      389201 : addmuliu(GEN x, GEN y, ulong u)
    1966             : {
    1967             :   pari_sp av;
    1968      389201 :   long ly = lgefint(y);
    1969      389201 :   if (ly == 2) return icopy(x);
    1970      389201 :   av = avma;
    1971      389201 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1972      389201 :   y = mului(u,y);
    1973      389197 :   set_avma(av); return addii(x, y);
    1974             : }
    1975             : /* x - u*y */
    1976             : INLINE GEN
    1977   126271190 : submuliu_inplace(GEN x, GEN y, ulong u)
    1978             : {
    1979             :   pari_sp av;
    1980   126271190 :   long ly = lgefint(y);
    1981   126271190 :   if (ly == 2) return x;
    1982    86282568 :   av = avma;
    1983    86282568 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1984    86290161 :   y = mului(u,y);
    1985    86288162 :   set_avma(av); return subii(x, y);
    1986             : }
    1987             : /* x + u*y */
    1988             : INLINE GEN
    1989   124883594 : addmuliu_inplace(GEN x, GEN y, ulong u)
    1990             : {
    1991             :   pari_sp av;
    1992   124883594 :   long ly = lgefint(y);
    1993   124883594 :   if (ly == 2) return x;
    1994    86239441 :   av = avma;
    1995    86239441 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1996    86246419 :   y = mului(u,y);
    1997    86244837 :   set_avma(av); return addii(x, y);
    1998             : }
    1999             : /* ux + vy */
    2000             : INLINE GEN
    2001    40101299 : lincombii(GEN u, GEN v, GEN x, GEN y)
    2002             : {
    2003    40101299 :   long lx = lgefint(x), ly;
    2004             :   GEN p1, p2;
    2005             :   pari_sp av;
    2006    40101299 :   if (lx == 2) return mulii(v,y);
    2007    24259362 :   ly = lgefint(y);
    2008    24259362 :   if (ly == 2) return mulii(u,x);
    2009    21599721 :   av = avma; (void)new_chunk(lx+ly+lgefint(u)+lgefint(v)); /* HACK */
    2010    21603779 :   p1 = mulii(u,x);
    2011    21601630 :   p2 = mulii(v,y);
    2012    21601476 :   set_avma(av); return addii(p1,p2);
    2013             : }
    2014             : 
    2015             : /*******************************************************************/
    2016             : /*                                                                 */
    2017             : /*                          GEN SUBTYPES                           */
    2018             : /*                                                                 */
    2019             : /*******************************************************************/
    2020             : 
    2021             : INLINE int
    2022  4105456376 : is_const_t(long t) { return (t < t_POLMOD); }
    2023             : INLINE int
    2024        6853 : is_extscalar_t(long t) { return (t <= t_POL); }
    2025             : INLINE int
    2026     8203021 : is_intreal_t(long t) { return (t <= t_REAL); }
    2027             : INLINE int
    2028   596071498 : is_matvec_t(long t) { return (t >= t_VEC && t <= t_MAT); }
    2029             : INLINE int
    2030    92010812 : is_noncalc_t(long tx) { return (tx) >= t_LIST; }
    2031             : INLINE int
    2032           0 : is_qfb_t(long t) { return (t == t_QFB); }
    2033             : INLINE int
    2034     3751501 : is_rational_t(long t) { return (t == t_INT || t == t_FRAC); }
    2035             : INLINE int
    2036    62051871 : is_real_t(long t) { return (t == t_INT || t == t_REAL || t == t_FRAC); }
    2037             : INLINE int
    2038  7215918907 : is_recursive_t(long t) { return lontyp[t]; }
    2039             : INLINE int
    2040   300578083 : is_scalar_t(long t) { return (t < t_POL); }
    2041             : INLINE int
    2042     1528941 : is_vec_t(long t) { return (t == t_VEC || t == t_COL); }
    2043             : 
    2044             : INLINE int
    2045    56824171 : qfb_is_qfi(GEN q) { return signe(gel(q,4)) < 0; }
    2046             : 
    2047             : /*******************************************************************/
    2048             : /*                                                                 */
    2049             : /*                         TRANSCENDENTAL                          */
    2050             : /*                                                                 */
    2051             : /*******************************************************************/
    2052             : INLINE GEN
    2053    57543342 : sqrtr(GEN x) {
    2054    57543342 :   long s = signe(x);
    2055    57543342 :   if (s == 0) return real_0_bit(expo(x) >> 1);
    2056    57510191 :   if (s >= 0) return sqrtr_abs(x);
    2057      263503 :   retmkcomplex(gen_0, sqrtr_abs(x));
    2058             : }
    2059             : INLINE GEN
    2060           0 : cbrtr_abs(GEN x) { return sqrtnr_abs(x, 3); }
    2061             : INLINE GEN
    2062           0 : cbrtr(GEN x) {
    2063           0 :   long s = signe(x);
    2064             :   GEN r;
    2065           0 :   if (s == 0) return real_0_bit(expo(x) / 3);
    2066           0 :   r = cbrtr_abs(x);
    2067           0 :   if (s < 0) togglesign(r);
    2068           0 :   return r;
    2069             : }
    2070             : INLINE GEN
    2071     1894556 : sqrtnr(GEN x, long n) {
    2072     1894556 :   long s = signe(x);
    2073             :   GEN r;
    2074     1894556 :   if (s == 0) return real_0_bit(expo(x) / n);
    2075     1894556 :   r = sqrtnr_abs(x, n);
    2076     1894580 :   if (s < 0) pari_err_IMPL("sqrtnr for x < 0");
    2077     1894580 :   return r;
    2078             : }
    2079             : INLINE long
    2080      678362 : logint(GEN B, GEN y) { return logintall(B,y,NULL); }
    2081             : INLINE ulong
    2082     2033162 : ulogint(ulong B, ulong y)
    2083             : {
    2084             :   ulong r;
    2085             :   long e;
    2086     2033162 :   if (y == 2) return expu(B);
    2087     1981553 :   r = y;
    2088     5784580 :   for (e=1;; e++)
    2089             :   { /* here, r = y^e, r2 = y^(e-1) */
    2090     5784580 :     if (r >= B) return r == B? e: e-1;
    2091     3804485 :     r = umuluu_or_0(y, r);
    2092     3804579 :     if (!r) return e;
    2093             :   }
    2094             : }
    2095             : 
    2096             : /*******************************************************************/
    2097             : /*                                                                 */
    2098             : /*                         MISCELLANEOUS                           */
    2099             : /*                                                                 */
    2100             : /*******************************************************************/
    2101     8202936 : INLINE int ismpzero(GEN x) { return is_intreal_t(typ(x)) && !signe(x); }
    2102  2545909551 : INLINE int isintzero(GEN x) { return typ(x) == t_INT && !signe(x); }
    2103    15049191 : INLINE int isint1(GEN x) { return typ(x)==t_INT && equali1(x); }
    2104     4587645 : INLINE int isintm1(GEN x){ return typ(x)==t_INT && equalim1(x);}
    2105  1074070345 : INLINE int equali1(GEN n)
    2106  1074070345 : { return (ulong) n[1] == (evallgefint(3UL) | evalsigne(1)) && n[2] == 1; }
    2107   137857632 : INLINE int equalim1(GEN n)
    2108   137857632 : { return (ulong) n[1] == (evallgefint(3UL) | evalsigne(-1)) && n[2] == 1; }
    2109             : /* works only for POSITIVE integers */
    2110  2144439564 : INLINE int is_pm1(GEN n)
    2111  2144439564 : { return lgefint(n) == 3 && n[2] == 1; }
    2112   564866294 : INLINE int is_bigint(GEN n)
    2113   564866294 : { long l = lgefint(n); return l > 3 || (l == 3 && (n[2] & HIGHBIT)); }
    2114             : 
    2115  1897537201 : INLINE int odd(long x) { return x & 1; }
    2116    62321848 : INLINE int both_odd(long x, long y) { return x & y & 1; }
    2117             : 
    2118             : INLINE int
    2119  6793946693 : isonstack(GEN x)
    2120  6793946693 : { return ((pari_sp)x >= pari_mainstack->bot
    2121  6793946693 :        && (pari_sp)x <  pari_mainstack->top); }
    2122             : 
    2123             : /* assume x != 0 and x t_REAL, return an approximation to log2(|x|) */
    2124             : INLINE double
    2125    65823120 : dbllog2r(GEN x)
    2126    65823120 : { return log2((double)(ulong)x[2]) + (double)(expo(x) - (BITS_IN_LONG-1)); }
    2127             : 
    2128             : INLINE GEN
    2129     1329344 : mul_content(GEN cx, GEN cy)
    2130             : {
    2131     1329344 :   if (!cx) return cy;
    2132      522560 :   if (!cy) return cx;
    2133      338076 :   return gmul(cx,cy);
    2134             : }
    2135             : INLINE GEN
    2136           0 : inv_content(GEN c) { return c? ginv(c): NULL; }
    2137             : INLINE GEN
    2138       37010 : div_content(GEN cx, GEN cy)
    2139             : {
    2140       37010 :   if (!cy) return cx;
    2141       35960 :   if (!cx) return ginv(cy);
    2142        7395 :   return gdiv(cx,cy);
    2143             : }
    2144             : INLINE GEN
    2145     5998449 : mul_denom(GEN dx, GEN dy)
    2146             : {
    2147     5998449 :   if (!dx) return dy;
    2148     1695664 :   if (!dy) return dx;
    2149      690724 :   return mulii(dx,dy);
    2150             : }
    2151             : 
    2152             : /* POLYNOMIALS */
    2153             : INLINE GEN
    2154     1327394 : constant_coeff(GEN x) { return signe(x)? gel(x,2): gen_0; }
    2155             : INLINE GEN
    2156   158834890 : leading_coeff(GEN x) { return lg(x) == 2? gen_0: gel(x,lg(x)-1); }
    2157             : INLINE ulong
    2158      671199 : Flx_lead(GEN x) { return lg(x) == 2? 0: x[lg(x)-1]; }
    2159             : INLINE ulong
    2160      124520 : Flx_constant(GEN x) { return lg(x) == 2? 0: x[2]; }
    2161             : INLINE long
    2162  4674281101 : degpol(GEN x) { return lg(x)-3; }
    2163             : INLINE long
    2164  2390790752 : lgpol(GEN x) { return lg(x)-2; }
    2165             : INLINE long
    2166   290738293 : lgcols(GEN x) { return lg(gel(x,1)); }
    2167             : INLINE long
    2168   139648781 : nbrows(GEN x) { return lg(gel(x,1))-1; }
    2169             : INLINE GEN
    2170           0 : truecoef(GEN x, long n) { return polcoef(x,n,-1); }
    2171             : 
    2172             : INLINE GEN
    2173     1450982 : ZXQ_mul(GEN y, GEN x, GEN T) { return ZX_rem(ZX_mul(y, x), T); }
    2174             : INLINE GEN
    2175      603716 : ZXQ_sqr(GEN x, GEN T) { return ZX_rem(ZX_sqr(x), T); }
    2176             : 
    2177             : INLINE GEN
    2178    97155524 : RgX_copy(GEN x)
    2179             : {
    2180             :   long lx, i;
    2181    97155524 :   GEN y = cgetg_copy(x, &lx); y[1] = x[1];
    2182   352860998 :   for (i = 2; i<lx; i++) gel(y,i) = gcopy(gel(x,i));
    2183    97155557 :   return y;
    2184             : }
    2185             : /* have to use ulong to avoid silly warnings from gcc "assuming signed
    2186             :  * overflow does not occur" */
    2187             : INLINE GEN
    2188     2429047 : RgX_coeff(GEN x, long n)
    2189             : {
    2190     2429047 :   ulong l = lg(x);
    2191     2429047 :   return (n < 0 || ((ulong)n+3) > l)? gen_0: gel(x,n+2);
    2192             : }
    2193             : INLINE GEN
    2194      347497 : RgX_renormalize(GEN x) { return RgX_renormalize_lg(x, lg(x)); }
    2195             : INLINE GEN
    2196     6919563 : RgX_div(GEN x, GEN y) { return RgX_divrem(x,y,NULL); }
    2197             : INLINE GEN
    2198        1792 : RgXQX_div(GEN x, GEN y, GEN T) { return RgXQX_divrem(x,y,T,NULL); }
    2199             : INLINE GEN
    2200      105939 : RgXQX_rem(GEN x, GEN y, GEN T) { return RgXQX_divrem(x,y,T,ONLY_REM); }
    2201             : INLINE GEN
    2202     5095672 : FpX_div(GEN x, GEN y, GEN p) { return FpX_divrem(x,y,p, NULL); }
    2203             : INLINE GEN
    2204     1983683 : Flx_div(GEN x, GEN y, ulong p) { return Flx_divrem(x,y,p, NULL); }
    2205             : INLINE GEN
    2206    20602357 : Flx_div_pre(GEN x, GEN y, ulong p, ulong pi)
    2207    20602357 : { return Flx_divrem_pre(x,y,p,pi, NULL); }
    2208             : INLINE GEN
    2209     1259860 : F2x_div(GEN x, GEN y) { return F2x_divrem(x,y, NULL); }
    2210             : INLINE GEN
    2211           0 : FpV_FpC_mul(GEN x, GEN y, GEN p) { return FpV_dotproduct(x,y,p); }
    2212             : INLINE GEN
    2213    96078016 : pol0_Flx(long sv) { return mkvecsmall(sv); }
    2214             : INLINE GEN
    2215    52463586 : pol1_Flx(long sv) { return mkvecsmall2(sv, 1); }
    2216             : INLINE GEN
    2217    35127427 : polx_Flx(long sv) { return mkvecsmall3(sv, 0, 1); }
    2218             : INLINE GEN
    2219           0 : zero_zx(long sv) { return zero_Flx(sv); }
    2220             : INLINE GEN
    2221           0 : polx_zx(long sv) { return polx_Flx(sv); }
    2222             : INLINE GEN
    2223           0 : zx_shift(GEN x, long n) { return Flx_shift(x,n); }
    2224             : INLINE GEN
    2225       14042 : zx_renormalize(GEN x, long l) { return Flx_renormalize(x,l); }
    2226             : INLINE GEN
    2227        1357 : zero_F2x(long sv) { return zero_Flx(sv); }
    2228             : INLINE GEN
    2229    13081737 : pol0_F2x(long sv) { return pol0_Flx(sv); }
    2230             : INLINE GEN
    2231     3900880 : pol1_F2x(long sv) { return pol1_Flx(sv); }
    2232             : INLINE GEN
    2233     1006485 : polx_F2x(long sv) { return mkvecsmall2(sv, 2); }
    2234             : INLINE int
    2235     2870743 : F2x_equal1(GEN x) { return Flx_equal1(x); }
    2236             : INLINE int
    2237     4617853 : F2x_equal(GEN V, GEN W) { return Flx_equal(V,W); }
    2238             : INLINE GEN
    2239    60047823 : F2x_copy(GEN x) { return leafcopy(x); }
    2240             : INLINE GEN
    2241        4074 : F2v_copy(GEN x) { return leafcopy(x); }
    2242             : INLINE GEN
    2243     2377165 : Flv_copy(GEN x) { return leafcopy(x); }
    2244             : INLINE GEN
    2245   166603384 : Flx_copy(GEN x) { return leafcopy(x); }
    2246             : INLINE GEN
    2247     3944062 : vecsmall_copy(GEN x) { return leafcopy(x); }
    2248             : INLINE int
    2249    10047787 : Flx_equal1(GEN x) { return degpol(x)==0 && x[2] == 1; }
    2250             : INLINE int
    2251       24455 : ZX_equal1(GEN x) { return degpol(x)==0 && equali1(gel(x,2)); }
    2252             : INLINE int
    2253     5740617 : ZX_is_monic(GEN x) { return equali1(leading_coeff(x)); }
    2254             : 
    2255             : INLINE GEN
    2256   141928798 : ZX_renormalize(GEN x, long lx)    { return ZXX_renormalize(x,lx); }
    2257             : INLINE GEN
    2258   139435650 : FpX_renormalize(GEN x, long lx)   { return ZXX_renormalize(x,lx); }
    2259             : INLINE GEN
    2260      842719 : FpXX_renormalize(GEN x, long lx)  { return ZXX_renormalize(x,lx); }
    2261             : INLINE GEN
    2262     4587224 : FpXQX_renormalize(GEN x, long lx) { return ZXX_renormalize(x,lx); }
    2263             : INLINE GEN
    2264   119033589 : F2x_renormalize(GEN x, long lx)   { return Flx_renormalize(x,lx); }
    2265             : INLINE GEN
    2266       38392 : F2v_to_F2x(GEN x, long sv) {
    2267       38392 :   GEN y = leafcopy(x);
    2268       38392 :   y[1] = sv; F2x_renormalize(y, lg(y)); return y;
    2269             : }
    2270             : 
    2271             : INLINE long
    2272         385 : sturm(GEN x) { return sturmpart(x, NULL, NULL); }
    2273             : 
    2274             : INLINE long
    2275        4977 : gval(GEN x, long v)
    2276        4977 : { pari_sp av = avma; return gc_long(av, gvaluation(x, pol_x(v))); }
    2277             : 
    2278             : INLINE void
    2279      491180 : RgX_shift_inplace_init(long v)
    2280      491180 : { if (v) (void)cgetg(v, t_VECSMALL); }
    2281             : /* shift polynomial in place. assume v free cells have been left before x */
    2282             : INLINE GEN
    2283      491180 : RgX_shift_inplace(GEN x, long v)
    2284             : {
    2285             :   long i, lx;
    2286             :   GEN z;
    2287      491180 :   if (!v) return x;
    2288      253169 :   lx = lg(x);
    2289      253169 :   if (lx == 2) return x;
    2290      253169 :   z = x + lx;
    2291             :   /* stackdummy's from normalizepol */
    2292      253169 :   while (lg(z) != v) z += lg(z);
    2293      253169 :   z += v;
    2294     4654514 :   for (i = lx-1; i >= 2; i--) gel(--z,0) = gel(x,i);
    2295      675895 :   for (i = 0;  i < v; i++) gel(--z,0) = gen_0;
    2296      253169 :   z -= 2;
    2297      253169 :   z[1] = x[1];
    2298      253169 :   z[0] = evaltyp(t_POL) | evallg(lx+v);
    2299      253169 :   stackdummy((pari_sp)z, (pari_sp)x); return z;
    2300             : }
    2301             : 
    2302             : 
    2303             : /* LINEAR ALGEBRA */
    2304             : INLINE GEN
    2305      494398 : zv_to_ZV(GEN x) { return vecsmall_to_vec(x); }
    2306             : INLINE GEN
    2307     7636953 : zc_to_ZC(GEN x) { return vecsmall_to_col(x); }
    2308             : INLINE GEN
    2309     3418495 : ZV_to_zv(GEN x) { return vec_to_vecsmall(x); }
    2310             : INLINE GEN
    2311           0 : zx_to_zv(GEN x, long N) { return Flx_to_Flv(x,N); }
    2312             : INLINE GEN
    2313      104139 : zv_to_zx(GEN x, long sv) { return Flv_to_Flx(x,sv); }
    2314             : INLINE GEN
    2315           0 : zm_to_zxV(GEN x, long sv) { return Flm_to_FlxV(x,sv); }
    2316             : INLINE GEN
    2317           0 : zero_zm(long x, long y) { return zero_Flm(x,y); }
    2318             : INLINE GEN
    2319    30644138 : zero_zv(long x) { return zero_Flv(x); }
    2320             : INLINE GEN
    2321         266 : zm_transpose(GEN x) { return Flm_transpose(x); }
    2322             : INLINE GEN
    2323           0 : zm_copy(GEN x) { return Flm_copy(x); }
    2324             : INLINE GEN
    2325     2149366 : zv_copy(GEN x) { return Flv_copy(x); }
    2326             : INLINE GEN
    2327           0 : zm_row(GEN x, long i) { return Flm_row(x,i); }
    2328             : 
    2329             : INLINE GEN
    2330    10991411 : ZC_hnfrem(GEN x, GEN y) { return ZC_hnfremdiv(x,y,NULL); }
    2331             : INLINE GEN
    2332      326243 : ZM_hnfrem(GEN x, GEN y) { return ZM_hnfdivrem(x,y,NULL); }
    2333             : INLINE GEN
    2334     3735196 : ZM_lll(GEN x, double D, long f) { return ZM_lll_norms(x,D,f,NULL); }
    2335             : INLINE void
    2336     9231318 : RgM_dimensions(GEN x, long *m, long *n) { *n = lg(x)-1; *m = *n? nbrows(x): 0; }
    2337             : INLINE GEN
    2338    16166962 : RgM_shallowcopy(GEN x)
    2339             : {
    2340             :   long l;
    2341    16166962 :   GEN y = cgetg_copy(x, &l);
    2342    82059033 :   while (--l > 0) gel(y,l) = leafcopy(gel(x,l));
    2343    16166366 :   return y;
    2344             : }
    2345             : INLINE GEN
    2346      194742 : F2m_copy(GEN x) { return RgM_shallowcopy(x); }
    2347             : 
    2348             : INLINE GEN
    2349           0 : F3m_copy(GEN x) { return RgM_shallowcopy(x); }
    2350             : 
    2351             : INLINE GEN
    2352     5945594 : Flm_copy(GEN x) { return RgM_shallowcopy(x); }
    2353             : 
    2354             : /* divisibility: return 1 if y[i] | x[i] for all i, 0 otherwise. Assume
    2355             :  * x,y are ZV of the same length */
    2356             : INLINE int
    2357       23240 : ZV_dvd(GEN x, GEN y)
    2358             : {
    2359       23240 :   long i, l = lg(x);
    2360       36722 :   for (i=1; i < l; i++)
    2361       29575 :     if ( ! dvdii( gel(x,i), gel(y,i) ) ) return 0;
    2362        7147 :   return 1;
    2363             : }
    2364             : INLINE GEN
    2365      535116 : ZM_ZV_mod(GEN x, GEN y)
    2366     1529070 : { pari_APPLY_same(ZV_ZV_mod(gel(x,i), y)) }
    2367             : INLINE GEN
    2368     7304159 : ZV_ZV_mod(GEN x, GEN y)
    2369    18860647 : { pari_APPLY_same(modii(gel(x,i), gel(y,i))) }
    2370             : INLINE GEN
    2371           0 : vecmodii(GEN x, GEN y) { return ZV_ZV_mod(x,y); }
    2372             : INLINE GEN
    2373      174881 : vecmoduu(GEN x, GEN y) { pari_APPLY_ulong(((ulong*)x)[i] % ((ulong*)y)[i]) }
    2374             : 
    2375             : /* Fq */
    2376             : INLINE GEN
    2377     3418341 : Fq_red(GEN x, GEN T, GEN p)
    2378     3418341 : { return typ(x)==t_INT? Fp_red(x,p): FpXQ_red(x,T,p); }
    2379             : INLINE GEN
    2380      101651 : Fq_to_FpXQ(GEN x, GEN T, GEN p /*unused*/)
    2381             : {
    2382             :   (void) p;
    2383      101651 :   return typ(x)==t_INT ? scalarpol(x, get_FpX_var(T)): x;
    2384             : }
    2385             : INLINE GEN
    2386         756 : Rg_to_Fq(GEN x, GEN T, GEN p) { return T? Rg_to_FpXQ(x,T,p): Rg_to_Fp(x,p); }
    2387             : 
    2388             : INLINE GEN
    2389       14623 : gener_Fq_local(GEN T, GEN p, GEN L)
    2390           0 : { return T? gener_FpXQ_local(T,p, L)
    2391       14623 :           : pgener_Fp_local(p, L); }
    2392             : 
    2393             : /* FpXQX */
    2394             : INLINE GEN
    2395        4496 : FpXQX_div(GEN x, GEN y, GEN T, GEN p) { return FpXQX_divrem(x, y, T, p, NULL); }
    2396             : INLINE GEN
    2397           0 : FlxqX_div(GEN x, GEN y, GEN T, ulong p) { return FlxqX_divrem(x, y, T, p, NULL); }
    2398             : INLINE GEN
    2399      163992 : FlxqX_div_pre(GEN x, GEN y, GEN T, ulong p, ulong pi) { return FlxqX_divrem_pre(x, y, T, p, pi, NULL); }
    2400             : INLINE GEN
    2401       33418 : F2xqX_div(GEN x, GEN y, GEN T) { return F2xqX_divrem(x, y, T, NULL); }
    2402             : 
    2403             : INLINE GEN
    2404       20846 : FpXY_Fq_evaly(GEN Q, GEN y, GEN T, GEN p, long vx)
    2405       20846 : { return T ? FpXY_FpXQ_evaly(Q, y, T, p, vx): FpXY_evaly(Q, y, p, vx); }
    2406             : 
    2407             : /* FqX */
    2408             : INLINE GEN
    2409       25445 : FqX_red(GEN z, GEN T, GEN p) { return T? FpXQX_red(z, T, p): FpX_red(z, p); }
    2410             : INLINE GEN
    2411      128933 : FqX_add(GEN x,GEN y,GEN T,GEN p) { return T? FpXX_add(x,y,p): FpX_add(x,y,p); }
    2412             : INLINE GEN
    2413       25502 : FqX_neg(GEN x,GEN T,GEN p) { return T? FpXX_neg(x,p): FpX_neg(x,p); }
    2414             : INLINE GEN
    2415       69664 : FqX_sub(GEN x,GEN y,GEN T,GEN p) { return T? FpXX_sub(x,y,p): FpX_sub(x,y,p); }
    2416             : INLINE GEN
    2417      550336 : FqX_Fp_mul(GEN P, GEN u, GEN T, GEN p)
    2418      550336 : { return T? FpXX_Fp_mul(P, u, p): FpX_Fp_mul(P, u, p); }
    2419             : INLINE GEN
    2420      427606 : FqX_Fq_mul(GEN P, GEN U, GEN T, GEN p)
    2421      427606 : { return typ(U)==t_INT ? FqX_Fp_mul(P, U, T, p): FpXQX_FpXQ_mul(P, U, T, p); }
    2422             : INLINE GEN
    2423      368965 : FqX_mul(GEN x, GEN y, GEN T, GEN p)
    2424      368965 : { return T? FpXQX_mul(x, y, T, p): FpX_mul(x, y, p); }
    2425             : INLINE GEN
    2426       22208 : FqX_mulu(GEN x, ulong y, GEN T, GEN p)
    2427       22208 : { return T? FpXX_mulu(x, y, p): FpX_mulu(x, y, p); }
    2428             : INLINE GEN
    2429       72954 : FqX_sqr(GEN x, GEN T, GEN p)
    2430       72954 : { return T? FpXQX_sqr(x, T, p): FpX_sqr(x, p); }
    2431             : INLINE GEN
    2432        1309 : FqX_powu(GEN x, ulong n, GEN T, GEN p)
    2433        1309 : { return T? FpXQX_powu(x, n, T, p): FpX_powu(x, n, p); }
    2434             : INLINE GEN
    2435       19719 : FqX_halve(GEN x, GEN T, GEN p)
    2436       19719 : { return T? FpXX_halve(x, p): FpX_halve(x, p); }
    2437             : INLINE GEN
    2438       39742 : FqX_div(GEN x, GEN y, GEN T, GEN p)
    2439       39742 : { return T? FpXQX_divrem(x,y,T,p,NULL): FpX_divrem(x,y,p,NULL); }
    2440             : INLINE GEN
    2441        6174 : FqX_get_red(GEN S, GEN T, GEN p)
    2442        6174 : { return T? FpXQX_get_red(S,T,p): FpX_get_red(S,p); }
    2443             : INLINE GEN
    2444       38226 : FqX_rem(GEN x, GEN y, GEN T, GEN p)
    2445       38226 : { return T? FpXQX_rem(x,y,T,p): FpX_rem(x,y,p); }
    2446             : INLINE GEN
    2447           0 : FqX_divrem(GEN x, GEN y, GEN T, GEN p, GEN *z)
    2448           0 : { return T? FpXQX_divrem(x,y,T,p,z): FpX_divrem(x,y,p,z); }
    2449             : INLINE GEN
    2450        5936 : FqX_div_by_X_x(GEN x, GEN y, GEN T, GEN p, GEN *z)
    2451        5936 : { return T? FpXQX_div_by_X_x(x,y,T,p,z): FpX_div_by_X_x(x,y,p,z); }
    2452             : INLINE GEN
    2453           0 : FqX_halfgcd(GEN P,GEN Q,GEN T,GEN p)
    2454           0 : {return T? FpXQX_halfgcd(P,Q,T,p): FpX_halfgcd(P,Q,p);}
    2455             : INLINE GEN
    2456      262654 : FqX_gcd(GEN P,GEN Q,GEN T,GEN p)
    2457      262654 : {return T? FpXQX_gcd(P,Q,T,p): FpX_gcd(P,Q,p);}
    2458             : INLINE GEN
    2459      430940 : FqX_extgcd(GEN P,GEN Q,GEN T,GEN p, GEN *U, GEN *V)
    2460      430940 : { return T? FpXQX_extgcd(P,Q,T,p,U,V): FpX_extgcd(P,Q,p,U,V); }
    2461             : INLINE GEN
    2462        4431 : FqX_normalize(GEN z, GEN T, GEN p)
    2463        4431 : { return T? FpXQX_normalize(z, T, p): FpX_normalize(z, p); }
    2464             : INLINE GEN
    2465      294420 : FqX_deriv(GEN f, GEN T, GEN p) { return T? FpXX_deriv(f, p): FpX_deriv(f, p); }
    2466             : INLINE GEN
    2467           0 : FqX_integ(GEN f, GEN T, GEN p) { return T? FpXX_integ(f, p): FpX_integ(f, p); }
    2468             : INLINE GEN
    2469       87093 : FqX_factor(GEN f, GEN T, GEN p)
    2470       87093 : { return T?FpXQX_factor(f, T, p): FpX_factor(f, p); }
    2471             : INLINE GEN
    2472           7 : FqX_factor_squarefree(GEN f, GEN T, GEN p)
    2473           7 : { return T ? FpXQX_factor_squarefree(f, T, p): FpX_factor_squarefree(f, p); }
    2474             : INLINE GEN
    2475           7 : FqX_ddf(GEN f, GEN T, GEN p)
    2476           7 : { return T ? FpXQX_ddf(f, T, p): FpX_ddf(f, p); }
    2477             : INLINE GEN
    2478       63104 : FqX_degfact(GEN f, GEN T, GEN p)
    2479       63104 : { return T?FpXQX_degfact(f, T, p): FpX_degfact(f, p); }
    2480             : INLINE GEN
    2481        7329 : FqX_roots(GEN f, GEN T, GEN p)
    2482        7329 : { return T?FpXQX_roots(f, T, p): FpX_roots(f, p); }
    2483             : INLINE GEN
    2484         175 : FqX_to_mod(GEN f, GEN T, GEN p)
    2485         175 : { return T?FpXQX_to_mod(f, T, p): FpX_to_mod(f, p); }
    2486             : 
    2487             : /*FqXQ*/
    2488             : INLINE GEN
    2489           0 : FqXQ_add(GEN x, GEN y, GEN S/*unused*/, GEN T, GEN p)
    2490           0 : { (void)S; return T? FpXX_add(x,y,p): FpX_add(x,y,p); }
    2491             : INLINE GEN
    2492           0 : FqXQ_sub(GEN x, GEN y, GEN S/*unused*/, GEN T, GEN p)
    2493           0 : { (void)S; return T? FpXX_sub(x,y,p): FpX_sub(x,y,p); }
    2494             : INLINE GEN
    2495           0 : FqXQ_div(GEN x, GEN y, GEN S, GEN T, GEN p)
    2496           0 : { return T? FpXQXQ_div(x,y,S,T,p): FpXQ_div(x,y,S,p); }
    2497             : INLINE GEN
    2498           0 : FqXQ_inv(GEN x, GEN S, GEN T, GEN p)
    2499           0 : { return T? FpXQXQ_inv(x,S,T,p): FpXQ_inv(x,S,p); }
    2500             : INLINE GEN
    2501           0 : FqXQ_invsafe(GEN x, GEN S, GEN T, GEN p)
    2502           0 : { return T? FpXQXQ_invsafe(x,S,T,p): FpXQ_inv(x,S,p); }
    2503             : INLINE GEN
    2504       23277 : FqXQ_mul(GEN x, GEN y, GEN S, GEN T, GEN p)
    2505       23277 : { return T? FpXQXQ_mul(x,y,S,T,p): FpXQ_mul(x,y,S,p); }
    2506             : INLINE GEN
    2507           0 : FqXQ_sqr(GEN x, GEN S, GEN T, GEN p)
    2508           0 : { return T? FpXQXQ_sqr(x,S,T,p): FpXQ_sqr(x,S,p); }
    2509             : INLINE GEN
    2510           0 : FqXQ_pow(GEN x, GEN n, GEN S, GEN T, GEN p)
    2511           0 : { return T? FpXQXQ_pow(x,n,S,T,p): FpXQ_pow(x,n,S,p); }
    2512             : 
    2513             : /*FqXn*/
    2514             : INLINE GEN
    2515        6681 : FqXn_expint(GEN x, long n, GEN T, GEN p)
    2516        6681 : { return T? FpXQXn_expint(x,n,T,p): FpXn_expint(x,n,p); }
    2517             : INLINE GEN
    2518           0 : FqXn_exp(GEN x, long n, GEN T, GEN p)
    2519           0 : { return T? FpXQXn_exp(x,n,T,p): FpXn_exp(x,n,p); }
    2520             : INLINE GEN
    2521        7217 : FqXn_inv(GEN x, long n, GEN T, GEN p)
    2522        7217 : { return T? FpXQXn_inv(x,n,T,p): FpXn_inv(x,n,p); }
    2523             : INLINE GEN
    2524      267428 : FqXn_mul(GEN x, GEN y, long n, GEN T, GEN p)
    2525      267428 : { return T? FpXQXn_mul(x, y, n, T, p): FpXn_mul(x, y, n, p); }
    2526             : INLINE GEN
    2527           0 : FqXn_sqr(GEN x, long n, GEN T, GEN p)
    2528           0 : { return T? FpXQXn_sqr(x,n,T,p): FpXn_sqr(x,n,p); }
    2529             : 
    2530             : /*FpXQ*/
    2531             : INLINE GEN
    2532           0 : FpXQ_add(GEN x,GEN y,GEN T/*unused*/,GEN p)
    2533           0 : { (void)T; return FpX_add(x,y,p); }
    2534             : INLINE GEN
    2535           0 : FpXQ_sub(GEN x,GEN y,GEN T/*unused*/,GEN p)
    2536           0 : { (void)T; return FpX_sub(x,y,p); }
    2537             : 
    2538             : /*Flxq*/
    2539             : INLINE GEN
    2540           0 : Flxq_add(GEN x,GEN y,GEN T/*unused*/,ulong p)
    2541           0 : { (void)T; return Flx_add(x,y,p); }
    2542             : INLINE GEN
    2543           0 : Flxq_sub(GEN x,GEN y,GEN T/*unused*/,ulong p)
    2544           0 : { (void)T; return Flx_sub(x,y,p); }
    2545             : 
    2546             : /* F2x */
    2547             : 
    2548             : INLINE ulong
    2549   649007014 : F2x_coeff(GEN x,long v)
    2550             : {
    2551   649007014 :    ulong u=(ulong)x[2+divsBIL(v)];
    2552   649005670 :    return (u>>remsBIL(v))&1UL;
    2553             : }
    2554             : 
    2555             : INLINE void
    2556    11601033 : F2x_clear(GEN x,long v)
    2557             : {
    2558    11601033 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2559    11600953 :    *u&=~(1UL<<remsBIL(v));
    2560    11600919 : }
    2561             : 
    2562             : INLINE void
    2563   127048786 : F2x_set(GEN x,long v)
    2564             : {
    2565   127048786 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2566   127047949 :    *u|=1UL<<remsBIL(v);
    2567   127044757 : }
    2568             : 
    2569             : INLINE void
    2570     1566513 : F2x_flip(GEN x,long v)
    2571             : {
    2572     1566513 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2573     1566513 :    *u^=1UL<<remsBIL(v);
    2574     1566513 : }
    2575             : 
    2576             : /* F2v */
    2577             : 
    2578             : INLINE ulong
    2579   642303603 : F2v_coeff(GEN x,long v) { return F2x_coeff(x,v-1); }
    2580             : 
    2581             : INLINE void
    2582    11601046 : F2v_clear(GEN x,long v) { F2x_clear(x,v-1); }
    2583             : 
    2584             : INLINE void
    2585   100260904 : F2v_set(GEN x,long v)   { F2x_set(x,v-1); }
    2586             : 
    2587             : INLINE void
    2588     1566513 : F2v_flip(GEN x,long v) { F2x_flip(x,v-1); }
    2589             : 
    2590             : /* F2m */
    2591             : 
    2592             : INLINE ulong
    2593     6734347 : F2m_coeff(GEN x, long a, long b) { return F2v_coeff(gel(x,b), a); }
    2594             : 
    2595             : INLINE void
    2596           0 : F2m_clear(GEN x, long a, long b) { F2v_clear(gel(x,b), a); }
    2597             : 
    2598             : INLINE void
    2599         672 : F2m_set(GEN x, long a, long b) { F2v_set(gel(x,b), a); }
    2600             : 
    2601             : INLINE void
    2602     1566513 : F2m_flip(GEN x, long a, long b) { F2v_flip(gel(x,b), a); }
    2603             : 
    2604             : /* F3m */
    2605             : 
    2606             : INLINE ulong
    2607     1837024 : F3m_coeff(GEN x, long a, long b) { return F3v_coeff(gel(x,b), a); }
    2608             : 
    2609             : INLINE void
    2610           0 : F3m_set(GEN x, long a, long b, ulong c) { F3v_set(gel(x,b), a, c); }
    2611             : 
    2612             : /* ARITHMETIC */
    2613             : INLINE GEN
    2614       34167 : matpascal(long n) { return matqpascal(n, NULL); }
    2615             : INLINE long
    2616      454463 : Z_issquare(GEN x) { return Z_issquareall(x, NULL); }
    2617             : INLINE long
    2618          98 : Z_ispower(GEN x, ulong k) { return Z_ispowerall(x, k, NULL); }
    2619             : INLINE GEN
    2620     5929363 : sqrti(GEN x) { return sqrtremi(x,NULL); }
    2621             : INLINE GEN
    2622   130026747 : gaddgs(GEN y, long s) { return gaddsg(s,y); }
    2623             : INLINE int
    2624      579526 : gcmpgs(GEN y, long s) { return -gcmpsg(s,y); }
    2625             : INLINE int
    2626       24983 : gequalgs(GEN y, long s) { return gequalsg(s,y); }
    2627             : INLINE GEN
    2628           0 : gmaxsg(long s, GEN y) { return gmaxgs(y,s); }
    2629             : INLINE GEN
    2630           0 : gminsg(long s, GEN y) { return gmings(y,s); }
    2631             : INLINE GEN
    2632    45860738 : gmulgs(GEN y, long s) { return gmulsg(s,y); }
    2633             : INLINE GEN
    2634   133618809 : gmulgu(GEN y, ulong s) { return gmulug(s,y); }
    2635             : INLINE GEN
    2636     1404791 : gsubgs(GEN y, long s) { return gaddgs(y, -s); }
    2637             : INLINE GEN
    2638      679604 : gdivsg(long s, GEN y) { return gdiv(stoi(s), y); }
    2639             : 
    2640             : INLINE GEN
    2641    13508885 : gmax_shallow(GEN x, GEN y) { return gcmp(x,y)<0? y: x; }
    2642             : INLINE GEN
    2643      870036 : gmin_shallow(GEN x, GEN y) { return gcmp(x,y)<0? x: y; }
    2644             : 
    2645             : /* x t_COMPLEX */
    2646             : INLINE GEN
    2647    77335509 : cxnorm(GEN x) { return gadd(gsqr(gel(x,1)), gsqr(gel(x,2))); }
    2648             : /* q t_QUAD */
    2649             : INLINE GEN
    2650       69860 : quadnorm(GEN q)
    2651             : {
    2652       69860 :   GEN X = gel(q,1), b = gel(X,3), c = gel(X,2);
    2653       69860 :   GEN z, u = gel(q,3), v = gel(q,2);
    2654       69860 :   if (typ(u) == t_INT && typ(v) == t_INT) /* generic case */
    2655             :   {
    2656       69671 :     z = signe(b)? mulii(v, addii(u,v)): sqri(v);
    2657       69671 :     return addii(z, mulii(c, sqri(u)));
    2658             :   }
    2659             :   else
    2660             :   {
    2661         189 :     z = signe(b)? gmul(v, gadd(u,v)): gsqr(v);
    2662         189 :     return gadd(z, gmul(c, gsqr(u)));
    2663             :   }
    2664             : }
    2665             : /* x a t_QUAD, return the attached discriminant */
    2666             : INLINE GEN
    2667        1078 : quad_disc(GEN x)
    2668             : {
    2669        1078 :   GEN Q = gel(x,1), b = gel(Q,3), c = gel(Q,2), c4 = shifti(c,2);
    2670        1078 :   if (is_pm1(b)) return subsi(1, c4);
    2671         154 :   togglesign_safe(&c4); return c4;
    2672             : }
    2673             : INLINE GEN
    2674       85169 : qfb_disc3(GEN x, GEN y, GEN z) { return subii(sqri(y), shifti(mulii(x,z),2)); }
    2675             : INLINE GEN
    2676    18287232 : qfb_disc(GEN x) { return gel(x,4); }
    2677             : 
    2678             : INLINE GEN
    2679     3019383 : sqrfrac(GEN x)
    2680             : {
    2681     3019383 :   GEN z = cgetg(3,t_FRAC);
    2682     3019383 :   gel(z,1) = sqri(gel(x,1));
    2683     3019383 :   gel(z,2) = sqri(gel(x,2)); return z;
    2684             : }
    2685             : 
    2686             : INLINE void
    2687    15129988 : normalize_frac(GEN z) {
    2688    15129988 :   if (signe(gel(z,2)) < 0) { togglesign(gel(z,1)); setabssign(gel(z,2)); }
    2689    15129988 : }
    2690             : 
    2691             : INLINE GEN
    2692      664417 : powii(GEN x, GEN n)
    2693             : {
    2694      664417 :   long ln = lgefint(n);
    2695      664417 :   if (ln == 3) {
    2696             :     GEN z;
    2697      641797 :     if (signe(n) > 0) return powiu(x, n[2]);
    2698       69953 :     z = cgetg(3, t_FRAC);
    2699       69963 :     gel(z,1) = gen_1;
    2700       69963 :     gel(z,2) = powiu(x, n[2]);
    2701       69965 :     return z;
    2702             :   }
    2703       22620 :   if (ln == 2) return gen_1; /* rare */
    2704             :   /* should never happen */
    2705           0 :   return powgi(x, n); /* overflow unless x = 0, 1, -1 */
    2706             : }
    2707             : INLINE GEN
    2708        1575 : powIs(long n) {
    2709        1575 :   switch(n & 3)
    2710             :   {
    2711          63 :     case 1: return mkcomplex(gen_0,gen_1);
    2712         385 :     case 2: return gen_m1;
    2713         721 :     case 3: return mkcomplex(gen_0,gen_m1);
    2714             :   }
    2715         406 :   return gen_1;
    2716             : }
    2717             : 
    2718             : /*******************************************************************/
    2719             : /*                                                                 */
    2720             : /*                             ASSIGNMENTS                         */
    2721             : /*                                                                 */
    2722             : /*******************************************************************/
    2723           0 : INLINE void mpexpz(GEN x, GEN z)
    2724           0 : { pari_sp av = avma; gaffect(mpexp(x), z); set_avma(av); }
    2725           0 : INLINE void mplogz(GEN x, GEN z)
    2726           0 : { pari_sp av = avma; gaffect(mplog(x), z); set_avma(av); }
    2727           0 : INLINE void mpcosz(GEN x, GEN z)
    2728           0 : { pari_sp av = avma; gaffect(mpcos(x), z); set_avma(av); }
    2729           0 : INLINE void mpsinz(GEN x, GEN z)
    2730           0 : { pari_sp av = avma; gaffect(mpsin(x), z); set_avma(av); }
    2731           0 : INLINE void gnegz(GEN x, GEN z)
    2732           0 : { pari_sp av = avma; gaffect(gneg(x), z); set_avma(av); }
    2733           0 : INLINE void gabsz(GEN x, long prec, GEN z)
    2734           0 : { pari_sp av = avma; gaffect(gabs(x,prec), z); set_avma(av); }
    2735           0 : INLINE void gaddz(GEN x, GEN y, GEN z)
    2736           0 : { pari_sp av = avma; gaffect(gadd(x,y), z); set_avma(av); }
    2737           0 : INLINE void gsubz(GEN x, GEN y, GEN z)
    2738           0 : { pari_sp av = avma; gaffect(gsub(x,y), z); set_avma(av); }
    2739           0 : INLINE void gmulz(GEN x, GEN y, GEN z)
    2740           0 : { pari_sp av = avma; gaffect(gmul(x,y), z); set_avma(av); }
    2741           0 : INLINE void gdivz(GEN x, GEN y, GEN z)
    2742           0 : { pari_sp av = avma; gaffect(gdiv(x,y), z); set_avma(av); }
    2743           0 : INLINE void gdiventz(GEN x, GEN y, GEN z)
    2744           0 : { pari_sp av = avma; gaffect(gdivent(x,y), z); set_avma(av); }
    2745           0 : INLINE void gmodz(GEN x, GEN y, GEN z)
    2746           0 : { pari_sp av = avma; gaffect(gmod(x,y), z); set_avma(av); }
    2747           0 : INLINE void gmul2nz(GEN x, long s, GEN z)
    2748           0 : { pari_sp av = avma; gaffect(gmul2n(x,s), z); set_avma(av); }
    2749           0 : INLINE void gshiftz(GEN x, long s, GEN z)
    2750           0 : { pari_sp av = avma; gaffect(gshift(x,s), z); set_avma(av); }
    2751             : 
    2752             : /*******************************************************************/
    2753             : /*                                                                 */
    2754             : /*                       ELLIPTIC CURVES                           */
    2755             : /*                                                                 */
    2756             : /*******************************************************************/
    2757     4221560 : INLINE GEN ell_get_a1(GEN e) { return gel(e,1); }
    2758     3211779 : INLINE GEN ell_get_a2(GEN e) { return gel(e,2); }
    2759     4047203 : INLINE GEN ell_get_a3(GEN e) { return gel(e,3); }
    2760     3981143 : INLINE GEN ell_get_a4(GEN e) { return gel(e,4); }
    2761     4767911 : INLINE GEN ell_get_a6(GEN e) { return gel(e,5); }
    2762     3395266 : INLINE GEN ell_get_b2(GEN e) { return gel(e,6); }
    2763     1059544 : INLINE GEN ell_get_b4(GEN e) { return gel(e,7); }
    2764     1665919 : INLINE GEN ell_get_b6(GEN e) { return gel(e,8); }
    2765     1491485 : INLINE GEN ell_get_b8(GEN e) { return gel(e,9); }
    2766     6102543 : INLINE GEN ell_get_c4(GEN e) { return gel(e,10); }
    2767     7298991 : INLINE GEN ell_get_c6(GEN e) { return gel(e,11); }
    2768     9254452 : INLINE GEN ell_get_disc(GEN e) { return gel(e,12); }
    2769     1044820 : INLINE GEN ell_get_j(GEN e) { return gel(e,13); }
    2770     9962159 : INLINE long ell_get_type(GEN e) { return mael(e,14,1); }
    2771     1609734 : INLINE GEN ellff_get_field(GEN x) { return gmael(x, 15, 1); }
    2772      688952 : INLINE GEN ellff_get_a4a6(GEN x)  { return gmael(x, 15, 2); }
    2773        1484 : INLINE GEN ellQp_get_zero(GEN x) { return gmael(x, 15, 1); }
    2774         315 : INLINE long ellQp_get_prec(GEN E) { GEN z = ellQp_get_zero(E); return valp(z); }
    2775        1134 : INLINE GEN ellQp_get_p(GEN E) { GEN z = ellQp_get_zero(E); return gel(z,2); }
    2776       38878 : INLINE long ellR_get_prec(GEN x) { return nbits2prec(mael3(x, 15, 1, 1)); }
    2777       18139 : INLINE long ellR_get_sign(GEN x) { return mael3(x, 15, 1, 2); }
    2778      736486 : INLINE GEN ellnf_get_nf(GEN x) { return checknf_i(gmael(x,15,1)); }
    2779          70 : INLINE GEN ellnf_get_bnf(GEN x) { return checkbnf_i(gmael(x,15,1)); }
    2780             : 
    2781     4119424 : INLINE int checkell_i(GEN e) { return typ(e) == t_VEC && lg(e) == 17; }
    2782    42469043 : INLINE int ell_is_inf(GEN z) { return lg(z) == 2; }
    2783      957385 : INLINE GEN ellinf(void) { return mkvec(gen_0); }
    2784             : 
    2785             : /*******************************************************************/
    2786             : /*                                                                 */
    2787             : /*                    ALGEBRAIC NUMBER THEORY                      */
    2788             : /*                                                                 */
    2789             : /*******************************************************************/
    2790    20644728 : INLINE GEN modpr_get_pr(GEN x)  { return gel(x,3); }
    2791      726222 : INLINE GEN modpr_get_p(GEN x)  { return pr_get_p(modpr_get_pr(x)); }
    2792     8612754 : INLINE GEN modpr_get_T(GEN x)  { return lg(x) == 4? NULL: gel(x,4); }
    2793             : 
    2794    76190047 : INLINE GEN pr_get_p(GEN pr)  { return gel(pr,1); }
    2795    10743535 : INLINE GEN pr_get_gen(GEN pr){ return gel(pr,2); }
    2796             : /* .[2] instead of itos works: e and f are small positive integers */
    2797     8594541 : INLINE long pr_get_e(GEN pr) { return gel(pr,3)[2]; }
    2798    26235610 : INLINE long pr_get_f(GEN pr) { return gel(pr,4)[2]; }
    2799    49210528 : INLINE GEN pr_get_tau(GEN pr){ return gel(pr,5); }
    2800             : INLINE int
    2801     8567628 : pr_is_inert(GEN P) { return typ(pr_get_tau(P)) == t_INT; }
    2802             : INLINE GEN
    2803     1214876 : pr_norm(GEN pr) { return powiu(pr_get_p(pr), pr_get_f(pr)); }
    2804             : INLINE ulong
    2805      343935 : upr_norm(GEN pr) { return upowuu(pr_get_p(pr)[2], pr_get_f(pr)); }
    2806             : 
    2807             : /* assume nf a genuine nf */
    2808             : INLINE long
    2809      831256 : nf_get_varn(GEN nf) { return varn(gel(nf,1)); }
    2810             : INLINE GEN
    2811    77174351 : nf_get_pol(GEN nf) { return gel(nf,1); }
    2812             : INLINE long
    2813    54189681 : nf_get_degree(GEN nf) { return degpol( nf_get_pol(nf) ); }
    2814             : INLINE long
    2815     5911250 : nf_get_r1(GEN nf) { GEN x = gel(nf,2); return itou(gel(x,1)); }
    2816             : INLINE long
    2817        4146 : nf_get_r2(GEN nf) { GEN x = gel(nf,2); return itou(gel(x,2)); }
    2818             : INLINE GEN
    2819      445868 : nf_get_disc(GEN nf) { return gel(nf,3); }
    2820             : INLINE GEN
    2821     3145851 : nf_get_index(GEN nf) { return gel(nf,4); }
    2822             : INLINE GEN
    2823     5760825 : nf_get_M(GEN nf) { return gmael(nf,5,1); }
    2824             : INLINE GEN
    2825      547458 : nf_get_G(GEN nf) { return gmael(nf,5,2); }
    2826             : INLINE GEN
    2827     1925914 : nf_get_roundG(GEN nf) { return gmael(nf,5,3); }
    2828             : INLINE GEN
    2829       22202 : nf_get_Tr(GEN nf) { return gmael(nf,5,4); }
    2830             : INLINE GEN
    2831        4564 : nf_get_diff(GEN nf) { return gmael(nf,5,5); }
    2832             : INLINE GEN
    2833       56967 : nf_get_ramified_primes(GEN nf) { return gmael(nf,5,8); }
    2834             : INLINE GEN
    2835     1240304 : nf_get_roots(GEN nf) { return gel(nf,6); }
    2836             : INLINE GEN
    2837        1813 : nf_get_zk(GEN nf)
    2838             : {
    2839        1813 :   GEN y = gel(nf,7), D = gel(y, 1);
    2840        1813 :   if (typ(D) == t_POL) D = gel(D, 2);
    2841        1813 :   if (!equali1(D)) y = gdiv(y, D);
    2842        1813 :   return y;
    2843             : }
    2844             : INLINE GEN
    2845     3710681 : nf_get_zkprimpart(GEN nf)
    2846             : {
    2847     3710681 :   GEN y = gel(nf,7);
    2848             :   /* test for old format of nf.zk: non normalized */
    2849     3710681 :   if (!equali1(gel(nf,4)) && gequal1(gel(y,1))) y = Q_remove_denom(y,NULL);
    2850     3710671 :   return y;
    2851             : }
    2852             : INLINE GEN
    2853     3757297 : nf_get_zkden(GEN nf)
    2854             : {
    2855     3757297 :   GEN y = gel(nf,7), D = gel(y,1);
    2856     3757297 :   if (typ(D) == t_POL) D = gel(D,2);
    2857             :   /* test for old format of nf.zk: non normalized */
    2858     3757297 :   if (!equali1(gel(nf,4)) && equali1(D)) D = Q_denom(y);
    2859     3757274 :   return D;
    2860             : }
    2861             : INLINE GEN
    2862     8922030 : nf_get_invzk(GEN nf) { return gel(nf,8); }
    2863             : INLINE void
    2864      285539 : nf_get_sign(GEN nf, long *r1, long *r2)
    2865             : {
    2866      285539 :   GEN x = gel(nf,2);
    2867      285539 :   *r1 = itou(gel(x,1));
    2868      285539 :   *r2 = itou(gel(x,2));
    2869      285540 : }
    2870             : 
    2871             : INLINE GEN
    2872     2492990 : cyc_get_expo(GEN c) { return lg(c) == 1? gen_1: gel(c,1); }
    2873             : INLINE GEN
    2874      390305 : abgrp_get_no(GEN x) { return gel(x,1); }
    2875             : INLINE GEN
    2876    11484372 : abgrp_get_cyc(GEN x) { return gel(x,2); }
    2877             : INLINE GEN
    2878     1651467 : abgrp_get_gen(GEN x) { return gel(x,3); }
    2879             : INLINE GEN
    2880     9397908 : bnf_get_nf(GEN bnf) { return gel(bnf,7); }
    2881             : INLINE GEN
    2882     5085794 : bnf_get_clgp(GEN bnf) { return gmael(bnf,8,1); }
    2883             : INLINE GEN
    2884        8352 : bnf_get_no(GEN bnf) { return abgrp_get_no(bnf_get_clgp(bnf)); }
    2885             : INLINE GEN
    2886     3499323 : bnf_get_cyc(GEN bnf) { return abgrp_get_cyc(bnf_get_clgp(bnf)); }
    2887             : INLINE GEN
    2888     1577958 : bnf_get_gen(GEN bnf)  { return abgrp_get_gen(bnf_get_clgp(bnf)); }
    2889             : INLINE GEN
    2890         639 : bnf_get_reg(GEN bnf) { return gmael(bnf,8,2); }
    2891             : INLINE GEN
    2892     2699024 : bnf_get_logfu(GEN bnf) { return gel(bnf,3); }
    2893             : INLINE GEN
    2894     1276933 : bnf_get_sunits(GEN bnf)
    2895     1276933 : { GEN s = gmael(bnf,8,3); return typ(s) == t_INT? NULL: s; }
    2896             : INLINE GEN
    2897      290062 : bnf_get_tuU(GEN bnf) { return gmael3(bnf,8,4,2); }
    2898             : INLINE long
    2899      264741 : bnf_get_tuN(GEN bnf) { return gmael3(bnf,8,4,1)[2]; }
    2900             : INLINE GEN
    2901      287699 : bnf_get_fu_nocheck(GEN bnf) { return gmael(bnf,8,5); }
    2902             : INLINE GEN
    2903       26268 : nfV_to_scalar_or_alg(GEN nf, GEN x)
    2904       63353 : { pari_APPLY_same(nf_to_scalar_or_alg(nf, gel(x,i))) }
    2905             : INLINE GEN
    2906       25834 : bnf_get_fu(GEN bnf) {
    2907       25834 :   GEN fu = bnf_build_units(bnf), nf = bnf_get_nf(bnf);
    2908       25834 :   if (typ(fu) == t_MAT) pari_err(e_MISC,"missing units in bnf");
    2909       25834 :   return nfV_to_scalar_or_alg(nf, vecslice(fu, 2, lg(fu)-1));
    2910             : }
    2911             : 
    2912             : INLINE GEN
    2913     3624345 : bnr_get_bnf(GEN bnr) { return gel(bnr,1); }
    2914             : INLINE GEN
    2915     1932980 : bnr_get_bid(GEN bnr) { return gel(bnr,2); }
    2916             : INLINE GEN
    2917      140000 : bnr_get_mod(GEN bnr) { return gmael(bnr,2,1); }
    2918             : INLINE GEN
    2919     1257689 : bnr_get_nf(GEN bnr) { return gmael(bnr,1,7); }
    2920             : INLINE GEN
    2921     2722204 : bnr_get_clgp(GEN bnr) { return gel(bnr,5); }
    2922             : INLINE GEN
    2923      313898 : bnr_get_no(GEN bnr) { return abgrp_get_no(bnr_get_clgp(bnr)); }
    2924             : INLINE GEN
    2925     2390764 : bnr_get_cyc(GEN bnr) { return abgrp_get_cyc(bnr_get_clgp(bnr)); }
    2926             : INLINE GEN
    2927          70 : bnr_get_gen_nocheck(GEN bnr) { return abgrp_get_gen(bnr_get_clgp(bnr)); }
    2928             : INLINE GEN
    2929        7847 : bnr_get_gen(GEN bnr) {
    2930        7847 :   GEN G = bnr_get_clgp(bnr);
    2931        7847 :   if (lg(G) !=  4)
    2932           0 :     pari_err(e_MISC,"missing bnr generators: please use bnrinit(,,1)");
    2933        7847 :   return gel(G,3);
    2934             : }
    2935             : 
    2936             : /* localstar, used in gchar */
    2937             : INLINE GEN
    2938       51222 : locs_get_cyc(GEN locs) { return gel(locs,1); }
    2939             : INLINE GEN
    2940      191667 : locs_get_Lsprk(GEN locs) { return gel(locs,2); }
    2941             : INLINE GEN
    2942        1260 : locs_get_Lgenfil(GEN locs) { return gel(locs,3); }
    2943             : INLINE GEN
    2944        8071 : locs_get_mod(GEN locs) { return gel(locs,4); }
    2945             : /* pr dividing the modulus N of locs, 0 <= i < v_pr(N)
    2946             :  * return a t_MAT whose columns are the logs
    2947             :  * of generators of U_i(pr)/U_{i+1}(pr). */
    2948             : INLINE GEN
    2949        1260 : locs_get_famod(GEN locs) { return gmael(locs,4,1); }
    2950             : INLINE GEN
    2951      206976 : locs_get_m_infty(GEN locs) { return gmael(locs,4,2); }
    2952             : 
    2953             : /* G a grossenchar group */
    2954             : INLINE GEN
    2955       32093 : gchar_get_basis(GEN gc)  { return  gel(gc, 1); }
    2956             : INLINE GEN
    2957      203371 : gchar_get_bnf(GEN gc)    { return  gel(gc, 2); }
    2958             : INLINE GEN
    2959      240161 : gchar_get_nf(GEN gc)    { return  gel(gc, 3); }
    2960             : INLINE GEN
    2961      278022 : gchar_get_zm(GEN gc)     { return  gel(gc, 4); }
    2962             : INLINE GEN
    2963        8071 : gchar_get_mod(GEN gc)    { return  locs_get_mod(gchar_get_zm(gc)); }
    2964             : INLINE GEN
    2965        4025 : gchar_get_modP(GEN gc)    { return gmael(gchar_get_mod(gc),1,1); }
    2966             : INLINE GEN
    2967       36398 : gchar_get_S(GEN gc)      { return  gel(gc, 5); }
    2968             : INLINE GEN
    2969      188440 : gchar_get_DLdata(GEN gc)   { return  gel(gc, 6); }
    2970             : INLINE GEN
    2971        1925 : gchar_get_sfu(GEN gc) { return  gel(gc, 7); }
    2972             : INLINE GEN
    2973       15839 : gchar_get_cyc(GEN gc)    { return  gel(gc, 9); }
    2974             : INLINE GEN
    2975           0 : gchar_get_hnf(GEN gc)    { return  gmael(gc, 10, 1); }
    2976             : INLINE GEN
    2977           0 : gchar_get_U(GEN gc)      { return  gmael(gc, 10, 2); }
    2978             : INLINE GEN
    2979       10731 : gchar_get_Ui(GEN gc)     { return  gmael(gc, 10, 3); }
    2980             : INLINE GEN
    2981        3484 : gchar_get_m0(GEN gc)     { return gel(gc, 11); }
    2982             : INLINE GEN
    2983        4624 : gchar_get_u0(GEN gc)     { return gel(gc, 12); }
    2984             : INLINE long
    2985       17185 : gchar_get_r1(GEN gc)     { return nf_get_r1(gchar_get_nf(gc)); }
    2986             : INLINE long
    2987         623 : gchar_get_r2(GEN gc)     { return nf_get_r2(gchar_get_nf(gc)); }
    2988             : INLINE GEN
    2989       49614 : gchar_get_loccyc(GEN gc) { return locs_get_cyc(gchar_get_zm(gc)); }
    2990             : INLINE long
    2991       36664 : gchar_get_nc(GEN gc)     { return lg(gchar_get_loccyc(gc))-1; }
    2992             : INLINE long
    2993       36398 : gchar_get_ns(GEN gc)     { return lg(gchar_get_S(gc))-1; }
    2994             : INLINE long
    2995        1841 : gchar_get_nm(GEN gc)     { return lg(gchar_get_basis(gc))-1; }
    2996             : INLINE long
    2997        4004 : gchar_get_evalprec(GEN gc)   { return  gmael(gc, 8, 1)[1]; }
    2998             : INLINE long
    2999       18459 : gchar_get_prec(GEN gc)   { return  gmael(gc, 8, 1)[2]; }
    3000             : INLINE long
    3001       13153 : gchar_get_nfprec(GEN gc) { return  gmael(gc, 8, 1)[3]; }
    3002             : INLINE void
    3003        1757 : gchar_set_evalprec(GEN gc, long prec) { gmael(gc, 8, 1)[1] = prec; }
    3004             : INLINE void
    3005        1188 : gchar_set_prec(GEN gc, long prec) { gmael(gc, 8, 1)[2] = prec; }
    3006             : INLINE void
    3007        1188 : gchar_copy_precs(GEN gc, GEN gc2)
    3008             : {
    3009        1188 :   gel(gc2, 8) = shallowcopy(gel(gc,8));
    3010        1188 :   gmael(gc2, 8, 1) = shallowcopy(gmael(gc, 8, 1));
    3011        1188 : }
    3012             : INLINE void
    3013        3113 : gchar_set_nfprec(GEN gc, long prec) { gmael(gc, 8, 1)[3] = prec; }
    3014             : INLINE long
    3015         322 : gchar_get_ntors(GEN gc)   { return  gmael(gc, 8, 2)[1]; }
    3016             : INLINE long
    3017         322 : gchar_get_nfree(GEN gc)   { return  gmael(gc, 8, 2)[2]; }
    3018             : INLINE long
    3019        2028 : gchar_get_nalg(GEN gc)   { return  gmael(gc, 8, 2)[3]; }
    3020             : INLINE void
    3021        1559 : gchar_set_basis(GEN gc, GEN m_inv)  { gel(gc, 1) = m_inv; }
    3022             : INLINE void
    3023        2352 : gchar_set_nf(GEN gc, GEN nf)      { gel(gc, 3) = nf; }
    3024             : INLINE void
    3025         623 : gchar_set_ntors(GEN gc, long n)    { gmael(gc, 8, 2)[1] = n; }
    3026             : INLINE void
    3027         623 : gchar_set_nfree(GEN gc, long n)    { gmael(gc, 8, 2)[2] = n; }
    3028             : INLINE void
    3029         623 : gchar_set_nalg(GEN gc, long n)    { gmael(gc, 8, 2)[3] = n; }
    3030             : INLINE void
    3031        1559 : gchar_set_cyc(GEN gc, GEN cyc)      { gel(gc, 9) = cyc; }
    3032             : INLINE void
    3033         623 : gchar_set_HUUi(GEN gc, GEN hnf, GEN U, GEN Ui) { gel(gc, 10) = mkvec3(hnf, U, Ui); }
    3034             : INLINE void
    3035         936 : gchar_set_m0(GEN gc, GEN m0)     { gel(gc, 11) = m0; }
    3036             : INLINE void
    3037        2093 : gchar_set_u0(GEN gc, GEN u0)     { gel(gc, 12) = u0; }
    3038             : 
    3039             : INLINE GEN
    3040     1383040 : bid_get_mod(GEN bid) { return gel(bid,1); }
    3041             : INLINE GEN
    3042       71183 : bid_get_ideal(GEN bid) { return gmael(bid,1,1); }
    3043             : INLINE GEN
    3044       34944 : bid_get_arch(GEN bid) { return gmael(bid,1,2); }
    3045             : INLINE GEN
    3046     5403507 : bid_get_grp(GEN bid) { return gel(bid,2); }
    3047             : INLINE GEN
    3048     2308939 : bid_get_fact(GEN bid) { return gmael(bid,3,1); }
    3049             : INLINE GEN
    3050     2020796 : bid_get_fact2(GEN bid) { return gmael(bid,3,2); }
    3051             : INLINE GEN
    3052     1987002 : bid_get_sprk(GEN bid) { return gmael(bid,4,1); }
    3053             : INLINE GEN
    3054       51016 : bid_get_sarch(GEN bid) { return gmael(bid,4,2); }
    3055             : INLINE GEN
    3056     2212829 : bid_get_archp(GEN bid) { return gmael3(bid,4,2,2); }
    3057             : INLINE GEN
    3058     3370368 : bid_get_U(GEN bid) { return gel(bid,5); }
    3059             : INLINE GEN
    3060           0 : bid_get_no(GEN bid) { return abgrp_get_no(bid_get_grp(bid)); }
    3061             : INLINE GEN
    3062     5349841 : bid_get_cyc(GEN bid) { return abgrp_get_cyc(bid_get_grp(bid)); }
    3063             : INLINE GEN
    3064           0 : bid_get_gen_nocheck(GEN bid)  { return abgrp_get_gen(bid_get_grp(bid)); }
    3065             : INLINE GEN
    3066       53086 : bid_get_gen(GEN bid) {
    3067       53086 :   GEN G = bid_get_grp(bid);
    3068       53086 :   if (lg(G) != 4) pari_err(e_MISC,"missing bid generators. Use idealstar(,,2)");
    3069       53086 :   return abgrp_get_gen(G);
    3070             : }
    3071             : 
    3072             : INLINE GEN
    3073    29877219 : znstar_get_N(GEN G) { return gmael(G,1,1); }
    3074             : INLINE GEN
    3075     7118743 : znstar_get_faN(GEN G) { return gel(G,3); }
    3076             : INLINE GEN
    3077          14 : znstar_get_no(GEN G) { return abgrp_get_no(gel(G,2)); }
    3078             : INLINE GEN
    3079      228586 : znstar_get_cyc(GEN G) { return abgrp_get_cyc(gel(G,2)); }
    3080             : INLINE GEN
    3081       16150 : znstar_get_gen(GEN G) { return abgrp_get_gen(gel(G,2)); }
    3082             : INLINE GEN
    3083     7759564 : znstar_get_conreycyc(GEN G) { return gmael(G,4,5); }
    3084             : INLINE GEN
    3085     3210572 : znstar_get_conreygen(GEN G) { return gmael(G,4,4); }
    3086             : INLINE GEN
    3087       46788 : znstar_get_Ui(GEN G) { return gmael(G,4,3); }
    3088             : INLINE GEN
    3089      156031 : znstar_get_U(GEN G) { return gel(G,5); }
    3090             : INLINE GEN
    3091     2813049 : znstar_get_pe(GEN G) { return gmael(G,4,1); }
    3092             : INLINE GEN
    3093       35773 : gal_get_pol(GEN gal) { return gel(gal,1); }
    3094             : INLINE GEN
    3095        6006 : gal_get_p(GEN gal) { return gmael(gal,2,1); }
    3096             : INLINE GEN
    3097          91 : gal_get_e(GEN gal) { return gmael(gal,2,2); }
    3098             : INLINE GEN
    3099       23631 : gal_get_mod(GEN gal) { return gmael(gal,2,3); }
    3100             : INLINE GEN
    3101       32245 : gal_get_roots(GEN gal) { return gel(gal,3); }
    3102             : INLINE GEN
    3103       27387 : gal_get_invvdm(GEN gal) { return gel(gal,4); }
    3104             : INLINE GEN
    3105       27387 : gal_get_den(GEN gal) { return gel(gal,5); }
    3106             : INLINE GEN
    3107       79386 : gal_get_group(GEN gal) { return gel(gal,6); }
    3108             : INLINE GEN
    3109        8946 : gal_get_gen(GEN gal) { return gel(gal,7); }
    3110             : INLINE GEN
    3111        6944 : gal_get_orders(GEN gal) { return gel(gal,8); }
    3112             : 
    3113             : /* assume rnf a genuine rnf */
    3114             : INLINE long
    3115     1212244 : rnf_get_degree(GEN rnf) { return degpol(rnf_get_pol(rnf)); }
    3116             : INLINE long
    3117       16982 : rnf_get_nfdegree(GEN rnf) { return degpol(nf_get_pol(rnf_get_nf(rnf))); }
    3118             : INLINE long
    3119      763616 : rnf_get_absdegree(GEN rnf) { return degpol(gmael(rnf,11,1)); }
    3120             : INLINE GEN
    3121         742 : rnf_get_idealdisc(GEN rnf) { return gmael(rnf,3,1); }
    3122             : INLINE GEN
    3123         812 : rnf_get_k(GEN rnf) { return gmael(rnf,11,3); }
    3124             : INLINE GEN
    3125         917 : rnf_get_alpha(GEN rnf) { return gmael(rnf, 11, 2); }
    3126             : INLINE GEN
    3127      448048 : rnf_get_nf(GEN rnf) { return gel(rnf,10); }
    3128             : INLINE GEN
    3129        4228 : rnf_get_nfzk(GEN rnf) { return gel(rnf,2); }
    3130             : INLINE GEN
    3131      219743 : rnf_get_polabs(GEN rnf) { return gmael(rnf,11,1); }
    3132             : INLINE GEN
    3133     1464853 : rnf_get_pol(GEN rnf) { return gel(rnf,1); }
    3134             : INLINE GEN
    3135         238 : rnf_get_disc(GEN rnf) { return gel(rnf,3); }
    3136             : INLINE GEN
    3137         105 : rnf_get_index(GEN rnf) { return gel(rnf,4); }
    3138             : INLINE GEN
    3139        1778 : rnf_get_ramified_primes(GEN rnf) { return gel(rnf,5); }
    3140             : INLINE long
    3141         231 : rnf_get_varn(GEN rnf) { return varn(gel(rnf,1)); }
    3142             : INLINE GEN
    3143      192759 : rnf_get_nfpol(GEN rnf) { return gmael(rnf,10,1); }
    3144             : INLINE long
    3145        3367 : rnf_get_nfvarn(GEN rnf) { return varn(gmael(rnf,10,1)); }
    3146             : INLINE GEN
    3147        3724 : rnf_get_zk(GEN rnf) { return gel(rnf,7); }
    3148             : INLINE GEN
    3149      105151 : rnf_get_map(GEN rnf) { return gel(rnf,11); }
    3150             : INLINE GEN
    3151        1197 : rnf_get_invzk(GEN rnf) { return gel(rnf,8); }
    3152             : 
    3153             : INLINE GEN
    3154      135778 : idealred(GEN nf, GEN I) { return idealred0(nf, I, NULL); }
    3155             : 
    3156             : INLINE GEN
    3157        2406 : idealchineseinit(GEN nf, GEN x)
    3158        2406 : { return idealchinese(nf,x,NULL); }
    3159             : 
    3160             : /*******************************************************************/
    3161             : /*                                                                 */
    3162             : /*                              CLOSURES                           */
    3163             : /*                                                                 */
    3164             : /*******************************************************************/
    3165   352401606 : INLINE long closure_arity(GEN C)          { return ((ulong)C[1])&ARITYBITS; }
    3166    37406523 : INLINE long closure_is_variadic(GEN C) { return !!(((ulong)C[1])&VARARGBITS); }
    3167   308493266 : INLINE const char *closure_codestr(GEN C)  { return GSTR(gel(C,2))-1; }
    3168           0 : INLINE GEN closure_get_code(GEN C)  { return gel(C,2); }
    3169   308474802 : INLINE GEN closure_get_oper(GEN C)  { return gel(C,3); }
    3170   308459400 : INLINE GEN closure_get_data(GEN C)  { return gel(C,4); }
    3171       12536 : INLINE GEN closure_get_dbg(GEN C)   { return gel(C,5); }
    3172       29015 : INLINE GEN closure_get_text(GEN C)  { return gel(C,6); }
    3173     8199839 : INLINE GEN closure_get_frame(GEN C) { return gel(C,7); }
    3174             : 
    3175             : /*******************************************************************/
    3176             : /*                                                                 */
    3177             : /*                               ERRORS                            */
    3178             : /*                                                                 */
    3179             : /*******************************************************************/
    3180             : INLINE long
    3181       59017 : err_get_num(GEN e) { return e[1]; }
    3182             : INLINE GEN
    3183         273 : err_get_compo(GEN e, long i) { return gel(e, i+1); }
    3184             : 
    3185             : INLINE void
    3186          14 : pari_err_BUG(const char *f) { pari_err(e_BUG,f); }
    3187             : INLINE void
    3188          21 : pari_err_CONSTPOL(const char *f) { pari_err(e_CONSTPOL, f); }
    3189             : INLINE void
    3190          84 : pari_err_COPRIME(const char *f, GEN x, GEN y) { pari_err(e_COPRIME, f,x,y); }
    3191             : INLINE void
    3192         648 : pari_err_DIM(const char *f) { pari_err(e_DIM, f); }
    3193             : INLINE void
    3194           0 : pari_err_FILE(const char *f, const char *g) { pari_err(e_FILE, f,g); }
    3195             : INLINE void
    3196          36 : pari_err_FILEDESC(const char *f, long n) { pari_err(e_FILEDESC, f,n); }
    3197             : INLINE void
    3198          98 : pari_err_FLAG(const char *f) { pari_err(e_FLAG,f); }
    3199             : INLINE void
    3200         476 : pari_err_IMPL(const char *f) { pari_err(e_IMPL,f); }
    3201             : INLINE void
    3202       19998 : pari_err_INV(const char *f, GEN x) { pari_err(e_INV,f,x); }
    3203             : INLINE void
    3204          63 : pari_err_IRREDPOL(const char *f, GEN x) { pari_err(e_IRREDPOL, f,x); }
    3205             : INLINE void
    3206        2645 : 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); }
    3207             : INLINE void
    3208         200 : pari_err_COMPONENT(const char *f, const char *op, GEN l, GEN x) { pari_err(e_COMPONENT, f,op,l,x); }
    3209             : INLINE void
    3210           0 : pari_err_MAXPRIME(ulong c) { pari_err(e_MAXPRIME, c); }
    3211             : INLINE void
    3212         378 : pari_err_OP(const char *f, GEN x, GEN y) { pari_err(e_OP, f,x,y); }
    3213             : INLINE void
    3214         149 : pari_err_OVERFLOW(const char *f) { pari_err(e_OVERFLOW, f); }
    3215             : INLINE void
    3216         239 : pari_err_PREC(const char *f) { pari_err(e_PREC,f); }
    3217             : INLINE void
    3218           0 : pari_err_PACKAGE(const char *f) { pari_err(e_PACKAGE,f); }
    3219             : INLINE void
    3220          77 : pari_err_PRIME(const char *f, GEN x) { pari_err(e_PRIME, f,x); }
    3221             : INLINE void
    3222         756 : pari_err_MODULUS(const char *f, GEN x, GEN y) { pari_err(e_MODULUS, f,x,y); }
    3223             : INLINE void
    3224          56 : pari_err_ROOTS0(const char *f) { pari_err(e_ROOTS0, f); }
    3225             : INLINE void
    3226          84 : pari_err_SQRTN(const char *f, GEN x) { pari_err(e_SQRTN, f,x); }
    3227             : INLINE void
    3228       14117 : pari_err_TYPE(const char *f, GEN x) { pari_err(e_TYPE, f,x); }
    3229             : INLINE void
    3230        3493 : pari_err_TYPE2(const char *f, GEN x, GEN y) { pari_err(e_TYPE2, f,x,y); }
    3231             : INLINE void
    3232         287 : pari_err_VAR(const char *f, GEN x, GEN y) { pari_err(e_VAR, f,x,y); }
    3233             : INLINE void
    3234         231 : pari_err_PRIORITY(const char *f, GEN x, const char *op, long v)
    3235         231 : { pari_err(e_PRIORITY, f,x,op,v); }
    3236             : 

Generated by: LCOV version 1.14