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.14.0 lcov report (development 27377-eea28b22aa) Lines: 1438 1588 90.6 %
Date: 2022-01-28 08:19:09 Functions: 637 709 89.8 %
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             : /*                       MALLOC/FREE WRAPPERS                        */
      17             : /*********************************************************************/
      18             : #define BLOCK_SIGALRM_START          \
      19             : {                                    \
      20             :   int block=PARI_SIGINT_block;       \
      21             :   PARI_SIGINT_block = 2;             \
      22             :   MT_SIGINT_BLOCK(block);
      23             : 
      24             : #define BLOCK_SIGINT_START           \
      25             : {                                    \
      26             :   int block=PARI_SIGINT_block;       \
      27             :   PARI_SIGINT_block = 1;             \
      28             :   MT_SIGINT_BLOCK(block);
      29             : 
      30             : #define BLOCK_SIGINT_END             \
      31             :   PARI_SIGINT_block = block;         \
      32             :   MT_SIGINT_UNBLOCK(block);          \
      33             :   if (!block && PARI_SIGINT_pending) \
      34             :   {                                  \
      35             :     int sig = PARI_SIGINT_pending;   \
      36             :     PARI_SIGINT_pending = 0;         \
      37             :     raise(sig);                      \
      38             :   }                                  \
      39             : }
      40             : 
      41             : /*******************************************************************/
      42             : /*                                                                 */
      43             : /*                          CONSTRUCTORS                           */
      44             : /*                                                                 */
      45             : /*******************************************************************/
      46             : #define retmkfrac(x,y)\
      47             :   do { GEN _v = cgetg(3, t_FRAC);\
      48             :        gel(_v,1) = (x);\
      49             :        gel(_v,2) = (y); return _v; } while(0)
      50             : #define retmkrfrac(x,y)\
      51             :   do { GEN _v = cgetg(3, t_RFRAC);\
      52             :        gel(_v,1) = (x);\
      53             :        gel(_v,2) = (y); return _v; } while(0)
      54             : #define retmkintmod(x,y)\
      55             :   do { GEN _v = cgetg(3, t_INTMOD);\
      56             :        gel(_v,1) = (y);\
      57             :        gel(_v,2) = (x); return _v; } while(0)
      58             : #define retmkcomplex(x,y)\
      59             :   do { GEN _v = cgetg(3, t_COMPLEX);\
      60             :        gel(_v,1) = (x);\
      61             :        gel(_v,2) = (y); return _v; } while(0)
      62             : #define retmkpolmod(x,y)\
      63             :   do { GEN _v = cgetg(3, t_POLMOD);\
      64             :        gel(_v,1) = (y);\
      65             :        gel(_v,2) = (x); return _v; } while(0)
      66             : #define retmkvec(x)\
      67             :   do { GEN _v = cgetg(2, t_VEC);\
      68             :        gel(_v,1) = (x); return _v; } while(0)
      69             : #define retmkvec2(x,y)\
      70             :   do { GEN _v = cgetg(3, t_VEC);\
      71             :        gel(_v,1) = (x);\
      72             :        gel(_v,2) = (y); return _v; } while(0)
      73             : #define retmkvec3(x,y,z)\
      74             :   do { GEN _v = cgetg(4, t_VEC);\
      75             :        gel(_v,1) = (x);\
      76             :        gel(_v,2) = (y);\
      77             :        gel(_v,3) = (z); return _v; } while(0)
      78             : #define retmkqfb(x,y,z,d)\
      79             :   do { GEN _v = cgetg(5, t_QFB);\
      80             :        gel(_v,1) = (x);\
      81             :        gel(_v,2) = (y);\
      82             :        gel(_v,3) = (z);\
      83             :        gel(_v,4) = (d); return _v; } while(0)
      84             : #define retmkquad(x,y,z)\
      85             :   do { GEN _v = cgetg(4, t_QUAD);\
      86             :        gel(_v,1) = (x);\
      87             :        gel(_v,2) = (y);\
      88             :        gel(_v,3) = (z); return _v; } while(0)
      89             : #define retmkvec4(x,y,z,t)\
      90             :   do { GEN _v = cgetg(5, t_VEC);\
      91             :        gel(_v,1) = (x);\
      92             :        gel(_v,2) = (y);\
      93             :        gel(_v,3) = (z);\
      94             :        gel(_v,4) = (t); return _v; } while(0)
      95             : #define retmkvec5(x,y,z,t,u)\
      96             :   do { GEN _v = cgetg(6, t_VEC);\
      97             :        gel(_v,1) = (x);\
      98             :        gel(_v,2) = (y);\
      99             :        gel(_v,3) = (z);\
     100             :        gel(_v,4) = (t);\
     101             :        gel(_v,5) = (u); return _v; } while(0)
     102             : #define retmkcol(x)\
     103             :   do { GEN _v = cgetg(2, t_COL);\
     104             :        gel(_v,1) = (x); return _v; } while(0)
     105             : #define retmkcol2(x,y)\
     106             :   do { GEN _v = cgetg(3, t_COL);\
     107             :        gel(_v,1) = (x);\
     108             :        gel(_v,2) = (y); return _v; } while(0)
     109             : #define retmkcol3(x,y,z)\
     110             :   do { GEN _v = cgetg(4, t_COL);\
     111             :        gel(_v,1) = (x);\
     112             :        gel(_v,2) = (y);\
     113             :        gel(_v,3) = (z); return _v; } while(0)
     114             : #define retmkcol4(x,y,z,t)\
     115             :   do { GEN _v = cgetg(5, t_COL);\
     116             :        gel(_v,1) = (x);\
     117             :        gel(_v,2) = (y);\
     118             :        gel(_v,3) = (z);\
     119             :        gel(_v,4) = (t); return _v; } while(0)
     120             : #define retmkcol5(x,y,z,t,u)\
     121             :   do { GEN _v = cgetg(6, t_COL);\
     122             :        gel(_v,1) = (x);\
     123             :        gel(_v,2) = (y);\
     124             :        gel(_v,3) = (z);\
     125             :        gel(_v,4) = (t);\
     126             :        gel(_v,5) = (u); return _v; } while(0)
     127             : #define retmkcol6(x,y,z,t,u,v)\
     128             :   do { GEN _v = cgetg(7, t_COL);\
     129             :        gel(_v,1) = (x);\
     130             :        gel(_v,2) = (y);\
     131             :        gel(_v,3) = (z);\
     132             :        gel(_v,4) = (t);\
     133             :        gel(_v,5) = (u);\
     134             :        gel(_v,6) = (v); return _v; } while(0)
     135             : #define retmkmat(x)\
     136             :   do { GEN _v = cgetg(2, t_MAT);\
     137             :        gel(_v,1) = (x); return _v; } while(0)
     138             : #define retmkmat2(x,y)\
     139             :   do { GEN _v = cgetg(3, t_MAT);\
     140             :        gel(_v,1) = (x);\
     141             :        gel(_v,2) = (y); return _v; } while(0)
     142             : #define retmkmat3(x,y,z)\
     143             :   do { GEN _v = cgetg(4, t_MAT);\
     144             :        gel(_v,1) = (x);\
     145             :        gel(_v,2) = (y);\
     146             :        gel(_v,3) = (z); return _v; } while(0)
     147             : #define retmkmat4(x,y,z,t)\
     148             :   do { GEN _v = cgetg(5, t_MAT);\
     149             :        gel(_v,1) = (x);\
     150             :        gel(_v,2) = (y);\
     151             :        gel(_v,3) = (z);\
     152             :        gel(_v,4) = (t); return _v; } while(0)
     153             : #define retmkmat5(x,y,z,t,u)\
     154             :   do { GEN _v = cgetg(6, t_MAT);\
     155             :        gel(_v,1) = (x);\
     156             :        gel(_v,2) = (y);\
     157             :        gel(_v,3) = (z);\
     158             :        gel(_v,4) = (t);\
     159             :        gel(_v,5) = (u); return _v; } while(0)
     160             : 
     161             : INLINE GEN
     162     6517514 : mkintmod(GEN x, GEN y) { retmkintmod(x,y); }
     163             : INLINE GEN
     164        1666 : mkintmodu(ulong x, ulong y) {
     165        1666 :   GEN v = cgetg(3,t_INTMOD);
     166        1666 :   gel(v,1) = utoipos(y);
     167        1666 :   gel(v,2) = utoi(x); return v;
     168             : }
     169             : INLINE GEN
     170     2583769 : mkpolmod(GEN x, GEN y) { retmkpolmod(x,y); }
     171             : INLINE GEN
     172    29260274 : mkfrac(GEN x, GEN y) { retmkfrac(x,y); }
     173             : INLINE GEN
     174     1205515 : mkfracss(long x, long y) { retmkfrac(stoi(x),utoipos(y)); }
     175             : /* q = n/d a t_FRAC or t_INT; recover (n,d) */
     176             : INLINE void
     177       18053 : Qtoss(GEN q, long *n, long *d)
     178             : {
     179       18053 :   if (typ(q) == t_INT) { *n = itos(q); *d = 1; }
     180        5607 :   else { *n = itos(gel(q,1)); *d = itou(gel(q,2)); }
     181       18053 : }
     182             : INLINE GEN
     183      739963 : sstoQ(long n, long d)
     184             : {
     185             :   ulong r;
     186             :   long g, q;
     187      739963 :   if (!n)
     188             :   {
     189       91826 :     if (!d) pari_err_INV("sstoQ",gen_0);
     190       91826 :     return gen_0;
     191             :   }
     192      648137 :   if (d < 0) { d = -d; n = -n; }
     193      648137 :   if (d == 1) return stoi(n);
     194      636461 :   r = labs(n);
     195      636461 :   if (r == 1) retmkfrac(n > 0? gen_1: gen_m1, utoipos(d));
     196      602476 :   q = udivuu_rem(r, d, &r);
     197      602476 :   if (!r) return n > 0? utoipos(q): utoineg(q);
     198      551866 :   g = ugcd(d,r); /* gcd(n,d) */
     199      551866 :   if (g != 1) { n /= g; d /= g; }
     200      551866 :   retmkfrac(stoi(n), utoipos(d));
     201             : }
     202             : 
     203             : INLINE GEN
     204   157821236 : uutoQ(ulong n, ulong d)
     205             : {
     206             :   ulong r;
     207             :   long g, q;
     208   157821236 :   if (!n)
     209             :   {
     210        9438 :     if (!d) pari_err_INV("uutoQ",gen_0);
     211        9438 :     return gen_0;
     212             :   }
     213   157811798 :   if (d == 1) return utoipos(n);
     214   157800703 :   if (n == 1) retmkfrac(gen_1, utoipos(d));
     215   157713511 :   q = udivuu_rem(n,d,&r);
     216   157713511 :   if (!r) return utoipos(q);
     217     5105741 :   g = ugcd(d,r); /* gcd(n,d) */
     218     5105741 :   if (g != 1) { n /= g; d /= g; }
     219     5105741 :   retmkfrac(utoipos(n), utoipos(d));
     220             : }
     221             : 
     222             : INLINE GEN
     223     3800323 : mkfraccopy(GEN x, GEN y) { retmkfrac(icopy(x), icopy(y)); }
     224             : INLINE GEN
     225       10248 : mkrfrac(GEN x, GEN y) { GEN v = cgetg(3, t_RFRAC);
     226       10248 :   gel(v,1) = x; gel(v,2) = y; return v; }
     227             : INLINE GEN
     228           7 : mkrfraccopy(GEN x, GEN y) { GEN v = cgetg(3, t_RFRAC);
     229           7 :   gel(v,1) = gcopy(x); gel(v,2) = gcopy(y); return v; }
     230             : INLINE GEN
     231    89239416 : mkcomplex(GEN x, GEN y) { retmkcomplex(x,y); }
     232             : INLINE GEN
     233      869889 : gen_I(void) { return mkcomplex(gen_0, gen_1); }
     234             : INLINE GEN
     235      293089 : cgetc(long l) { retmkcomplex(cgetr(l), cgetr(l)); }
     236             : INLINE GEN
     237       69132 : mkquad(GEN n, GEN x, GEN y) { GEN v = cgetg(4, t_QUAD);
     238       69132 :   gel(v,1) = n; gel(v,2) = x; gel(v,3) = y; return v; }
     239             : /* vecsmall */
     240             : INLINE GEN
     241   114153108 : mkvecsmall(long x) { GEN v = cgetg(2, t_VECSMALL); v[1] = x; return v; }
     242             : INLINE GEN
     243   516768291 : mkvecsmall2(long x,long y) { GEN v = cgetg(3, t_VECSMALL);
     244   516741516 :   v[1]=x; v[2]=y; return v; }
     245             : INLINE GEN
     246   229306503 : mkvecsmall3(long x,long y,long z) { GEN v = cgetg(4, t_VECSMALL);
     247   229287919 :   v[1]=x; v[2]=y; v[3]=z; return v; }
     248             : INLINE GEN
     249    13923350 : mkvecsmall4(long x,long y,long z,long t) { GEN v = cgetg(5, t_VECSMALL);
     250    13910732 :   v[1]=x; v[2]=y; v[3]=z; v[4]=t; return v; }
     251             : INLINE GEN
     252      576132 : mkvecsmall5(long x,long y,long z,long t,long u) { GEN v = cgetg(6, t_VECSMALL);
     253      576132 :   v[1]=x; v[2]=y; v[3]=z; v[4]=t; v[5]=u; return v; }
     254             : 
     255             : INLINE GEN
     256    16868322 : mkqfb(GEN x, GEN y, GEN z, GEN d) { retmkqfb(x,y,z,d); }
     257             : /* vec */
     258             : INLINE GEN
     259    58786883 : mkvec(GEN x) { retmkvec(x); }
     260             : INLINE GEN
     261   146456885 : mkvec2(GEN x, GEN y) { retmkvec2(x,y); }
     262             : INLINE GEN
     263   160613951 : mkvec3(GEN x, GEN y, GEN z) { retmkvec3(x,y,z); }
     264             : INLINE GEN
     265     5924691 : mkvec4(GEN x, GEN y, GEN z, GEN t) { retmkvec4(x,y,z,t); }
     266             : INLINE GEN
     267    14455169 : mkvec5(GEN x, GEN y, GEN z, GEN t, GEN u) { retmkvec5(x,y,z,t,u); }
     268             : INLINE GEN
     269         126 : mkvecs(long x) { retmkvec(stoi(x)); }
     270             : INLINE GEN
     271      208949 : mkvec2s(long x, long y) { retmkvec2(stoi(x),stoi(y)); }
     272             : INLINE GEN
     273      488650 : mkvec3s(long x, long y, long z) { retmkvec3(stoi(x),stoi(y),stoi(z)); }
     274             : INLINE GEN
     275          21 : mkvec4s(long x, long y, long z, long t) { retmkvec4(stoi(x),stoi(y),stoi(z),stoi(t)); }
     276             : INLINE GEN
     277       35854 : mkveccopy(GEN x) { GEN v = cgetg(2, t_VEC); gel(v,1) = gcopy(x); return v; }
     278             : INLINE GEN
     279      121412 : mkvec2copy(GEN x, GEN y) {
     280      121412 :   GEN v = cgetg(3,t_VEC); gel(v,1) = gcopy(x); gel(v,2) = gcopy(y); return v; }
     281             : /* col */
     282             : INLINE GEN
     283     5338244 : mkcol(GEN x) { retmkcol(x); }
     284             : INLINE GEN
     285   251059202 : mkcol2(GEN x, GEN y) { retmkcol2(x,y); }
     286             : INLINE GEN
     287       85067 : mkcol3(GEN x, GEN y, GEN z) { retmkcol3(x,y,z); }
     288             : INLINE GEN
     289           0 : mkcol4(GEN x, GEN y, GEN z, GEN t) { retmkcol4(x,y,z,t); }
     290             : INLINE GEN
     291          87 : mkcol5(GEN x, GEN y, GEN z, GEN t, GEN u) { retmkcol5(x,y,z,t,u); }
     292             : INLINE GEN
     293       11979 : mkcol6(GEN x, GEN y, GEN z, GEN t, GEN u, GEN v) { retmkcol6(x,y,z,t,u,v); }
     294             : INLINE GEN
     295       36589 : mkcols(long x) { retmkcol(stoi(x)); }
     296             : INLINE GEN
     297     2761556 : mkcol2s(long x, long y) { retmkcol2(stoi(x),stoi(y)); }
     298             : INLINE GEN
     299         301 : mkcol3s(long x, long y, long z) { retmkcol3(stoi(x),stoi(y),stoi(z)); }
     300             : INLINE GEN
     301           0 : mkcol4s(long x, long y, long z, long t) { retmkcol4(stoi(x),stoi(y),stoi(z),stoi(t)); }
     302             : INLINE GEN
     303       27956 : mkcolcopy(GEN x) { GEN v = cgetg(2, t_COL); gel(v,1) = gcopy(x); return v; }
     304             : /* mat */
     305             : INLINE GEN
     306     3707516 : mkmat(GEN x) { retmkmat(x); }
     307             : INLINE GEN
     308    38247052 : mkmat2(GEN x, GEN y) { retmkmat2(x,y); }
     309             : INLINE GEN
     310       16317 : mkmat3(GEN x, GEN y, GEN z) { retmkmat3(x,y,z); }
     311             : INLINE GEN
     312           0 : mkmat4(GEN x, GEN y, GEN z, GEN t) { retmkmat4(x,y,z,t); }
     313             : INLINE GEN
     314           0 : mkmat5(GEN x, GEN y, GEN z, GEN t, GEN u) { retmkmat5(x,y,z,t,u); }
     315             : INLINE GEN
     316      115329 : mkmatcopy(GEN x) { GEN v = cgetg(2, t_MAT); gel(v,1) = gcopy(x); return v; }
     317             : INLINE GEN
     318           0 : mkerr(long x) { GEN v = cgetg(2, t_ERROR); v[1] = x; return v; }
     319             : INLINE GEN
     320      199217 : mkoo(void) { GEN v = cgetg(2, t_INFINITY); gel(v,1) = gen_1; return v; }
     321             : INLINE GEN
     322      102639 : mkmoo(void) { GEN v = cgetg(2, t_INFINITY); gel(v,1) = gen_m1; return v; }
     323             : INLINE long
     324      313637 : inf_get_sign(GEN x) { return signe(gel(x,1)); }
     325             : INLINE GEN
     326       12432 : mkmat22s(long a, long b, long c, long d) {retmkmat2(mkcol2s(a,c),mkcol2s(b,d));}
     327             : INLINE GEN
     328    39593693 : mkmat22(GEN a, GEN b, GEN c, GEN d) { retmkmat2(mkcol2(a,c),mkcol2(b,d)); }
     329             : 
     330             : /* pol */
     331             : INLINE GEN
     332     2471675 : pol_x(long v) {
     333     2471675 :   GEN p = cgetg(4, t_POL);
     334     2471694 :   p[1] = evalsigne(1)|evalvarn(v);
     335     2471694 :   gel(p,2) = gen_0;
     336     2471694 :   gel(p,3) = gen_1; return p;
     337             : }
     338             : /* x^n, assume n >= 0 */
     339             : INLINE GEN
     340     2146474 : pol_xn(long n, long v) {
     341     2146474 :   long i, a = n+2;
     342     2146474 :   GEN p = cgetg(a+1, t_POL);
     343     2146478 :   p[1] = evalsigne(1)|evalvarn(v);
     344     5051529 :   for (i = 2; i < a; i++) gel(p,i) = gen_0;
     345     2146478 :   gel(p,a) = gen_1; return p;
     346             : }
     347             : /* x^n, no assumption on n */
     348             : INLINE GEN
     349         287 : pol_xnall(long n, long v)
     350             : {
     351         287 :   if (n < 0) retmkrfrac(gen_1, pol_xn(-n,v));
     352         280 :   return pol_xn(n, v);
     353             : }
     354             : /* x^n, assume n >= 0 */
     355             : INLINE GEN
     356         210 : polxn_Flx(long n, long sv) {
     357         210 :   long i, a = n+2;
     358         210 :   GEN p = cgetg(a+1, t_VECSMALL);
     359         210 :   p[1] = sv;
     360        1022 :   for (i = 2; i < a; i++) p[i] = 0;
     361         210 :   p[a] = 1; return p;
     362             : }
     363             : INLINE GEN
     364     3189641 : pol_1(long v) {
     365     3189641 :   GEN p = cgetg(3, t_POL);
     366     3189634 :   p[1] = evalsigne(1)|evalvarn(v);
     367     3189634 :   gel(p,2) = gen_1; return p;
     368             : }
     369             : INLINE GEN
     370    33012978 : pol_0(long v)
     371             : {
     372    33012978 :   GEN x = cgetg(2,t_POL);
     373    33012963 :   x[1] = evalvarn(v); return x;
     374             : }
     375             : #define retconst_vec(n,x)\
     376             :   do { long _i, _n = (n);\
     377             :        GEN _v = cgetg(_n+1, t_VEC), _x = (x);\
     378             :        for (_i = 1; _i <= _n; _i++) gel(_v,_i) = _x;\
     379             :        return _v; } while(0)
     380             : INLINE GEN
     381   202130148 : const_vec(long n, GEN x) { retconst_vec(n, x); }
     382             : #define retconst_col(n,x)\
     383             :   do { long _i, _n = (n);\
     384             :        GEN _v = cgetg(_n+1, t_COL), _x = (x);\
     385             :        for (_i = 1; _i <= _n; _i++) gel(_v,_i) = _x;\
     386             :        return _v; } while(0)
     387             : INLINE GEN
     388    37061414 : const_col(long n, GEN x) { retconst_col(n, x); }
     389             : INLINE GEN
     390    16025086 : const_vecsmall(long n, long c)
     391             : {
     392             :   long i;
     393    16025086 :   GEN V = cgetg(n+1,t_VECSMALL);
     394   584487148 :   for(i=1;i<=n;i++) V[i] = c;
     395    16025485 :   return V;
     396             : }
     397             : 
     398             : /***   ZERO   ***/
     399             : /* O(p^e) */
     400             : INLINE GEN
     401      827231 : zeropadic(GEN p, long e)
     402             : {
     403      827231 :   GEN y = cgetg(5,t_PADIC);
     404      827237 :   gel(y,4) = gen_0;
     405      827237 :   gel(y,3) = gen_1;
     406      827237 :   gel(y,2) = icopy(p);
     407      827132 :   y[1] = evalvalp(e) | _evalprecp(0);
     408      827111 :   return y;
     409             : }
     410             : INLINE GEN
     411        4592 : zeropadic_shallow(GEN p, long e)
     412             : {
     413        4592 :   GEN y = cgetg(5,t_PADIC);
     414        4592 :   gel(y,4) = gen_0;
     415        4592 :   gel(y,3) = gen_1;
     416        4592 :   gel(y,2) = p;
     417        4592 :   y[1] = evalvalp(e) | _evalprecp(0);
     418        4592 :   return y;
     419             : }
     420             : /* O(pol_x(v)^e) */
     421             : INLINE GEN
     422      135471 : zeroser(long v, long e)
     423             : {
     424      135471 :   GEN x = cgetg(2, t_SER);
     425      135471 :   x[1] = evalvalp(e) | evalvarn(v); return x;
     426             : }
     427             : INLINE int
     428     9270310 : ser_isexactzero(GEN x)
     429             : {
     430     9270310 :   if (!signe(x)) switch(lg(x))
     431             :   {
     432      130676 :     case 2: return 1;
     433        1302 :     case 3: return isexactzero(gel(x,2));
     434             :   }
     435     9138332 :   return 0;
     436             : }
     437             : /* 0 * pol_x(v) */
     438             : INLINE GEN
     439    14568392 : zeropol(long v) { return pol_0(v); }
     440             : /* vector(n) */
     441             : INLINE GEN
     442    66026983 : zerocol(long n)
     443             : {
     444    66026983 :   GEN y = cgetg(n+1,t_COL);
     445   514555540 :   long i; for (i=1; i<=n; i++) gel(y,i) = gen_0;
     446    66027327 :   return y;
     447             : }
     448             : /* vectorv(n) */
     449             : INLINE GEN
     450    25144391 : zerovec(long n)
     451             : {
     452    25144391 :   GEN y = cgetg(n+1,t_VEC);
     453   329421405 :   long i; for (i=1; i<=n; i++) gel(y,i) = gen_0;
     454    25144391 :   return y;
     455             : }
     456             : /* matrix(m, n) */
     457             : INLINE GEN
     458       91349 : zeromat(long m, long n)
     459             : {
     460       91349 :   GEN y = cgetg(n+1,t_MAT);
     461       91349 :   GEN v = zerocol(m);
     462      296278 :   long i; for (i=1; i<=n; i++) gel(y,i) = v;
     463       91347 :   return y;
     464             : }
     465             : /* = zero_zx, sv is a evalvarn()*/
     466             : INLINE GEN
     467     1098498 : zero_Flx(long sv) { return pol0_Flx(sv); }
     468             : INLINE GEN
     469    50077601 : zero_Flv(long n)
     470             : {
     471    50077601 :   GEN y = cgetg(n+1,t_VECSMALL);
     472  1002080835 :   long i; for (i=1; i<=n; i++) y[i] = 0;
     473    50078536 :   return y;
     474             : }
     475             : /* matrix(m, n) */
     476             : INLINE GEN
     477     2131435 : zero_Flm(long m, long n)
     478             : {
     479     2131435 :   GEN y = cgetg(n+1,t_MAT);
     480     2131434 :   GEN v = zero_Flv(m);
     481    13855137 :   long i; for (i=1; i<=n; i++) gel(y,i) = v;
     482     2131431 :   return y;
     483             : }
     484             : /* matrix(m, n) */
     485             : INLINE GEN
     486      220335 : zero_Flm_copy(long m, long n)
     487             : {
     488      220335 :   GEN y = cgetg(n+1,t_MAT);
     489     2232792 :   long i; for (i=1; i<=n; i++) gel(y,i) = zero_Flv(m);
     490      220340 :   return y;
     491             : }
     492             : 
     493             : INLINE GEN
     494     2798102 : zero_F2v(long m)
     495             : {
     496     2798102 :   long l = nbits2nlong(m);
     497     2798084 :   GEN v  = zero_Flv(l+1);
     498     2798104 :   v[1] = m;
     499     2798104 :   return v;
     500             : }
     501             : 
     502             : INLINE GEN
     503           0 : zero_F2m(long m, long n)
     504             : {
     505             :   long i;
     506           0 :   GEN M = cgetg(n+1, t_MAT);
     507           0 :   GEN v = zero_F2v(m);
     508           0 :   for (i = 1; i <= n; i++)
     509           0 :     gel(M,i) = v;
     510           0 :   return M;
     511             : }
     512             : 
     513             : 
     514             : INLINE GEN
     515      825367 : zero_F2m_copy(long m, long n)
     516             : {
     517             :   long i;
     518      825367 :   GEN M = cgetg(n+1, t_MAT);
     519     1937098 :   for (i = 1; i <= n; i++)
     520     1111732 :     gel(M,i)= zero_F2v(m);
     521      825366 :   return M;
     522             : }
     523             : 
     524             : /* matrix(m, n) */
     525             : INLINE GEN
     526     4863001 : zeromatcopy(long m, long n)
     527             : {
     528     4863001 :   GEN y = cgetg(n+1,t_MAT);
     529    24839371 :   long i; for (i=1; i<=n; i++) gel(y,i) = zerocol(m);
     530     4863037 :   return y;
     531             : }
     532             : 
     533             : INLINE GEN
     534       18235 : zerovec_block(long len)
     535             : {
     536             :   long i;
     537       18235 :   GEN blk = cgetg_block(len + 1, t_VEC);
     538      601755 :   for (i = 1; i <= len; ++i)
     539      583520 :     gel(blk, i) = gen_0;
     540       18235 :   return blk;
     541             : }
     542             : 
     543             : /* i-th vector in the standard basis */
     544             : INLINE GEN
     545     4276772 : col_ei(long n, long i) { GEN e = zerocol(n); gel(e,i) = gen_1; return e; }
     546             : INLINE GEN
     547     1708680 : vec_ei(long n, long i) { GEN e = zerovec(n); gel(e,i) = gen_1; return e; }
     548             : INLINE GEN
     549          42 : F2v_ei(long n, long i) { GEN e = zero_F2v(n); F2v_set(e,i); return e; }
     550             : INLINE GEN
     551       62054 : vecsmall_ei(long n, long i) { GEN e = zero_zv(n); e[i] = 1; return e; }
     552             : INLINE GEN
     553     1125137 : Rg_col_ei(GEN x, long n, long i) { GEN e = zerocol(n); gel(e,i) = x; return e; }
     554             : 
     555             : INLINE GEN
     556    17998360 : shallowcopy(GEN x)
     557    17998360 : { return typ(x) == t_MAT ? RgM_shallowcopy(x): leafcopy(x); }
     558             : 
     559             : /* routines for naive growarrays */
     560             : INLINE GEN
     561    11168089 : vectrunc_init(long l)
     562             : {
     563    11168089 :   GEN z = new_chunk(l);
     564    11167966 :   z[0] = evaltyp(t_VEC) | _evallg(1); return z;
     565             : }
     566             : INLINE GEN
     567      348810 : coltrunc_init(long l)
     568             : {
     569      348810 :   GEN z = new_chunk(l);
     570      348810 :   z[0] = evaltyp(t_COL) | _evallg(1); return z;
     571             : }
     572             : INLINE void
     573   267197955 : lg_increase(GEN x) { x[0]++; }
     574             : INLINE void
     575    14037462 : vectrunc_append(GEN x, GEN t) { gel(x, lg(x)) = t; lg_increase(x); }
     576             : INLINE void
     577       10864 : vectrunc_append_batch(GEN x, GEN y)
     578             : {
     579       10864 :   long i, l = lg(x), ly = lg(y);
     580       10864 :   GEN z = x + l-1;
     581       36358 :   for (i = 1; i < ly; i++) gel(z,i) = gel(y,i);
     582       10864 :   setlg(x, l+ly-1);
     583       10864 : }
     584             : INLINE GEN
     585   105723631 : vecsmalltrunc_init(long l)
     586             : {
     587   105723631 :   GEN z = new_chunk(l);
     588   105659697 :   z[0] = evaltyp(t_VECSMALL) | _evallg(1); return z;
     589             : }
     590             : INLINE void
     591    36069912 : vecsmalltrunc_append(GEN x, long t) { x[ lg(x) ] = t; lg_increase(x); }
     592             : 
     593             : /*******************************************************************/
     594             : /*                                                                 */
     595             : /*                    STRING HASH FUNCTIONS                        */
     596             : /*                                                                 */
     597             : /*******************************************************************/
     598             : INLINE ulong
     599     2468696 : hash_str(const char *str)
     600             : {
     601     2468696 :   ulong hash = 5381UL, c;
     602    25420580 :   while ( (c = (ulong)*str++) )
     603    22951884 :     hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
     604     2468696 :   return hash;
     605             : }
     606             : INLINE ulong
     607   136744709 : hash_str_len(const char *str, long len)
     608             : {
     609   136744709 :   ulong hash = 5381UL;
     610             :   long i;
     611   571759363 :   for (i = 0; i < len; i++)
     612             :   {
     613   435014654 :     ulong c = (ulong)*str++;
     614   435014654 :     hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
     615             :   }
     616   136744709 :   return hash;
     617             : }
     618             : 
     619             : /*******************************************************************/
     620             : /*                                                                 */
     621             : /*                        VEC / COL / VECSMALL                     */
     622             : /*                                                                 */
     623             : /*******************************************************************/
     624             : /* shallow*/
     625             : INLINE GEN
     626           0 : vec_shorten(GEN v, long n)
     627             : {
     628             :   long i;
     629           0 :   GEN V = cgetg(n+1,t_VEC);
     630           0 :   for(i=1;i<=n;i++) gel(V,i) = gel(v,i);
     631           0 :   return V;
     632             : }
     633             : /* shallow*/
     634             : INLINE GEN
     635       17826 : vec_lengthen(GEN v, long n)
     636             : {
     637             :   long i;
     638       17826 :   long l=lg(v);
     639       17826 :   GEN V = cgetg(n+1,t_VEC);
     640     7018921 :   for(i=1;i<l;i++) gel(V,i) = gel(v,i);
     641       17826 :   return V;
     642             : }
     643             : /* shallow*/
     644             : INLINE GEN
     645     3358637 : vec_append(GEN V, GEN s)
     646             : {
     647     3358637 :   long i, l2 = lg(V);
     648     3358637 :   GEN res = cgetg(l2+1, typ(V));
     649     9024825 :   for (i = 1; i < l2; ++i) gel(res, i) = gel(V,i);
     650     3358616 :   gel(res,l2) = s; return res;
     651             : }
     652             : /* shallow*/
     653             : INLINE GEN
     654      271835 : vec_prepend(GEN v, GEN s)
     655             : {
     656      271835 :   long i, l = lg(v);
     657      271835 :   GEN w = cgetg(l+1, typ(v));
     658      271839 :   gel(w,1) = s;
     659      573281 :   for (i = 2; i <= l; ++i) gel(w,i) = gel(v,i-1);
     660      271839 :   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       51844 : vecsmall_shorten(GEN v, long n)
     672             : {
     673             :   long i;
     674       51844 :   GEN V = cgetg(n+1,t_VECSMALL);
     675      628576 :   for(i=1;i<=n;i++) V[i] = v[i];
     676       51843 :   return V;
     677             : }
     678             : INLINE GEN
     679         434 : vecsmall_lengthen(GEN v, long n)
     680             : {
     681         434 :   long i, l = lg(v);
     682         434 :   GEN V = cgetg(n+1,t_VECSMALL);
     683       24752 :   for(i=1;i<l;i++) V[i] = v[i];
     684         434 :   return V;
     685             : }
     686             : 
     687             : INLINE GEN
     688     4237546 : vec_to_vecsmall(GEN x)
     689    19616676 : { pari_APPLY_long(itos(gel(x,i))) }
     690             : INLINE GEN
     691      491631 : vecsmall_to_vec(GEN x)
     692     6194904 : { pari_APPLY_type(t_VEC, stoi(x[i])) }
     693             : INLINE GEN
     694        2457 : vecsmall_to_vec_inplace(GEN z)
     695             : {
     696        2457 :   long i, l = lg(z);
     697       76587 :   for (i=1; i<l; i++) gel(z,i) = stoi(z[i]);
     698        2457 :   settyp(z, t_VEC); return z;
     699             : }
     700             : INLINE GEN
     701     6893292 : vecsmall_to_col(GEN x)
     702    57138218 : { pari_APPLY_type(t_COL, stoi(x[i])) }
     703             : 
     704             : INLINE int
     705     7051023 : vecsmall_lexcmp(GEN x, GEN y)
     706             : {
     707             :   long lx,ly,l,i;
     708     7051023 :   lx = lg(x);
     709     7051023 :   ly = lg(y); l = minss(lx,ly);
     710    30491405 :   for (i=1; i<l; i++)
     711    28864634 :     if (x[i] != y[i]) return x[i]<y[i]? -1: 1;
     712     1626771 :   if (lx == ly) return 0;
     713       30579 :   return (lx < ly)? -1 : 1;
     714             : }
     715             : 
     716             : INLINE int
     717   109454576 : vecsmall_prefixcmp(GEN x, GEN y)
     718             : {
     719   109454576 :   long i, lx = lg(x), ly = lg(y), l = minss(lx,ly);
     720   578736669 :   for (i=1; i<l; i++)
     721   556596460 :     if (x[i] != y[i]) return x[i]<y[i]? -1: 1;
     722    22140209 :   return 0;
     723             : }
     724             : 
     725             : /*Can be used on t_VEC, but coeffs not gcopy-ed*/
     726             : INLINE GEN
     727      182742 : vecsmall_prepend(GEN V, long s)
     728             : {
     729      182742 :   long i, l2 = lg(V);
     730      182742 :   GEN res = cgetg(l2+1, typ(V));
     731      182742 :   res[1] = s;
     732      613004 :   for (i = 2; i <= l2; ++i) res[i] = V[i - 1];
     733      182742 :   return res;
     734             : }
     735             : 
     736             : INLINE GEN
     737     3616358 : vecsmall_append(GEN V, long s)
     738             : {
     739     3616358 :   long i, l2 = lg(V);
     740     3616358 :   GEN res = cgetg(l2+1, t_VECSMALL);
     741     5454269 :   for (i = 1; i < l2; ++i) res[i] = V[i];
     742     3616358 :   res[l2] = s; return res;
     743             : }
     744             : 
     745             : INLINE GEN
     746     1623901 : vecsmall_concat(GEN u, GEN v)
     747             : {
     748     1623901 :   long i, l1 = lg(u)-1, l2 = lg(v)-1;
     749     1623901 :   GEN res = cgetg(l1+l2+1, t_VECSMALL);
     750    13317340 :   for (i = 1; i <= l1; ++i) res[i]    = u[i];
     751    16663380 :   for (i = 1; i <= l2; ++i) res[i+l1] = v[i];
     752     1623899 :   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          68 :   for (i = 1; i < l; i++)
     771          52 :     if (v[i] == x) return i;
     772          16 :   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      680369 : vecsmall_max(GEN x)
     794             : {
     795      680369 :   long i, t = x[1], lx = lg(x);
     796     2036848 :   for (i=2; i<lx; i++)
     797     1356479 :     if (x[i] > t) t = x[i];
     798      680369 :   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        1428 : vecsmall_min(GEN x)
     812             : {
     813        1428 :   long i, t = x[1], lx =lg(x);
     814        9996 :   for (i=2; i<lx; i++)
     815        8568 :     if (x[i] < t) t = x[i];
     816        1428 :   return t;
     817             : }
     818             : 
     819             : INLINE int
     820    28497360 : ZV_isscalar(GEN x)
     821             : {
     822    28497360 :   long l = lg(x);
     823    45947332 :   while (--l > 1)
     824    45549257 :     if (signe(gel(x, l))) return 0;
     825      398075 :   return 1;
     826             : }
     827             : INLINE int
     828    34611067 : QV_isscalar(GEN x)
     829             : {
     830    34611067 :   long lx = lg(x),i;
     831    40460418 :   for (i=2; i<lx; i++)
     832    39002212 :     if (!isintzero(gel(x, i))) return 0;
     833     1458206 :   return 1;
     834             : }
     835             : INLINE int
     836        8653 : RgV_isscalar(GEN x)
     837             : {
     838        8653 :   long lx = lg(x),i;
     839       10381 :   for (i=2; i<lx; i++)
     840       10339 :     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    25069690 : 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       64311 : RgX_is_rational(GEN x)
     858             : {
     859             :   long i;
     860      296533 :   for (i = lg(x)-1; i > 1; i--)
     861      281408 :     if (!is_rational_t(typ(gel(x,i)))) return 0;
     862       15125 :   return 1;
     863             : }
     864             : INLINE int
     865    11376752 : RgX_is_ZX(GEN x)
     866             : {
     867             :   long i;
     868    48572892 :   for (i = lg(x)-1; i > 1; i--)
     869    37254583 :     if (typ(gel(x,i)) != t_INT) return 0;
     870    11318309 :   return 1;
     871             : }
     872             : INLINE int
     873      334719 : RgX_is_QX(GEN x)
     874             : {
     875      334719 :   long k = lg(x)-1;
     876     1234404 :   for ( ; k>1; k--)
     877      899965 :     if (!is_rational_t(typ(gel(x,k)))) return 0;
     878      334439 :   return 1;
     879             : }
     880             : INLINE int
     881    17167832 : RgX_is_monomial(GEN x)
     882             : {
     883             :   long i;
     884    17167832 :   if (!signe(x)) return 0;
     885    35518540 :   for (i=lg(x)-2; i>1; i--)
     886    18398208 :     if (!isexactzero(gel(x,i))) return 0;
     887    17120332 :   return 1;
     888             : }
     889             : INLINE int
     890    29895519 : RgV_is_ZV(GEN x)
     891             : {
     892             :   long i;
     893   119889652 :   for (i = lg(x)-1; i > 0; i--)
     894    90023211 :     if (typ(gel(x,i)) != t_INT) return 0;
     895    29866441 :   return 1;
     896             : }
     897             : INLINE int
     898      109696 : RgV_is_QV(GEN x)
     899             : {
     900             :   long i;
     901      524545 :   for (i = lg(x)-1; i > 0; i--)
     902      417804 :     if (!is_rational_t(typ(gel(x,i)))) return 0;
     903      106741 :   return 1;
     904             : }
     905             : INLINE long
     906      215012 : RgV_isin_i(GEN v, GEN x, long n)
     907             : {
     908             :   long i;
     909     4005575 :   for (i = 1; i <= n; i++)
     910     4001081 :     if (gequal(gel(v,i), x)) return i;
     911        4494 :   return 0;
     912             : }
     913             : INLINE long
     914      215012 : 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  1102837606 : pari_stack_base(pari_stack *s) { return s->data; }
     923             : 
     924             : INLINE void
     925     3571291 : pari_stack_init(pari_stack *s, size_t size, void **data)
     926             : {
     927     3571291 :   s->data = data;
     928     3571291 :   *data = NULL;
     929     3571291 :   s->n = 0;
     930     3571291 :   s->alloc = 0;
     931     3571291 :   s->size = size;
     932     3571291 : }
     933             : 
     934             : INLINE void
     935  1099536359 : pari_stack_alloc(pari_stack *s, long nb)
     936             : {
     937  1099536359 :   void **sdat = pari_stack_base(s);
     938  1099454097 :   long alloc = s->alloc;
     939  1099454097 :   if (s->n+nb <= alloc) return;
     940     1378940 :   if (!alloc)
     941     1282971 :     alloc = nb;
     942             :   else
     943             :   {
     944      195463 :     while (s->n+nb > alloc) alloc <<= 1;
     945             :   }
     946     1378940 :   pari_realloc_ip(sdat,alloc*s->size);
     947     1389879 :   s->alloc = alloc;
     948             : }
     949             : 
     950             : INLINE long
     951  1013594751 : pari_stack_new(pari_stack *s) { pari_stack_alloc(s, 1); return s->n++; }
     952             : 
     953             : INLINE void
     954     3331566 : pari_stack_delete(pari_stack *s)
     955             : {
     956     3331566 :   void **sdat = pari_stack_base(s);
     957     3325523 :   if (*sdat) pari_free(*sdat);
     958     3347023 : }
     959             : 
     960             : INLINE void
     961        5494 : pari_stack_pushp(pari_stack *s, void *u)
     962             : {
     963        5494 :   long n = pari_stack_new(s);
     964        5494 :   void **sdat =(void**) *pari_stack_base(s);
     965        5494 :   sdat[n] = u;
     966        5494 : }
     967             : 
     968             : /*******************************************************************/
     969             : /*                                                                 */
     970             : /*                            EXTRACT                              */
     971             : /*                                                                 */
     972             : /*******************************************************************/
     973             : INLINE GEN
     974   547075667 : vecslice(GEN A, long y1, long y2)
     975             : {
     976   547075667 :   long i,lB = y2 - y1 + 2;
     977   547075667 :   GEN B = cgetg(lB, typ(A));
     978  2446951184 :   for (i=1; i<lB; i++) B[i] = A[y1-1+i];
     979   547067059 :   return B;
     980             : }
     981             : INLINE GEN
     982     1877781 : vecslicepermute(GEN A, GEN p, long y1, long y2)
     983             : {
     984     1877781 :   long i,lB = y2 - y1 + 2;
     985     1877781 :   GEN B = cgetg(lB, typ(A));
     986    28368123 :   for (i=1; i<lB; i++) B[i] = A[p[y1-1+i]];
     987     1877777 :   return B;
     988             : }
     989             : /* rowslice(rowpermute(A,p), x1, x2) */
     990             : INLINE GEN
     991      167641 : rowslicepermute(GEN x, GEN p, long j1, long j2)
     992      722448 : { pari_APPLY_same(vecslicepermute(gel(x,i),p,j1,j2)) }
     993             : 
     994             : INLINE GEN
     995    58836805 : rowslice(GEN x, long j1, long j2)
     996   557481069 : { pari_APPLY_same(vecslice(gel(x,i), j1, j2)) }
     997             : 
     998             : INLINE GEN
     999     8653803 : matslice(GEN A, long x1, long x2, long y1, long y2)
    1000     8653803 : { 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      351764 : vecsplice(GEN a, long j)
    1010             : {
    1011      351764 :   long i, k, l = lg(a);
    1012             :   GEN b;
    1013      351764 :   if (l == 1) pari_err(e_MISC, "incorrect component in vecsplice");
    1014      351764 :   b = cgetg(l-1, typ(a));
    1015     1484564 :   for (i = k = 1; i < l; i++)
    1016     1132801 :     if (i != j) gel(b, k++) = gel(a,i);
    1017      351763 :   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      457838 : row(GEN x, long j)
    1032     4305655 : { pari_APPLY_type(t_VEC, gcoeff(x, j, i)) }
    1033             : INLINE GEN
    1034     9061454 : Flm_row(GEN x, long j)
    1035   233365657 : { 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      398615 : vecreverse(GEN A)
    1052             : {
    1053             :   long i, l;
    1054      398615 :   GEN B = cgetg_copy(A, &l);
    1055     1187081 :   for (i=1; i<l; i++) gel(B, i) = gel(A, l-i);
    1056      398615 :   return B;
    1057             : }
    1058             : 
    1059             : INLINE GEN
    1060        2961 : vecsmall_reverse(GEN A)
    1061             : {
    1062             :   long i, l;
    1063        2961 :   GEN B = cgetg_copy(A, &l);
    1064       11669 :   for (i=1; i<l; i++) B[i] = A[l-i];
    1065        2961 :   return B;
    1066             : }
    1067             : 
    1068             : INLINE void
    1069        1604 : vecreverse_inplace(GEN y)
    1070             : {
    1071        1604 :   long l = lg(y), lim = l>>1, i;
    1072        5561 :   for (i = 1; i <= lim; i++)
    1073             :   {
    1074        3957 :     GEN z = gel(y,i);
    1075        3957 :     gel(y,i)    = gel(y,l-i);
    1076        3957 :     gel(y,l-i) = z;
    1077             :   }
    1078        1604 : }
    1079             : 
    1080             : INLINE GEN
    1081    68855328 : vecsmallpermute(GEN A, GEN p) { return perm_mul(A, p); }
    1082             : 
    1083             : INLINE GEN
    1084    11014666 : vecpermute(GEN A, GEN x)
    1085    88237876 : { pari_APPLY_type(typ(A), gel(A, x[i])) }
    1086             : 
    1087             : INLINE GEN
    1088     9079539 : rowpermute(GEN x, GEN p)
    1089    80095848 : { 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     1924509 : identity_zv(long n)
    1099             : {
    1100     1924509 :   GEN v = cgetg(n+1, t_VECSMALL);
    1101             :   long i;
    1102    24036712 :   for (i = 1; i <= n; i++) v[i] = i;
    1103     1924502 :   return v;
    1104             : }
    1105             : INLINE GEN
    1106        4179 : identity_ZV(long n)
    1107             : {
    1108        4179 :   GEN v = cgetg(n+1, t_VEC);
    1109             :   long i;
    1110       51121 :   for (i = 1; i <= n; i++) gel(v,i) = utoipos(i);
    1111        4179 :   return v;
    1112             : }
    1113             : /* identity permutation */
    1114             : INLINE GEN
    1115     1900253 : identity_perm(long n) { return identity_zv(n); }
    1116             : 
    1117             : /* assume d <= n */
    1118             : INLINE GEN
    1119       98490 : cyclic_perm(long n, long d)
    1120             : {
    1121       98490 :   GEN perm = cgetg(n+1, t_VECSMALL);
    1122             :   long i;
    1123      504112 :   for (i = 1; i <= n-d; i++) perm[i] = i+d;
    1124      225050 :   for (     ; i <= n;   i++) perm[i] = i-n+d;
    1125       98490 :   return perm;
    1126             : }
    1127             : 
    1128             : /* Multiply (compose) two permutations */
    1129             : INLINE GEN
    1130    70931803 : perm_mul(GEN s, GEN x)
    1131   940761335 : { pari_APPLY_long(s[x[i]]) }
    1132             : 
    1133             : INLINE GEN
    1134         749 : perm_sqr(GEN x)
    1135       18725 : { pari_APPLY_long(x[x[i]]) }
    1136             : 
    1137             : /* Compute the inverse (reciprocal) of a permutation. */
    1138             : INLINE GEN
    1139     2461986 : perm_inv(GEN x)
    1140             : {
    1141             :   long i, lx;
    1142     2461986 :   GEN y = cgetg_copy(x, &lx);
    1143    34990507 :   for (i=1; i<lx; i++) y[ x[i] ] = i;
    1144     2461986 :   return y;
    1145             : }
    1146             : /* Return s*t*s^-1 */
    1147             : INLINE GEN
    1148      418061 : perm_conj(GEN s, GEN t)
    1149             : {
    1150             :   long i, l;
    1151      418061 :   GEN v = cgetg_copy(s, &l);
    1152     6856213 :   for (i = 1; i < l; i++) v[ s[i] ] = s[ t[i] ];
    1153      418061 :   return v;
    1154             : }
    1155             : 
    1156             : INLINE void
    1157   442594174 : pari_free(void *pointer)
    1158             : {
    1159   442594174 :   BLOCK_SIGINT_START;
    1160   442658970 :   free(pointer);
    1161   442658970 :   BLOCK_SIGINT_END;
    1162   442662465 : }
    1163             : INLINE void*
    1164   665137480 : pari_malloc(size_t size)
    1165             : {
    1166   665137480 :   if (size)
    1167             :   {
    1168             :     char *tmp;
    1169   665138868 :     BLOCK_SIGINT_START;
    1170   665218728 :     tmp = (char*)malloc(size);
    1171   665218728 :     BLOCK_SIGINT_END;
    1172   665204465 :     if (!tmp) pari_err(e_MEM);
    1173   665214722 :     return tmp;
    1174             :   }
    1175           0 :   return NULL;
    1176             : }
    1177             : INLINE void*
    1178        1771 : pari_realloc(void *pointer, size_t size)
    1179             : {
    1180             :   char *tmp;
    1181             : 
    1182        1771 :   BLOCK_SIGINT_START;
    1183        1771 :   if (!pointer) tmp = (char *) malloc(size);
    1184        1771 :   else tmp = (char *) realloc(pointer,size);
    1185        1771 :   BLOCK_SIGINT_END;
    1186        1771 :   if (!tmp) pari_err(e_MEM);
    1187        1771 :   return tmp;
    1188             : }
    1189             : INLINE void
    1190     1445509 : pari_realloc_ip(void **pointer, size_t size)
    1191             : {
    1192             :   char *tmp;
    1193     1445509 :   BLOCK_SIGINT_START;
    1194     1445250 :   if (!*pointer) tmp = (char *) malloc(size);
    1195      100226 :   else tmp = (char *) realloc(*pointer,size);
    1196     1445250 :   if (!tmp) pari_err(e_MEM);
    1197     1445250 :   *pointer = tmp;
    1198     1445250 :   BLOCK_SIGINT_END;
    1199     1441993 : }
    1200             : 
    1201             : INLINE void*
    1202       42904 : pari_calloc(size_t size)
    1203             : {
    1204       42904 :   void *t = pari_malloc(size);
    1205       42904 :   memset(t, 0, size); return t;
    1206             : }
    1207             : INLINE GEN
    1208        8017 : cgetalloc(long t, size_t l)
    1209             : { /* evallg may raise e_OVERFLOW, which would leak x */
    1210        8017 :   ulong x0 = evaltyp(t) | evallg(l);
    1211        8017 :   GEN x = (GEN)pari_malloc(l * sizeof(long));
    1212        8017 :   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  6686378819 : icopy_avma(GEN x, pari_sp av)
    1223             : {
    1224  6686378819 :   long i = lgefint(x), lx = i;
    1225  6686378819 :   GEN y = ((GEN)av) - i;
    1226 57109979578 :   while (--i > 0) y[i] = x[i];
    1227  6686378819 :   y[0] = evaltyp(t_INT)|evallg(lx);
    1228  6690353810 :   return y;
    1229             : }
    1230             : /* copy leaf x as if we had set_avma(av) */
    1231             : INLINE GEN
    1232   455737472 : leafcopy_avma(GEN x, pari_sp av)
    1233             : {
    1234   455737472 :   long i = lg(x);
    1235   455737472 :   GEN y = ((GEN)av) - i;
    1236  2835647274 :   while (--i > 0) y[i] = x[i];
    1237   455737472 :   y[0] = x[0] & (~CLONEBIT);
    1238   455737472 :   return y;
    1239             : }
    1240             : INLINE GEN
    1241   981314037 : gerepileuptoleaf(pari_sp av, GEN x)
    1242             : {
    1243             :   long lx;
    1244             :   GEN q;
    1245             : 
    1246   981314037 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1247   980680781 :   lx = lg(x);
    1248   980680781 :   q = ((GEN)av) - lx;
    1249   980680781 :   set_avma((pari_sp)q);
    1250  9936033333 :   while (--lx >= 0) q[lx] = x[lx];
    1251   980559628 :   return q;
    1252             : }
    1253             : INLINE GEN
    1254  2946176928 : gerepileuptoint(pari_sp av, GEN x)
    1255             : {
    1256  2946176928 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1257  2601211956 :   set_avma((pari_sp)icopy_avma(x, av));
    1258  2604558387 :   return (GEN)avma;
    1259             : }
    1260             : INLINE GEN
    1261  1494830154 : gerepileupto(pari_sp av, GEN x)
    1262             : {
    1263  1494830154 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1264  1316137966 :   switch(typ(x))
    1265             :   { /* non-default = !is_recursive_t(tq) */
    1266   351143508 :     case t_INT: return gerepileuptoint(av, x);
    1267   294572324 :     case t_REAL:
    1268             :     case t_STR:
    1269   294572324 :     case t_VECSMALL: return gerepileuptoleaf(av,x);
    1270   670422777 :     default:
    1271             :       /* NB: x+i --> ((long)x) + i*sizeof(long) */
    1272   670422777 :       return gerepile(av, (pari_sp) (x+lg(x)), x);
    1273             :   }
    1274             : }
    1275             : 
    1276             : /* gerepileupto(av, gcopy(x)) */
    1277             : INLINE GEN
    1278   211862213 : gerepilecopy(pari_sp av, GEN x)
    1279             : {
    1280   211862213 :   if (is_recursive_t(typ(x)))
    1281             :   {
    1282   205572802 :     GENbin *p = copy_bin(x);
    1283   205588627 :     set_avma(av); return bin_copy(p);
    1284             :   }
    1285             :   else
    1286             :   {
    1287     6290760 :     set_avma(av);
    1288     6290806 :     if (x < (GEN)av) {
    1289     4553244 :       if (x < (GEN)pari_mainstack->bot) new_chunk(lg(x));
    1290     4553249 :       x = leafcopy_avma(x, av);
    1291     4553278 :       set_avma((pari_sp)x);
    1292             :     } else
    1293     1737565 :       x = leafcopy(x);
    1294     6290841 :     return x;
    1295             :   }
    1296             : }
    1297             : 
    1298             : INLINE void
    1299    27884678 : guncloneNULL(GEN x) { if (x) gunclone(x); }
    1300             : INLINE void
    1301      868199 : 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      937031 : gerepilemany(pari_sp av, GEN* gptr[], int n)
    1308             : {
    1309             :   int i;
    1310     3740016 :   for (i=0; i<n; i++) *gptr[i] = (GEN)copy_bin(*gptr[i]);
    1311      936703 :   set_avma(av);
    1312     3740733 :   for (i=0; i<n; i++) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1313      937241 : }
    1314             : 
    1315             : INLINE void
    1316    11605078 : gerepileall(pari_sp av, int n, ...)
    1317             : {
    1318             :   int i;
    1319    11605078 :   va_list a; va_start(a, n);
    1320    11605078 :   if (n < 10)
    1321             :   {
    1322             :     GEN *gptr[10];
    1323    35245684 :     for (i=0; i<n; i++)
    1324    23640253 :     { gptr[i] = va_arg(a,GEN*); *gptr[i] = (GEN)copy_bin(*gptr[i]); }
    1325    11605431 :     set_avma(av);
    1326    35246109 :     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    11605788 :   va_end(a);
    1339    11605788 : }
    1340             : 
    1341             : /* assume 1 <= n < 10 */
    1342             : INLINE GEN
    1343    69635576 : gc_all(pari_sp av, int n, ...)
    1344             : {
    1345             :   int i;
    1346             :   GEN *v[10];
    1347    69635576 :   va_list a; va_start(a, n);
    1348   238794847 :   for (i=0; i<n; i++) { v[i] = va_arg(a,GEN*); *v[i] = (GEN)copy_bin(*v[i]); }
    1349    69636016 :   set_avma(av);
    1350   238795876 :   for (i=0; i<n; i++) *v[i] = bin_copy((GENbin*)*v[i]);
    1351    69636405 :   return *v[0];
    1352             : }
    1353             : 
    1354             : INLINE void
    1355     2750820 : gerepilecoeffs(pari_sp av, GEN x, int n)
    1356             : {
    1357             :   int i;
    1358    32343536 :   for (i=0; i<n; i++) gel(x,i) = (GEN)copy_bin(gel(x,i));
    1359     2751319 :   set_avma(av);
    1360    32345026 :   for (i=0; i<n; i++) gel(x,i) = bin_copy((GENbin*)x[i]);
    1361     2751012 : }
    1362             : 
    1363             : /* p from copy_bin. Copy p->x back to stack, then destroy p */
    1364             : INLINE GEN
    1365   430821928 : bin_copy(GENbin *p)
    1366             : {
    1367             :   GEN x, y, base;
    1368             :   long dx, len;
    1369             : 
    1370   430821928 :   x   = p->x; if (!x) { pari_free(p); return gen_0; }
    1371   403119457 :   len = p->len;
    1372   403119457 :   base= p->base; dx = x - base;
    1373   403119457 :   y = (GEN)memcpy((void*)new_chunk(len), (void*)GENbinbase(p), len*sizeof(long));
    1374   403114458 :   y += dx;
    1375   403114458 :   p->rebase(y, ((ulong)y-(ulong)x));
    1376   403111729 :   pari_free(p); return y;
    1377             : }
    1378             : 
    1379             : INLINE GEN
    1380   833928715 : GENbinbase(GENbin *p) { return (GEN)(p + 1); }
    1381             : 
    1382             : INLINE void
    1383   114269787 : cgiv(GEN x)
    1384             : {
    1385   114269787 :   pari_sp av = (pari_sp)(x+lg(x));
    1386   114269787 :   if (isonstack((GEN)av)) set_avma(av);
    1387   114271887 : }
    1388             : 
    1389             : INLINE void
    1390     6712387 : killblock(GEN x) { gunclone(x); }
    1391             : 
    1392             : INLINE int
    1393   273785374 : 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    18289355 : cxcompotor(GEN z, long prec)
    1403             : {
    1404    18289355 :   switch(typ(z))
    1405             :   {
    1406    13517040 :     case t_INT:  return itor(z, prec);
    1407      359450 :     case t_FRAC: return fractor(z, prec);
    1408     4413286 :     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     9129491 : cxtofp(GEN x, long prec)
    1415     9129491 : { retmkcomplex(cxcompotor(gel(x,1),prec), cxcompotor(gel(x,2),prec)); }
    1416             : 
    1417             : INLINE GEN
    1418      274889 : cxtoreal(GEN q)
    1419      274889 : { return (typ(q) == t_COMPLEX && gequal0(gel(q,2)))? gel(q,1): q; }
    1420             : 
    1421             : INLINE double
    1422    65338690 : gtodouble(GEN x)
    1423             : {
    1424    65338690 :   if (typ(x)!=t_REAL) {
    1425     6012067 :     pari_sp av = avma;
    1426     6012067 :     x = gtofp(x, DEFAULTPREC);
    1427     6011377 :     if (typ(x)!=t_REAL) pari_err_TYPE("gtodouble [t_REAL expected]", x);
    1428     6011377 :     set_avma(av);
    1429             :   }
    1430    65337888 :   return rtodbl(x);
    1431             : }
    1432             : 
    1433             : INLINE int
    1434     9682860 : gisdouble(GEN x, double *g)
    1435             : {
    1436     9682860 :   if (typ(x)!=t_REAL) {
    1437      136292 :     pari_sp av = avma;
    1438      136292 :     x = gtofp(x, DEFAULTPREC);
    1439      136289 :     if (typ(x)!=t_REAL) pari_err_TYPE("gisdouble [t_REAL expected]", x);
    1440      136289 :     set_avma(av);
    1441             :   }
    1442     9682846 :   if (expo(x) >= 0x3ff) return 0;
    1443     9682846 :   *g = rtodbl(x); return 1;
    1444             : }
    1445             : 
    1446             : INLINE long
    1447    83957724 : gtos(GEN x) {
    1448    83957724 :   if (typ(x) != t_INT) pari_err_TYPE("gtos [integer expected]",x);
    1449    83957717 :   return itos(x);
    1450             : }
    1451             : 
    1452             : INLINE ulong
    1453      101637 : gtou(GEN x) {
    1454      101637 :   if (typ(x) != t_INT || signe(x)<0)
    1455           7 :     pari_err_TYPE("gtou [integer >=0 expected]",x);
    1456      101630 :   return itou(x);
    1457             : }
    1458             : 
    1459             : INLINE GEN
    1460    41476281 : absfrac(GEN x)
    1461             : {
    1462    41476281 :   GEN y = cgetg(3, t_FRAC);
    1463    41476279 :   gel(y,1) = absi(gel(x,1));
    1464    41476296 :   gel(y,2) = icopy(gel(x,2)); return y;
    1465             : }
    1466             : INLINE GEN
    1467       43813 : absfrac_shallow(GEN x)
    1468       43813 : { return signe(gel(x,1))>0? x: mkfrac(negi(gel(x,1)), gel(x,2)); }
    1469             : INLINE GEN
    1470     7168602 : Q_abs(GEN x) { return (typ(x) == t_INT)? absi(x): absfrac(x); }
    1471             : INLINE GEN
    1472      158768 : Q_abs_shallow(GEN x)
    1473      158768 : { 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    82488151 : gtofp(GEN z, long prec)
    1484             : {
    1485    82488151 :   switch(typ(z))
    1486             :   {
    1487    46160734 :     case t_INT:  return itor(z, prec);
    1488     4394174 :     case t_FRAC: return fractor(z, prec);
    1489    23075768 :     case t_REAL: return rtor(z, prec);
    1490     8865640 :     case t_COMPLEX: {
    1491     8865640 :       GEN a = gel(z,1), b = gel(z,2);
    1492     8865640 :       if (isintzero(b)) return cxcompotor(a, prec);
    1493     8865673 :       if (isintzero(a)) {
    1494        9446 :         GEN y = cgetg(3, t_COMPLEX);
    1495        9446 :         b = cxcompotor(b, prec);
    1496        9446 :         gel(y,1) = real_0_bit(expo(b) - prec2nbits(prec));
    1497        9446 :         gel(y,2) = b; return y;
    1498             :       }
    1499     8856189 :       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     5933333 : RgX_gtofp(GEN x, long prec)
    1524             : {
    1525             :   long l;
    1526     5933333 :   GEN y = cgetg_copy(x, &l);
    1527    33953461 :   while (--l > 1) gel(y,l) = gtofp(gel(x,l), prec);
    1528     5931310 :   y[1] = x[1]; return y;
    1529             : }
    1530             : INLINE GEN
    1531     3075299 : RgC_gtofp(GEN x, long prec)
    1532    25120668 : { pari_APPLY_type(t_COL, gtofp(gel(x,i), prec)) }
    1533             : 
    1534             : INLINE GEN
    1535          49 : RgV_gtofp(GEN x, long prec)
    1536        4746 : { pari_APPLY_type(t_VEC, gtofp(gel(x,i), prec)) }
    1537             : 
    1538             : INLINE GEN
    1539      581709 : RgM_gtofp(GEN x, long prec)
    1540     3073361 : { 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      100384 : RgX_fpnorml2(GEN x, long prec)
    1552             : {
    1553      100384 :   pari_sp av = avma;
    1554      100384 :   return gerepileupto(av, gnorml2(RgX_gtofp(x, prec)));
    1555             : }
    1556             : INLINE GEN
    1557      573272 : RgC_fpnorml2(GEN x, long prec)
    1558             : {
    1559      573272 :   pari_sp av = avma;
    1560      573272 :   return gerepileupto(av, gnorml2(RgC_gtofp(x, prec)));
    1561             : }
    1562             : INLINE GEN
    1563       19190 : RgM_fpnorml2(GEN x, long prec)
    1564             : {
    1565       19190 :   pari_sp av = avma;
    1566       19190 :   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      244540 : affc_fixlg(GEN x, GEN res)
    1585             : {
    1586      244540 :   if (typ(x) == t_COMPLEX)
    1587             :   {
    1588      212800 :     affrr_fixlg(gel(x,1), gel(res,1));
    1589      212800 :     affrr_fixlg(gel(x,2), gel(res,2));
    1590             :   }
    1591             :   else
    1592             :   {
    1593       31740 :     set_avma((pari_sp)(res+3));
    1594       31738 :     res = cgetr(realprec(gel(res,1)));
    1595       31743 :     affrr_fixlg(x, res);
    1596             :   }
    1597      244545 :   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       37850 : ndec2nlong(long x) { return 1 + (long)((x)*(LOG2_10/BITS_IN_LONG)); }
    1610             : INLINE long
    1611       29527 : ndec2prec(long x) { return 2 + ndec2nlong(x); }
    1612             : INLINE long
    1613        8323 : 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    10711311 : nbits2nlong(long x) {
    1619    10711311 :   return (long)(((ulong)x+BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1620             : }
    1621             : 
    1622             : INLINE long
    1623   468338871 : nbits2extraprec(long x) {
    1624   468338871 :   return (long)(((ulong)x+BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1625             : }
    1626             : 
    1627             : /* Fast implementation of 2 + nbits2nlong(x) */
    1628             : INLINE long
    1629   208067657 : nbits2prec(long x) {
    1630   208067657 :   return (long)(((ulong)x+3*BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1631             : }
    1632             : INLINE long
    1633   296271397 : nbits2lg(long x) {
    1634   296271397 :   return (long)(((ulong)x+3*BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1635             : }
    1636             : /* ceil(x / sizeof(long)) */
    1637             : INLINE long
    1638    90872549 : nchar2nlong(long x) {
    1639    90872549 :   return (long)(((ulong)x+sizeof(long)-1) >> (TWOPOTBITS_IN_LONG-3L));
    1640             : }
    1641             : INLINE long
    1642  4903666608 : prec2nbits(long x) { return (x-2) * BITS_IN_LONG; }
    1643             : INLINE double
    1644     2866685 : bit_accuracy_mul(long x, double y) { return (x-2) * (BITS_IN_LONG*y); }
    1645             : INLINE double
    1646      588673 : prec2nbits_mul(long x, double y) { return (x-2) * (BITS_IN_LONG*y); }
    1647             : INLINE long
    1648   137841968 : bit_prec(GEN x) { return prec2nbits(realprec(x)); }
    1649             : INLINE long
    1650  4636432254 : bit_accuracy(long x) { return prec2nbits(x); }
    1651             : INLINE long
    1652       12980 : 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        4663 : precdbl(long x) {return (x - 1) << 1;}
    1657             : INLINE long
    1658  7237563248 : divsBIL(long n) { return n >> TWOPOTBITS_IN_LONG; }
    1659             : INLINE long
    1660  7143973183 : 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    45680633 : Fp_red(GEN a, GEN m) { return modii(a, m); }
    1671             : INLINE GEN
    1672   109750661 : Fp_add(GEN a, GEN b, GEN m)
    1673             : {
    1674   109750661 :   pari_sp av=avma;
    1675   109750661 :   GEN p = addii(a,b);
    1676   108105025 :   long s = signe(p);
    1677   108105025 :   if (!s) return p; /* = gen_0 */
    1678    97193812 :   if (s > 0) /* general case */
    1679             :   {
    1680    97211520 :     GEN t = subii(p, m);
    1681    96865231 :     s = signe(t);
    1682    96865231 :     if (!s) return gc_const(av, gen_0);
    1683    89447346 :     if (s < 0) return gc_const((pari_sp)p, p);
    1684    45028027 :     if (cmpii(t, m) < 0) return gerepileuptoint(av, t); /* general case ! */
    1685     3001754 :     p = remii(t, m);
    1686             :   }
    1687             :   else
    1688      226365 :     p = modii(p, m);
    1689     3228240 :   return gerepileuptoint(av, p);
    1690             : }
    1691             : INLINE GEN
    1692   111800955 : Fp_sub(GEN a, GEN b, GEN m)
    1693             : {
    1694   111800955 :   pari_sp av=avma;
    1695   111800955 :   GEN p = subii(a,b);
    1696   109585063 :   long s = signe(p);
    1697   109585063 :   if (!s) return p; /* = gen_0 */
    1698    97942797 :   if (s > 0)
    1699             :   {
    1700    44315416 :     if (cmpii(p, m) < 0) return p; /* general case ! */
    1701     1257828 :     p = remii(p, m);
    1702             :   }
    1703             :   else
    1704             :   {
    1705    53627381 :     GEN t = addii(p, m);
    1706    55482654 :     if (!s) return gc_const(av, gen_0);
    1707    55537874 :     if (s > 0) return gerepileuptoint(av, t); /* general case ! */
    1708    55537874 :     p = modii(t, m);
    1709             :   }
    1710    57084410 :   return gerepileuptoint(av, p);
    1711             : }
    1712             : INLINE GEN
    1713    16853189 : Fp_neg(GEN b, GEN m)
    1714             : {
    1715    16853189 :   pari_sp av = avma;
    1716    16853189 :   long s = signe(b);
    1717             :   GEN p;
    1718    16853189 :   if (!s) return gen_0;
    1719    12889254 :   if (s > 0)
    1720             :   {
    1721    11773439 :     p = subii(m, b);
    1722    11770689 :     if (signe(p) >= 0) return p; /* general case ! */
    1723      382823 :     p = modii(p, m);
    1724             :   } else
    1725     1116901 :     p = remii(negi(b), m);
    1726     1499938 :   return gerepileuptoint(av, p);
    1727             : }
    1728             : 
    1729             : INLINE GEN
    1730       63924 : Fp_halve(GEN a, GEN p)
    1731             : {
    1732       63924 :   if (mpodd(a)) a = addii(a,p);
    1733       63924 :   return shifti(a,-1);
    1734             : }
    1735             : 
    1736             : /* assume 0 <= u < p and ps2 = p>>1 */
    1737             : INLINE GEN
    1738    58240559 : Fp_center(GEN u, GEN p, GEN ps2)
    1739    58240559 : { return abscmpii(u,ps2)<=0? icopy(u): subii(u,p); }
    1740             : /* same without copy */
    1741             : INLINE GEN
    1742    12119145 : Fp_center_i(GEN u, GEN p, GEN ps2)
    1743    12119145 : { return abscmpii(u,ps2)<=0? u: subii(u,p); }
    1744             : 
    1745             : /* x + y*z mod p */
    1746             : INLINE GEN
    1747    10712752 : Fp_addmul(GEN x, GEN y, GEN z, GEN p)
    1748             : {
    1749             :   pari_sp av;
    1750    10712752 :   if (!signe(y) || !signe(z)) return Fp_red(x, p);
    1751    10384099 :   if (!signe(x)) return Fp_mul(z,y, p);
    1752     9422323 :   av = avma;
    1753     9422323 :   return gerepileuptoint(av, modii(addii(x, mulii(y,z)), p));
    1754             : }
    1755             : 
    1756             : INLINE GEN
    1757   169268197 : Fp_mul(GEN a, GEN b, GEN m)
    1758             : {
    1759   169268197 :   pari_sp av=avma;
    1760             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1761   169268197 :   (void)new_chunk(lg(a)+lg(b)+(lg(m)<<1));
    1762   169282346 :   p = mulii(a,b);
    1763   169394214 :   set_avma(av); return modii(p,m);
    1764             : }
    1765             : INLINE GEN
    1766    67914912 : Fp_sqr(GEN a, GEN m)
    1767             : {
    1768    67914912 :   pari_sp av=avma;
    1769             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1770    67914912 :   (void)new_chunk((lg(a)+lg(m))<<1);
    1771    67994166 :   p = sqri(a);
    1772    65227973 :   set_avma(av); return remii(p,m); /*Use remii: p >= 0 */
    1773             : }
    1774             : INLINE GEN
    1775    78297872 : Fp_mulu(GEN a, ulong b, GEN m)
    1776             : {
    1777    78297872 :   long l = lgefint(m);
    1778    78297872 :   if (l == 3)
    1779             :   {
    1780    43784838 :     ulong mm = m[2];
    1781    43784838 :     return utoi( Fl_mul(umodiu(a, mm), b, mm) );
    1782             :   } else {
    1783    34513034 :     pari_sp av = avma;
    1784             :     GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1785    34513034 :     (void)new_chunk(lg(a)+1+(l<<1));
    1786    34484706 :     p = muliu(a,b);
    1787    32547340 :     set_avma(av); return modii(p,m);
    1788             :   }
    1789             : }
    1790             : INLINE GEN
    1791       17290 : Fp_muls(GEN a, long b, GEN m)
    1792             : {
    1793       17290 :   long l = lgefint(m);
    1794       17290 :   if (l == 3)
    1795             :   {
    1796        3058 :     ulong mm = m[2];
    1797        3058 :     if (b < 0)
    1798             :     {
    1799        3058 :       ulong t = Fl_mul(umodiu(a, mm), -b, mm);
    1800        3058 :       return t? utoipos(mm - t): gen_0;
    1801             :     }
    1802             :     else
    1803           0 :       return utoi( Fl_mul(umodiu(a, mm), b, mm) );
    1804             :   } else {
    1805       14232 :     pari_sp av = avma;
    1806             :     GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1807       14232 :     (void)new_chunk(lg(a)+1+(l<<1));
    1808       14232 :     p = mulis(a,b);
    1809       14232 :     set_avma(av); return modii(p,m);
    1810             :   }
    1811             : }
    1812             : 
    1813             : INLINE GEN
    1814    23617831 : Fp_inv(GEN a, GEN m)
    1815             : {
    1816             :   GEN res;
    1817    23617831 :   if (! invmod(a,m,&res)) pari_err_INV("Fp_inv", mkintmod(res,m));
    1818    23617037 :   return res;
    1819             : }
    1820             : INLINE GEN
    1821      777186 : Fp_invsafe(GEN a, GEN m)
    1822             : {
    1823             :   GEN res;
    1824      777186 :   if (! invmod(a,m,&res)) return NULL;
    1825      777076 :   return res;
    1826             : }
    1827             : INLINE GEN
    1828     1459086 : Fp_div(GEN a, GEN b, GEN m)
    1829             : {
    1830     1459086 :   pari_sp av = avma;
    1831             :   GEN p;
    1832     1459086 :   if (lgefint(b) == 3)
    1833             :   {
    1834      486425 :     a = Fp_divu(a, b[2], m);
    1835      486425 :     if (signe(b) < 0) a = Fp_neg(a, m);
    1836      486425 :     return a;
    1837             :   }
    1838             :   /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1839      972661 :   (void)new_chunk(lg(a)+(lg(m)<<1));
    1840      972661 :   p = mulii(a, Fp_inv(b,m));
    1841      972661 :   set_avma(av); return modii(p,m);
    1842             : }
    1843             : INLINE GEN
    1844     1651572 : Fp_divu(GEN x, ulong a, GEN p)
    1845             : {
    1846     1651572 :   pari_sp av = avma;
    1847             :   ulong b;
    1848     1651572 :   if (lgefint(p) == 3)
    1849             :   {
    1850     1353341 :     ulong pp = p[2], xp = umodiu(x, pp);
    1851     1353341 :     return xp? utoipos(Fl_div(xp, a % pp, pp)): gen_0;
    1852             :   }
    1853      298231 :   x = Fp_red(x, p);
    1854      298230 :   b = Fl_neg(Fl_div(umodiu(x,a), umodiu(p,a), a), a); /* x + pb = 0 (mod a) */
    1855      298233 :   return gerepileuptoint(av, diviuexact(addmuliu(x, p, b), a));
    1856             : }
    1857             : 
    1858             : INLINE GEN
    1859     1067684 : Flx_mulu(GEN x, ulong a, ulong p) { return Flx_Fl_mul(x,a%p,p); }
    1860             : 
    1861             : INLINE GEN
    1862     1902774 : get_F2x_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1863             : 
    1864             : INLINE long
    1865     2469435 : get_F2x_var(GEN T) { return typ(T)==t_VEC? mael(T,2,1): T[1]; }
    1866             : 
    1867             : INLINE long
    1868     1930184 : get_F2x_degree(GEN T) { return typ(T)==t_VEC? F2x_degree(gel(T,2)): F2x_degree(T); }
    1869             : 
    1870             : INLINE GEN
    1871         406 : get_F2xqX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1872             : 
    1873             : INLINE long
    1874      376187 : get_F2xqX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1875             : 
    1876             : INLINE long
    1877      201481 : get_F2xqX_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1878             : 
    1879             : INLINE GEN
    1880    24290858 : get_Flx_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1881             : 
    1882             : INLINE long
    1883    66416758 : get_Flx_var(GEN T) { return typ(T)==t_VEC? mael(T,2,1): T[1]; }
    1884             : 
    1885             : INLINE long
    1886    84385671 : get_Flx_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1887             : 
    1888             : INLINE GEN
    1889        6997 : get_FlxqX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1890             : 
    1891             : INLINE long
    1892      233855 : get_FlxqX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1893             : 
    1894             : INLINE long
    1895      289675 : get_FlxqX_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1896             : 
    1897             : INLINE GEN
    1898     2632154 : get_FpX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1899             : 
    1900             : INLINE long
    1901     6527209 : get_FpX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1902             : 
    1903             : INLINE long
    1904     5235304 : 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       34808 : get_FpXQX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1911             : 
    1912             : INLINE long
    1913        2259 : 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    43654829 : submulii(GEN x, GEN y, GEN z)
    1923             : {
    1924    43654829 :   long lx = lgefint(x), ly, lz;
    1925             :   pari_sp av;
    1926             :   GEN t;
    1927    43654829 :   if (lx == 2) { t = mulii(z,y); togglesign(t); return t; }
    1928    38882159 :   ly = lgefint(y);
    1929    38882159 :   if (ly == 2) return icopy(x);
    1930    36742265 :   lz = lgefint(z);
    1931    36742265 :   av = avma; (void)new_chunk(lx+ly+lz); /* HACK */
    1932    36742265 :   t = mulii(z, y);
    1933    36742265 :   set_avma(av); return subii(x,t);
    1934             : }
    1935             : /* y*z - x */
    1936             : INLINE GEN
    1937     2418844 : mulsubii(GEN y, GEN z, GEN x)
    1938             : {
    1939     2418844 :   long lx = lgefint(x), ly, lz;
    1940             :   pari_sp av;
    1941             :   GEN t;
    1942     2418844 :   if (lx == 2) return mulii(z,y);
    1943     1472115 :   ly = lgefint(y);
    1944     1472115 :   if (ly == 2) return negi(x);
    1945     1296459 :   lz = lgefint(z);
    1946     1296459 :   av = avma; (void)new_chunk(lx+ly+lz); /* HACK */
    1947     1296514 :   t = mulii(z, y);
    1948     1296470 :   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      306301 : addmuliu(GEN x, GEN y, ulong u)
    1966             : {
    1967             :   pari_sp av;
    1968      306301 :   long ly = lgefint(y);
    1969      306301 :   if (ly == 2) return icopy(x);
    1970      306301 :   av = avma;
    1971      306301 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1972      306301 :   y = mului(u,y);
    1973      306300 :   set_avma(av); return addii(x, y);
    1974             : }
    1975             : /* x - u*y */
    1976             : INLINE GEN
    1977   148817641 : submuliu_inplace(GEN x, GEN y, ulong u)
    1978             : {
    1979             :   pari_sp av;
    1980   148817641 :   long ly = lgefint(y);
    1981   148817641 :   if (ly == 2) return x;
    1982   103965486 :   av = avma;
    1983   103965486 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1984   103973281 :   y = mului(u,y);
    1985   103970809 :   set_avma(av); return subii(x, y);
    1986             : }
    1987             : /* x + u*y */
    1988             : INLINE GEN
    1989   147649689 : addmuliu_inplace(GEN x, GEN y, ulong u)
    1990             : {
    1991             :   pari_sp av;
    1992   147649689 :   long ly = lgefint(y);
    1993   147649689 :   if (ly == 2) return x;
    1994   104092661 :   av = avma;
    1995   104092661 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1996   104099604 :   y = mului(u,y);
    1997   104097183 :   set_avma(av); return addii(x, y);
    1998             : }
    1999             : /* ux + vy */
    2000             : INLINE GEN
    2001    30377236 : lincombii(GEN u, GEN v, GEN x, GEN y)
    2002             : {
    2003    30377236 :   long lx = lgefint(x), ly;
    2004             :   GEN p1, p2;
    2005             :   pari_sp av;
    2006    30377236 :   if (lx == 2) return mulii(v,y);
    2007    17217267 :   ly = lgefint(y);
    2008    17217267 :   if (ly == 2) return mulii(u,x);
    2009    14804645 :   av = avma; (void)new_chunk(lx+ly+lgefint(u)+lgefint(v)); /* HACK */
    2010    14808397 :   p1 = mulii(u,x);
    2011    14806195 :   p2 = mulii(v,y);
    2012    14806096 :   set_avma(av); return addii(p1,p2);
    2013             : }
    2014             : 
    2015             : /*******************************************************************/
    2016             : /*                                                                 */
    2017             : /*                          GEN SUBTYPES                           */
    2018             : /*                                                                 */
    2019             : /*******************************************************************/
    2020             : 
    2021             : INLINE int
    2022  3950550695 : is_const_t(long t) { return (t < t_POLMOD); }
    2023             : INLINE int
    2024        6843 : is_extscalar_t(long t) { return (t <= t_POL); }
    2025             : INLINE int
    2026     5582889 : is_intreal_t(long t) { return (t <= t_REAL); }
    2027             : INLINE int
    2028   779619080 : is_matvec_t(long t) { return (t >= t_VEC && t <= t_MAT); }
    2029             : INLINE int
    2030    83337196 : 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     3683720 : is_rational_t(long t) { return (t == t_INT || t == t_FRAC); }
    2035             : INLINE int
    2036     1151906 : is_real_t(long t) { return (t == t_INT || t == t_REAL || t == t_FRAC); }
    2037             : INLINE int
    2038  8268584572 : is_recursive_t(long t) { return lontyp[t]; }
    2039             : INLINE int
    2040   242922664 : is_scalar_t(long t) { return (t < t_POL); }
    2041             : INLINE int
    2042     1137944 : is_vec_t(long t) { return (t == t_VEC || t == t_COL); }
    2043             : 
    2044             : INLINE int
    2045    61867251 : qfb_is_qfi(GEN q) { return signe(gel(q,4)) < 0; }
    2046             : 
    2047             : /*******************************************************************/
    2048             : /*                                                                 */
    2049             : /*                         TRANSCENDENTAL                          */
    2050             : /*                                                                 */
    2051             : /*******************************************************************/
    2052             : INLINE GEN
    2053    45087209 : sqrtr(GEN x) {
    2054    45087209 :   long s = signe(x);
    2055    45087209 :   if (s == 0) return real_0_bit(expo(x) >> 1);
    2056    45054119 :   if (s >= 0) return sqrtr_abs(x);
    2057      287905 :   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     1083021 : sqrtnr(GEN x, long n) {
    2072     1083021 :   long s = signe(x);
    2073             :   GEN r;
    2074     1083021 :   if (s == 0) return real_0_bit(expo(x) / n);
    2075     1083021 :   r = sqrtnr_abs(x, n);
    2076     1083042 :   if (s < 0) pari_err_IMPL("sqrtnr for x < 0");
    2077     1083042 :   return r;
    2078             : }
    2079             : INLINE long
    2080      568276 : logint(GEN B, GEN y) { return logintall(B,y,NULL); }
    2081             : INLINE ulong
    2082     2764510 : ulogint(ulong B, ulong y)
    2083             : {
    2084             :   ulong r;
    2085             :   long e;
    2086     2764510 :   if (y == 2) return expu(B);
    2087     2710221 :   r = y;
    2088     2710221 :   for (e=1;; e++)
    2089             :   { /* here, r = y^e, r2 = y^(e-1) */
    2090     8275585 :     if (r >= B) return r == B? e: e-1;
    2091     5566845 :     r = umuluu_or_0(y, r);
    2092     5566912 :     if (!r) return e;
    2093             :   }
    2094             : }
    2095             : 
    2096             : /*******************************************************************/
    2097             : /*                                                                 */
    2098             : /*                         MISCELLANEOUS                           */
    2099             : /*                                                                 */
    2100             : /*******************************************************************/
    2101     5582813 : INLINE int ismpzero(GEN x) { return is_intreal_t(typ(x)) && !signe(x); }
    2102  3302310228 : INLINE int isintzero(GEN x) { return typ(x) == t_INT && !signe(x); }
    2103    15224918 : INLINE int isint1(GEN x) { return typ(x)==t_INT && equali1(x); }
    2104     4759206 : INLINE int isintm1(GEN x){ return typ(x)==t_INT && equalim1(x);}
    2105  1030726107 : INLINE int equali1(GEN n)
    2106  1030726107 : { return (ulong) n[1] == (evallgefint(3UL) | evalsigne(1)) && n[2] == 1; }
    2107   136953186 : INLINE int equalim1(GEN n)
    2108   136953186 : { return (ulong) n[1] == (evallgefint(3UL) | evalsigne(-1)) && n[2] == 1; }
    2109             : /* works only for POSITIVE integers */
    2110  2837339751 : INLINE int is_pm1(GEN n)
    2111  2837339751 : { return lgefint(n) == 3 && n[2] == 1; }
    2112   488914767 : INLINE int is_bigint(GEN n)
    2113   488914767 : { long l = lgefint(n); return l > 3 || (l == 3 && (n[2] & HIGHBIT)); }
    2114             : 
    2115  1814925739 : INLINE int odd(long x) { return x & 1; }
    2116    56857498 : INLINE int both_odd(long x, long y) { return x & y & 1; }
    2117             : 
    2118             : INLINE int
    2119  6103948038 : isonstack(GEN x)
    2120  6103948038 : { return ((pari_sp)x >= pari_mainstack->bot
    2121  6103948038 :        && (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    66620126 : dbllog2r(GEN x)
    2126    66620126 : { return log2((double)(ulong)x[2]) + (double)(expo(x) - (BITS_IN_LONG-1)); }
    2127             : 
    2128             : INLINE GEN
    2129     1335993 : mul_content(GEN cx, GEN cy)
    2130             : {
    2131     1335993 :   if (!cx) return cy;
    2132      570822 :   if (!cy) return cx;
    2133      377142 :   return gmul(cx,cy);
    2134             : }
    2135             : INLINE GEN
    2136           0 : inv_content(GEN c) { return c? ginv(c): NULL; }
    2137             : INLINE GEN
    2138       36365 : div_content(GEN cx, GEN cy)
    2139             : {
    2140       36365 :   if (!cy) return cx;
    2141       35315 :   if (!cx) return ginv(cy);
    2142        7220 :   return gdiv(cx,cy);
    2143             : }
    2144             : INLINE GEN
    2145     5226440 : mul_denom(GEN dx, GEN dy)
    2146             : {
    2147     5226440 :   if (!dx) return dy;
    2148     1606726 :   if (!dy) return dx;
    2149      660021 :   return mulii(dx,dy);
    2150             : }
    2151             : 
    2152             : /* POLYNOMIALS */
    2153             : INLINE GEN
    2154     1309130 : constant_coeff(GEN x) { return signe(x)? gel(x,2): gen_0; }
    2155             : INLINE GEN
    2156    77586336 : leading_coeff(GEN x) { return lg(x) == 2? gen_0: gel(x,lg(x)-1); }
    2157             : INLINE ulong
    2158      685815 : Flx_lead(GEN x) { return lg(x) == 2? 0: x[lg(x)-1]; }
    2159             : INLINE ulong
    2160       34445 : Flx_constant(GEN x) { return lg(x) == 2? 0: x[2]; }
    2161             : INLINE long
    2162  4563626999 : degpol(GEN x) { return lg(x)-3; }
    2163             : INLINE long
    2164  2333465606 : lgpol(GEN x) { return lg(x)-2; }
    2165             : INLINE long
    2166   258546427 : lgcols(GEN x) { return lg(gel(x,1)); }
    2167             : INLINE long
    2168   120411356 : 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     1420632 : ZXQ_mul(GEN y, GEN x, GEN T) { return ZX_rem(ZX_mul(y, x), T); }
    2174             : INLINE GEN
    2175      574089 : ZXQ_sqr(GEN x, GEN T) { return ZX_rem(ZX_sqr(x), T); }
    2176             : 
    2177             : INLINE GEN
    2178    96743908 : RgX_copy(GEN x)
    2179             : {
    2180             :   long lx, i;
    2181    96743908 :   GEN y = cgetg_copy(x, &lx); y[1] = x[1];
    2182   351653254 :   for (i = 2; i<lx; i++) gel(y,i) = gcopy(gel(x,i));
    2183    96743927 :   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     2218048 : RgX_coeff(GEN x, long n)
    2189             : {
    2190     2218048 :   ulong l = lg(x);
    2191     2218048 :   return (n < 0 || ((ulong)n+3) > l)? gen_0: gel(x,n+2);
    2192             : }
    2193             : INLINE GEN
    2194      345537 : RgX_renormalize(GEN x) { return RgX_renormalize_lg(x, lg(x)); }
    2195             : INLINE GEN
    2196     6838185 : 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      105078 : RgXQX_rem(GEN x, GEN y, GEN T) { return RgXQX_divrem(x,y,T,ONLY_REM); }
    2201             : INLINE GEN
    2202     4441492 : FpX_div(GEN x, GEN y, GEN p) { return FpX_divrem(x,y,p, NULL); }
    2203             : INLINE GEN
    2204    23075187 : Flx_div(GEN x, GEN y, ulong p) { return Flx_divrem(x,y,p, NULL); }
    2205             : INLINE GEN
    2206     1252619 : F2x_div(GEN x, GEN y) { return F2x_divrem(x,y, NULL); }
    2207             : INLINE GEN
    2208           0 : FpV_FpC_mul(GEN x, GEN y, GEN p) { return FpV_dotproduct(x,y,p); }
    2209             : INLINE GEN
    2210    89686418 : pol0_Flx(long sv) { return mkvecsmall(sv); }
    2211             : INLINE GEN
    2212    51812803 : pol1_Flx(long sv) { return mkvecsmall2(sv, 1); }
    2213             : INLINE GEN
    2214    35453769 : polx_Flx(long sv) { return mkvecsmall3(sv, 0, 1); }
    2215             : INLINE GEN
    2216           0 : zero_zx(long sv) { return zero_Flx(sv); }
    2217             : INLINE GEN
    2218           0 : polx_zx(long sv) { return polx_Flx(sv); }
    2219             : INLINE GEN
    2220           0 : zx_shift(GEN x, long n) { return Flx_shift(x,n); }
    2221             : INLINE GEN
    2222       14028 : zx_renormalize(GEN x, long l) { return Flx_renormalize(x,l); }
    2223             : INLINE GEN
    2224        1341 : zero_F2x(long sv) { return zero_Flx(sv); }
    2225             : INLINE GEN
    2226    11863433 : pol0_F2x(long sv) { return pol0_Flx(sv); }
    2227             : INLINE GEN
    2228     3287226 : pol1_F2x(long sv) { return pol1_Flx(sv); }
    2229             : INLINE GEN
    2230     1004469 : polx_F2x(long sv) { return mkvecsmall2(sv, 2); }
    2231             : INLINE int
    2232     1026261 : F2x_equal1(GEN x) { return Flx_equal1(x); }
    2233             : INLINE int
    2234     3394213 : F2x_equal(GEN V, GEN W) { return Flx_equal(V,W); }
    2235             : INLINE GEN
    2236    56974938 : F2x_copy(GEN x) { return leafcopy(x); }
    2237             : INLINE GEN
    2238        4074 : F2v_copy(GEN x) { return leafcopy(x); }
    2239             : INLINE GEN
    2240     2342074 : Flv_copy(GEN x) { return leafcopy(x); }
    2241             : INLINE GEN
    2242   161676508 : Flx_copy(GEN x) { return leafcopy(x); }
    2243             : INLINE GEN
    2244     3940897 : vecsmall_copy(GEN x) { return leafcopy(x); }
    2245             : INLINE int
    2246     7679338 : Flx_equal1(GEN x) { return degpol(x)==0 && x[2] == 1; }
    2247             : INLINE int
    2248       19366 : ZX_equal1(GEN x) { return degpol(x)==0 && equali1(gel(x,2)); }
    2249             : INLINE int
    2250     5694920 : ZX_is_monic(GEN x) { return equali1(leading_coeff(x)); }
    2251             : 
    2252             : INLINE GEN
    2253   137602202 : ZX_renormalize(GEN x, long lx)    { return ZXX_renormalize(x,lx); }
    2254             : INLINE GEN
    2255    98341385 : FpX_renormalize(GEN x, long lx)   { return ZXX_renormalize(x,lx); }
    2256             : INLINE GEN
    2257      676855 : FpXX_renormalize(GEN x, long lx)  { return ZXX_renormalize(x,lx); }
    2258             : INLINE GEN
    2259     4250094 : FpXQX_renormalize(GEN x, long lx) { return ZXX_renormalize(x,lx); }
    2260             : INLINE GEN
    2261   114128166 : F2x_renormalize(GEN x, long lx)   { return Flx_renormalize(x,lx); }
    2262             : INLINE GEN
    2263       39946 : F2v_to_F2x(GEN x, long sv) {
    2264       39946 :   GEN y = leafcopy(x);
    2265       39946 :   y[1] = sv; F2x_renormalize(y, lg(y)); return y;
    2266             : }
    2267             : 
    2268             : INLINE long
    2269         371 : sturm(GEN x) { return sturmpart(x, NULL, NULL); }
    2270             : 
    2271             : INLINE long
    2272        4613 : gval(GEN x, long v)
    2273        4613 : { pari_sp av = avma; return gc_long(av, gvaluation(x, pol_x(v))); }
    2274             : 
    2275             : INLINE void
    2276      494108 : RgX_shift_inplace_init(long v)
    2277      494108 : { if (v) (void)cgetg(v, t_VECSMALL); }
    2278             : /* shift polynomial in place. assume v free cells have been left before x */
    2279             : INLINE GEN
    2280      494108 : RgX_shift_inplace(GEN x, long v)
    2281             : {
    2282             :   long i, lx;
    2283             :   GEN z;
    2284      494108 :   if (!v) return x;
    2285      253165 :   lx = lg(x);
    2286      253165 :   if (lx == 2) return x;
    2287      253165 :   z = x + lx;
    2288             :   /* stackdummy's from normalizepol */
    2289      253165 :   while (lg(z) != v) z += lg(z);
    2290      253165 :   z += v;
    2291     4654452 :   for (i = lx-1; i >= 2; i--) gel(--z,0) = gel(x,i);
    2292      675883 :   for (i = 0;  i < v; i++) gel(--z,0) = gen_0;
    2293      253165 :   z -= 2;
    2294      253165 :   z[1] = x[1];
    2295      253165 :   z[0] = evaltyp(t_POL) | evallg(lx+v);
    2296      253165 :   stackdummy((pari_sp)z, (pari_sp)x); return z;
    2297             : }
    2298             : 
    2299             : 
    2300             : /* LINEAR ALGEBRA */
    2301             : INLINE GEN
    2302      486577 : zv_to_ZV(GEN x) { return vecsmall_to_vec(x); }
    2303             : INLINE GEN
    2304     6879492 : zc_to_ZC(GEN x) { return vecsmall_to_col(x); }
    2305             : INLINE GEN
    2306     3417273 : ZV_to_zv(GEN x) { return vec_to_vecsmall(x); }
    2307             : INLINE GEN
    2308           0 : zx_to_zv(GEN x, long N) { return Flx_to_Flv(x,N); }
    2309             : INLINE GEN
    2310      104132 : zv_to_zx(GEN x, long sv) { return Flv_to_Flx(x,sv); }
    2311             : INLINE GEN
    2312           0 : zm_to_zxV(GEN x, long sv) { return Flm_to_FlxV(x,sv); }
    2313             : INLINE GEN
    2314           0 : zero_zm(long x, long y) { return zero_Flm(x,y); }
    2315             : INLINE GEN
    2316    27241883 : zero_zv(long x) { return zero_Flv(x); }
    2317             : INLINE GEN
    2318         266 : zm_transpose(GEN x) { return Flm_transpose(x); }
    2319             : INLINE GEN
    2320           0 : zm_copy(GEN x) { return Flm_copy(x); }
    2321             : INLINE GEN
    2322     2114626 : zv_copy(GEN x) { return Flv_copy(x); }
    2323             : INLINE GEN
    2324           0 : zm_row(GEN x, long i) { return Flm_row(x,i); }
    2325             : 
    2326             : INLINE GEN
    2327     7037620 : ZC_hnfrem(GEN x, GEN y) { return ZC_hnfremdiv(x,y,NULL); }
    2328             : INLINE GEN
    2329      313284 : ZM_hnfrem(GEN x, GEN y) { return ZM_hnfdivrem(x,y,NULL); }
    2330             : INLINE GEN
    2331     2445056 : ZM_lll(GEN x, double D, long f) { return ZM_lll_norms(x,D,f,NULL); }
    2332             : INLINE void
    2333     9156614 : RgM_dimensions(GEN x, long *m, long *n) { *n = lg(x)-1; *m = *n? nbrows(x): 0; }
    2334             : INLINE GEN
    2335    17409548 : RgM_shallowcopy(GEN x)
    2336             : {
    2337             :   long l;
    2338    17409548 :   GEN y = cgetg_copy(x, &l);
    2339    90201707 :   while (--l > 0) gel(y,l) = leafcopy(gel(x,l));
    2340    17409079 :   return y;
    2341             : }
    2342             : INLINE GEN
    2343      191691 : F2m_copy(GEN x) { return RgM_shallowcopy(x); }
    2344             : 
    2345             : INLINE GEN
    2346           0 : F3m_copy(GEN x) { return RgM_shallowcopy(x); }
    2347             : 
    2348             : INLINE GEN
    2349     5384256 : Flm_copy(GEN x) { return RgM_shallowcopy(x); }
    2350             : 
    2351             : /* divisibility: return 1 if y[i] | x[i] for all i, 0 otherwise. Assume
    2352             :  * x,y are ZV of the same length */
    2353             : INLINE int
    2354       23198 : ZV_dvd(GEN x, GEN y)
    2355             : {
    2356       23198 :   long i, l = lg(x);
    2357       36666 :   for (i=1; i < l; i++)
    2358       29533 :     if ( ! dvdii( gel(x,i), gel(y,i) ) ) return 0;
    2359        7133 :   return 1;
    2360             : }
    2361             : 
    2362             : /* Fq */
    2363             : INLINE GEN
    2364     2559245 : Fq_red(GEN x, GEN T, GEN p)
    2365     2559245 : { return typ(x)==t_INT? Fp_red(x,p): FpXQ_red(x,T,p); }
    2366             : INLINE GEN
    2367      101163 : Fq_to_FpXQ(GEN x, GEN T, GEN p /*unused*/)
    2368             : {
    2369             :   (void) p;
    2370      101163 :   return typ(x)==t_INT ? scalarpol(x, get_FpX_var(T)): x;
    2371             : }
    2372             : INLINE GEN
    2373         756 : Rg_to_Fq(GEN x, GEN T, GEN p) { return T? Rg_to_FpXQ(x,T,p): Rg_to_Fp(x,p); }
    2374             : 
    2375             : INLINE GEN
    2376       14560 : gener_Fq_local(GEN T, GEN p, GEN L)
    2377           0 : { return T? gener_FpXQ_local(T,p, L)
    2378       14560 :           : pgener_Fp_local(p, L); }
    2379             : 
    2380             : /* FpXQX */
    2381             : INLINE GEN
    2382        4417 : FpXQX_div(GEN x, GEN y, GEN T, GEN p) { return FpXQX_divrem(x, y, T, p, NULL); }
    2383             : INLINE GEN
    2384      163808 : FlxqX_div(GEN x, GEN y, GEN T, ulong p) { return FlxqX_divrem(x, y, T, p, NULL); }
    2385             : INLINE GEN
    2386       33376 : F2xqX_div(GEN x, GEN y, GEN T) { return F2xqX_divrem(x, y, T, NULL); }
    2387             : 
    2388             : INLINE GEN
    2389       20006 : FpXY_Fq_evaly(GEN Q, GEN y, GEN T, GEN p, long vx)
    2390       20006 : { return T ? FpXY_FpXQ_evaly(Q, y, T, p, vx): FpXY_evaly(Q, y, p, vx); }
    2391             : 
    2392             : /* FqX */
    2393             : INLINE GEN
    2394       25109 : FqX_red(GEN z, GEN T, GEN p) { return T? FpXQX_red(z, T, p): FpX_red(z, p); }
    2395             : INLINE GEN
    2396      105343 : FqX_add(GEN x,GEN y,GEN T,GEN p) { return T? FpXX_add(x,y,p): FpX_add(x,y,p); }
    2397             : INLINE GEN
    2398       24313 : FqX_neg(GEN x,GEN T,GEN p) { return T? FpXX_neg(x,p): FpX_neg(x,p); }
    2399             : INLINE GEN
    2400       66458 : FqX_sub(GEN x,GEN y,GEN T,GEN p) { return T? FpXX_sub(x,y,p): FpX_sub(x,y,p); }
    2401             : INLINE GEN
    2402      628933 : FqX_Fp_mul(GEN P, GEN u, GEN T, GEN p)
    2403      628933 : { return T? FpXX_Fp_mul(P, u, p): FpX_Fp_mul(P, u, p); }
    2404             : INLINE GEN
    2405      405080 : FqX_Fq_mul(GEN P, GEN U, GEN T, GEN p)
    2406      405080 : { return typ(U)==t_INT ? FqX_Fp_mul(P, U, T, p): FpXQX_FpXQ_mul(P, U, T, p); }
    2407             : INLINE GEN
    2408      377515 : FqX_mul(GEN x, GEN y, GEN T, GEN p)
    2409      377515 : { return T? FpXQX_mul(x, y, T, p): FpX_mul(x, y, p); }
    2410             : INLINE GEN
    2411       17510 : FqX_mulu(GEN x, ulong y, GEN T, GEN p)
    2412       17510 : { return T? FpXX_mulu(x, y, p): FpX_mulu(x, y, p); }
    2413             : INLINE GEN
    2414       69678 : FqX_sqr(GEN x, GEN T, GEN p)
    2415       69678 : { return T? FpXQX_sqr(x, T, p): FpX_sqr(x, p); }
    2416             : INLINE GEN
    2417        1281 : FqX_powu(GEN x, ulong n, GEN T, GEN p)
    2418        1281 : { return T? FpXQX_powu(x, n, T, p): FpX_powu(x, n, p); }
    2419             : INLINE GEN
    2420       18774 : FqX_halve(GEN x, GEN T, GEN p)
    2421       18774 : { return T? FpXX_halve(x, p): FpX_halve(x, p); }
    2422             : INLINE GEN
    2423       38884 : FqX_div(GEN x, GEN y, GEN T, GEN p)
    2424       38884 : { return T? FpXQX_divrem(x,y,T,p,NULL): FpX_divrem(x,y,p,NULL); }
    2425             : INLINE GEN
    2426        6081 : FqX_get_red(GEN S, GEN T, GEN p)
    2427        6081 : { return T? FpXQX_get_red(S,T,p): FpX_get_red(S,p); }
    2428             : INLINE GEN
    2429       31086 : FqX_rem(GEN x, GEN y, GEN T, GEN p)
    2430       31086 : { return T? FpXQX_rem(x,y,T,p): FpX_rem(x,y,p); }
    2431             : INLINE GEN
    2432           0 : FqX_divrem(GEN x, GEN y, GEN T, GEN p, GEN *z)
    2433           0 : { return T? FpXQX_divrem(x,y,T,p,z): FpX_divrem(x,y,p,z); }
    2434             : INLINE GEN
    2435        5936 : FqX_div_by_X_x(GEN x, GEN y, GEN T, GEN p, GEN *z)
    2436        5936 : { return T? FpXQX_div_by_X_x(x,y,T,p,z): FpX_div_by_X_x(x,y,p,z); }
    2437             : INLINE GEN
    2438           0 : FqX_halfgcd(GEN P,GEN Q,GEN T,GEN p)
    2439           0 : {return T? FpXQX_halfgcd(P,Q,T,p): FpX_halfgcd(P,Q,p);}
    2440             : INLINE GEN
    2441      260883 : FqX_gcd(GEN P,GEN Q,GEN T,GEN p)
    2442      260883 : {return T? FpXQX_gcd(P,Q,T,p): FpX_gcd(P,Q,p);}
    2443             : INLINE GEN
    2444      479090 : FqX_extgcd(GEN P,GEN Q,GEN T,GEN p, GEN *U, GEN *V)
    2445      479090 : { return T? FpXQX_extgcd(P,Q,T,p,U,V): FpX_extgcd(P,Q,p,U,V); }
    2446             : INLINE GEN
    2447        3955 : FqX_normalize(GEN z, GEN T, GEN p)
    2448        3955 : { return T? FpXQX_normalize(z, T, p): FpX_normalize(z, p); }
    2449             : INLINE GEN
    2450      291893 : FqX_deriv(GEN f, GEN T, GEN p) { return T? FpXX_deriv(f, p): FpX_deriv(f, p); }
    2451             : INLINE GEN
    2452           0 : FqX_integ(GEN f, GEN T, GEN p) { return T? FpXX_integ(f, p): FpX_integ(f, p); }
    2453             : INLINE GEN
    2454       86310 : FqX_factor(GEN f, GEN T, GEN p)
    2455       86310 : { return T?FpXQX_factor(f, T, p): FpX_factor(f, p); }
    2456             : INLINE GEN
    2457           7 : FqX_factor_squarefree(GEN f, GEN T, GEN p)
    2458           7 : { return T ? FpXQX_factor_squarefree(f, T, p): FpX_factor_squarefree(f, p); }
    2459             : INLINE GEN
    2460           7 : FqX_ddf(GEN f, GEN T, GEN p)
    2461           7 : { return T ? FpXQX_ddf(f, T, p): FpX_ddf(f, p); }
    2462             : INLINE GEN
    2463       61404 : FqX_degfact(GEN f, GEN T, GEN p)
    2464       61404 : { return T?FpXQX_degfact(f, T, p): FpX_degfact(f, p); }
    2465             : INLINE GEN
    2466        7147 : FqX_roots(GEN f, GEN T, GEN p)
    2467        7147 : { return T?FpXQX_roots(f, T, p): FpX_roots(f, p); }
    2468             : INLINE GEN
    2469         175 : FqX_to_mod(GEN f, GEN T, GEN p)
    2470         175 : { return T?FpXQX_to_mod(f, T, p): FpX_to_mod(f, p); }
    2471             : 
    2472             : /*FqXQ*/
    2473             : INLINE GEN
    2474           0 : FqXQ_add(GEN x, GEN y, GEN S/*unused*/, GEN T, GEN p)
    2475           0 : { (void)S; return T? FpXX_add(x,y,p): FpX_add(x,y,p); }
    2476             : INLINE GEN
    2477           0 : FqXQ_sub(GEN x, GEN y, GEN S/*unused*/, GEN T, GEN p)
    2478           0 : { (void)S; return T? FpXX_sub(x,y,p): FpX_sub(x,y,p); }
    2479             : INLINE GEN
    2480           0 : FqXQ_div(GEN x, GEN y, GEN S, GEN T, GEN p)
    2481           0 : { return T? FpXQXQ_div(x,y,S,T,p): FpXQ_div(x,y,S,p); }
    2482             : INLINE GEN
    2483           0 : FqXQ_inv(GEN x, GEN S, GEN T, GEN p)
    2484           0 : { return T? FpXQXQ_inv(x,S,T,p): FpXQ_inv(x,S,p); }
    2485             : INLINE GEN
    2486           0 : FqXQ_invsafe(GEN x, GEN S, GEN T, GEN p)
    2487           0 : { return T? FpXQXQ_invsafe(x,S,T,p): FpXQ_inv(x,S,p); }
    2488             : INLINE GEN
    2489       22320 : FqXQ_mul(GEN x, GEN y, GEN S, GEN T, GEN p)
    2490       22320 : { return T? FpXQXQ_mul(x,y,S,T,p): FpXQ_mul(x,y,S,p); }
    2491             : INLINE GEN
    2492           0 : FqXQ_sqr(GEN x, GEN S, GEN T, GEN p)
    2493           0 : { return T? FpXQXQ_sqr(x,S,T,p): FpXQ_sqr(x,S,p); }
    2494             : INLINE GEN
    2495           0 : FqXQ_pow(GEN x, GEN n, GEN S, GEN T, GEN p)
    2496           0 : { return T? FpXQXQ_pow(x,n,S,T,p): FpXQ_pow(x,n,S,p); }
    2497             : 
    2498             : /*FqXn*/
    2499             : INLINE GEN
    2500        6610 : FqXn_expint(GEN x, long n, GEN T, GEN p)
    2501        6610 : { return T? FpXQXn_expint(x,n,T,p): FpXn_expint(x,n,p); }
    2502             : INLINE GEN
    2503           0 : FqXn_exp(GEN x, long n, GEN T, GEN p)
    2504           0 : { return T? FpXQXn_exp(x,n,T,p): FpXn_exp(x,n,p); }
    2505             : INLINE GEN
    2506        6916 : FqXn_inv(GEN x, long n, GEN T, GEN p)
    2507        6916 : { return T? FpXQXn_inv(x,n,T,p): FpXn_inv(x,n,p); }
    2508             : INLINE GEN
    2509      254926 : FqXn_mul(GEN x, GEN y, long n, GEN T, GEN p)
    2510      254926 : { return T? FpXQXn_mul(x, y, n, T, p): FpXn_mul(x, y, n, p); }
    2511             : INLINE GEN
    2512           0 : FqXn_sqr(GEN x, long n, GEN T, GEN p)
    2513           0 : { return T? FpXQXn_sqr(x,n,T,p): FpXn_sqr(x,n,p); }
    2514             : 
    2515             : /*FpXQ*/
    2516             : INLINE GEN
    2517           0 : FpXQ_add(GEN x,GEN y,GEN T/*unused*/,GEN p)
    2518           0 : { (void)T; return FpX_add(x,y,p); }
    2519             : INLINE GEN
    2520           0 : FpXQ_sub(GEN x,GEN y,GEN T/*unused*/,GEN p)
    2521           0 : { (void)T; return FpX_sub(x,y,p); }
    2522             : 
    2523             : /*Flxq*/
    2524             : INLINE GEN
    2525           0 : Flxq_add(GEN x,GEN y,GEN T/*unused*/,ulong p)
    2526           0 : { (void)T; return Flx_add(x,y,p); }
    2527             : INLINE GEN
    2528           0 : Flxq_sub(GEN x,GEN y,GEN T/*unused*/,ulong p)
    2529           0 : { (void)T; return Flx_sub(x,y,p); }
    2530             : 
    2531             : /* F2x */
    2532             : 
    2533             : INLINE ulong
    2534   663824906 : F2x_coeff(GEN x,long v)
    2535             : {
    2536   663824906 :    ulong u=(ulong)x[2+divsBIL(v)];
    2537   663823128 :    return (u>>remsBIL(v))&1UL;
    2538             : }
    2539             : 
    2540             : INLINE void
    2541    11464501 : F2x_clear(GEN x,long v)
    2542             : {
    2543    11464501 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2544    11464425 :    *u&=~(1UL<<remsBIL(v));
    2545    11464407 : }
    2546             : 
    2547             : INLINE void
    2548   119730878 : F2x_set(GEN x,long v)
    2549             : {
    2550   119730878 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2551   119711077 :    *u|=1UL<<remsBIL(v);
    2552   119701795 : }
    2553             : 
    2554             : INLINE void
    2555     1581048 : F2x_flip(GEN x,long v)
    2556             : {
    2557     1581048 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2558     1581048 :    *u^=1UL<<remsBIL(v);
    2559     1581048 : }
    2560             : 
    2561             : /* F2v */
    2562             : 
    2563             : INLINE ulong
    2564   657058568 : F2v_coeff(GEN x,long v) { return F2x_coeff(x,v-1); }
    2565             : 
    2566             : INLINE void
    2567    11464507 : F2v_clear(GEN x,long v) { F2x_clear(x,v-1); }
    2568             : 
    2569             : INLINE void
    2570    94056954 : F2v_set(GEN x,long v)   { F2x_set(x,v-1); }
    2571             : 
    2572             : INLINE void
    2573     1581048 : F2v_flip(GEN x,long v) { F2x_flip(x,v-1); }
    2574             : 
    2575             : /* F2m */
    2576             : 
    2577             : INLINE ulong
    2578     6557162 : F2m_coeff(GEN x, long a, long b) { return F2v_coeff(gel(x,b), a); }
    2579             : 
    2580             : INLINE void
    2581           0 : F2m_clear(GEN x, long a, long b) { F2v_clear(gel(x,b), a); }
    2582             : 
    2583             : INLINE void
    2584         672 : F2m_set(GEN x, long a, long b) { F2v_set(gel(x,b), a); }
    2585             : 
    2586             : INLINE void
    2587     1581048 : F2m_flip(GEN x, long a, long b) { F2v_flip(gel(x,b), a); }
    2588             : 
    2589             : /* F3m */
    2590             : 
    2591             : INLINE ulong
    2592     1404497 : F3m_coeff(GEN x, long a, long b) { return F3v_coeff(gel(x,b), a); }
    2593             : 
    2594             : INLINE void
    2595           0 : F3m_set(GEN x, long a, long b, ulong c) { F3v_set(gel(x,b), a, c); }
    2596             : 
    2597             : /* ARITHMETIC */
    2598             : INLINE GEN
    2599       34180 : matpascal(long n) { return matqpascal(n, NULL); }
    2600             : INLINE long
    2601      543996 : Z_issquare(GEN x) { return Z_issquareall(x, NULL); }
    2602             : INLINE long
    2603          14 : Z_ispower(GEN x, ulong k) { return Z_ispowerall(x, k, NULL); }
    2604             : INLINE GEN
    2605     4838506 : sqrti(GEN x) { return sqrtremi(x,NULL); }
    2606             : INLINE GEN
    2607   128309881 : gaddgs(GEN y, long s) { return gaddsg(s,y); }
    2608             : INLINE int
    2609      552715 : gcmpgs(GEN y, long s) { return -gcmpsg(s,y); }
    2610             : INLINE int
    2611       24976 : gequalgs(GEN y, long s) { return gequalsg(s,y); }
    2612             : INLINE GEN
    2613           0 : gmaxsg(long s, GEN y) { return gmaxgs(y,s); }
    2614             : INLINE GEN
    2615           0 : gminsg(long s, GEN y) { return gmings(y,s); }
    2616             : INLINE GEN
    2617    47581406 : gmulgs(GEN y, long s) { return gmulsg(s,y); }
    2618             : INLINE GEN
    2619   132187381 : gmulgu(GEN y, ulong s) { return gmulug(s,y); }
    2620             : INLINE GEN
    2621     1384538 : gsubgs(GEN y, long s) { return gaddgs(y, -s); }
    2622             : INLINE GEN
    2623      223769 : gdivsg(long s, GEN y) { return gdiv(stoi(s), y); }
    2624             : 
    2625             : INLINE GEN
    2626    13508203 : gmax_shallow(GEN x, GEN y) { return gcmp(x,y)<0? y: x; }
    2627             : INLINE GEN
    2628      908950 : gmin_shallow(GEN x, GEN y) { return gcmp(x,y)<0? x: y; }
    2629             : 
    2630             : /* x t_COMPLEX */
    2631             : INLINE GEN
    2632    65935027 : cxnorm(GEN x) { return gadd(gsqr(gel(x,1)), gsqr(gel(x,2))); }
    2633             : /* q t_QUAD */
    2634             : INLINE GEN
    2635       69853 : quadnorm(GEN q)
    2636             : {
    2637       69853 :   GEN X = gel(q,1), b = gel(X,3), c = gel(X,2);
    2638       69853 :   GEN z, u = gel(q,3), v = gel(q,2);
    2639       69853 :   if (typ(u) == t_INT && typ(v) == t_INT) /* generic case */
    2640             :   {
    2641       69664 :     z = signe(b)? mulii(v, addii(u,v)): sqri(v);
    2642       69664 :     return addii(z, mulii(c, sqri(u)));
    2643             :   }
    2644             :   else
    2645             :   {
    2646         189 :     z = signe(b)? gmul(v, gadd(u,v)): gsqr(v);
    2647         189 :     return gadd(z, gmul(c, gsqr(u)));
    2648             :   }
    2649             : }
    2650             : /* x a t_QUAD, return the attached discriminant */
    2651             : INLINE GEN
    2652        1064 : quad_disc(GEN x)
    2653             : {
    2654        1064 :   GEN Q = gel(x,1), b = gel(Q,3), c = gel(Q,2), c4 = shifti(c,2);
    2655        1064 :   if (is_pm1(b)) return subsi(1, c4);
    2656         154 :   togglesign_safe(&c4); return c4;
    2657             : }
    2658             : INLINE GEN
    2659       84609 : qfb_disc3(GEN x, GEN y, GEN z) { return subii(sqri(y), shifti(mulii(x,z),2)); }
    2660             : INLINE GEN
    2661    18273498 : qfb_disc(GEN x) { return gel(x,4); }
    2662             : 
    2663             : INLINE GEN
    2664     2824521 : sqrfrac(GEN x)
    2665             : {
    2666     2824521 :   GEN z = cgetg(3,t_FRAC);
    2667     2824521 :   gel(z,1) = sqri(gel(x,1));
    2668     2824521 :   gel(z,2) = sqri(gel(x,2)); return z;
    2669             : }
    2670             : 
    2671             : INLINE void
    2672    14938009 : normalize_frac(GEN z) {
    2673    14938009 :   if (signe(gel(z,2)) < 0) { togglesign(gel(z,1)); setabssign(gel(z,2)); }
    2674    14938009 : }
    2675             : 
    2676             : INLINE GEN
    2677      657086 : powii(GEN x, GEN n)
    2678             : {
    2679      657086 :   long ln = lgefint(n);
    2680      657086 :   if (ln == 3) {
    2681             :     GEN z;
    2682      634698 :     if (signe(n) > 0) return powiu(x, n[2]);
    2683       69302 :     z = cgetg(3, t_FRAC);
    2684       69312 :     gel(z,1) = gen_1;
    2685       69312 :     gel(z,2) = powiu(x, n[2]);
    2686       69314 :     return z;
    2687             :   }
    2688       22388 :   if (ln == 2) return gen_1; /* rare */
    2689             :   /* should never happen */
    2690           0 :   return powgi(x, n); /* overflow unless x = 0, 1, -1 */
    2691             : }
    2692             : INLINE GEN
    2693        1533 : powIs(long n) {
    2694        1533 :   switch(n & 3)
    2695             :   {
    2696          63 :     case 1: return mkcomplex(gen_0,gen_1);
    2697         385 :     case 2: return gen_m1;
    2698         721 :     case 3: return mkcomplex(gen_0,gen_m1);
    2699             :   }
    2700         364 :   return gen_1;
    2701             : }
    2702             : 
    2703             : /*******************************************************************/
    2704             : /*                                                                 */
    2705             : /*                             ASSIGNMENTS                         */
    2706             : /*                                                                 */
    2707             : /*******************************************************************/
    2708           0 : INLINE void mpexpz(GEN x, GEN z)
    2709           0 : { pari_sp av = avma; gaffect(mpexp(x), z); set_avma(av); }
    2710           0 : INLINE void mplogz(GEN x, GEN z)
    2711           0 : { pari_sp av = avma; gaffect(mplog(x), z); set_avma(av); }
    2712           0 : INLINE void mpcosz(GEN x, GEN z)
    2713           0 : { pari_sp av = avma; gaffect(mpcos(x), z); set_avma(av); }
    2714           0 : INLINE void mpsinz(GEN x, GEN z)
    2715           0 : { pari_sp av = avma; gaffect(mpsin(x), z); set_avma(av); }
    2716           0 : INLINE void gnegz(GEN x, GEN z)
    2717           0 : { pari_sp av = avma; gaffect(gneg(x), z); set_avma(av); }
    2718           0 : INLINE void gabsz(GEN x, long prec, GEN z)
    2719           0 : { pari_sp av = avma; gaffect(gabs(x,prec), z); set_avma(av); }
    2720           0 : INLINE void gaddz(GEN x, GEN y, GEN z)
    2721           0 : { pari_sp av = avma; gaffect(gadd(x,y), z); set_avma(av); }
    2722           0 : INLINE void gsubz(GEN x, GEN y, GEN z)
    2723           0 : { pari_sp av = avma; gaffect(gsub(x,y), z); set_avma(av); }
    2724           0 : INLINE void gmulz(GEN x, GEN y, GEN z)
    2725           0 : { pari_sp av = avma; gaffect(gmul(x,y), z); set_avma(av); }
    2726           0 : INLINE void gdivz(GEN x, GEN y, GEN z)
    2727           0 : { pari_sp av = avma; gaffect(gdiv(x,y), z); set_avma(av); }
    2728           0 : INLINE void gdiventz(GEN x, GEN y, GEN z)
    2729           0 : { pari_sp av = avma; gaffect(gdivent(x,y), z); set_avma(av); }
    2730           0 : INLINE void gmodz(GEN x, GEN y, GEN z)
    2731           0 : { pari_sp av = avma; gaffect(gmod(x,y), z); set_avma(av); }
    2732           0 : INLINE void gmul2nz(GEN x, long s, GEN z)
    2733           0 : { pari_sp av = avma; gaffect(gmul2n(x,s), z); set_avma(av); }
    2734           0 : INLINE void gshiftz(GEN x, long s, GEN z)
    2735           0 : { pari_sp av = avma; gaffect(gshift(x,s), z); set_avma(av); }
    2736             : 
    2737             : /*******************************************************************/
    2738             : /*                                                                 */
    2739             : /*                       ELLIPTIC CURVES                           */
    2740             : /*                                                                 */
    2741             : /*******************************************************************/
    2742     4214702 : INLINE GEN ell_get_a1(GEN e) { return gel(e,1); }
    2743     3208702 : INLINE GEN ell_get_a2(GEN e) { return gel(e,2); }
    2744     4041060 : INLINE GEN ell_get_a3(GEN e) { return gel(e,3); }
    2745     3978338 : INLINE GEN ell_get_a4(GEN e) { return gel(e,4); }
    2746     4764571 : INLINE GEN ell_get_a6(GEN e) { return gel(e,5); }
    2747     3390379 : INLINE GEN ell_get_b2(GEN e) { return gel(e,6); }
    2748     1058067 : INLINE GEN ell_get_b4(GEN e) { return gel(e,7); }
    2749     1664113 : INLINE GEN ell_get_b6(GEN e) { return gel(e,8); }
    2750     1490482 : INLINE GEN ell_get_b8(GEN e) { return gel(e,9); }
    2751     6066002 : INLINE GEN ell_get_c4(GEN e) { return gel(e,10); }
    2752     7264399 : INLINE GEN ell_get_c6(GEN e) { return gel(e,11); }
    2753     9223166 : INLINE GEN ell_get_disc(GEN e) { return gel(e,12); }
    2754     1044062 : INLINE GEN ell_get_j(GEN e) { return gel(e,13); }
    2755     9900091 : INLINE long ell_get_type(GEN e) { return mael(e,14,1); }
    2756     1571405 : INLINE GEN ellff_get_field(GEN x) { return gmael(x, 15, 1); }
    2757      683555 : INLINE GEN ellff_get_a4a6(GEN x)  { return gmael(x, 15, 2); }
    2758        1484 : INLINE GEN ellQp_get_zero(GEN x) { return gmael(x, 15, 1); }
    2759         315 : INLINE long ellQp_get_prec(GEN E) { GEN z = ellQp_get_zero(E); return valp(z); }
    2760        1134 : INLINE GEN ellQp_get_p(GEN E) { GEN z = ellQp_get_zero(E); return gel(z,2); }
    2761       37562 : INLINE long ellR_get_prec(GEN x) { return nbits2prec(mael3(x, 15, 1, 1)); }
    2762       17225 : INLINE long ellR_get_sign(GEN x) { return mael3(x, 15, 1, 2); }
    2763      715892 : INLINE GEN ellnf_get_nf(GEN x) { return checknf_i(gmael(x,15,1)); }
    2764          56 : INLINE GEN ellnf_get_bnf(GEN x) { return checkbnf_i(gmael(x,15,1)); }
    2765             : 
    2766     4131662 : INLINE int checkell_i(GEN e) { return typ(e) == t_VEC && lg(e) == 17; }
    2767    38154570 : INLINE int ell_is_inf(GEN z) { return lg(z) == 2; }
    2768      918609 : INLINE GEN ellinf(void) { return mkvec(gen_0); }
    2769             : 
    2770             : /*******************************************************************/
    2771             : /*                                                                 */
    2772             : /*                    ALGEBRAIC NUMBER THEORY                      */
    2773             : /*                                                                 */
    2774             : /*******************************************************************/
    2775    16768060 : INLINE GEN modpr_get_pr(GEN x)  { return gel(x,3); }
    2776      724815 : INLINE GEN modpr_get_p(GEN x)  { return pr_get_p(modpr_get_pr(x)); }
    2777     7028566 : INLINE GEN modpr_get_T(GEN x)  { return lg(x) == 4? NULL: gel(x,4); }
    2778             : 
    2779    62879101 : INLINE GEN pr_get_p(GEN pr)  { return gel(pr,1); }
    2780     8627815 : INLINE GEN pr_get_gen(GEN pr){ return gel(pr,2); }
    2781             : /* .[2] instead of itos works: e and f are small positive integers */
    2782     7565075 : INLINE long pr_get_e(GEN pr) { return gel(pr,3)[2]; }
    2783    21871097 : INLINE long pr_get_f(GEN pr) { return gel(pr,4)[2]; }
    2784    39828394 : INLINE GEN pr_get_tau(GEN pr){ return gel(pr,5); }
    2785             : INLINE int
    2786     5687002 : pr_is_inert(GEN P) { return typ(pr_get_tau(P)) == t_INT; }
    2787             : INLINE GEN
    2788     1169322 : pr_norm(GEN pr) { return powiu(pr_get_p(pr), pr_get_f(pr)); }
    2789             : INLINE ulong
    2790      310077 : upr_norm(GEN pr) { return upowuu(pr_get_p(pr)[2], pr_get_f(pr)); }
    2791             : 
    2792             : /* assume nf a genuine nf */
    2793             : INLINE long
    2794      817700 : nf_get_varn(GEN nf) { return varn(gel(nf,1)); }
    2795             : INLINE GEN
    2796    64899224 : nf_get_pol(GEN nf) { return gel(nf,1); }
    2797             : INLINE long
    2798    45096220 : nf_get_degree(GEN nf) { return degpol( nf_get_pol(nf) ); }
    2799             : INLINE long
    2800     3578638 : nf_get_r1(GEN nf) { GEN x = gel(nf,2); return itou(gel(x,1)); }
    2801             : INLINE long
    2802       15025 : nf_get_r2(GEN nf) { GEN x = gel(nf,2); return itou(gel(x,2)); }
    2803             : INLINE GEN
    2804      441899 : nf_get_disc(GEN nf) { return gel(nf,3); }
    2805             : INLINE GEN
    2806     2398794 : nf_get_index(GEN nf) { return gel(nf,4); }
    2807             : INLINE GEN
    2808     3249980 : nf_get_M(GEN nf) { return gmael(nf,5,1); }
    2809             : INLINE GEN
    2810      533077 : nf_get_G(GEN nf) { return gmael(nf,5,2); }
    2811             : INLINE GEN
    2812     1264870 : nf_get_roundG(GEN nf) { return gmael(nf,5,3); }
    2813             : INLINE GEN
    2814       21531 : nf_get_Tr(GEN nf) { return gmael(nf,5,4); }
    2815             : INLINE GEN
    2816        5908 : nf_get_diff(GEN nf) { return gmael(nf,5,5); }
    2817             : INLINE GEN
    2818       55179 : nf_get_ramified_primes(GEN nf) { return gmael(nf,5,8); }
    2819             : INLINE GEN
    2820     1234527 : nf_get_roots(GEN nf) { return gel(nf,6); }
    2821             : INLINE GEN
    2822        1792 : nf_get_zk(GEN nf)
    2823             : {
    2824        1792 :   GEN y = gel(nf,7), D = gel(y, 1);
    2825        1792 :   if (typ(D) == t_POL) D = gel(D, 2);
    2826        1792 :   if (!equali1(D)) y = gdiv(y, D);
    2827        1792 :   return y;
    2828             : }
    2829             : INLINE GEN
    2830     3056136 : nf_get_zkprimpart(GEN nf)
    2831             : {
    2832     3056136 :   GEN y = gel(nf,7);
    2833             :   /* test for old format of nf.zk: non normalized */
    2834     3056136 :   if (!equali1(gel(nf,4)) && gequal1(gel(y,1))) y = Q_remove_denom(y,NULL);
    2835     3056133 :   return y;
    2836             : }
    2837             : INLINE GEN
    2838     3102617 : nf_get_zkden(GEN nf)
    2839             : {
    2840     3102617 :   GEN y = gel(nf,7), D = gel(y,1);
    2841     3102617 :   if (typ(D) == t_POL) D = gel(D,2);
    2842             :   /* test for old format of nf.zk: non normalized */
    2843     3102617 :   if (!equali1(gel(nf,4)) && equali1(D)) D = Q_denom(y);
    2844     3102615 :   return D;
    2845             : }
    2846             : INLINE GEN
    2847     7557069 : nf_get_invzk(GEN nf) { return gel(nf,8); }
    2848             : INLINE void
    2849      242172 : nf_get_sign(GEN nf, long *r1, long *r2)
    2850             : {
    2851      242172 :   GEN x = gel(nf,2);
    2852      242172 :   *r1 = itou(gel(x,1));
    2853      242171 :   *r2 = itou(gel(x,2));
    2854      242174 : }
    2855             : 
    2856             : INLINE GEN
    2857     1462060 : cyc_get_expo(GEN c) { return lg(c) == 1? gen_1: gel(c,1); }
    2858             : INLINE GEN
    2859      409612 : abgrp_get_no(GEN x) { return gel(x,1); }
    2860             : INLINE GEN
    2861     5807709 : abgrp_get_cyc(GEN x) { return gel(x,2); }
    2862             : INLINE GEN
    2863      995906 : abgrp_get_gen(GEN x) { return gel(x,3); }
    2864             : INLINE GEN
    2865     5617333 : bnf_get_nf(GEN bnf) { return gel(bnf,7); }
    2866             : INLINE GEN
    2867     2805932 : bnf_get_clgp(GEN bnf) { return gmael(bnf,8,1); }
    2868             : INLINE GEN
    2869       30303 : bnf_get_no(GEN bnf) { return abgrp_get_no(bnf_get_clgp(bnf)); }
    2870             : INLINE GEN
    2871     1836200 : bnf_get_cyc(GEN bnf) { return abgrp_get_cyc(bnf_get_clgp(bnf)); }
    2872             : INLINE GEN
    2873      939278 : bnf_get_gen(GEN bnf)  { return abgrp_get_gen(bnf_get_clgp(bnf)); }
    2874             : INLINE GEN
    2875         643 : bnf_get_reg(GEN bnf) { return gmael(bnf,8,2); }
    2876             : INLINE GEN
    2877     1436496 : bnf_get_logfu(GEN bnf) { return gel(bnf,3); }
    2878             : INLINE GEN
    2879      634397 : bnf_get_sunits(GEN bnf)
    2880      634397 : { GEN s = gmael(bnf,8,3); return typ(s) == t_INT? NULL: s; }
    2881             : INLINE GEN
    2882      289035 : bnf_get_tuU(GEN bnf) { return gmael3(bnf,8,4,2); }
    2883             : INLINE long
    2884      263814 : bnf_get_tuN(GEN bnf) { return gmael3(bnf,8,4,1)[2]; }
    2885             : INLINE GEN
    2886      287150 : bnf_get_fu_nocheck(GEN bnf) { return gmael(bnf,8,5); }
    2887             : INLINE GEN
    2888       26418 : nfV_to_scalar_or_alg(GEN nf, GEN x)
    2889       63714 : { pari_APPLY_same(nf_to_scalar_or_alg(nf, gel(x,i))) }
    2890             : INLINE GEN
    2891       25984 : bnf_get_fu(GEN bnf) {
    2892       25984 :   GEN fu = bnf_build_units(bnf), nf = bnf_get_nf(bnf);
    2893       25984 :   if (typ(fu) == t_MAT) pari_err(e_MISC,"missing units in bnf");
    2894       25984 :   return nfV_to_scalar_or_alg(nf, vecslice(fu, 2, lg(fu)-1));
    2895             : }
    2896             : 
    2897             : INLINE GEN
    2898     1628000 : bnr_get_bnf(GEN bnr) { return gel(bnr,1); }
    2899             : INLINE GEN
    2900      934099 : bnr_get_bid(GEN bnr) { return gel(bnr,2); }
    2901             : INLINE GEN
    2902      137046 : bnr_get_mod(GEN bnr) { return gmael(bnr,2,1); }
    2903             : INLINE GEN
    2904      564454 : bnr_get_nf(GEN bnr) { return gmael(bnr,1,7); }
    2905             : INLINE GEN
    2906     1715000 : bnr_get_clgp(GEN bnr) { return gel(bnr,5); }
    2907             : INLINE GEN
    2908      311289 : bnr_get_no(GEN bnr) { return abgrp_get_no(bnr_get_clgp(bnr)); }
    2909             : INLINE GEN
    2910     1386926 : bnr_get_cyc(GEN bnr) { return abgrp_get_cyc(bnr_get_clgp(bnr)); }
    2911             : INLINE GEN
    2912          70 : bnr_get_gen_nocheck(GEN bnr) { return abgrp_get_gen(bnr_get_clgp(bnr)); }
    2913             : INLINE GEN
    2914        7847 : bnr_get_gen(GEN bnr) {
    2915        7847 :   GEN G = bnr_get_clgp(bnr);
    2916        7847 :   if (lg(G) !=  4)
    2917           0 :     pari_err(e_MISC,"missing bnr generators: please use bnrinit(,,1)");
    2918        7847 :   return gel(G,3);
    2919             : }
    2920             : 
    2921             : /* localstar, used in gchar */
    2922             : INLINE GEN
    2923      263451 : locs_get_cyc(GEN locs) { return gel(locs,1); }
    2924             : INLINE GEN
    2925      164696 : locs_get_Lsprk(GEN locs) { return gel(locs,2); }
    2926             : INLINE GEN
    2927        1211 : locs_get_Lgenfil(GEN locs) { return gel(locs,3); }
    2928             : INLINE GEN
    2929        5691 : locs_get_mod(GEN locs) { return gel(locs,4); }
    2930             : /* pr dividing the modulus N of locs, 0 <= i < v_pr(N)
    2931             :  * return a t_MAT whose columns are the logs
    2932             :  * of generators of U_i(pr)/U_{i+1}(pr). */
    2933             : INLINE GEN
    2934        1211 : locs_get_famod(GEN locs) { return gmael(locs,4,1); }
    2935             : INLINE GEN
    2936      186382 : locs_get_m_infty(GEN locs) { return gmael(locs,4,2); }
    2937             : 
    2938             : /* G a grossenchar group */
    2939             : INLINE GEN
    2940      264313 : gchar_get_basis(GEN gc)  { return  gel(gc, 1); }
    2941             : INLINE GEN
    2942      430238 : gchar_get_bnf(GEN gc)    { return  gel(gc, 2); }
    2943             : INLINE GEN
    2944      648969 : gchar_get_zm(GEN gc)     { return  gel(gc, 3); }
    2945             : INLINE GEN
    2946        5691 : gchar_get_mod(GEN gc)    { return  locs_get_mod(gel(gc, 3)); }
    2947             : INLINE GEN
    2948       62857 : gchar_get_S(GEN gc)      { return  gel(gc, 4); }
    2949             : INLINE GEN
    2950      162120 : gchar_get_valS(GEN gc)   { return  gel(gc, 5); }
    2951             : INLINE GEN
    2952         287 : gchar_get_Sunits(GEN gc) { return  gmael(gc, 6, 1); }
    2953             : INLINE GEN
    2954         287 : gchar_get_fu(GEN gc)    { return  gmael(gc, 6, 2); }
    2955             : INLINE GEN
    2956       41143 : gchar_get_cyc(GEN gc)    { return  gel(gc, 8); }
    2957             : INLINE GEN
    2958           0 : gchar_get_hnf(GEN gc)    { return  gmael(gc, 9, 1); }
    2959             : INLINE GEN
    2960           0 : gchar_get_U(GEN gc)      { return  gmael(gc, 9, 2); }
    2961             : INLINE GEN
    2962       29673 : gchar_get_Ui(GEN gc)     { return  gmael(gc, 9, 3); }
    2963             : INLINE GEN
    2964         665 : gchar_get_m0(GEN gc)     { return gel(gc, 10); }
    2965             : INLINE GEN
    2966         287 : gchar_get_u0(GEN gc)     { return gel(gc, 11); }
    2967             : INLINE long
    2968       34426 : gchar_get_r1(GEN gc)     { return nf_get_r1(bnf_get_nf(gchar_get_bnf(gc))); }
    2969             : INLINE long
    2970       11753 : gchar_get_r2(GEN gc)     { return nf_get_r2(bnf_get_nf(gchar_get_bnf(gc))); }
    2971             : INLINE GEN
    2972      262777 : gchar_get_loccyc(GEN gc) { return locs_get_cyc(gchar_get_zm(gc)); }
    2973             : INLINE long
    2974       63116 : gchar_get_nc(GEN gc)     { return lg(gchar_get_loccyc(gc))-1; }
    2975             : INLINE long
    2976       62857 : gchar_get_ns(GEN gc)     { return lg(gchar_get_S(gc))-1; }
    2977             : INLINE long
    2978        1106 : gchar_get_nm(GEN gc)     { return lg(gchar_get_basis(gc))-1; }
    2979             : INLINE long
    2980        5530 : gchar_get_evalprec(GEN gc)   { return  gmael(gc, 7, 1)[1]; }
    2981             : INLINE long
    2982      356307 : gchar_get_prec(GEN gc)   { return  gmael(gc, 7, 1)[2]; }
    2983             : INLINE long
    2984      200204 : gchar_get_nfprec(GEN gc) { return  gmael(gc, 7, 1)[3]; }
    2985             : INLINE void
    2986           0 : gchar_set_evalprec(GEN gc, long prec) { gmael(gc, 7, 1)[1] = prec; }
    2987             : INLINE void
    2988           0 : gchar_set_prec(GEN gc, long prec) { gmael(gc, 7, 1)[2] = prec; }
    2989             : INLINE void
    2990         287 : gchar_set_nfprec(GEN gc, long prec) { gmael(gc, 7, 1)[3] = prec; }
    2991             : INLINE long
    2992         112 : gchar_get_ntors(GEN gc)   { return  gmael(gc, 7, 2)[1]; }
    2993             : INLINE long
    2994         112 : gchar_get_nfree(GEN gc)   { return  gmael(gc, 7, 2)[2]; }
    2995             : INLINE long
    2996         788 : gchar_get_nalg(GEN gc)   { return  gmael(gc, 7, 2)[3]; }
    2997             : INLINE void
    2998         564 : gchar_set_basis(GEN gc, GEN m_inv)  { gel(gc, 1) = m_inv; }
    2999             : INLINE void
    3000         287 : gchar_set_bnf(GEN gc, GEN bnf)      { gel(gc, 2) = bnf; }
    3001             : INLINE void
    3002         378 : gchar_set_ntors(GEN gc, long n)    { gmael(gc, 7, 2)[1] = n; }
    3003             : INLINE void
    3004         378 : gchar_set_nfree(GEN gc, long n)    { gmael(gc, 7, 2)[2] = n; }
    3005             : INLINE void
    3006         378 : gchar_set_nalg(GEN gc, long n)    { gmael(gc, 7, 2)[3] = n; }
    3007             : INLINE void
    3008         564 : gchar_set_cyc(GEN gc, GEN cyc)      { gel(gc, 8) = cyc; }
    3009             : INLINE void
    3010         378 : gchar_set_HUUi(GEN gc, GEN hnf, GEN U, GEN Ui) { gel(gc, 9) = mkvec3(hnf, U, Ui); }
    3011             : INLINE void
    3012         287 : gchar_set_m0(GEN gc, GEN m0)     { gel(gc, 10) = m0; }
    3013             : INLINE void
    3014         868 : gchar_set_u0(GEN gc, GEN u0)     { gel(gc, 11) = u0; }
    3015             : 
    3016             : INLINE GEN
    3017      385745 : bid_get_mod(GEN bid) { return gel(bid,1); }
    3018             : INLINE GEN
    3019       69545 : bid_get_ideal(GEN bid) { return gmael(bid,1,1); }
    3020             : INLINE GEN
    3021       33537 : bid_get_arch(GEN bid) { return gmael(bid,1,2); }
    3022             : INLINE GEN
    3023     2408824 : bid_get_grp(GEN bid) { return gel(bid,2); }
    3024             : INLINE GEN
    3025     1307957 : bid_get_fact(GEN bid) { return gmael(bid,3,1); }
    3026             : INLINE GEN
    3027     1020771 : bid_get_fact2(GEN bid) { return gmael(bid,3,2); }
    3028             : INLINE GEN
    3029      987015 : bid_get_sprk(GEN bid) { return gmael(bid,4,1); }
    3030             : INLINE GEN
    3031       50736 : bid_get_sarch(GEN bid) { return gmael(bid,4,2); }
    3032             : INLINE GEN
    3033     1212456 : bid_get_archp(GEN bid) { return gmael3(bid,4,2,2); }
    3034             : INLINE GEN
    3035     1373024 : bid_get_U(GEN bid) { return gel(bid,5); }
    3036             : INLINE GEN
    3037           0 : bid_get_no(GEN bid) { return abgrp_get_no(bid_get_grp(bid)); }
    3038             : INLINE GEN
    3039     2356218 : bid_get_cyc(GEN bid) { return abgrp_get_cyc(bid_get_grp(bid)); }
    3040             : INLINE GEN
    3041           0 : bid_get_gen_nocheck(GEN bid)  { return abgrp_get_gen(bid_get_grp(bid)); }
    3042             : INLINE GEN
    3043       52038 : bid_get_gen(GEN bid) {
    3044       52038 :   GEN G = bid_get_grp(bid);
    3045       52038 :   if (lg(G) != 4) pari_err(e_MISC,"missing bid generators. Use idealstar(,,2)");
    3046       52038 :   return abgrp_get_gen(G);
    3047             : }
    3048             : 
    3049             : INLINE GEN
    3050    29845389 : znstar_get_N(GEN G) { return gmael(G,1,1); }
    3051             : INLINE GEN
    3052     7078547 : znstar_get_faN(GEN G) { return gel(G,3); }
    3053             : INLINE GEN
    3054          14 : znstar_get_no(GEN G) { return abgrp_get_no(gel(G,2)); }
    3055             : INLINE GEN
    3056      212681 : znstar_get_cyc(GEN G) { return abgrp_get_cyc(gel(G,2)); }
    3057             : INLINE GEN
    3058         343 : znstar_get_gen(GEN G) { return abgrp_get_gen(gel(G,2)); }
    3059             : INLINE GEN
    3060     7734503 : znstar_get_conreycyc(GEN G) { return gmael(G,4,5); }
    3061             : INLINE GEN
    3062     3191160 : znstar_get_conreygen(GEN G) { return gmael(G,4,4); }
    3063             : INLINE GEN
    3064       46788 : znstar_get_Ui(GEN G) { return gmael(G,4,3); }
    3065             : INLINE GEN
    3066      140203 : znstar_get_U(GEN G) { return gel(G,5); }
    3067             : INLINE GEN
    3068     2794449 : znstar_get_pe(GEN G) { return gmael(G,4,1); }
    3069             : INLINE GEN
    3070       35794 : gal_get_pol(GEN gal) { return gel(gal,1); }
    3071             : INLINE GEN
    3072        5908 : gal_get_p(GEN gal) { return gmael(gal,2,1); }
    3073             : INLINE GEN
    3074          91 : gal_get_e(GEN gal) { return gmael(gal,2,2); }
    3075             : INLINE GEN
    3076       23404 : gal_get_mod(GEN gal) { return gmael(gal,2,3); }
    3077             : INLINE GEN
    3078       31951 : gal_get_roots(GEN gal) { return gel(gal,3); }
    3079             : INLINE GEN
    3080       27128 : gal_get_invvdm(GEN gal) { return gel(gal,4); }
    3081             : INLINE GEN
    3082       27128 : gal_get_den(GEN gal) { return gel(gal,5); }
    3083             : INLINE GEN
    3084       79230 : gal_get_group(GEN gal) { return gel(gal,6); }
    3085             : INLINE GEN
    3086        8883 : gal_get_gen(GEN gal) { return gel(gal,7); }
    3087             : INLINE GEN
    3088        6853 : gal_get_orders(GEN gal) { return gel(gal,8); }
    3089             : 
    3090             : /* assume rnf a genuine rnf */
    3091             : INLINE long
    3092     1237180 : rnf_get_degree(GEN rnf) { return degpol(rnf_get_pol(rnf)); }
    3093             : INLINE long
    3094       16765 : rnf_get_nfdegree(GEN rnf) { return degpol(nf_get_pol(rnf_get_nf(rnf))); }
    3095             : INLINE long
    3096      777028 : rnf_get_absdegree(GEN rnf) { return degpol(gmael(rnf,11,1)); }
    3097             : INLINE GEN
    3098         700 : rnf_get_idealdisc(GEN rnf) { return gmael(rnf,3,1); }
    3099             : INLINE GEN
    3100         749 : rnf_get_k(GEN rnf) { return gmael(rnf,11,3); }
    3101             : INLINE GEN
    3102         861 : rnf_get_alpha(GEN rnf) { return gmael(rnf, 11, 2); }
    3103             : INLINE GEN
    3104      442904 : rnf_get_nf(GEN rnf) { return gel(rnf,10); }
    3105             : INLINE GEN
    3106        4004 : rnf_get_nfzk(GEN rnf) { return gel(rnf,2); }
    3107             : INLINE GEN
    3108      215607 : rnf_get_polabs(GEN rnf) { return gmael(rnf,11,1); }
    3109             : INLINE GEN
    3110     1484063 : rnf_get_pol(GEN rnf) { return gel(rnf,1); }
    3111             : INLINE GEN
    3112         175 : rnf_get_disc(GEN rnf) { return gel(rnf,3); }
    3113             : INLINE GEN
    3114         105 : rnf_get_index(GEN rnf) { return gel(rnf,4); }
    3115             : INLINE GEN
    3116        1638 : rnf_get_ramified_primes(GEN rnf) { return gel(rnf,5); }
    3117             : INLINE long
    3118         231 : rnf_get_varn(GEN rnf) { return varn(gel(rnf,1)); }
    3119             : INLINE GEN
    3120      189133 : rnf_get_nfpol(GEN rnf) { return gmael(rnf,10,1); }
    3121             : INLINE long
    3122        3332 : rnf_get_nfvarn(GEN rnf) { return varn(gmael(rnf,10,1)); }
    3123             : INLINE GEN
    3124        3584 : rnf_get_zk(GEN rnf) { return gel(rnf,7); }
    3125             : INLINE GEN
    3126      103271 : rnf_get_map(GEN rnf) { return gel(rnf,11); }
    3127             : INLINE GEN
    3128        1197 : rnf_get_invzk(GEN rnf) { return gel(rnf,8); }
    3129             : 
    3130             : /* I integral ZM (not HNF), G ZM, rounded Cholesky form of a weighted
    3131             :  * T2 matrix. Reduce I wrt G */
    3132             : INLINE GEN
    3133      646556 : idealpseudored(GEN I, GEN G)
    3134      646556 : { return ZM_mul(I, ZM_lll(ZM_mul(G, I), 0.99, LLL_IM)); }
    3135             : 
    3136             : /* Same I, G; m in I with T2(m) small */
    3137             : INLINE GEN
    3138      128776 : idealpseudomin(GEN I, GEN G)
    3139             : {
    3140      128776 :   GEN u = ZM_lll(ZM_mul(G, I), 0.99, LLL_IM);
    3141      128777 :   return ZM_ZC_mul(I, gel(u,1));
    3142             : }
    3143             : /* Same I,G; irrational m in I with T2(m) small */
    3144             : INLINE GEN
    3145           0 : idealpseudomin_nonscalar(GEN I, GEN G)
    3146             : {
    3147           0 :   GEN u = ZM_lll(ZM_mul(G, I), 0.99, LLL_IM);
    3148           0 :   GEN m = ZM_ZC_mul(I, gel(u,1));
    3149           0 :   if (ZV_isscalar(m) && lg(u) > 2) m = ZM_ZC_mul(I, gel(u,2));
    3150           0 :   return m;
    3151             : }
    3152             : /* Same I,G; t_VEC of irrational m in I with T2(m) small */
    3153             : INLINE GEN
    3154      568292 : idealpseudominvec(GEN I, GEN G)
    3155             : {
    3156      568292 :   long i, j, k, n = lg(I)-1;
    3157      568292 :   GEN x, L, b = idealpseudored(I, G);
    3158      568289 :   L = cgetg(1 + (n*(n+1))/2, t_VEC);
    3159     2307687 :   for (i = k = 1; i <= n; i++)
    3160             :   {
    3161     1739394 :     x = gel(b,i);
    3162     1739394 :     if (!ZV_isscalar(x)) gel(L,k++) = x;
    3163             :   }
    3164     1739397 :   for (i = 2; i <= n; i++)
    3165     3241140 :     for (j = 1; j < i; j++)
    3166             :     {
    3167     2070036 :       x = ZC_add(gel(b,i),gel(b,j));
    3168     2070033 :       if (!ZV_isscalar(x)) gel(L,k++) = x;
    3169             :     }
    3170      568290 :   setlg(L,k); return L;
    3171             : }
    3172             : 
    3173             : INLINE GEN
    3174       13734 : idealred_elt(GEN nf, GEN I) {
    3175       13734 :   pari_sp av = avma;
    3176       13734 :   GEN u = idealpseudomin(I, nf_get_roundG(nf));
    3177       13734 :   return gerepileupto(av, u);
    3178             : }
    3179             : INLINE GEN
    3180      124200 : idealred(GEN nf, GEN I) { return idealred0(nf, I, NULL); }
    3181             : 
    3182             : INLINE GEN
    3183        2142 : idealchineseinit(GEN nf, GEN x)
    3184        2142 : { return idealchinese(nf,x,NULL); }
    3185             : 
    3186             : /*******************************************************************/
    3187             : /*                                                                 */
    3188             : /*                              CLOSURES                           */
    3189             : /*                                                                 */
    3190             : /*******************************************************************/
    3191   350552621 : INLINE long closure_arity(GEN C)          { return ((ulong)C[1])&ARITYBITS; }
    3192    36214154 : INLINE long closure_is_variadic(GEN C) { return !!(((ulong)C[1])&VARARGBITS); }
    3193   308053759 : INLINE const char *closure_codestr(GEN C)  { return GSTR(gel(C,2))-1; }
    3194           0 : INLINE GEN closure_get_code(GEN C)  { return gel(C,2); }
    3195   308042543 : INLINE GEN closure_get_oper(GEN C)  { return gel(C,3); }
    3196   308024062 : INLINE GEN closure_get_data(GEN C)  { return gel(C,4); }
    3197       11500 : INLINE GEN closure_get_dbg(GEN C)   { return gel(C,5); }
    3198       26943 : INLINE GEN closure_get_text(GEN C)  { return gel(C,6); }
    3199     7666689 : INLINE GEN closure_get_frame(GEN C) { return gel(C,7); }
    3200             : 
    3201             : /*******************************************************************/
    3202             : /*                                                                 */
    3203             : /*                               ERRORS                            */
    3204             : /*                                                                 */
    3205             : /*******************************************************************/
    3206             : INLINE long
    3207       56913 : err_get_num(GEN e) { return e[1]; }
    3208             : INLINE GEN
    3209         238 : err_get_compo(GEN e, long i) { return gel(e, i+1); }
    3210             : 
    3211             : INLINE void
    3212          14 : pari_err_BUG(const char *f) { pari_err(e_BUG,f); }
    3213             : INLINE void
    3214           7 : pari_err_CONSTPOL(const char *f) { pari_err(e_CONSTPOL, f); }
    3215             : INLINE void
    3216          77 : pari_err_COPRIME(const char *f, GEN x, GEN y) { pari_err(e_COPRIME, f,x,y); }
    3217             : INLINE void
    3218         550 : pari_err_DIM(const char *f) { pari_err(e_DIM, f); }
    3219             : INLINE void
    3220           0 : pari_err_FILE(const char *f, const char *g) { pari_err(e_FILE, f,g); }
    3221             : INLINE void
    3222          36 : pari_err_FILEDESC(const char *f, long n) { pari_err(e_FILEDESC, f,n); }
    3223             : INLINE void
    3224          98 : pari_err_FLAG(const char *f) { pari_err(e_FLAG,f); }
    3225             : INLINE void
    3226         476 : pari_err_IMPL(const char *f) { pari_err(e_IMPL,f); }
    3227             : INLINE void
    3228       19927 : pari_err_INV(const char *f, GEN x) { pari_err(e_INV,f,x); }
    3229             : INLINE void
    3230          63 : pari_err_IRREDPOL(const char *f, GEN x) { pari_err(e_IRREDPOL, f,x); }
    3231             : INLINE void
    3232        2512 : 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); }
    3233             : INLINE void
    3234         200 : pari_err_COMPONENT(const char *f, const char *op, GEN l, GEN x) { pari_err(e_COMPONENT, f,op,l,x); }
    3235             : INLINE void
    3236           0 : pari_err_MAXPRIME(ulong c) { pari_err(e_MAXPRIME, c); }
    3237             : INLINE void
    3238         378 : pari_err_OP(const char *f, GEN x, GEN y) { pari_err(e_OP, f,x,y); }
    3239             : INLINE void
    3240         135 : pari_err_OVERFLOW(const char *f) { pari_err(e_OVERFLOW, f); }
    3241             : INLINE void
    3242         239 : pari_err_PREC(const char *f) { pari_err(e_PREC,f); }
    3243             : INLINE void
    3244           0 : pari_err_PACKAGE(const char *f) { pari_err(e_PACKAGE,f); }
    3245             : INLINE void
    3246          77 : pari_err_PRIME(const char *f, GEN x) { pari_err(e_PRIME, f,x); }
    3247             : INLINE void
    3248         756 : pari_err_MODULUS(const char *f, GEN x, GEN y) { pari_err(e_MODULUS, f,x,y); }
    3249             : INLINE void
    3250          56 : pari_err_ROOTS0(const char *f) { pari_err(e_ROOTS0, f); }
    3251             : INLINE void
    3252          84 : pari_err_SQRTN(const char *f, GEN x) { pari_err(e_SQRTN, f,x); }
    3253             : INLINE void
    3254       13515 : pari_err_TYPE(const char *f, GEN x) { pari_err(e_TYPE, f,x); }
    3255             : INLINE void
    3256        3395 : pari_err_TYPE2(const char *f, GEN x, GEN y) { pari_err(e_TYPE2, f,x,y); }
    3257             : INLINE void
    3258         280 : pari_err_VAR(const char *f, GEN x, GEN y) { pari_err(e_VAR, f,x,y); }
    3259             : INLINE void
    3260         231 : pari_err_PRIORITY(const char *f, GEN x, const char *op, long v)
    3261         231 : { pari_err(e_PRIORITY, f,x,op,v); }

Generated by: LCOV version 1.13