Code coverage tests

This page documents the degree to which the PARI/GP source code is tested by our public test suite, distributed with the source distribution in directory src/test/. This is measured by the gcov utility; we then process gcov output using the lcov frond-end.

We test a few variants depending on Configure flags on the pari.math.u-bordeaux.fr machine (x86_64 architecture), and agregate them in the final report:

The target is to exceed 90% coverage for all mathematical modules (given that branches depending on DEBUGLEVEL or DEBUGMEM are not covered). This script is run to produce the results below.

LCOV - code coverage report
Current view: top level - headers - pariinl.h (source / functions) Hit Total Coverage
Test: PARI/GP v2.18.0 lcov report (development 29818-b3e15d99d2) Lines: 1436 1578 91.0 %
Date: 2024-12-27 09:09:37 Functions: 647 717 90.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* Copyright (C) 2000-2010  The PARI group.
       2             : 
       3             : This file is part of the PARI/GP package.
       4             : 
       5             : PARI/GP is free software; you can redistribute it and/or modify it under the
       6             : terms of the GNU General Public License as published by the Free Software
       7             : Foundation; either version 2 of the License, or (at your option) any later
       8             : version. It is distributed in the hope that it will be useful, but WITHOUT
       9             : ANY WARRANTY WHATSOEVER.
      10             : 
      11             : Check the License for details. You should have received a copy of it, along
      12             : with the package; see the file 'COPYING'. If not, write to the Free Software
      13             : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
      14             : 
      15             : 
      16             : /*********************************************************************/
      17             : /*                       MALLOC/FREE WRAPPERS                        */
      18             : /*********************************************************************/
      19             : #define BLOCK_SIGALRM_START          \
      20             : {                                    \
      21             :   int block=PARI_SIGINT_block;       \
      22             :   PARI_SIGINT_block = 2;             \
      23             :   MT_SIGINT_BLOCK(block);
      24             : 
      25             : #define BLOCK_SIGINT_START           \
      26             : {                                    \
      27             :   int block=PARI_SIGINT_block;       \
      28             :   PARI_SIGINT_block = 1;             \
      29             :   MT_SIGINT_BLOCK(block);
      30             : 
      31             : #define BLOCK_SIGINT_END             \
      32             :   PARI_SIGINT_block = block;         \
      33             :   MT_SIGINT_UNBLOCK(block);          \
      34             :   if (!block && PARI_SIGINT_pending) \
      35             :   {                                  \
      36             :     int sig = PARI_SIGINT_pending;   \
      37             :     PARI_SIGINT_pending = 0;         \
      38             :     raise(sig);                      \
      39             :   }                                  \
      40             : }
      41             : 
      42             : /*******************************************************************/
      43             : /*                                                                 */
      44             : /*                          CONSTRUCTORS                           */
      45             : /*                                                                 */
      46             : /*******************************************************************/
      47             : #define retmkfrac(x,y)\
      48             :   do { GEN _v = cgetg(3, t_FRAC);\
      49             :        gel(_v,1) = (x);\
      50             :        gel(_v,2) = (y); return _v; } while(0)
      51             : #define retmkrfrac(x,y)\
      52             :   do { GEN _v = cgetg(3, t_RFRAC);\
      53             :        gel(_v,1) = (x);\
      54             :        gel(_v,2) = (y); return _v; } while(0)
      55             : #define retmkintmod(x,y)\
      56             :   do { GEN _v = cgetg(3, t_INTMOD);\
      57             :        gel(_v,1) = (y);\
      58             :        gel(_v,2) = (x); return _v; } while(0)
      59             : #define retmkcomplex(x,y)\
      60             :   do { GEN _v = cgetg(3, t_COMPLEX);\
      61             :        gel(_v,1) = (x);\
      62             :        gel(_v,2) = (y); return _v; } while(0)
      63             : #define retmkpolmod(x,y)\
      64             :   do { GEN _v = cgetg(3, t_POLMOD);\
      65             :        gel(_v,1) = (y);\
      66             :        gel(_v,2) = (x); return _v; } while(0)
      67             : #define retmkvec(x)\
      68             :   do { GEN _v = cgetg(2, t_VEC);\
      69             :        gel(_v,1) = (x); return _v; } while(0)
      70             : #define retmkvec2(x,y)\
      71             :   do { GEN _v = cgetg(3, t_VEC);\
      72             :        gel(_v,1) = (x);\
      73             :        gel(_v,2) = (y); return _v; } while(0)
      74             : #define retmkvec3(x,y,z)\
      75             :   do { GEN _v = cgetg(4, t_VEC);\
      76             :        gel(_v,1) = (x);\
      77             :        gel(_v,2) = (y);\
      78             :        gel(_v,3) = (z); return _v; } while(0)
      79             : #define retmkqfb(x,y,z,d)\
      80             :   do { GEN _v = cgetg(5, t_QFB);\
      81             :        gel(_v,1) = (x);\
      82             :        gel(_v,2) = (y);\
      83             :        gel(_v,3) = (z);\
      84             :        gel(_v,4) = (d); return _v; } while(0)
      85             : #define retmkquad(x,y,z)\
      86             :   do { GEN _v = cgetg(4, t_QUAD);\
      87             :        gel(_v,1) = (x);\
      88             :        gel(_v,2) = (y);\
      89             :        gel(_v,3) = (z); return _v; } while(0)
      90             : #define retmkvec4(x,y,z,t)\
      91             :   do { GEN _v = cgetg(5, t_VEC);\
      92             :        gel(_v,1) = (x);\
      93             :        gel(_v,2) = (y);\
      94             :        gel(_v,3) = (z);\
      95             :        gel(_v,4) = (t); return _v; } while(0)
      96             : #define retmkvec5(x,y,z,t,u)\
      97             :   do { GEN _v = cgetg(6, t_VEC);\
      98             :        gel(_v,1) = (x);\
      99             :        gel(_v,2) = (y);\
     100             :        gel(_v,3) = (z);\
     101             :        gel(_v,4) = (t);\
     102             :        gel(_v,5) = (u); return _v; } while(0)
     103             : #define retmkcol(x)\
     104             :   do { GEN _v = cgetg(2, t_COL);\
     105             :        gel(_v,1) = (x); return _v; } while(0)
     106             : #define retmkcol2(x,y)\
     107             :   do { GEN _v = cgetg(3, t_COL);\
     108             :        gel(_v,1) = (x);\
     109             :        gel(_v,2) = (y); return _v; } while(0)
     110             : #define retmkcol3(x,y,z)\
     111             :   do { GEN _v = cgetg(4, t_COL);\
     112             :        gel(_v,1) = (x);\
     113             :        gel(_v,2) = (y);\
     114             :        gel(_v,3) = (z); return _v; } while(0)
     115             : #define retmkcol4(x,y,z,t)\
     116             :   do { GEN _v = cgetg(5, t_COL);\
     117             :        gel(_v,1) = (x);\
     118             :        gel(_v,2) = (y);\
     119             :        gel(_v,3) = (z);\
     120             :        gel(_v,4) = (t); return _v; } while(0)
     121             : #define retmkcol5(x,y,z,t,u)\
     122             :   do { GEN _v = cgetg(6, t_COL);\
     123             :        gel(_v,1) = (x);\
     124             :        gel(_v,2) = (y);\
     125             :        gel(_v,3) = (z);\
     126             :        gel(_v,4) = (t);\
     127             :        gel(_v,5) = (u); return _v; } while(0)
     128             : #define retmkcol6(x,y,z,t,u,v)\
     129             :   do { GEN _v = cgetg(7, t_COL);\
     130             :        gel(_v,1) = (x);\
     131             :        gel(_v,2) = (y);\
     132             :        gel(_v,3) = (z);\
     133             :        gel(_v,4) = (t);\
     134             :        gel(_v,5) = (u);\
     135             :        gel(_v,6) = (v); return _v; } while(0)
     136             : #define retmkmat(x)\
     137             :   do { GEN _v = cgetg(2, t_MAT);\
     138             :        gel(_v,1) = (x); return _v; } while(0)
     139             : #define retmkmat2(x,y)\
     140             :   do { GEN _v = cgetg(3, t_MAT);\
     141             :        gel(_v,1) = (x);\
     142             :        gel(_v,2) = (y); return _v; } while(0)
     143             : #define retmkmat3(x,y,z)\
     144             :   do { GEN _v = cgetg(4, t_MAT);\
     145             :        gel(_v,1) = (x);\
     146             :        gel(_v,2) = (y);\
     147             :        gel(_v,3) = (z); return _v; } while(0)
     148             : #define retmkmat4(x,y,z,t)\
     149             :   do { GEN _v = cgetg(5, t_MAT);\
     150             :        gel(_v,1) = (x);\
     151             :        gel(_v,2) = (y);\
     152             :        gel(_v,3) = (z);\
     153             :        gel(_v,4) = (t); return _v; } while(0)
     154             : #define retmkmat5(x,y,z,t,u)\
     155             :   do { GEN _v = cgetg(6, t_MAT);\
     156             :        gel(_v,1) = (x);\
     157             :        gel(_v,2) = (y);\
     158             :        gel(_v,3) = (z);\
     159             :        gel(_v,4) = (t);\
     160             :        gel(_v,5) = (u); return _v; } while(0)
     161             : #define retmkmat22(a,b,c,d)\
     162             :   do { GEN _v = cgetg(3, t_MAT);\
     163             :        gel(_v,1) = mkcol2(a,c);\
     164             :        gel(_v,2) = mkcol2(b,d); return _v; } while(0)
     165             : INLINE GEN
     166     8024631 : mkintmod(GEN x, GEN y) { retmkintmod(x,y); }
     167             : INLINE GEN
     168        1813 : mkintmodu(ulong x, ulong y) {
     169        1813 :   GEN v = cgetg(3,t_INTMOD);
     170        1813 :   gel(v,1) = utoipos(y);
     171        1813 :   gel(v,2) = utoi(x); return v;
     172             : }
     173             : INLINE GEN
     174     2973560 : mkpolmod(GEN x, GEN y) { retmkpolmod(x,y); }
     175             : INLINE GEN
     176    33747737 : mkfrac(GEN x, GEN y) { retmkfrac(x,y); }
     177             : INLINE GEN
     178     1209528 : mkfracss(long x, long y) { retmkfrac(stoi(x),utoipos(y)); }
     179             : /* q = n/d a t_FRAC or t_INT; recover (n,d) */
     180             : INLINE void
     181       19838 : Qtoss(GEN q, long *n, long *d)
     182             : {
     183       19838 :   if (typ(q) == t_INT) { *n = itos(q); *d = 1; }
     184        5796 :   else { *n = itos(gel(q,1)); *d = itou(gel(q,2)); }
     185       19838 : }
     186             : INLINE GEN
     187     1074486 : sstoQ(long n, long d)
     188             : {
     189             :   ulong r;
     190             :   long g, q;
     191     1074486 :   if (!n)
     192             :   {
     193       95095 :     if (!d) pari_err_INV("sstoQ",gen_0);
     194       95095 :     return gen_0;
     195             :   }
     196      979391 :   if (d < 0) { d = -d; n = -n; }
     197      979391 :   if (d == 1) return stoi(n);
     198      960078 :   r = labs(n);
     199      960078 :   if (r == 1) retmkfrac(n > 0? gen_1: gen_m1, utoipos(d));
     200      910168 :   q = udivuu_rem(r, d, &r);
     201      910168 :   if (!r) return n > 0? utoipos(q): utoineg(q);
     202      855281 :   g = ugcd(d,r); /* gcd(n,d) */
     203      855281 :   if (g != 1) { n /= g; d /= g; }
     204      855281 :   retmkfrac(stoi(n), utoipos(d));
     205             : }
     206             : 
     207             : INLINE GEN
     208   158074130 : uutoQ(ulong n, ulong d)
     209             : {
     210             :   ulong r;
     211             :   long g, q;
     212   158074130 :   if (!n)
     213             :   {
     214       38108 :     if (!d) pari_err_INV("uutoQ",gen_0);
     215       38108 :     return gen_0;
     216             :   }
     217   158036022 :   if (d == 1) return utoipos(n);
     218   158024920 :   if (n == 1) retmkfrac(gen_1, utoipos(d));
     219   157935993 :   q = udivuu_rem(n,d,&r);
     220   157935993 :   if (!r) return utoipos(q);
     221     5180964 :   g = ugcd(d,r); /* gcd(n,d) */
     222     5180964 :   if (g != 1) { n /= g; d /= g; }
     223     5180964 :   retmkfrac(utoipos(n), utoipos(d));
     224             : }
     225             : 
     226             : INLINE GEN
     227     4795479 : mkfraccopy(GEN x, GEN y) { retmkfrac(icopy(x), icopy(y)); }
     228             : INLINE GEN
     229      698145 : mkrfrac(GEN x, GEN y) { GEN v = cgetg(3, t_RFRAC);
     230      698145 :   gel(v,1) = x; gel(v,2) = y; return v; }
     231             : INLINE GEN
     232          14 : mkrfraccopy(GEN x, GEN y) { GEN v = cgetg(3, t_RFRAC);
     233          14 :   gel(v,1) = gcopy(x); gel(v,2) = gcopy(y); return v; }
     234             : INLINE GEN
     235    89952211 : mkcomplex(GEN x, GEN y) { retmkcomplex(x,y); }
     236             : INLINE GEN
     237     1267750 : gen_I(void) { return mkcomplex(gen_0, gen_1); }
     238             : INLINE GEN
     239      963392 : cgetc(long l) { retmkcomplex(cgetr(l), cgetr(l)); }
     240             : INLINE GEN
     241       69118 : mkquad(GEN n, GEN x, GEN y) { GEN v = cgetg(4, t_QUAD);
     242       69118 :   gel(v,1) = n; gel(v,2) = x; gel(v,3) = y; return v; }
     243             : /* vecsmall */
     244             : INLINE GEN
     245   129392920 : mkvecsmall(long x) { GEN v = cgetg(2, t_VECSMALL); v[1] = x; return v; }
     246             : INLINE GEN
     247   224061936 : mkvecsmall2(long x,long y) { GEN v = cgetg(3, t_VECSMALL);
     248   224075830 :   v[1]=x; v[2]=y; return v; }
     249             : INLINE GEN
     250   100371741 : mkvecsmall3(long x,long y,long z) { GEN v = cgetg(4, t_VECSMALL);
     251   100369046 :   v[1]=x; v[2]=y; v[3]=z; return v; }
     252             : INLINE GEN
     253    15488460 : mkvecsmall4(long x,long y,long z,long t) { GEN v = cgetg(5, t_VECSMALL);
     254    15492963 :   v[1]=x; v[2]=y; v[3]=z; v[4]=t; return v; }
     255             : INLINE GEN
     256      688700 : mkvecsmall5(long x,long y,long z,long t,long u) { GEN v = cgetg(6, t_VECSMALL);
     257      688700 :   v[1]=x; v[2]=y; v[3]=z; v[4]=t; v[5]=u; return v; }
     258             : 
     259             : INLINE GEN
     260    27798145 : mkqfb(GEN x, GEN y, GEN z, GEN d) { retmkqfb(x,y,z,d); }
     261             : /* vec */
     262             : INLINE GEN
     263    67484838 : mkvec(GEN x) { retmkvec(x); }
     264             : INLINE GEN
     265   182850952 : mkvec2(GEN x, GEN y) { retmkvec2(x,y); }
     266             : INLINE GEN
     267   120507062 : mkvec3(GEN x, GEN y, GEN z) { retmkvec3(x,y,z); }
     268             : INLINE GEN
     269     6589142 : mkvec4(GEN x, GEN y, GEN z, GEN t) { retmkvec4(x,y,z,t); }
     270             : INLINE GEN
     271    14485991 : mkvec5(GEN x, GEN y, GEN z, GEN t, GEN u) { retmkvec5(x,y,z,t,u); }
     272             : INLINE GEN
     273         161 : mkvecs(long x) { retmkvec(stoi(x)); }
     274             : INLINE GEN
     275      219599 : mkvec2s(long x, long y) { retmkvec2(stoi(x),stoi(y)); }
     276             : INLINE GEN
     277      524441 : mkvec3s(long x, long y, long z) { retmkvec3(stoi(x),stoi(y),stoi(z)); }
     278             : INLINE GEN
     279          21 : mkvec4s(long x, long y, long z, long t) { retmkvec4(stoi(x),stoi(y),stoi(z),stoi(t)); }
     280             : INLINE GEN
     281      122507 : mkveccopy(GEN x) { GEN v = cgetg(2, t_VEC); gel(v,1) = gcopy(x); return v; }
     282             : INLINE GEN
     283      123183 : mkvec2copy(GEN x, GEN y) {
     284      123183 :   GEN v = cgetg(3,t_VEC); gel(v,1) = gcopy(x); gel(v,2) = gcopy(y); return v; }
     285             : /* col */
     286             : INLINE GEN
     287    10174280 : mkcol(GEN x) { retmkcol(x); }
     288             : INLINE GEN
     289   155871813 : mkcol2(GEN x, GEN y) { retmkcol2(x,y); }
     290             : INLINE GEN
     291       88314 : mkcol3(GEN x, GEN y, GEN z) { retmkcol3(x,y,z); }
     292             : INLINE GEN
     293      103320 : mkcol4(GEN x, GEN y, GEN z, GEN t) { retmkcol4(x,y,z,t); }
     294             : INLINE GEN
     295          94 : mkcol5(GEN x, GEN y, GEN z, GEN t, GEN u) { retmkcol5(x,y,z,t,u); }
     296             : INLINE GEN
     297      232043 : mkcol6(GEN x, GEN y, GEN z, GEN t, GEN u, GEN v) { retmkcol6(x,y,z,t,u,v); }
     298             : INLINE GEN
     299       40411 : mkcols(long x) { retmkcol(stoi(x)); }
     300             : INLINE GEN
     301     4415292 : mkcol2s(long x, long y) { retmkcol2(stoi(x),stoi(y)); }
     302             : INLINE GEN
     303         315 : mkcol3s(long x, long y, long z) { retmkcol3(stoi(x),stoi(y),stoi(z)); }
     304             : INLINE GEN
     305           0 : mkcol4s(long x, long y, long z, long t) { retmkcol4(stoi(x),stoi(y),stoi(z),stoi(t)); }
     306             : INLINE GEN
     307       33534 : mkcolcopy(GEN x) { GEN v = cgetg(2, t_COL); gel(v,1) = gcopy(x); return v; }
     308             : /* mat */
     309             : INLINE GEN
     310     4640629 : mkmat(GEN x) { retmkmat(x); }
     311             : INLINE GEN
     312    32544448 : mkmat2(GEN x, GEN y) { retmkmat2(x,y); }
     313             : INLINE GEN
     314       17001 : mkmat3(GEN x, GEN y, GEN z) { retmkmat3(x,y,z); }
     315             : INLINE GEN
     316          63 : mkmat4(GEN x, GEN y, GEN z, GEN t) { retmkmat4(x,y,z,t); }
     317             : INLINE GEN
     318           0 : mkmat5(GEN x, GEN y, GEN z, GEN t, GEN u) { retmkmat5(x,y,z,t,u); }
     319             : INLINE GEN
     320      121019 : mkmatcopy(GEN x) { GEN v = cgetg(2, t_MAT); gel(v,1) = gcopy(x); return v; }
     321             : INLINE GEN
     322           0 : mkerr(long x) { GEN v = cgetg(2, t_ERROR); v[1] = x; return v; }
     323             : INLINE GEN
     324     1075302 : mkoo(void) { GEN v = cgetg(2, t_INFINITY); gel(v,1) = gen_1; return v; }
     325             : INLINE GEN
     326      105721 : mkmoo(void) { GEN v = cgetg(2, t_INFINITY); gel(v,1) = gen_m1; return v; }
     327             : INLINE long
     328     1193293 : inf_get_sign(GEN x) { return signe(gel(x,1)); }
     329             : INLINE GEN
     330      207452 : mkmat22s(long a, long b, long c, long d) {retmkmat2(mkcol2s(a,c),mkcol2s(b,d));}
     331             : INLINE GEN
     332    50319532 : mkmat22(GEN a, GEN b, GEN c, GEN d) { retmkmat2(mkcol2(a,c),mkcol2(b,d)); }
     333             : 
     334             : /* pol */
     335             : INLINE GEN
     336     3537730 : pol_x(long v) {
     337     3537730 :   GEN p = cgetg(4, t_POL);
     338     3537727 :   p[1] = evalsigne(1)|evalvarn(v);
     339     3537727 :   gel(p,2) = gen_0;
     340     3537727 :   gel(p,3) = gen_1; return p;
     341             : }
     342             : /* x^n, assume n >= 0 */
     343             : INLINE GEN
     344     2221296 : pol_xn(long n, long v) {
     345     2221296 :   long i, a = n+2;
     346     2221296 :   GEN p = cgetg(a+1, t_POL);
     347     2221299 :   p[1] = evalsigne(1)|evalvarn(v);
     348     5302965 :   for (i = 2; i < a; i++) gel(p,i) = gen_0;
     349     2221299 :   gel(p,a) = gen_1; return p;
     350             : }
     351             : /* x^n, no assumption on n */
     352             : INLINE GEN
     353         294 : pol_xnall(long n, long v)
     354             : {
     355         294 :   if (n < 0) retmkrfrac(gen_1, pol_xn(-n,v));
     356         287 :   return pol_xn(n, v);
     357             : }
     358             : /* x^n, assume n >= 0 */
     359             : INLINE GEN
     360         371 : polxn_Flx(long n, long sv) {
     361         371 :   long i, a = n+2;
     362         371 :   GEN p = cgetg(a+1, t_VECSMALL);
     363         371 :   p[1] = sv;
     364        1806 :   for (i = 2; i < a; i++) p[i] = 0;
     365         371 :   p[a] = 1; return p;
     366             : }
     367             : INLINE GEN
     368     4372911 : pol_1(long v) {
     369     4372911 :   GEN p = cgetg(3, t_POL);
     370     4372904 :   p[1] = evalsigne(1)|evalvarn(v);
     371     4372904 :   gel(p,2) = gen_1; return p;
     372             : }
     373             : INLINE GEN
     374    34998483 : pol_0(long v)
     375             : {
     376    34998483 :   GEN x = cgetg(2,t_POL);
     377    34998485 :   x[1] = evalvarn(v); return x;
     378             : }
     379             : #define retconst_vec(n,x)\
     380             :   do { long _i, _n = (n);\
     381             :        GEN _v = cgetg(_n+1, t_VEC), _x = (x);\
     382             :        for (_i = 1; _i <= _n; _i++) gel(_v,_i) = _x;\
     383             :        return _v; } while(0)
     384             : INLINE GEN
     385   233827635 : const_vec(long n, GEN x) { retconst_vec(n, x); }
     386             : #define retconst_col(n,x)\
     387             :   do { long _i, _n = (n);\
     388             :        GEN _v = cgetg(_n+1, t_COL), _x = (x);\
     389             :        for (_i = 1; _i <= _n; _i++) gel(_v,_i) = _x;\
     390             :        return _v; } while(0)
     391             : INLINE GEN
     392    39300093 : const_col(long n, GEN x) { retconst_col(n, x); }
     393             : INLINE GEN
     394    19082343 : const_vecsmall(long n, long c)
     395             : {
     396             :   long i;
     397    19082343 :   GEN V = cgetg(n+1,t_VECSMALL);
     398   753407541 :   for(i=1;i<=n;i++) V[i] = c;
     399    19082886 :   return V;
     400             : }
     401             : 
     402             : /***   ZERO   ***/
     403             : /* O(p^e) */
     404             : INLINE GEN
     405      855591 : zeropadic(GEN p, long e)
     406             : {
     407      855591 :   GEN y = cgetg(5,t_PADIC);
     408      855552 :   gel(y,4) = gen_0;
     409      855552 :   gel(y,3) = gen_1;
     410      855552 :   gel(y,2) = icopy(p);
     411      855455 :   y[1] = evalvalp(e) | _evalprecp(0);
     412      855443 :   return y;
     413             : }
     414             : INLINE GEN
     415       15358 : zeropadic_shallow(GEN p, long e)
     416             : {
     417       15358 :   GEN y = cgetg(5,t_PADIC);
     418       15358 :   gel(y,4) = gen_0;
     419       15358 :   gel(y,3) = gen_1;
     420       15358 :   gel(y,2) = p;
     421       15358 :   y[1] = evalvalp(e) | _evalprecp(0);
     422       15358 :   return y;
     423             : }
     424             : /* O(pol_x(v)^e) */
     425             : INLINE GEN
     426      138698 : zeroser(long v, long e)
     427             : {
     428      138698 :   GEN x = cgetg(2, t_SER);
     429      138698 :   x[1] = evalvalser(e) | evalvarn(v); return x;
     430             : }
     431             : INLINE int
     432    10079024 : ser_isexactzero(GEN x)
     433             : {
     434    10079024 :   if (!signe(x)) switch(lg(x))
     435             :   {
     436      132741 :     case 2: return 1;
     437        4648 :     case 3: return isexactzero(gel(x,2));
     438             :   }
     439     9941635 :   return 0;
     440             : }
     441             : /* 0 * pol_x(v) */
     442             : INLINE GEN
     443    14736361 : zeropol(long v) { return pol_0(v); }
     444             : /* vector(n) */
     445             : INLINE GEN
     446   118964375 : zerocol(long n)
     447             : {
     448   118964375 :   GEN y = cgetg(n+1,t_COL);
     449   802725513 :   long i; for (i=1; i<=n; i++) gel(y,i) = gen_0;
     450   118965294 :   return y;
     451             : }
     452             : /* vectorv(n) */
     453             : INLINE GEN
     454    26622869 : zerovec(long n)
     455             : {
     456    26622869 :   GEN y = cgetg(n+1,t_VEC);
     457   391731927 :   long i; for (i=1; i<=n; i++) gel(y,i) = gen_0;
     458    26622870 :   return y;
     459             : }
     460             : /* matrix(m, n) */
     461             : INLINE GEN
     462      108859 : zeromat(long m, long n)
     463             : {
     464      108859 :   GEN y = cgetg(n+1,t_MAT);
     465      108860 :   GEN v = zerocol(m);
     466      401473 :   long i; for (i=1; i<=n; i++) gel(y,i) = v;
     467      108862 :   return y;
     468             : }
     469             : /* = zero_zx, sv is a evalvarn()*/
     470             : INLINE GEN
     471     1428886 : zero_Flx(long sv) { return pol0_Flx(sv); }
     472             : INLINE GEN
     473    58627933 : zero_Flv(long n)
     474             : {
     475    58627933 :   GEN y = cgetg(n+1,t_VECSMALL);
     476   946420853 :   long i; for (i=1; i<=n; i++) y[i] = 0;
     477    58628172 :   return y;
     478             : }
     479             : /* matrix(m, n) */
     480             : INLINE GEN
     481     2750937 : zero_Flm(long m, long n)
     482             : {
     483     2750937 :   GEN y = cgetg(n+1,t_MAT);
     484     2750930 :   GEN v = zero_Flv(m);
     485    17519916 :   long i; for (i=1; i<=n; i++) gel(y,i) = v;
     486     2750928 :   return y;
     487             : }
     488             : /* matrix(m, n) */
     489             : INLINE GEN
     490      232072 : zero_Flm_copy(long m, long n)
     491             : {
     492      232072 :   GEN y = cgetg(n+1,t_MAT);
     493     2397519 :   long i; for (i=1; i<=n; i++) gel(y,i) = zero_Flv(m);
     494      232069 :   return y;
     495             : }
     496             : 
     497             : INLINE GEN
     498     3616951 : zero_F2v(long m)
     499             : {
     500     3616951 :   long l = nbits2nlong(m);
     501     3616940 :   GEN v  = zero_Flv(l+1);
     502     3616916 :   v[1] = m;
     503     3616916 :   return v;
     504             : }
     505             : 
     506             : INLINE GEN
     507           0 : zero_F2m(long m, long n)
     508             : {
     509             :   long i;
     510           0 :   GEN M = cgetg(n+1, t_MAT);
     511           0 :   GEN v = zero_F2v(m);
     512           0 :   for (i = 1; i <= n; i++)
     513           0 :     gel(M,i) = v;
     514           0 :   return M;
     515             : }
     516             : 
     517             : 
     518             : INLINE GEN
     519      841298 : zero_F2m_copy(long m, long n)
     520             : {
     521             :   long i;
     522      841298 :   GEN M = cgetg(n+1, t_MAT);
     523     2008912 :   for (i = 1; i <= n; i++)
     524     1167620 :     gel(M,i)= zero_F2v(m);
     525      841292 :   return M;
     526             : }
     527             : 
     528             : /* matrix(m, n) */
     529             : INLINE GEN
     530    14017391 : zeromatcopy(long m, long n)
     531             : {
     532    14017391 :   GEN y = cgetg(n+1,t_MAT);
     533    70921370 :   long i; for (i=1; i<=n; i++) gel(y,i) = zerocol(m);
     534    14017424 :   return y;
     535             : }
     536             : 
     537             : INLINE GEN
     538       24429 : zerovec_block(long len)
     539             : {
     540             :   long i;
     541       24429 :   GEN blk = cgetg_block(len + 1, t_VEC);
     542      806157 :   for (i = 1; i <= len; ++i)
     543      781728 :     gel(blk, i) = gen_0;
     544       24429 :   return blk;
     545             : }
     546             : 
     547             : /* i-th vector in the standard basis */
     548             : INLINE GEN
     549     5700472 : col_ei(long n, long i) { GEN e = zerocol(n); gel(e,i) = gen_1; return e; }
     550             : INLINE GEN
     551     1703546 : vec_ei(long n, long i) { GEN e = zerovec(n); gel(e,i) = gen_1; return e; }
     552             : INLINE GEN
     553          42 : F2v_ei(long n, long i) { GEN e = zero_F2v(n); F2v_set(e,i); return e; }
     554             : INLINE GEN
     555      495147 : vecsmall_ei(long n, long i) { GEN e = zero_zv(n); e[i] = 1; return e; }
     556             : INLINE GEN
     557     1288284 : Rg_col_ei(GEN x, long n, long i) { GEN e = zerocol(n); gel(e,i) = x; return e; }
     558             : 
     559             : INLINE GEN
     560    25842790 : shallowcopy(GEN x)
     561    25842790 : { return typ(x) == t_MAT ? RgM_shallowcopy(x): leafcopy(x); }
     562             : 
     563             : /* routines for naive growarrays */
     564             : INLINE GEN
     565    11714814 : vectrunc_init(long l)
     566             : {
     567    11714814 :   GEN z = new_chunk(l);
     568    11714557 :   z[0] = evaltyp(t_VEC) | _evallg(1); return z;
     569             : }
     570             : INLINE GEN
     571      393680 : coltrunc_init(long l)
     572             : {
     573      393680 :   GEN z = new_chunk(l);
     574      393680 :   z[0] = evaltyp(t_COL) | _evallg(1); return z;
     575             : }
     576             : INLINE void
     577   317182772 : lg_increase(GEN x) { x[0]++; }
     578             : INLINE void
     579    15248301 : vectrunc_append(GEN x, GEN t) { gel(x, lg(x)) = t; lg_increase(x); }
     580             : INLINE void
     581       10864 : vectrunc_append_batch(GEN x, GEN y)
     582             : {
     583       10864 :   long i, l = lg(x), ly = lg(y);
     584       10864 :   GEN z = x + l-1;
     585       36358 :   for (i = 1; i < ly; i++) gel(z,i) = gel(y,i);
     586       10864 :   setlg(x, l+ly-1);
     587       10864 : }
     588             : INLINE GEN
     589   189120468 : vecsmalltrunc_init(long l)
     590             : {
     591   189120468 :   GEN z = new_chunk(l);
     592   189118191 :   z[0] = evaltyp(t_VECSMALL) | _evallg(1); return z;
     593             : }
     594             : INLINE void
     595    99941921 : vecsmalltrunc_append(GEN x, long t) { x[ lg(x) ] = t; lg_increase(x); }
     596             : 
     597             : /*******************************************************************/
     598             : /*                                                                 */
     599             : /*                    STRING HASH FUNCTIONS                        */
     600             : /*                                                                 */
     601             : /*******************************************************************/
     602             : INLINE ulong
     603     2688625 : hash_str(const char *str)
     604             : {
     605     2688625 :   ulong hash = 5381UL, c;
     606    27919480 :   while ( (c = (ulong)*str++) )
     607    25230855 :     hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
     608     2688625 :   return hash;
     609             : }
     610             : INLINE ulong
     611    18259633 : hash_str_len(const char *str, long len)
     612             : {
     613    18259633 :   ulong hash = 5381UL;
     614             :   long i;
     615   166194619 :   for (i = 0; i < len; i++)
     616             :   {
     617   147934986 :     ulong c = (ulong)*str++;
     618   147934986 :     hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
     619             :   }
     620    18259633 :   return hash;
     621             : }
     622             : 
     623             : /*******************************************************************/
     624             : /*                                                                 */
     625             : /*                        VEC / COL / VECSMALL                     */
     626             : /*                                                                 */
     627             : /*******************************************************************/
     628             : /* shallow*/
     629             : INLINE GEN
     630       11550 : vec_shorten(GEN v, long n)
     631             : {
     632       11550 :   GEN V = cgetg(n+1, t_VEC);
     633             :   long i;
     634       13006 :   for(i = 1; i <= n; i++) gel(V,i) = gel(v,i);
     635       11550 :   return V;
     636             : }
     637             : /* shallow*/
     638             : INLINE GEN
     639       18941 : vec_lengthen(GEN v, long n)
     640             : {
     641       18941 :   GEN V = cgetg(n+1, t_VEC);
     642       18941 :   long i, l = lg(v);
     643     1935639 :   for(i = 1; i < l; i++) gel(V,i) = gel(v,i);
     644       18941 :   return V;
     645             : }
     646             : /* shallow*/
     647             : INLINE GEN
     648     3430115 : vec_append(GEN V, GEN s)
     649             : {
     650     3430115 :   long i, l2 = lg(V);
     651     3430115 :   GEN res = cgetg(l2+1, typ(V));
     652    10730723 :   for (i = 1; i < l2; i++) gel(res, i) = gel(V,i);
     653     3430115 :   gel(res,l2) = s; return res;
     654             : }
     655             : /* shallow*/
     656             : INLINE GEN
     657      300927 : vec_prepend(GEN v, GEN s)
     658             : {
     659      300927 :   long i, l = lg(v);
     660      300927 :   GEN w = cgetg(l+1, typ(v));
     661      300927 :   gel(w,1) = s;
     662      769397 :   for (i = 2; i <= l; i++) gel(w,i) = gel(v,i-1);
     663      300927 :   return w;
     664             : }
     665             : /* shallow*/
     666             : INLINE GEN
     667           0 : vec_setconst(GEN v, GEN x)
     668             : {
     669           0 :   long i, l = lg(v);
     670           0 :   for (i = 1; i < l; i++) gel(v,i) = x;
     671           0 :   return v;
     672             : }
     673             : INLINE GEN
     674       72590 : vecsmall_shorten(GEN v, long n)
     675             : {
     676       72590 :   GEN V = cgetg(n+1,t_VECSMALL);
     677             :   long i;
     678      889715 :   for(i = 1; i <= n; i++) V[i] = v[i];
     679       72589 :   return V;
     680             : }
     681             : INLINE GEN
     682         505 : vecsmall_lengthen(GEN v, long n)
     683             : {
     684         505 :   long i, l = lg(v);
     685         505 :   GEN V = cgetg(n+1,t_VECSMALL);
     686       46147 :   for(i = 1; i < l; i++) V[i] = v[i];
     687         505 :   return V;
     688             : }
     689             : 
     690             : INLINE GEN
     691     4014919 : vec_to_vecsmall(GEN x)
     692    18857055 : { pari_APPLY_long(itos(gel(x,i))) }
     693             : INLINE GEN
     694      510059 : vecsmall_to_vec(GEN x)
     695     7066741 : { pari_APPLY_type(t_VEC, stoi(x[i])) }
     696             : INLINE GEN
     697        3304 : vecsmall_to_vec_inplace(GEN z)
     698             : {
     699        3304 :   long i, l = lg(z);
     700       79604 :   for (i=1; i<l; i++) gel(z,i) = stoi(z[i]);
     701        3304 :   settyp(z, t_VEC); return z;
     702             : }
     703             : INLINE GEN
     704     7760786 : vecsmall_to_col(GEN x)
     705    59563326 : { pari_APPLY_type(t_COL, stoi(x[i])) }
     706             : 
     707             : INLINE int
     708     7208565 : vecsmall_lexcmp(GEN x, GEN y)
     709             : {
     710             :   long lx,ly,l,i;
     711     7208565 :   lx = lg(x);
     712     7208565 :   ly = lg(y); l = minss(lx,ly);
     713    30644497 :   for (i=1; i<l; i++)
     714    29017633 :     if (x[i] != y[i]) return x[i]<y[i]? -1: 1;
     715     1626864 :   if (lx == ly) return 0;
     716       30578 :   return (lx < ly)? -1 : 1;
     717             : }
     718             : 
     719             : INLINE int
     720   108088071 : vecsmall_prefixcmp(GEN x, GEN y)
     721             : {
     722   108088071 :   long i, lx = lg(x), ly = lg(y), l = minss(lx,ly);
     723   542691324 :   for (i=1; i<l; i++)
     724   519806035 :     if (x[i] != y[i]) return x[i]<y[i]? -1: 1;
     725    22885289 :   return 0;
     726             : }
     727             : 
     728             : /*Can be used on t_VEC, but coeffs not gcopy-ed*/
     729             : INLINE GEN
     730      186789 : vecsmall_prepend(GEN V, long s)
     731             : {
     732      186789 :   long i, l2 = lg(V);
     733      186789 :   GEN res = cgetg(l2+1, typ(V));
     734      186789 :   res[1] = s;
     735      624925 :   for (i = 2; i <= l2; ++i) res[i] = V[i - 1];
     736      186789 :   return res;
     737             : }
     738             : 
     739             : INLINE GEN
     740     4065086 : vecsmall_append(GEN V, long s)
     741             : {
     742     4065086 :   long i, l2 = lg(V);
     743     4065086 :   GEN res = cgetg(l2+1, t_VECSMALL);
     744     5975387 :   for (i = 1; i < l2; ++i) res[i] = V[i];
     745     4065086 :   res[l2] = s; return res;
     746             : }
     747             : 
     748             : INLINE GEN
     749     1456754 : vecsmall_concat(GEN u, GEN v)
     750             : {
     751     1456754 :   long i, l1 = lg(u)-1, l2 = lg(v)-1;
     752     1456754 :   GEN res = cgetg(l1+l2+1, t_VECSMALL);
     753    11548049 :   for (i = 1; i <= l1; ++i) res[i]    = u[i];
     754    15157563 :   for (i = 1; i <= l2; ++i) res[i+l1] = v[i];
     755     1456753 :   return res;
     756             : }
     757             : 
     758             : /* return the number of indices where u and v are equal */
     759             : INLINE long
     760           0 : vecsmall_coincidence(GEN u, GEN v)
     761             : {
     762           0 :   long i, s = 0, l = minss(lg(u),lg(v));
     763           0 :   for(i=1; i<l; i++)
     764           0 :     if(u[i] == v[i]) s++;
     765           0 :   return s;
     766             : }
     767             : 
     768             : /* returns the first index i<=n such that x=v[i] if it exists, 0 otherwise */
     769             : INLINE long
     770          84 : vecsmall_isin(GEN v, long x)
     771             : {
     772          84 :   long i, l = lg(v);
     773         124 :   for (i = 1; i < l; i++)
     774          80 :     if (v[i] == x) return i;
     775          44 :   return 0;
     776             : }
     777             : 
     778             : INLINE long
     779          84 : vecsmall_pack(GEN V, long base, long mod)
     780             : {
     781          84 :   long i, s = 0;
     782         273 :   for(i=1; i<lg(V); i++) s = (base*s + V[i]) % mod;
     783          84 :   return s;
     784             : }
     785             : 
     786             : INLINE long
     787          21 : vecsmall_indexmax(GEN x)
     788             : {
     789          21 :   long i, i0 = 1, t = x[1], lx = lg(x);
     790          84 :   for (i=2; i<lx; i++)
     791          63 :     if (x[i] > t) t = x[i0=i];
     792          21 :   return i0;
     793             : }
     794             : 
     795             : INLINE long
     796     1007805 : vecsmall_max(GEN x)
     797             : {
     798     1007805 :   long i, t = x[1], lx = lg(x);
     799     2807584 :   for (i=2; i<lx; i++)
     800     1799779 :     if (x[i] > t) t = x[i];
     801     1007805 :   return t;
     802             : }
     803             : 
     804             : INLINE long
     805          21 : vecsmall_indexmin(GEN x)
     806             : {
     807          21 :   long i, i0 = 1, t = x[1], lx =lg(x);
     808          84 :   for (i=2; i<lx; i++)
     809          63 :     if (x[i] < t) t = x[i0=i];
     810          21 :   return i0;
     811             : }
     812             : 
     813             : INLINE long
     814        1442 : vecsmall_min(GEN x)
     815             : {
     816        1442 :   long i, t = x[1], lx =lg(x);
     817       10094 :   for (i=2; i<lx; i++)
     818        8652 :     if (x[i] < t) t = x[i];
     819        1442 :   return t;
     820             : }
     821             : 
     822             : INLINE int
     823    22780538 : ZV_isscalar(GEN x)
     824             : {
     825    22780538 :   long l = lg(x);
     826    54293918 :   while (--l > 1)
     827    53894551 :     if (signe(gel(x, l))) return 0;
     828      399367 :   return 1;
     829             : }
     830             : INLINE int
     831    64684432 : QV_isscalar(GEN x)
     832             : {
     833    64684432 :   long lx = lg(x),i;
     834    80646686 :   for (i=2; i<lx; i++)
     835    76734008 :     if (!isintzero(gel(x, i))) return 0;
     836     3912678 :   return 1;
     837             : }
     838             : INLINE int
     839     1140305 : RgV_isscalar(GEN x)
     840             : {
     841     1140305 :   long lx = lg(x),i;
     842     1166509 :   for (i=2; i<lx; i++)
     843     1162786 :     if (!gequal0(gel(x, i))) return 0;
     844        3723 :   return 1;
     845             : }
     846             : INLINE int
     847           0 : RgX_isscalar(GEN x)
     848             : {
     849             :   long i;
     850           0 :   for (i=lg(x)-1; i>2; i--)
     851           0 :     if (!gequal0(gel(x, i))) return 0;
     852           0 :   return 1;
     853             : }
     854             : INLINE long
     855    26766290 : RgX_equal_var(GEN x, GEN y) { return varn(x) == varn(y) && RgX_equal(x,y); }
     856             : INLINE GEN
     857         140 : RgX_to_RgV(GEN x, long N) { x = RgX_to_RgC(x, N); settyp(x, t_VEC); return x; }
     858             : 
     859             : INLINE int
     860       67464 : RgX_is_rational(GEN x)
     861             : {
     862             :   long i;
     863      307821 :   for (i = lg(x)-1; i > 1; i--)
     864      292108 :     if (!is_rational_t(typ(gel(x,i)))) return 0;
     865       15713 :   return 1;
     866             : }
     867             : INLINE int
     868    15648146 : RgX_is_ZX(GEN x)
     869             : {
     870             :   long i;
     871    66311179 :   for (i = lg(x)-1; i > 1; i--)
     872    50727327 :     if (typ(gel(x,i)) != t_INT) return 0;
     873    15583852 :   return 1;
     874             : }
     875             : INLINE int
     876      378583 : RgX_is_QX(GEN x)
     877             : {
     878      378583 :   long k = lg(x)-1;
     879     1421865 :   for ( ; k>1; k--)
     880     1043562 :     if (!is_rational_t(typ(gel(x,k)))) return 0;
     881      378303 :   return 1;
     882             : }
     883             : INLINE int
     884     3079291 : RgX_is_monomial(GEN x)
     885             : {
     886             :   long i;
     887     3079291 :   if (!signe(x)) return 0;
     888     7056395 :   for (i=lg(x)-2; i>1; i--)
     889     4688743 :     if (!isexactzero(gel(x,i))) return 0;
     890     2367652 :   return 1;
     891             : }
     892             : INLINE int
     893    31340385 : RgV_is_ZV(GEN x)
     894             : {
     895             :   long i;
     896   124631697 :   for (i = lg(x)-1; i > 0; i--)
     897    93323414 :     if (typ(gel(x,i)) != t_INT) return 0;
     898    31308283 :   return 1;
     899             : }
     900             : INLINE int
     901      139963 : RgV_is_QV(GEN x)
     902             : {
     903             :   long i;
     904      619104 :   for (i = lg(x)-1; i > 0; i--)
     905      482095 :     if (!is_rational_t(typ(gel(x,i)))) return 0;
     906      137009 :   return 1;
     907             : }
     908             : INLINE long
     909      109213 : RgV_isin_i(GEN v, GEN x, long n)
     910             : {
     911             :   long i;
     912     1031582 :   for (i = 1; i <= n; i++)
     913     1025758 :     if (gequal(gel(v,i), x)) return i;
     914        5824 :   return 0;
     915             : }
     916             : INLINE long
     917      109213 : RgV_isin(GEN v, GEN x) { return RgV_isin_i(v, x, lg(v)-1); }
     918             : 
     919             : /********************************************************************/
     920             : /**                                                                **/
     921             : /**            Dynamic arrays implementation                       **/
     922             : /**                                                                **/
     923             : /********************************************************************/
     924             : INLINE void **
     925   695681666 : pari_stack_base(pari_stack *s) { return s->data; }
     926             : 
     927             : INLINE void
     928     5553291 : pari_stack_init(pari_stack *s, size_t size, void **data)
     929             : {
     930     5553291 :   s->data = data;
     931     5553291 :   *data = NULL;
     932     5553291 :   s->n = 0;
     933     5553291 :   s->alloc = 0;
     934     5553291 :   s->size = size;
     935     5553291 : }
     936             : 
     937             : INLINE void
     938   690600540 : pari_stack_alloc(pari_stack *s, long nb)
     939             : {
     940   690600540 :   void **sdat = pari_stack_base(s);
     941   690460948 :   long alloc = s->alloc;
     942   690460948 :   if (s->n+nb <= alloc) return;
     943     2071422 :   if (!alloc)
     944     1975550 :     alloc = nb;
     945             :   else
     946             :   {
     947      195803 :     while (s->n+nb > alloc) alloc <<= 1;
     948             :   }
     949     2071422 :   pari_realloc_ip(sdat,alloc*s->size);
     950     2073620 :   s->alloc = alloc;
     951             : }
     952             : 
     953             : INLINE long
     954   597680432 : pari_stack_new(pari_stack *s) { pari_stack_alloc(s, 1); return s->n++; }
     955             : 
     956             : INLINE void
     957     5135239 : pari_stack_delete(pari_stack *s)
     958             : {
     959     5135239 :   void **sdat = pari_stack_base(s);
     960     5125616 :   if (*sdat) pari_free(*sdat);
     961     5152401 : }
     962             : 
     963             : INLINE void
     964        5767 : pari_stack_pushp(pari_stack *s, void *u)
     965             : {
     966        5767 :   long n = pari_stack_new(s);
     967        5767 :   void **sdat =(void**) *pari_stack_base(s);
     968        5767 :   sdat[n] = u;
     969        5767 : }
     970             : 
     971             : /*******************************************************************/
     972             : /*                                                                 */
     973             : /*                            EXTRACT                              */
     974             : /*                                                                 */
     975             : /*******************************************************************/
     976             : INLINE GEN
     977   633937722 : vecslice(GEN A, long y1, long y2)
     978             : {
     979   633937722 :   long i,lB = y2 - y1 + 2;
     980   633937722 :   GEN B = cgetg(lB, typ(A));
     981  2827558370 :   for (i=1; i<lB; i++) B[i] = A[y1-1+i];
     982   633920857 :   return B;
     983             : }
     984             : INLINE GEN
     985     2618012 : vecslicepermute(GEN A, GEN p, long y1, long y2)
     986             : {
     987     2618012 :   long i,lB = y2 - y1 + 2;
     988     2618012 :   GEN B = cgetg(lB, typ(A));
     989    29737813 :   for (i=1; i<lB; i++) B[i] = A[p[y1-1+i]];
     990     2618012 :   return B;
     991             : }
     992             : /* rowslice(rowpermute(A,p), x1, x2) */
     993             : INLINE GEN
     994      182156 : rowslicepermute(GEN x, GEN p, long j1, long j2)
     995      770167 : { pari_APPLY_same(vecslicepermute(gel(x,i),p,j1,j2)) }
     996             : 
     997             : INLINE GEN
     998    77527793 : rowslice(GEN x, long j1, long j2)
     999   649573646 : { pari_APPLY_same(vecslice(gel(x,i), j1, j2)) }
    1000             : 
    1001             : INLINE GEN
    1002    16470741 : matslice(GEN A, long x1, long x2, long y1, long y2)
    1003    16470741 : { return rowslice(vecslice(A, y1, y2), x1, x2); }
    1004             : 
    1005             : /* shallow, remove coeff of index j */
    1006             : INLINE GEN
    1007         273 : rowsplice(GEN x, long j)
    1008        1225 : { pari_APPLY_same(vecsplice(gel(x,i), j)) }
    1009             : 
    1010             : /* shallow, remove coeff of index j */
    1011             : INLINE GEN
    1012      354715 : vecsplice(GEN a, long j)
    1013             : {
    1014      354715 :   long i, k, l = lg(a);
    1015             :   GEN b;
    1016      354715 :   if (l == 1) pari_err(e_MISC, "incorrect component in vecsplice");
    1017      354715 :   b = cgetg(l-1, typ(a));
    1018     1503236 :   for (i = k = 1; i < l; i++)
    1019     1148519 :     if (i != j) gel(b, k++) = gel(a,i);
    1020      354717 :   return b;
    1021             : }
    1022             : /* shallow */
    1023             : INLINE GEN
    1024        1036 : RgM_minor(GEN a, long i, long j)
    1025             : {
    1026        1036 :   GEN b = vecsplice(a, j);
    1027        1036 :   long k, l = lg(b);
    1028        4242 :   for (k = 1; k < l; k++) gel(b,k) = vecsplice(gel(b,k), i);
    1029        1036 :   return b;
    1030             : }
    1031             : 
    1032             : /* A[x0,] */
    1033             : INLINE GEN
    1034      762515 : row(GEN x, long j)
    1035     6685725 : { pari_APPLY_type(t_VEC, gcoeff(x, j, i)) }
    1036             : INLINE GEN
    1037     8463889 : Flm_row(GEN x, long j)
    1038   226575915 : { pari_APPLY_ulong((ulong)coeff(x, j, i)) }
    1039             : /* A[x0,] */
    1040             : INLINE GEN
    1041      204988 : rowcopy(GEN x, long j)
    1042     2105509 : { pari_APPLY_type(t_VEC, gcopy(gcoeff(x, j, i))) }
    1043             : /* A[x0, x1..x2] */
    1044             : INLINE GEN
    1045         987 : row_i(GEN A, long x0, long x1, long x2)
    1046             : {
    1047         987 :   long i, lB = x2 - x1 + 2;
    1048         987 :   GEN B  = cgetg(lB, t_VEC);
    1049        2989 :   for (i=x1; i<=x2; i++) gel(B, i) = gcoeff(A, x0, i);
    1050         987 :   return B;
    1051             : }
    1052             : 
    1053             : INLINE GEN
    1054      697025 : vecreverse(GEN A)
    1055             : {
    1056             :   long i, l;
    1057      697025 :   GEN B = cgetg_copy(A, &l);
    1058     2407755 :   for (i=1; i<l; i++) gel(B, i) = gel(A, l-i);
    1059      697025 :   return B;
    1060             : }
    1061             : 
    1062             : INLINE GEN
    1063        3052 : vecsmall_reverse(GEN A)
    1064             : {
    1065             :   long i, l;
    1066        3052 :   GEN B = cgetg_copy(A, &l);
    1067       12698 :   for (i=1; i<l; i++) B[i] = A[l-i];
    1068        3052 :   return B;
    1069             : }
    1070             : 
    1071             : INLINE void
    1072        2570 : vecreverse_inplace(GEN y)
    1073             : {
    1074        2570 :   long l = lg(y), lim = l>>1, i;
    1075        8242 :   for (i = 1; i <= lim; i++)
    1076             :   {
    1077        5672 :     GEN z = gel(y,i);
    1078        5672 :     gel(y,i)    = gel(y,l-i);
    1079        5672 :     gel(y,l-i) = z;
    1080             :   }
    1081        2570 : }
    1082             : 
    1083             : INLINE GEN
    1084    77037197 : vecsmallpermute(GEN A, GEN p) { return perm_mul(A, p); }
    1085             : 
    1086             : INLINE GEN
    1087    20009772 : vecpermute(GEN A, GEN x)
    1088   113003472 : { pari_APPLY_type(typ(A), gel(A, x[i])) }
    1089             : 
    1090             : INLINE GEN
    1091     6905039 : veclast(GEN A) { return gel(A, lg(A)-1); }
    1092             : 
    1093             : INLINE GEN
    1094    14407607 : rowpermute(GEN x, GEN p)
    1095   100134099 : { pari_APPLY_same(typ(gel(x,i)) == t_VECSMALL ? vecsmallpermute(gel(x, i), p)
    1096             :                                               : vecpermute(gel(x, i), p))
    1097             : }
    1098             : /*******************************************************************/
    1099             : /*                                                                 */
    1100             : /*                          PERMUTATIONS                           */
    1101             : /*                                                                 */
    1102             : /*******************************************************************/
    1103             : INLINE GEN
    1104     3126970 : identity_zv(long n)
    1105             : {
    1106     3126970 :   GEN v = cgetg(n+1, t_VECSMALL);
    1107             :   long i;
    1108    31981283 :   for (i = 1; i <= n; i++) v[i] = i;
    1109     3126964 :   return v;
    1110             : }
    1111             : INLINE GEN
    1112        4333 : identity_ZV(long n)
    1113             : {
    1114        4333 :   GEN v = cgetg(n+1, t_VEC);
    1115             :   long i;
    1116       51898 :   for (i = 1; i <= n; i++) gel(v,i) = utoipos(i);
    1117        4333 :   return v;
    1118             : }
    1119             : /* identity permutation */
    1120             : INLINE GEN
    1121     3102625 : identity_perm(long n) { return identity_zv(n); }
    1122             : 
    1123             : /* assume d <= n */
    1124             : INLINE GEN
    1125       99911 : cyclic_perm(long n, long d)
    1126             : {
    1127       99911 :   GEN perm = cgetg(n+1, t_VECSMALL);
    1128             :   long i;
    1129      520240 :   for (i = 1; i <= n-d; i++) perm[i] = i+d;
    1130      226702 :   for (     ; i <= n;   i++) perm[i] = i-n+d;
    1131       99911 :   return perm;
    1132             : }
    1133             : 
    1134             : /* Multiply (compose) two permutations */
    1135             : INLINE GEN
    1136    79227117 : perm_mul(GEN s, GEN x)
    1137  1004961472 : { pari_APPLY_long(s[x[i]]) }
    1138             : 
    1139             : INLINE GEN
    1140         728 : perm_sqr(GEN x)
    1141       18284 : { pari_APPLY_long(x[x[i]]) }
    1142             : 
    1143             : /* Compute the inverse (reciprocal) of a permutation. */
    1144             : INLINE GEN
    1145     2763377 : perm_inv(GEN x)
    1146             : {
    1147             :   long i, lx;
    1148     2763377 :   GEN y = cgetg_copy(x, &lx);
    1149    38846005 :   for (i=1; i<lx; i++) y[ x[i] ] = i;
    1150     2763377 :   return y;
    1151             : }
    1152             : /* Return s*t*s^-1 */
    1153             : INLINE GEN
    1154      418299 : perm_conj(GEN s, GEN t)
    1155             : {
    1156             :   long i, l;
    1157      418299 :   GEN v = cgetg_copy(s, &l);
    1158     6857893 :   for (i = 1; i < l; i++) v[ s[i] ] = s[ t[i] ];
    1159      418299 :   return v;
    1160             : }
    1161             : 
    1162             : INLINE void
    1163   489776525 : pari_free(void *pointer)
    1164             : {
    1165   489776525 :   BLOCK_SIGINT_START;
    1166   489830026 :   free(pointer);
    1167   489830026 :   BLOCK_SIGINT_END;
    1168   489825897 : }
    1169             : INLINE void*
    1170   720112955 : pari_malloc(size_t size)
    1171             : {
    1172   720112955 :   if (size)
    1173             :   {
    1174             :     char *tmp;
    1175   720119503 :     BLOCK_SIGINT_START;
    1176   720172787 :     tmp = (char*)malloc(size);
    1177   720172787 :     BLOCK_SIGINT_END;
    1178   720176463 :     if (!tmp) pari_err(e_MEM);
    1179   720185915 :     return tmp;
    1180             :   }
    1181           0 :   return NULL;
    1182             : }
    1183             : INLINE void*
    1184        1862 : pari_realloc(void *pointer, size_t size)
    1185             : {
    1186             :   char *tmp;
    1187             : 
    1188        1862 :   BLOCK_SIGINT_START;
    1189        1862 :   if (!pointer) tmp = (char *) malloc(size);
    1190        1862 :   else tmp = (char *) realloc(pointer,size);
    1191        1862 :   BLOCK_SIGINT_END;
    1192        1862 :   if (!tmp) pari_err(e_MEM);
    1193        1862 :   return tmp;
    1194             : }
    1195             : INLINE void
    1196     2075588 : pari_realloc_ip(void **pointer, size_t size)
    1197             : {
    1198             :   char *tmp;
    1199     2075588 :   BLOCK_SIGINT_START;
    1200     2075408 :   if (!*pointer) tmp = (char *) malloc(size);
    1201      100234 :   else tmp = (char *) realloc(*pointer,size);
    1202     2075408 :   if (!tmp) pari_err(e_MEM);
    1203     2075408 :   *pointer = tmp;
    1204     2075408 :   BLOCK_SIGINT_END;
    1205     2074888 : }
    1206             : 
    1207             : INLINE void*
    1208       46684 : pari_calloc(size_t size)
    1209             : {
    1210       46684 :   void *t = pari_malloc(size);
    1211       46684 :   memset(t, 0, size); return t;
    1212             : }
    1213             : INLINE GEN
    1214        8213 : cgetalloc(size_t l, long t)
    1215             : { /* evallg may raise e_OVERFLOW, which would leak x */
    1216        8213 :   ulong x0 = evaltyp(t) | evallg(l);
    1217        8213 :   GEN x = (GEN)pari_malloc(l * sizeof(long));
    1218        8213 :   x[0] = x0; return x;
    1219             : }
    1220             : 
    1221             : /*******************************************************************/
    1222             : /*                                                                 */
    1223             : /*                       GARBAGE COLLECTION                        */
    1224             : /*                                                                 */
    1225             : /*******************************************************************/
    1226             : /* copy integer x as if we had set_avma(av) */
    1227             : INLINE GEN
    1228  7810371207 : icopy_avma(GEN x, pari_sp av)
    1229             : {
    1230  7810371207 :   long i = lgefint(x), lx = i;
    1231  7810371207 :   GEN y = ((GEN)av) - i;
    1232 53408966379 :   while (--i > 0) y[i] = x[i];
    1233  7810371207 :   y[0] = evaltyp(t_INT)|evallg(lx);
    1234  7813616750 :   return y;
    1235             : }
    1236             : /* copy leaf x as if we had set_avma(av) */
    1237             : INLINE GEN
    1238   550380319 : leafcopy_avma(GEN x, pari_sp av)
    1239             : {
    1240   550380319 :   long i = lg(x);
    1241   550380319 :   GEN y = ((GEN)av) - i;
    1242  2991782271 :   while (--i > 0) y[i] = x[i];
    1243   550380319 :   y[0] = x[0] & (~CLONEBIT);
    1244   550380319 :   return y;
    1245             : }
    1246             : INLINE GEN
    1247  1081772481 : gerepileuptoleaf(pari_sp av, GEN x)
    1248             : {
    1249             :   long lx;
    1250             :   GEN q;
    1251             : 
    1252  1081772481 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1253  1080534862 :   lx = lg(x);
    1254  1080534862 :   q = ((GEN)av) - lx;
    1255  1080534862 :   set_avma((pari_sp)q);
    1256 10859119007 :   while (--lx >= 0) q[lx] = x[lx];
    1257  1080145380 :   return q;
    1258             : }
    1259             : INLINE GEN
    1260  3953553358 : gerepileuptoint(pari_sp av, GEN x)
    1261             : {
    1262  3953553358 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1263  3519891518 :   set_avma((pari_sp)icopy_avma(x, av));
    1264  3523425049 :   return (GEN)avma;
    1265             : }
    1266             : INLINE GEN
    1267  1808643956 : gerepileupto(pari_sp av, GEN x)
    1268             : {
    1269  1808643956 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1270  1634875333 :   switch(typ(x))
    1271             :   { /* non-default = !is_recursive_t(tq) */
    1272   482629718 :     case t_INT: return gerepileuptoint(av, x);
    1273   337957789 :     case t_REAL:
    1274             :     case t_STR:
    1275   337957789 :     case t_VECSMALL: return gerepileuptoleaf(av,x);
    1276   814289520 :     default:
    1277             :       /* NB: x+i --> ((long)x) + i*sizeof(long) */
    1278   814289520 :       return gerepile(av, (pari_sp) (x+lg(x)), x);
    1279             :   }
    1280             : }
    1281             : 
    1282             : /* gerepileupto(av, gcopy(x)) */
    1283             : INLINE GEN
    1284   227092177 : gerepilecopy(pari_sp av, GEN x)
    1285             : {
    1286   227092177 :   if (is_recursive_t(typ(x)))
    1287             :   {
    1288   207566712 :     GENbin *p = copy_bin(x);
    1289   207584515 :     set_avma(av); return bin_copy(p);
    1290             :   }
    1291             :   else
    1292             :   {
    1293    19524941 :     set_avma(av);
    1294    19525106 :     if (x < (GEN)av) {
    1295    19317323 :       if (x < (GEN)pari_mainstack->bot) new_chunk(lg(x));
    1296    19317326 :       x = leafcopy_avma(x, av);
    1297    19317357 :       set_avma((pari_sp)x);
    1298             :     } else
    1299      207787 :       x = leafcopy(x);
    1300    19525134 :     return x;
    1301             :   }
    1302             : }
    1303             : 
    1304             : INLINE void
    1305    48394240 : guncloneNULL(GEN x) { if (x) gunclone(x); }
    1306             : INLINE void
    1307     1320571 : guncloneNULL_deep(GEN x) { if (x) gunclone_deep(x); }
    1308             : 
    1309             : /* Takes an array of pointers to GENs, of length n. Copies all
    1310             :  * objects to contiguous locations and cleans up the stack between
    1311             :  * av and avma. */
    1312             : INLINE void
    1313      984829 : gerepilemany(pari_sp av, GEN* gptr[], int n)
    1314             : {
    1315             :   int i;
    1316     3912772 :   for (i=0; i<n; i++) *gptr[i] = (GEN)copy_bin(*gptr[i]);
    1317      984682 :   set_avma(av);
    1318     3913253 :   for (i=0; i<n; i++) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1319      984976 : }
    1320             : 
    1321             : INLINE void
    1322    19027782 : gerepileall(pari_sp av, int n, ...)
    1323             : {
    1324             :   int i;
    1325    19027782 :   va_list a; va_start(a, n);
    1326    19027782 :   if (n < 10)
    1327             :   {
    1328             :     GEN *gptr[10];
    1329    57735268 :     for (i=0; i<n; i++)
    1330    38706752 :     { gptr[i] = va_arg(a,GEN*); *gptr[i] = (GEN)copy_bin(*gptr[i]); }
    1331    19028516 :     set_avma(av);
    1332    57736193 :     for (--i; i>=0; i--) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1333             : 
    1334             :   }
    1335             :   else
    1336             :   {
    1337           0 :     GEN **gptr = (GEN**)  pari_malloc(n*sizeof(GEN*));
    1338           0 :     for (i=0; i<n; i++)
    1339           0 :     { gptr[i] = va_arg(a,GEN*); *gptr[i] = (GEN)copy_bin(*gptr[i]); }
    1340           0 :     set_avma(av);
    1341           0 :     for (--i; i>=0; i--) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1342           0 :     pari_free(gptr);
    1343             :   }
    1344    19029009 :   va_end(a);
    1345    19029009 : }
    1346             : 
    1347             : /* assume 1 <= n < 10 */
    1348             : INLINE GEN
    1349    86193232 : gc_all(pari_sp av, int n, ...)
    1350             : {
    1351             :   int i;
    1352             :   GEN *v[10];
    1353    86193232 :   va_list a; va_start(a, n);
    1354   289571190 :   for (i=0; i<n; i++) { v[i] = va_arg(a,GEN*); *v[i] = (GEN)copy_bin(*v[i]); }
    1355    86193532 :   set_avma(av);
    1356   289571925 :   for (i=0; i<n; i++) *v[i] = bin_copy((GENbin*)*v[i]);
    1357    86193680 :   return *v[0];
    1358             : }
    1359             : 
    1360             : INLINE void
    1361     2196013 : gerepilecoeffs(pari_sp av, GEN x, int n)
    1362             : {
    1363             :   int i;
    1364    26159530 :   for (i=0; i<n; i++) gel(x,i) = (GEN)copy_bin(gel(x,i));
    1365     2196590 :   set_avma(av);
    1366    26160907 :   for (i=0; i<n; i++) gel(x,i) = bin_copy((GENbin*)x[i]);
    1367     2196199 : }
    1368             : 
    1369             : /* p from copy_bin. Copy p->x back to stack, then destroy p */
    1370             : INLINE GEN
    1371   476601498 : bin_copy(GENbin *p)
    1372             : {
    1373             :   GEN x, y, base;
    1374             :   long dx, len;
    1375             : 
    1376   476601498 :   x   = p->x; if (!x) { pari_free(p); return gen_0; }
    1377   447589723 :   len = p->len;
    1378   447589723 :   base= p->base; dx = x - base;
    1379   447589723 :   y = (GEN)memcpy((void*)new_chunk(len), (void*)GENbinbase(p), len*sizeof(long));
    1380   447583013 :   y += dx;
    1381   447583013 :   p->rebase(y, ((ulong)y-(ulong)x));
    1382   447587034 :   pari_free(p); return y;
    1383             : }
    1384             : 
    1385             : INLINE GEN
    1386   924190431 : GENbinbase(GENbin *p) { return (GEN)(p + 1); }
    1387             : 
    1388             : INLINE void
    1389   117512033 : cgiv(GEN x)
    1390             : {
    1391   117512033 :   pari_sp av = (pari_sp)(x+lg(x));
    1392   117512033 :   if (isonstack((GEN)av)) set_avma(av);
    1393   117526978 : }
    1394             : 
    1395             : INLINE void
    1396     1859186 : killblock(GEN x) { gunclone(x); }
    1397             : 
    1398             : INLINE int
    1399   291123151 : is_universal_constant(GEN x) { return (x >= gen_0 && x <= ghalf); }
    1400             : 
    1401             : /*******************************************************************/
    1402             : /*                                                                 */
    1403             : /*                    CONVERSION / ASSIGNMENT                      */
    1404             : /*                                                                 */
    1405             : /*******************************************************************/
    1406             : /* z is a type which may be a t_COMPLEX component (not a t_QUAD) */
    1407             : INLINE GEN
    1408    17885369 : cxcompotor(GEN z, long prec)
    1409             : {
    1410    17885369 :   switch(typ(z))
    1411             :   {
    1412    11743826 :     case t_INT:  return itor(z, prec);
    1413      293174 :     case t_FRAC: return fractor(z, prec);
    1414     5848629 :     case t_REAL: return rtor(z, prec);
    1415           0 :     default: pari_err_TYPE("cxcompotor",z);
    1416             :              return NULL; /* LCOV_EXCL_LINE */
    1417             :   }
    1418             : }
    1419             : INLINE GEN
    1420     8926808 : cxtofp(GEN x, long prec)
    1421     8926808 : { retmkcomplex(cxcompotor(gel(x,1),prec), cxcompotor(gel(x,2),prec)); }
    1422             : 
    1423             : INLINE GEN
    1424      384629 : cxtoreal(GEN q)
    1425      384629 : { return (typ(q) == t_COMPLEX && gequal0(gel(q,2)))? gel(q,1): q; }
    1426             : 
    1427             : INLINE double
    1428    60500212 : gtodouble(GEN x)
    1429             : {
    1430    60500212 :   if (typ(x)!=t_REAL) {
    1431     8159395 :     pari_sp av = avma;
    1432     8159395 :     x = gtofp(x, DEFAULTPREC);
    1433     8158871 :     if (typ(x)!=t_REAL) pari_err_TYPE("gtodouble [t_REAL expected]", x);
    1434     8158871 :     set_avma(av);
    1435             :   }
    1436    60499599 :   return rtodbl(x);
    1437             : }
    1438             : 
    1439             : INLINE int
    1440     2967776 : gisdouble(GEN x, double *g)
    1441             : {
    1442     2967776 :   if (typ(x)!=t_REAL) {
    1443       41893 :     pari_sp av = avma;
    1444       41893 :     x = gtofp(x, DEFAULTPREC);
    1445       41893 :     if (typ(x)!=t_REAL) pari_err_TYPE("gisdouble [t_REAL expected]", x);
    1446       41893 :     set_avma(av);
    1447             :   }
    1448     2967777 :   if (expo(x) >= 0x3ff) return 0;
    1449     2967777 :   *g = rtodbl(x); return 1;
    1450             : }
    1451             : 
    1452             : INLINE long
    1453    85800707 : gtos(GEN x) {
    1454    85800707 :   if (typ(x) != t_INT) pari_err_TYPE("gtos [integer expected]",x);
    1455    85800693 :   return itos(x);
    1456             : }
    1457             : 
    1458             : INLINE ulong
    1459      102638 : gtou(GEN x) {
    1460      102638 :   if (typ(x) != t_INT || signe(x)<0)
    1461           7 :     pari_err_TYPE("gtou [integer >=0 expected]",x);
    1462      102631 :   return itou(x);
    1463             : }
    1464             : 
    1465             : INLINE GEN
    1466    45168315 : absfrac(GEN x)
    1467             : {
    1468    45168315 :   GEN y = cgetg(3, t_FRAC);
    1469    45168353 :   gel(y,1) = absi(gel(x,1));
    1470    45168351 :   gel(y,2) = icopy(gel(x,2)); return y;
    1471             : }
    1472             : INLINE GEN
    1473       47277 : absfrac_shallow(GEN x)
    1474       47277 : { return signe(gel(x,1))>0? x: mkfrac(negi(gel(x,1)), gel(x,2)); }
    1475             : INLINE GEN
    1476     7793142 : Q_abs(GEN x) { return (typ(x) == t_INT)? absi(x): absfrac(x); }
    1477             : INLINE GEN
    1478      171571 : Q_abs_shallow(GEN x)
    1479      171571 : { return (typ(x) == t_INT)? absi_shallow(x): absfrac_shallow(x); }
    1480             : INLINE GEN
    1481       13083 : R_abs_shallow(GEN x)
    1482       13083 : { return (typ(x) == t_FRAC)? absfrac_shallow(x): mpabs_shallow(x); }
    1483             : INLINE GEN
    1484           0 : R_abs(GEN x)
    1485           0 : { return (typ(x) == t_FRAC)? absfrac(x): mpabs(x); }
    1486             : 
    1487             : /* Force z to be of type real/complex with floating point components */
    1488             : INLINE GEN
    1489   251847826 : gtofp(GEN z, long prec)
    1490             : {
    1491   251847826 :   switch(typ(z))
    1492             :   {
    1493   213183625 :     case t_INT:  return itor(z, prec);
    1494     4097405 :     case t_FRAC: return fractor(z, prec);
    1495    25900754 :     case t_REAL: return rtor(z, prec);
    1496     8673710 :     case t_COMPLEX: {
    1497     8673710 :       GEN a = gel(z,1), b = gel(z,2);
    1498     8673710 :       if (isintzero(b)) return cxcompotor(a, prec);
    1499     8673700 :       if (isintzero(a)) {
    1500        9102 :         GEN y = cgetg(3, t_COMPLEX);
    1501        9102 :         b = cxcompotor(b, prec);
    1502        9102 :         gel(y,1) = real_0_bit(expo(b) - prec);
    1503        9102 :         gel(y,2) = b; return y;
    1504             :       }
    1505     8664595 :       return cxtofp(z, prec);
    1506             :     }
    1507           0 :     case t_QUAD: return quadtofp(z, prec);
    1508           0 :     default: pari_err_TYPE("gtofp",z);
    1509             :              return NULL; /* LCOV_EXCL_LINE */
    1510             :   }
    1511             : }
    1512             : /* Force z to be of type real / int */
    1513             : INLINE GEN
    1514       22428 : gtomp(GEN z, long prec)
    1515             : {
    1516       22428 :   switch(typ(z))
    1517             :   {
    1518          42 :     case t_INT:  return z;
    1519       22386 :     case t_FRAC: return fractor(z, prec);
    1520           0 :     case t_REAL: return rtor(z, prec);
    1521           0 :     case t_QUAD: z = quadtofp(z, prec);
    1522           0 :                  if (typ(z) == t_REAL) return z;
    1523           0 :     default: pari_err_TYPE("gtomp",z);
    1524             :              return NULL; /* LCOV_EXCL_LINE */
    1525             :   }
    1526             : }
    1527             : 
    1528             : INLINE GEN
    1529     7114819 : RgX_gtofp(GEN x, long prec)
    1530    37116453 : { pari_APPLY_pol_normalized(gtofp(gel(x,i), prec)); }
    1531             : 
    1532             : INLINE GEN
    1533    33675851 : RgC_gtofp(GEN x, long prec)
    1534   216852292 : { pari_APPLY_type(t_COL, gtofp(gel(x,i), prec)) }
    1535             : 
    1536             : INLINE GEN
    1537          56 : RgV_gtofp(GEN x, long prec)
    1538        4781 : { pari_APPLY_type(t_VEC, gtofp(gel(x,i), prec)) }
    1539             : 
    1540             : INLINE GEN
    1541     8175250 : RgM_gtofp(GEN x, long prec)
    1542    41221377 : { pari_APPLY_same(RgC_gtofp(gel(x,i), prec)) }
    1543             : 
    1544             : INLINE GEN
    1545         574 : RgC_gtomp(GEN x, long prec)
    1546       23002 : { pari_APPLY_type(t_COL, gtomp(gel(x,i), prec)) }
    1547             : 
    1548             : INLINE GEN
    1549          21 : RgM_gtomp(GEN x, long prec)
    1550         595 : { pari_APPLY_same(RgC_gtomp(gel(x,i), prec)) }
    1551             : 
    1552             : INLINE GEN
    1553       60444 : RgX_fpnorml2(GEN x, long prec)
    1554             : {
    1555       60444 :   pari_sp av = avma;
    1556       60444 :   return gerepileupto(av, gnorml2(RgX_gtofp(x, prec)));
    1557             : }
    1558             : INLINE GEN
    1559      618672 : RgC_fpnorml2(GEN x, long prec)
    1560             : {
    1561      618672 :   pari_sp av = avma;
    1562      618672 :   return gerepileupto(av, gnorml2(RgC_gtofp(x, prec)));
    1563             : }
    1564             : INLINE GEN
    1565       22172 : RgM_fpnorml2(GEN x, long prec)
    1566             : {
    1567       22172 :   pari_sp av = avma;
    1568       22172 :   return gerepileupto(av, gnorml2(RgM_gtofp(x, prec)));
    1569             : }
    1570             : 
    1571             : /* y a t_REAL */
    1572             : INLINE void
    1573      220535 : affgr(GEN x, GEN y)
    1574             : {
    1575             :   pari_sp av;
    1576      220535 :   switch(typ(x)) {
    1577        5999 :     case t_INT:  affir(x,y); break;
    1578      214536 :     case t_REAL: affrr(x,y); break;
    1579           0 :     case t_FRAC: rdiviiz(gel(x,1),gel(x,2), y); break;
    1580           0 :     case t_QUAD: av = avma; affgr(quadtofp(x,realprec(y)), y); set_avma(av); break;
    1581           0 :     default: pari_err_TYPE2("=",x,y);
    1582             :   }
    1583      220535 : }
    1584             : 
    1585             : INLINE GEN
    1586      239591 : affc_fixlg(GEN x, GEN res)
    1587             : {
    1588      239591 :   if (typ(x) == t_COMPLEX)
    1589             :   {
    1590      206871 :     affrr_fixlg(gel(x,1), gel(res,1));
    1591      206871 :     affrr_fixlg(gel(x,2), gel(res,2));
    1592             :   }
    1593             :   else
    1594             :   {
    1595       32720 :     set_avma((pari_sp)(res+3));
    1596       32721 :     res = cgetr(realprec(gel(res,1)));
    1597       32721 :     affrr_fixlg(x, res);
    1598             :   }
    1599      239593 :   return res;
    1600             : }
    1601             : 
    1602             : INLINE GEN
    1603           0 : trunc_safe(GEN x) { long e; return gcvtoi(x,&e); }
    1604             : 
    1605             : /*******************************************************************/
    1606             : /*                                                                 */
    1607             : /*                          LENGTH CONVERSIONS                     */
    1608             : /*                                                                 */
    1609             : /*******************************************************************/
    1610             : INLINE long
    1611       41087 : ndec2nlong(long x) { return 1 + (long)((x)*(LOG2_10/BITS_IN_LONG)); }
    1612             : INLINE long
    1613       32831 : ndec2prec(long x) { return ndec2nlong(x) << TWOPOTBITS_IN_LONG; }
    1614             : INLINE long
    1615        8256 : ndec2nbits(long x) { return ndec2nlong(x) << TWOPOTBITS_IN_LONG; }
    1616             : /* Fast implementation of ceil(x / (8*sizeof(long))); typecast to (ulong)
    1617             :  * to avoid overflow. Faster than 1 + ((x-1)>>TWOPOTBITS_IN_LONG)) :
    1618             :  *   addl, shrl instead of subl, sarl, addl */
    1619             : INLINE long
    1620    12568925 : nbits2nlong(long x) {
    1621    12568925 :   return (long)(((ulong)x+BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1622             : }
    1623             : 
    1624             : INLINE long
    1625  1474512397 : nbits2extraprec(long x) {
    1626  1474512397 :   return (((ulong)x+BITS_IN_LONG-1)>>TWOPOTBITS_IN_LONG) << TWOPOTBITS_IN_LONG;
    1627             : }
    1628             : 
    1629             : INLINE long
    1630   185222516 : nbits2prec(long x) {
    1631   185222516 :   return (((ulong)x+BITS_IN_LONG-1)>>TWOPOTBITS_IN_LONG) << TWOPOTBITS_IN_LONG;
    1632             : }
    1633             : 
    1634             : INLINE long
    1635  4452889887 : prec2lg(long x) {
    1636  4452889887 :   return (long)(((ulong)x+3*BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1637             : }
    1638             : /* ceil(x / sizeof(long)) */
    1639             : INLINE long
    1640   120774415 : nchar2nlong(long x) {
    1641   120774415 :   return (long)(((ulong)x+sizeof(long)-1) >> (TWOPOTBITS_IN_LONG-3L));
    1642             : }
    1643             : INLINE long
    1644   104209797 : prec2nbits(long x) { return x; }
    1645             : INLINE double
    1646     3178219 : bit_accuracy_mul(long x, double y) { return (x-2) * (BITS_IN_LONG*y); }
    1647             : INLINE double
    1648      570919 : prec2nbits_mul(long x, double y) { return x * y; }
    1649             : INLINE long
    1650   141324145 : bit_prec(GEN x) { return realprec(x); }
    1651             : INLINE long
    1652  2834623624 : bit_accuracy(long x) { return (x-2) * BITS_IN_LONG; }
    1653             : INLINE long
    1654        9750 : prec2ndec(long x) { return (long)(x * LOG10_2); }
    1655             : INLINE long
    1656         214 : nbits2ndec(long x) { return prec2ndec(x); }
    1657             : INLINE long
    1658      474213 : precdbl(long x) {return x << 1;}
    1659             : INLINE long
    1660  8058333901 : divsBIL(long n) { return n >> TWOPOTBITS_IN_LONG; }
    1661             : INLINE long
    1662  7970302399 : remsBIL(long n) { return n & (BITS_IN_LONG-1); }
    1663             : 
    1664             : /*********************************************************************/
    1665             : /**                                                                 **/
    1666             : /**                      OPERATIONS MODULO m                        **/
    1667             : /**                                                                 **/
    1668             : /*********************************************************************/
    1669             : /* Assume m > 0, more efficient if 0 <= a, b < m */
    1670             : 
    1671             : INLINE GEN
    1672    80054526 : Fp_red(GEN a, GEN m) { return modii(a, m); }
    1673             : INLINE GEN
    1674   174305990 : Fp_add(GEN a, GEN b, GEN m)
    1675             : {
    1676   174305990 :   pari_sp av=avma;
    1677   174305990 :   GEN p = addii(a,b);
    1678   173824891 :   long s = signe(p);
    1679   173824891 :   if (!s) return p; /* = gen_0 */
    1680   161012435 :   if (s > 0) /* general case */
    1681             :   {
    1682   160752377 :     GEN t = subii(p, m);
    1683   160679114 :     s = signe(t);
    1684   160679114 :     if (!s) return gc_const(av, gen_0);
    1685   152351970 :     if (s < 0) return gc_const((pari_sp)p, p);
    1686    72859432 :     if (cmpii(t, m) < 0) return gerepileuptoint(av, t); /* general case ! */
    1687     3301154 :     p = remii(t, m);
    1688             :   }
    1689             :   else
    1690      262453 :     p = modii(p, m);
    1691     3563689 :   return gerepileuptoint(av, p);
    1692             : }
    1693             : INLINE GEN
    1694    20878860 : Fp_double(GEN x, GEN N)
    1695             : {
    1696    20878860 :   GEN z = shifti(x, 1);
    1697    20579074 :   return cmpii(z, N) >= 0? subii(z, N): z;
    1698             : }
    1699             : INLINE GEN
    1700   147341653 : Fp_sub(GEN a, GEN b, GEN m)
    1701             : {
    1702   147341653 :   pari_sp av=avma;
    1703   147341653 :   GEN p = subii(a,b);
    1704   146218171 :   long s = signe(p);
    1705   146218171 :   if (!s) return p; /* = gen_0 */
    1706   130572803 :   if (s > 0)
    1707             :   {
    1708    65572650 :     if (cmpii(p, m) < 0) return p; /* general case ! */
    1709     1450808 :     p = remii(p, m);
    1710             :   }
    1711             :   else
    1712             :   {
    1713    65000153 :     GEN t = addii(p, m);
    1714    66566781 :     if (!s) return gc_const(av, gen_0);
    1715    66567350 :     if (s > 0) return gerepileuptoint(av, t); /* general case ! */
    1716    66567350 :     p = modii(t, m);
    1717             :   }
    1718    68324431 :   return gerepileuptoint(av, p);
    1719             : }
    1720             : INLINE GEN
    1721    28711043 : Fp_neg(GEN b, GEN m)
    1722             : {
    1723    28711043 :   pari_sp av = avma;
    1724    28711043 :   long s = signe(b);
    1725             :   GEN p;
    1726    28711043 :   if (!s) return gen_0;
    1727    24281730 :   if (s > 0)
    1728             :   {
    1729    23149735 :     p = subii(m, b);
    1730    23149316 :     if (signe(p) >= 0) return p; /* general case ! */
    1731      386954 :     p = modii(p, m);
    1732             :   } else
    1733     1132656 :     p = remii(negi(b), m);
    1734     1519826 :   return gerepileuptoint(av, p);
    1735             : }
    1736             : 
    1737             : INLINE GEN
    1738      252335 : Fp_halve(GEN a, GEN p)
    1739             : {
    1740      252335 :   if (mpodd(a)) a = addii(a,p);
    1741      252335 :   return shifti(a,-1);
    1742             : }
    1743             : 
    1744             : /* assume 0 <= u < p and ps2 = p>>1 */
    1745             : INLINE GEN
    1746    74997636 : Fp_center(GEN u, GEN p, GEN ps2)
    1747    74997636 : { return abscmpii(u,ps2)<=0? icopy(u): subii(u,p); }
    1748             : /* same without copy */
    1749             : INLINE GEN
    1750    13855860 : Fp_center_i(GEN u, GEN p, GEN ps2)
    1751    13855860 : { return abscmpii(u,ps2)<=0? u: subii(u,p); }
    1752             : 
    1753             : /* x + y*z mod p */
    1754             : INLINE GEN
    1755    11230521 : Fp_addmul(GEN x, GEN y, GEN z, GEN p)
    1756             : {
    1757             :   pari_sp av;
    1758    11230521 :   if (!signe(y) || !signe(z)) return Fp_red(x, p);
    1759    10884441 :   if (!signe(x)) return Fp_mul(z,y, p);
    1760     9884671 :   av = avma;
    1761     9884671 :   return gerepileuptoint(av, modii(addii(x, mulii(y,z)), p));
    1762             : }
    1763             : 
    1764             : INLINE GEN
    1765   181803527 : Fp_mul(GEN a, GEN b, GEN m)
    1766             : {
    1767   181803527 :   pari_sp av=avma;
    1768             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1769   181803527 :   (void)new_chunk(lg(a)+lg(b)+(lg(m)<<1));
    1770   181875646 :   p = mulii(a,b);
    1771   181734359 :   set_avma(av); return modii(p,m);
    1772             : }
    1773             : INLINE GEN
    1774    63580642 : Fp_sqr(GEN a, GEN m)
    1775             : {
    1776    63580642 :   pari_sp av=avma;
    1777             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1778    63580642 :   (void)new_chunk((lg(a)+lg(m))<<1);
    1779    63872601 :   p = sqri(a);
    1780    62455568 :   set_avma(av); return remii(p,m); /*Use remii: p >= 0 */
    1781             : }
    1782             : INLINE GEN
    1783    70595787 : Fp_mulu(GEN a, ulong b, GEN m)
    1784             : {
    1785    70595787 :   long l = lgefint(m);
    1786    70595787 :   if (l == 3)
    1787             :   {
    1788    51021615 :     ulong mm = m[2];
    1789    51021615 :     return utoi( Fl_mul(umodiu(a, mm), b, mm) );
    1790             :   } else {
    1791    19574172 :     pari_sp av = avma;
    1792             :     GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1793    19574172 :     (void)new_chunk(lg(a)+1+(l<<1));
    1794    19546223 :     p = muliu(a,b);
    1795    19376401 :     set_avma(av); return modii(p,m);
    1796             :   }
    1797             : }
    1798             : INLINE GEN
    1799       17780 : Fp_muls(GEN a, long b, GEN m)
    1800             : {
    1801       17780 :   long l = lgefint(m);
    1802       17780 :   if (l == 3)
    1803             :   {
    1804        3578 :     ulong mm = m[2];
    1805        3578 :     if (b < 0)
    1806             :     {
    1807        3578 :       ulong t = Fl_mul(umodiu(a, mm), -b, mm);
    1808        3578 :       return t? utoipos(mm - t): gen_0;
    1809             :     }
    1810             :     else
    1811           0 :       return utoi( Fl_mul(umodiu(a, mm), b, mm) );
    1812             :   } else {
    1813       14202 :     pari_sp av = avma;
    1814             :     GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1815       14202 :     (void)new_chunk(lg(a)+1+(l<<1));
    1816       14202 :     p = mulis(a,b);
    1817       14202 :     set_avma(av); return modii(p,m);
    1818             :   }
    1819             : }
    1820             : 
    1821             : INLINE GEN
    1822    36330704 : Fp_inv(GEN a, GEN m)
    1823             : {
    1824             :   GEN res;
    1825    36330704 :   if (! invmod(a,m,&res)) pari_err_INV("Fp_inv", mkintmod(res,m));
    1826    36331265 :   return res;
    1827             : }
    1828             : INLINE GEN
    1829     1095789 : Fp_invsafe(GEN a, GEN m)
    1830             : {
    1831             :   GEN res;
    1832     1095789 :   if (! invmod(a,m,&res)) return NULL;
    1833     1095727 :   return res;
    1834             : }
    1835             : INLINE GEN
    1836     1614856 : Fp_div(GEN a, GEN b, GEN m)
    1837             : {
    1838     1614856 :   pari_sp av = avma;
    1839             :   GEN p;
    1840     1614856 :   if (lgefint(b) == 3)
    1841             :   {
    1842      660507 :     a = Fp_divu(a, b[2], m);
    1843      660507 :     if (signe(b) < 0) a = Fp_neg(a, m);
    1844      660507 :     return a;
    1845             :   }
    1846             :   /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1847      954349 :   (void)new_chunk(lg(a)+(lg(m)<<1));
    1848      954349 :   p = mulii(a, Fp_inv(b,m));
    1849      954349 :   set_avma(av); return modii(p,m);
    1850             : }
    1851             : INLINE GEN
    1852     1898892 : Fp_divu(GEN x, ulong a, GEN p)
    1853             : {
    1854     1898892 :   pari_sp av = avma;
    1855             :   ulong b;
    1856     1898892 :   if (lgefint(p) == 3)
    1857             :   {
    1858     1502393 :     ulong pp = p[2], xp = umodiu(x, pp);
    1859     1502393 :     return xp? utoipos(Fl_div(xp, a % pp, pp)): gen_0;
    1860             :   }
    1861      396499 :   x = Fp_red(x, p);
    1862      396499 :   b = Fl_neg(Fl_div(umodiu(x,a), umodiu(p,a), a), a); /* x + pb = 0 (mod a) */
    1863      396498 :   return gerepileuptoint(av, diviuexact(addmuliu(x, p, b), a));
    1864             : }
    1865             : 
    1866             : INLINE GEN
    1867     1086723 : Flx_mulu(GEN x, ulong a, ulong p) { return Flx_Fl_mul(x,a%p,p); }
    1868             : 
    1869             : INLINE GEN
    1870     2498826 : get_F2x_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1871             : 
    1872             : INLINE long
    1873     2529925 : get_F2x_var(GEN T) { return typ(T)==t_VEC? mael(T,2,1): T[1]; }
    1874             : 
    1875             : INLINE long
    1876     1928534 : get_F2x_degree(GEN T) { return typ(T)==t_VEC? F2x_degree(gel(T,2)): F2x_degree(T); }
    1877             : 
    1878             : INLINE GEN
    1879         399 : get_F2xqX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1880             : 
    1881             : INLINE long
    1882      375795 : get_F2xqX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1883             : 
    1884             : INLINE long
    1885      201201 : get_F2xqX_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1886             : 
    1887             : INLINE GEN
    1888    25490224 : get_Flx_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1889             : 
    1890             : INLINE long
    1891    67528254 : get_Flx_var(GEN T) { return typ(T)==t_VEC? mael(T,2,1): T[1]; }
    1892             : 
    1893             : INLINE long
    1894    83947698 : get_Flx_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1895             : 
    1896             : INLINE GEN
    1897        8047 : get_FlxqX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1898             : 
    1899             : INLINE long
    1900      264625 : get_FlxqX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1901             : 
    1902             : INLINE long
    1903      317862 : get_FlxqX_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1904             : 
    1905             : INLINE GEN
    1906     3388354 : get_FpX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1907             : 
    1908             : INLINE long
    1909     7217213 : get_FpX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1910             : 
    1911             : INLINE long
    1912     5989472 : get_FpX_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1913             : 
    1914             : INLINE GEN
    1915      146583 : get_FpXQX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1916             : 
    1917             : INLINE long
    1918       51784 : get_FpXQX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1919             : 
    1920             : INLINE long
    1921        3640 : get_FpXQX_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1922             : 
    1923             : /*******************************************************************/
    1924             : /*                                                                 */
    1925             : /*                        ADDMULII / SUBMULII                      */
    1926             : /*                                                                 */
    1927             : /*******************************************************************/
    1928             : /* x - y*z */
    1929             : INLINE GEN
    1930    32707271 : submulii(GEN x, GEN y, GEN z)
    1931             : {
    1932    32707271 :   long lx = lgefint(x), ly, lz;
    1933             :   pari_sp av;
    1934             :   GEN t;
    1935    32707271 :   if (lx == 2) { t = mulii(z,y); togglesign(t); return t; }
    1936    30259167 :   ly = lgefint(y);
    1937    30259167 :   if (ly == 2) return icopy(x);
    1938    28993179 :   lz = lgefint(z);
    1939    28993179 :   av = avma; (void)new_chunk(lx+ly+lz); /* HACK */
    1940    28993179 :   t = mulii(z, y);
    1941    28993179 :   set_avma(av); return subii(x,t);
    1942             : }
    1943             : /* y*z - x */
    1944             : INLINE GEN
    1945     3823996 : mulsubii(GEN y, GEN z, GEN x)
    1946             : {
    1947     3823996 :   long lx = lgefint(x), ly, lz;
    1948             :   pari_sp av;
    1949             :   GEN t;
    1950     3823996 :   if (lx == 2) return mulii(z,y);
    1951     2415107 :   ly = lgefint(y);
    1952     2415107 :   if (ly == 2) return negi(x);
    1953     2141560 :   lz = lgefint(z);
    1954     2141560 :   av = avma; (void)new_chunk(lx+ly+lz); /* HACK */
    1955     2141589 :   t = mulii(z, y);
    1956     2141575 :   set_avma(av); return subii(t,x);
    1957             : }
    1958             : 
    1959             : /* x - u*y */
    1960             : INLINE GEN
    1961        7693 : submuliu(GEN x, GEN y, ulong u)
    1962             : {
    1963             :   pari_sp av;
    1964        7693 :   long ly = lgefint(y);
    1965        7693 :   if (ly == 2) return icopy(x);
    1966        7693 :   av = avma;
    1967        7693 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1968        7693 :   y = mului(u,y);
    1969        7693 :   set_avma(av); return subii(x, y);
    1970             : }
    1971             : /* x + u*y */
    1972             : INLINE GEN
    1973      404566 : addmuliu(GEN x, GEN y, ulong u)
    1974             : {
    1975             :   pari_sp av;
    1976      404566 :   long ly = lgefint(y);
    1977      404566 :   if (ly == 2) return icopy(x);
    1978      404566 :   av = avma;
    1979      404566 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1980      404566 :   y = mului(u,y);
    1981      404566 :   set_avma(av); return addii(x, y);
    1982             : }
    1983             : /* x - u*y */
    1984             : INLINE GEN
    1985    59732190 : submuliu_inplace(GEN x, GEN y, ulong u)
    1986             : {
    1987             :   pari_sp av;
    1988    59732190 :   long ly = lgefint(y);
    1989    59732190 :   if (ly == 2) return x;
    1990    37865191 :   av = avma;
    1991    37865191 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1992    37869125 :   y = mului(u,y);
    1993    37868940 :   set_avma(av); return subii(x, y);
    1994             : }
    1995             : /* x + u*y */
    1996             : INLINE GEN
    1997    59178150 : addmuliu_inplace(GEN x, GEN y, ulong u)
    1998             : {
    1999             :   pari_sp av;
    2000    59178150 :   long ly = lgefint(y);
    2001    59178150 :   if (ly == 2) return x;
    2002    37772793 :   av = avma;
    2003    37772793 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    2004    37776665 :   y = mului(u,y);
    2005    37776434 :   set_avma(av); return addii(x, y);
    2006             : }
    2007             : /* ux + vy */
    2008             : INLINE GEN
    2009    37686023 : lincombii(GEN u, GEN v, GEN x, GEN y)
    2010             : {
    2011    37686023 :   long lx = lgefint(x), ly;
    2012             :   GEN p1, p2;
    2013             :   pari_sp av;
    2014    37686023 :   if (lx == 2) return mulii(v,y);
    2015    23722196 :   ly = lgefint(y);
    2016    23722196 :   if (ly == 2) return mulii(u,x);
    2017    21053600 :   av = avma; (void)new_chunk(lx+ly+lgefint(u)+lgefint(v)); /* HACK */
    2018    21056554 :   p1 = mulii(u,x);
    2019    21055442 :   p2 = mulii(v,y);
    2020    21055226 :   set_avma(av); return addii(p1,p2);
    2021             : }
    2022             : 
    2023             : /*******************************************************************/
    2024             : /*                                                                 */
    2025             : /*                          GEN SUBTYPES                           */
    2026             : /*                                                                 */
    2027             : /*******************************************************************/
    2028             : 
    2029             : INLINE int
    2030  4751422013 : is_const_t(long t) { return (t < t_POLMOD); }
    2031             : INLINE int
    2032        6946 : is_extscalar_t(long t) { return (t <= t_POL); }
    2033             : INLINE int
    2034     9579869 : is_intreal_t(long t) { return (t <= t_REAL); }
    2035             : INLINE int
    2036   603528776 : is_matvec_t(long t) { return (t >= t_VEC && t <= t_MAT); }
    2037             : INLINE int
    2038    93662981 : is_noncalc_t(long tx) { return (tx) >= t_LIST; }
    2039             : INLINE int
    2040           0 : is_qfb_t(long t) { return (t == t_QFB); }
    2041             : INLINE int
    2042     5127007 : is_rational_t(long t) { return (t == t_INT || t == t_FRAC); }
    2043             : INLINE int
    2044    62552929 : is_real_t(long t) { return (t == t_INT || t == t_REAL || t == t_FRAC); }
    2045             : INLINE int
    2046  8425054155 : is_recursive_t(long t) { return lontyp[t]; }
    2047             : INLINE int
    2048   314465041 : is_scalar_t(long t) { return (t < t_POL); }
    2049             : INLINE int
    2050    43372540 : is_vec_t(long t) { return (t == t_VEC || t == t_COL); }
    2051             : 
    2052             : INLINE int
    2053    68060239 : qfb_is_qfi(GEN q) { return signe(gel(q,4)) < 0; }
    2054             : 
    2055             : /*******************************************************************/
    2056             : /*                                                                 */
    2057             : /*                         TRANSCENDENTAL                          */
    2058             : /*                                                                 */
    2059             : /*******************************************************************/
    2060             : INLINE GEN
    2061    79825784 : sqrtr(GEN x) {
    2062    79825784 :   long s = signe(x);
    2063    79825784 :   if (s == 0) return real_0_bit(expo(x) >> 1);
    2064    79792676 :   if (s >= 0) return sqrtr_abs(x);
    2065      432772 :   retmkcomplex(gen_0, sqrtr_abs(x));
    2066             : }
    2067             : INLINE GEN
    2068           0 : cbrtr_abs(GEN x) { return sqrtnr_abs(x, 3); }
    2069             : INLINE GEN
    2070           0 : cbrtr(GEN x) {
    2071           0 :   long s = signe(x);
    2072             :   GEN r;
    2073           0 :   if (s == 0) return real_0_bit(expo(x) / 3);
    2074           0 :   r = cbrtr_abs(x);
    2075           0 :   if (s < 0) togglesign(r);
    2076           0 :   return r;
    2077             : }
    2078             : INLINE GEN
    2079     2791983 : sqrtnr(GEN x, long n) {
    2080     2791983 :   long s = signe(x);
    2081             :   GEN r;
    2082     2791983 :   if (s == 0) return real_0_bit(expo(x) / n);
    2083     2791983 :   r = sqrtnr_abs(x, n);
    2084     2791993 :   if (s < 0) pari_err_IMPL("sqrtnr for x < 0");
    2085     2791993 :   return r;
    2086             : }
    2087             : INLINE long
    2088      751937 : logint(GEN B, GEN y) { return logintall(B,y,NULL); }
    2089             : INLINE ulong
    2090     1726671 : ulogint(ulong B, ulong y)
    2091             : {
    2092             :   ulong r;
    2093             :   long e;
    2094     1726671 :   if (y == 2) return expu(B);
    2095     1678685 :   r = y;
    2096     5075118 :   for (e=1;; e++)
    2097             :   { /* here, r = y^e, r2 = y^(e-1) */
    2098     5075118 :     if (r >= B) return r == B? e: e-1;
    2099     3397952 :     r = umuluu_or_0(y, r);
    2100     3397966 :     if (!r) return e;
    2101             :   }
    2102             : }
    2103             : 
    2104             : /*******************************************************************/
    2105             : /*                                                                 */
    2106             : /*                         MISCELLANEOUS                           */
    2107             : /*                                                                 */
    2108             : /*******************************************************************/
    2109     9579758 : INLINE int ismpzero(GEN x) { return is_intreal_t(typ(x)) && !signe(x); }
    2110  2812679011 : INLINE int isintzero(GEN x) { return typ(x) == t_INT && !signe(x); }
    2111    17290044 : INLINE int isint1(GEN x) { return typ(x)==t_INT && equali1(x); }
    2112     5954045 : INLINE int isintm1(GEN x){ return typ(x)==t_INT && equalim1(x);}
    2113  1218477529 : INLINE int equali1(GEN n)
    2114  1218477529 : { return (ulong) n[1] == (evallgefint(3UL) | evalsigne(1)) && n[2] == 1; }
    2115   139002908 : INLINE int equalim1(GEN n)
    2116   139002908 : { return (ulong) n[1] == (evallgefint(3UL) | evalsigne(-1)) && n[2] == 1; }
    2117             : /* works only for POSITIVE integers */
    2118  2185282560 : INLINE int is_pm1(GEN n)
    2119  2185282560 : { return lgefint(n) == 3 && n[2] == 1; }
    2120   556645219 : INLINE int is_bigint(GEN n)
    2121   556645219 : { long l = lgefint(n); return l > 3 || (l == 3 && (n[2] & HIGHBIT)); }
    2122             : 
    2123  2028986315 : INLINE int odd(long x) { return x & 1; }
    2124   116543393 : INLINE int both_odd(long x, long y) { return x & y & 1; }
    2125             : 
    2126             : INLINE int
    2127  7909203534 : isonstack(GEN x)
    2128  7909203534 : { return ((pari_sp)x >= pari_mainstack->bot
    2129  7909203534 :        && (pari_sp)x <  pari_mainstack->top); }
    2130             : 
    2131             : /* assume x != 0 and x t_REAL, return an approximation to log2(|x|) */
    2132             : INLINE double
    2133    92793367 : dbllog2r(GEN x)
    2134    92793367 : { return log2((double)(ulong)x[2]) + (double)(expo(x) - (BITS_IN_LONG-1)); }
    2135             : 
    2136             : INLINE GEN
    2137     2508992 : mul_content(GEN cx, GEN cy)
    2138             : {
    2139     2508992 :   if (!cx) return cy;
    2140      526610 :   if (!cy) return cx;
    2141      338897 :   return gmul(cx,cy);
    2142             : }
    2143             : INLINE GEN
    2144           0 : inv_content(GEN c) { return c? ginv(c): NULL; }
    2145             : INLINE GEN
    2146       57571 : div_content(GEN cx, GEN cy)
    2147             : {
    2148       57571 :   if (!cy) return cx;
    2149       56451 :   if (!cx) return ginv(cy);
    2150       25653 :   return gdiv(cx,cy);
    2151             : }
    2152             : INLINE GEN
    2153    11277324 : mul_denom(GEN dx, GEN dy)
    2154             : {
    2155    11277324 :   if (!dx) return dy;
    2156     2570787 :   if (!dy) return dx;
    2157     1549386 :   return mulii(dx,dy);
    2158             : }
    2159             : 
    2160             : /* POLYNOMIALS */
    2161             : INLINE GEN
    2162     1435439 : constant_coeff(GEN x) { return signe(x)? gel(x,2): gen_0; }
    2163             : INLINE GEN
    2164   169441733 : leading_coeff(GEN x) { return lg(x) == 2? gen_0: gel(x,lg(x)-1); }
    2165             : INLINE ulong
    2166      968466 : Flx_lead(GEN x) { return lg(x) == 2? 0: x[lg(x)-1]; }
    2167             : INLINE ulong
    2168      294711 : Flx_constant(GEN x) { return lg(x) == 2? 0: x[2]; }
    2169             : INLINE long
    2170  5371555567 : degpol(GEN x) { return lg(x)-3; }
    2171             : INLINE long
    2172  2553466066 : lgpol(GEN x) { return lg(x)-2; }
    2173             : INLINE long
    2174   340361232 : lgcols(GEN x) { return lg(gel(x,1)); }
    2175             : INLINE long
    2176   154387113 : nbrows(GEN x) { return lg(gel(x,1))-1; }
    2177             : INLINE GEN
    2178           0 : truecoef(GEN x, long n) { return polcoef(x,n,-1); }
    2179             : 
    2180             : INLINE GEN
    2181     2124801 : ZXQ_mul(GEN y, GEN x, GEN T) { return ZX_rem(ZX_mul(y, x), T); }
    2182             : INLINE GEN
    2183      949847 : ZXQ_sqr(GEN x, GEN T) { return ZX_rem(ZX_sqr(x), T); }
    2184             : 
    2185             : INLINE GEN
    2186   103379528 : RgX_copy(GEN x)
    2187   376669156 : { pari_APPLY_pol_normalized(gcopy(gel(x,i))); }
    2188             : /* have to use ulong to avoid silly warnings from gcc "assuming signed
    2189             :  * overflow does not occur" */
    2190             : INLINE GEN
    2191     2544022 : RgX_coeff(GEN x, long n)
    2192             : {
    2193     2544022 :   ulong l = lg(x);
    2194     2544022 :   return (n < 0 || ((ulong)n+3) > l)? gen_0: gel(x,n+2);
    2195             : }
    2196             : INLINE GEN
    2197      347497 : RgX_renormalize(GEN x) { return RgX_renormalize_lg(x, lg(x)); }
    2198             : INLINE GEN
    2199     7051300 : RgX_div(GEN x, GEN y) { return RgX_divrem(x,y,NULL); }
    2200             : INLINE GEN
    2201        1904 : RgXQX_div(GEN x, GEN y, GEN T) { return RgXQX_divrem(x,y,T,NULL); }
    2202             : INLINE GEN
    2203      114083 : RgXQX_rem(GEN x, GEN y, GEN T) { return RgXQX_divrem(x,y,T,ONLY_REM); }
    2204             : INLINE GEN
    2205     5427165 : FpX_div(GEN x, GEN y, GEN p) { return FpX_divrem(x,y,p, NULL); }
    2206             : INLINE GEN
    2207     1989313 : Flx_div(GEN x, GEN y, ulong p) { return Flx_divrem(x,y,p, NULL); }
    2208             : INLINE GEN
    2209    21359844 : Flx_div_pre(GEN x, GEN y, ulong p, ulong pi)
    2210    21359844 : { return Flx_divrem_pre(x,y,p,pi, NULL); }
    2211             : INLINE GEN
    2212     1568272 : F2x_div(GEN x, GEN y) { return F2x_divrem(x,y, NULL); }
    2213             : INLINE GEN
    2214           0 : FpV_FpC_mul(GEN x, GEN y, GEN p) { return FpV_dotproduct(x,y,p); }
    2215             : INLINE GEN
    2216   102090796 : pol0_Flx(long sv) { return mkvecsmall(sv); }
    2217             : INLINE GEN
    2218    54800433 : pol1_Flx(long sv) { return mkvecsmall2(sv, 1); }
    2219             : INLINE GEN
    2220    37603654 : polx_Flx(long sv) { return mkvecsmall3(sv, 0, 1); }
    2221             : INLINE GEN
    2222           0 : zero_zx(long sv) { return zero_Flx(sv); }
    2223             : INLINE GEN
    2224           0 : polx_zx(long sv) { return polx_Flx(sv); }
    2225             : INLINE GEN
    2226           0 : zx_shift(GEN x, long n) { return Flx_shift(x,n); }
    2227             : INLINE GEN
    2228       14049 : zx_renormalize(GEN x, long l) { return Flx_renormalize(x,l); }
    2229             : INLINE GEN
    2230        1350 : zero_F2x(long sv) { return zero_Flx(sv); }
    2231             : INLINE GEN
    2232    13269139 : pol0_F2x(long sv) { return pol0_Flx(sv); }
    2233             : INLINE GEN
    2234     3952604 : pol1_F2x(long sv) { return pol1_Flx(sv); }
    2235             : INLINE GEN
    2236     1075964 : polx_F2x(long sv) { return mkvecsmall2(sv, 2); }
    2237             : INLINE int
    2238     2872172 : F2x_equal1(GEN x) { return Flx_equal1(x); }
    2239             : INLINE int
    2240     4690716 : F2x_equal(GEN V, GEN W) { return Flx_equal(V,W); }
    2241             : INLINE GEN
    2242    60652578 : F2x_copy(GEN x) { return leafcopy(x); }
    2243             : INLINE GEN
    2244        4487 : F2v_copy(GEN x) { return leafcopy(x); }
    2245             : INLINE GEN
    2246     2505305 : Flv_copy(GEN x) { return leafcopy(x); }
    2247             : INLINE GEN
    2248   172271770 : Flx_copy(GEN x) { return leafcopy(x); }
    2249             : INLINE GEN
    2250     4293270 : vecsmall_copy(GEN x) { return leafcopy(x); }
    2251             : INLINE int
    2252     8581544 : Flx_equal1(GEN x) { return degpol(x)==0 && x[2] == 1; }
    2253             : INLINE int
    2254       12080 : ZX_equal1(GEN x) { return degpol(x)==0 && equali1(gel(x,2)); }
    2255             : INLINE int
    2256     7180525 : ZX_is_monic(GEN x) { return equali1(leading_coeff(x)); }
    2257             : 
    2258             : INLINE GEN
    2259   152326870 : ZX_renormalize(GEN x, long lx)    { return ZXX_renormalize(x,lx); }
    2260             : INLINE GEN
    2261   142407732 : FpX_renormalize(GEN x, long lx)   { return ZXX_renormalize(x,lx); }
    2262             : INLINE GEN
    2263      850077 : FpXX_renormalize(GEN x, long lx)  { return ZXX_renormalize(x,lx); }
    2264             : INLINE GEN
    2265     4698170 : FpXQX_renormalize(GEN x, long lx) { return ZXX_renormalize(x,lx); }
    2266             : INLINE GEN
    2267   115529382 : F2x_renormalize(GEN x, long lx)   { return Flx_renormalize(x,lx); }
    2268             : 
    2269             : INLINE GEN
    2270           0 : F2xX_shift(GEN a, long n, long vs) { return FlxX_shift(a, n, vs); }
    2271             : 
    2272             : INLINE GEN
    2273       38185 : F2v_to_F2x(GEN x, long sv) {
    2274       38185 :   GEN y = leafcopy(x);
    2275       38184 :   y[1] = sv; F2x_renormalize(y, lg(y)); return y;
    2276             : }
    2277             : 
    2278             : INLINE long
    2279         385 : sturm(GEN x) { return sturmpart(x, NULL, NULL); }
    2280             : 
    2281             : INLINE long
    2282        5796 : gval(GEN x, long v)
    2283        5796 : { pari_sp av = avma; return gc_long(av, gvaluation(x, pol_x(v))); }
    2284             : 
    2285             : INLINE void
    2286      480553 : RgX_shift_inplace_init(long v)
    2287      480553 : { if (v) (void)cgetg(v, t_VECSMALL); }
    2288             : /* shift polynomial in place. assume v free cells have been left before x */
    2289             : INLINE GEN
    2290      480553 : RgX_shift_inplace(GEN x, long v)
    2291             : {
    2292             :   long i, lx;
    2293             :   GEN z;
    2294      480553 :   if (!v) return x;
    2295      253169 :   lx = lg(x);
    2296      253169 :   if (lx == 2) return x;
    2297      253169 :   z = x + lx;
    2298             :   /* stackdummy's from normalizepol */
    2299      253169 :   while (lg(z) != v) z += lg(z);
    2300      253169 :   z += v;
    2301     4654514 :   for (i = lx-1; i >= 2; i--) gel(--z,0) = gel(x,i);
    2302      675895 :   for (i = 0;  i < v; i++) gel(--z,0) = gen_0;
    2303      253169 :   z -= 2;
    2304      253169 :   z[1] = x[1];
    2305      253169 :   z[0] = evaltyp(t_POL) | evallg(lx+v);
    2306      253169 :   stackdummy((pari_sp)z, (pari_sp)x); return z;
    2307             : }
    2308             : 
    2309             : 
    2310             : /* LINEAR ALGEBRA */
    2311             : INLINE GEN
    2312      501498 : zv_to_ZV(GEN x) { return vecsmall_to_vec(x); }
    2313             : INLINE GEN
    2314     7746604 : zc_to_ZC(GEN x) { return vecsmall_to_col(x); }
    2315             : INLINE GEN
    2316     3190421 : ZV_to_zv(GEN x) { return vec_to_vecsmall(x); }
    2317             : INLINE GEN
    2318           0 : zx_to_zv(GEN x, long N) { return Flx_to_Flv(x,N); }
    2319             : INLINE GEN
    2320      104146 : zv_to_zx(GEN x, long sv) { return Flv_to_Flx(x,sv); }
    2321             : INLINE GEN
    2322           0 : zm_to_zxV(GEN x, long sv) { return Flm_to_FlxV(x,sv); }
    2323             : INLINE GEN
    2324           0 : zero_zm(long x, long y) { return zero_Flm(x,y); }
    2325             : INLINE GEN
    2326    36080193 : zero_zv(long x) { return zero_Flv(x); }
    2327             : INLINE GEN
    2328         266 : zm_transpose(GEN x) { return Flm_transpose(x); }
    2329             : INLINE GEN
    2330           0 : zm_copy(GEN x) { return Flm_copy(x); }
    2331             : INLINE GEN
    2332     2183302 : zv_copy(GEN x) { return Flv_copy(x); }
    2333             : INLINE GEN
    2334           0 : zm_row(GEN x, long i) { return Flm_row(x,i); }
    2335             : 
    2336             : INLINE GEN
    2337    10675901 : ZC_hnfrem(GEN x, GEN y) { return ZC_hnfdivrem(x,y,NULL); }
    2338             : INLINE GEN
    2339      326809 : ZM_hnfrem(GEN x, GEN y) { return ZM_hnfdivrem(x,y,NULL); }
    2340             : INLINE GEN
    2341     6933683 : ZM_lll(GEN x, double D, long f) { return ZM_lll_norms(x,D,f,NULL); }
    2342             : INLINE void
    2343     9406532 : RgM_dimensions(GEN x, long *m, long *n) { *n = lg(x)-1; *m = *n? nbrows(x): 0; }
    2344             : INLINE GEN
    2345    21103235 : RgM_shallowcopy(GEN x)
    2346    92407173 : { pari_APPLY_same(leafcopy(gel(x,i))); }
    2347             : INLINE GEN
    2348      197828 : F2m_copy(GEN x) { return RgM_shallowcopy(x); }
    2349             : 
    2350             : INLINE GEN
    2351           0 : F3m_copy(GEN x) { return RgM_shallowcopy(x); }
    2352             : 
    2353             : INLINE GEN
    2354     6245112 : Flm_copy(GEN x) { return RgM_shallowcopy(x); }
    2355             : 
    2356             : /* divisibility: return 1 if y[i] | x[i] for all i, 0 otherwise. Assume
    2357             :  * x,y are ZV of the same length */
    2358             : INLINE int
    2359       23485 : ZV_dvd(GEN x, GEN y)
    2360             : {
    2361       23485 :   long i, l = lg(x);
    2362       37856 :   for (i=1; i < l; i++)
    2363       30464 :     if ( ! dvdii( gel(x,i), gel(y,i) ) ) return 0;
    2364        7392 :   return 1;
    2365             : }
    2366             : INLINE GEN
    2367      539086 : ZM_ZV_mod(GEN x, GEN y)
    2368     1537833 : { pari_APPLY_same(ZV_ZV_mod(gel(x,i), y)) }
    2369             : INLINE GEN
    2370     7322829 : ZV_ZV_mod(GEN x, GEN y)
    2371    18920849 : { pari_APPLY_same(modii(gel(x,i), gel(y,i))) }
    2372             : INLINE GEN
    2373           0 : vecmodii(GEN x, GEN y) { return ZV_ZV_mod(x,y); }
    2374             : INLINE GEN
    2375      174881 : vecmoduu(GEN x, GEN y) { pari_APPLY_ulong(((ulong*)x)[i] % ((ulong*)y)[i]) }
    2376             : 
    2377             : /* Fq */
    2378             : INLINE GEN
    2379     3476647 : Fq_red(GEN x, GEN T, GEN p)
    2380     3476647 : { return typ(x)==t_INT? Fp_red(x,p): FpXQ_red(x,T,p); }
    2381             : INLINE GEN
    2382      110255 : Fq_to_FpXQ(GEN x, GEN T, GEN p /*unused*/)
    2383             : {
    2384             :   (void) p;
    2385      110255 :   return typ(x)==t_INT ? scalarpol(x, get_FpX_var(T)): x;
    2386             : }
    2387             : INLINE GEN
    2388         756 : Rg_to_Fq(GEN x, GEN T, GEN p) { return T? Rg_to_FpXQ(x,T,p): Rg_to_Fp(x,p); }
    2389             : 
    2390             : INLINE GEN
    2391       14601 : gener_Fq_local(GEN T, GEN p, GEN L)
    2392           0 : { return T? gener_FpXQ_local(T,p, L)
    2393       14601 :           : pgener_Fp_local(p, L); }
    2394             : 
    2395             : INLINE GEN
    2396           0 : random_Fq(GEN T, GEN p)
    2397           0 : { return T ? random_FpX(get_FpX_degree(T), get_FpX_var(T), p): randomi(p); }
    2398             : 
    2399             : /* FpXQX */
    2400             : INLINE GEN
    2401        4525 : FpXQX_div(GEN x, GEN y, GEN T, GEN p) { return FpXQX_divrem(x, y, T, p, NULL); }
    2402             : INLINE GEN
    2403           0 : FlxqX_div(GEN x, GEN y, GEN T, ulong p) { return FlxqX_divrem(x, y, T, p, NULL); }
    2404             : INLINE GEN
    2405      165453 : FlxqX_div_pre(GEN x, GEN y, GEN T, ulong p, ulong pi) { return FlxqX_divrem_pre(x, y, T, p, pi, NULL); }
    2406             : INLINE GEN
    2407       33243 : F2xqX_div(GEN x, GEN y, GEN T) { return F2xqX_divrem(x, y, T, NULL); }
    2408             : 
    2409             : INLINE GEN
    2410       20587 : FpXY_Fq_evaly(GEN Q, GEN y, GEN T, GEN p, long vx)
    2411       20587 : { return T ? FpXY_FpXQ_evaly(Q, y, T, p, vx): FpXY_evaly(Q, y, p, vx); }
    2412             : 
    2413             : /* FqX */
    2414             : INLINE GEN
    2415       25354 : FqX_red(GEN z, GEN T, GEN p) { return T? FpXQX_red(z, T, p): FpX_red(z, p); }
    2416             : INLINE GEN
    2417      127694 : FqX_add(GEN x,GEN y,GEN T,GEN p) { return T? FpXX_add(x,y,p): FpX_add(x,y,p); }
    2418             : INLINE GEN
    2419       24956 : FqX_neg(GEN x,GEN T,GEN p) { return T? FpXX_neg(x,p): FpX_neg(x,p); }
    2420             : INLINE GEN
    2421       68607 : FqX_sub(GEN x,GEN y,GEN T,GEN p) { return T? FpXX_sub(x,y,p): FpX_sub(x,y,p); }
    2422             : INLINE GEN
    2423      568082 : FqX_Fp_mul(GEN P, GEN u, GEN T, GEN p)
    2424      568082 : { return T? FpXX_Fp_mul(P, u, p): FpX_Fp_mul(P, u, p); }
    2425             : INLINE GEN
    2426      427376 : FqX_Fq_mul(GEN P, GEN U, GEN T, GEN p)
    2427      427376 : { return typ(U)==t_INT ? FqX_Fp_mul(P, U, T, p): FpXQX_FpXQ_mul(P, U, T, p); }
    2428             : INLINE GEN
    2429      368601 : FqX_mul(GEN x, GEN y, GEN T, GEN p)
    2430      368601 : { return T? FpXQX_mul(x, y, T, p): FpX_mul(x, y, p); }
    2431             : INLINE GEN
    2432       21942 : FqX_mulu(GEN x, ulong y, GEN T, GEN p)
    2433       21942 : { return T? FpXX_mulu(x, y, p): FpX_mulu(x, y, p); }
    2434             : INLINE GEN
    2435       71855 : FqX_sqr(GEN x, GEN T, GEN p)
    2436       71855 : { return T? FpXQX_sqr(x, T, p): FpX_sqr(x, p); }
    2437             : INLINE GEN
    2438        1295 : FqX_powu(GEN x, ulong n, GEN T, GEN p)
    2439        1295 : { return T? FpXQX_powu(x, n, T, p): FpX_powu(x, n, p); }
    2440             : INLINE GEN
    2441       19411 : FqX_halve(GEN x, GEN T, GEN p)
    2442       19411 : { return T? FpXX_halve(x, p): FpX_halve(x, p); }
    2443             : INLINE GEN
    2444       40283 : FqX_div(GEN x, GEN y, GEN T, GEN p)
    2445       40283 : { return T? FpXQX_divrem(x,y,T,p,NULL): FpX_divrem(x,y,p,NULL); }
    2446             : INLINE GEN
    2447        6090 : FqX_get_red(GEN S, GEN T, GEN p)
    2448        6090 : { return T? FpXQX_get_red(S,T,p): FpX_get_red(S,p); }
    2449             : INLINE GEN
    2450       37743 : FqX_rem(GEN x, GEN y, GEN T, GEN p)
    2451       37743 : { return T? FpXQX_rem(x,y,T,p): FpX_rem(x,y,p); }
    2452             : INLINE GEN
    2453           0 : FqX_divrem(GEN x, GEN y, GEN T, GEN p, GEN *z)
    2454           0 : { return T? FpXQX_divrem(x,y,T,p,z): FpX_divrem(x,y,p,z); }
    2455             : INLINE GEN
    2456       71939 : FqX_div_by_X_x(GEN x, GEN y, GEN T, GEN p, GEN *z)
    2457       71939 : { return T? FpXQX_div_by_X_x(x,y,T,p,z): FpX_div_by_X_x(x,y,p,z); }
    2458             : INLINE GEN
    2459           0 : FqX_halfgcd(GEN P,GEN Q,GEN T,GEN p)
    2460           0 : {return T? FpXQX_halfgcd(P,Q,T,p): FpX_halfgcd(P,Q,p);}
    2461             : INLINE GEN
    2462      693364 : FqX_gcd(GEN P,GEN Q,GEN T,GEN p)
    2463      693364 : {return T? FpXQX_gcd(P,Q,T,p): FpX_gcd(P,Q,p);}
    2464             : INLINE GEN
    2465      442903 : FqX_extgcd(GEN P,GEN Q,GEN T,GEN p, GEN *U, GEN *V)
    2466      442903 : { return T? FpXQX_extgcd(P,Q,T,p,U,V): FpX_extgcd(P,Q,p,U,V); }
    2467             : INLINE GEN
    2468        4872 : FqX_normalize(GEN z, GEN T, GEN p)
    2469        4872 : { return T? FpXQX_normalize(z, T, p): FpX_normalize(z, p); }
    2470             : INLINE GEN
    2471      723681 : FqX_deriv(GEN f, GEN T, GEN p) { return T? FpXX_deriv(f, p): FpX_deriv(f, p); }
    2472             : INLINE GEN
    2473           0 : FqX_integ(GEN f, GEN T, GEN p) { return T? FpXX_integ(f, p): FpX_integ(f, p); }
    2474             : INLINE GEN
    2475      141723 : FqX_factor(GEN f, GEN T, GEN p)
    2476      141723 : { return T?FpXQX_factor(f, T, p): FpX_factor(f, p); }
    2477             : INLINE GEN
    2478           7 : FqX_factor_squarefree(GEN f, GEN T, GEN p)
    2479           7 : { return T ? FpXQX_factor_squarefree(f, T, p): FpX_factor_squarefree(f, p); }
    2480             : INLINE GEN
    2481           7 : FqX_ddf(GEN f, GEN T, GEN p)
    2482           7 : { return T ? FpXQX_ddf(f, T, p): FpX_ddf(f, p); }
    2483             : INLINE GEN
    2484       47786 : FqX_degfact(GEN f, GEN T, GEN p)
    2485       47786 : { return T?FpXQX_degfact(f, T, p): FpX_degfact(f, p); }
    2486             : INLINE GEN
    2487        7273 : FqX_roots(GEN f, GEN T, GEN p)
    2488        7273 : { return T?FpXQX_roots(f, T, p): FpX_roots(f, p); }
    2489             : INLINE GEN
    2490         175 : FqX_to_mod(GEN f, GEN T, GEN p)
    2491         175 : { return T?FpXQX_to_mod(f, T, p): FpX_to_mod(f, p); }
    2492             : 
    2493             : /*FqXQ*/
    2494             : INLINE GEN
    2495           0 : FqXQ_add(GEN x, GEN y, GEN S/*unused*/, GEN T, GEN p)
    2496           0 : { (void)S; return T? FpXX_add(x,y,p): FpX_add(x,y,p); }
    2497             : INLINE GEN
    2498           0 : FqXQ_sub(GEN x, GEN y, GEN S/*unused*/, GEN T, GEN p)
    2499           0 : { (void)S; return T? FpXX_sub(x,y,p): FpX_sub(x,y,p); }
    2500             : INLINE GEN
    2501           0 : FqXQ_div(GEN x, GEN y, GEN S, GEN T, GEN p)
    2502           0 : { return T? FpXQXQ_div(x,y,S,T,p): FpXQ_div(x,y,S,p); }
    2503             : INLINE GEN
    2504           0 : FqXQ_inv(GEN x, GEN S, GEN T, GEN p)
    2505           0 : { return T? FpXQXQ_inv(x,S,T,p): FpXQ_inv(x,S,p); }
    2506             : INLINE GEN
    2507           0 : FqXQ_invsafe(GEN x, GEN S, GEN T, GEN p)
    2508           0 : { return T? FpXQXQ_invsafe(x,S,T,p): FpXQ_inv(x,S,p); }
    2509             : INLINE GEN
    2510       22766 : FqXQ_mul(GEN x, GEN y, GEN S, GEN T, GEN p)
    2511       22766 : { return T? FpXQXQ_mul(x,y,S,T,p): FpXQ_mul(x,y,S,p); }
    2512             : INLINE GEN
    2513           0 : FqXQ_sqr(GEN x, GEN S, GEN T, GEN p)
    2514           0 : { return T? FpXQXQ_sqr(x,S,T,p): FpXQ_sqr(x,S,p); }
    2515             : INLINE GEN
    2516           0 : FqXQ_pow(GEN x, GEN n, GEN S, GEN T, GEN p)
    2517           0 : { return T? FpXQXQ_pow(x,n,S,T,p): FpXQ_pow(x,n,S,p); }
    2518             : 
    2519             : /*FqXn*/
    2520             : INLINE GEN
    2521        6590 : FqXn_expint(GEN x, long n, GEN T, GEN p)
    2522        6590 : { return T? FpXQXn_expint(x,n,T,p): FpXn_expint(x,n,p); }
    2523             : INLINE GEN
    2524           0 : FqXn_exp(GEN x, long n, GEN T, GEN p)
    2525           0 : { return T? FpXQXn_exp(x,n,T,p): FpXn_exp(x,n,p); }
    2526             : INLINE GEN
    2527        7126 : FqXn_inv(GEN x, long n, GEN T, GEN p)
    2528        7126 : { return T? FpXQXn_inv(x,n,T,p): FpXn_inv(x,n,p); }
    2529             : INLINE GEN
    2530      263403 : FqXn_mul(GEN x, GEN y, long n, GEN T, GEN p)
    2531      263403 : { return T? FpXQXn_mul(x, y, n, T, p): FpXn_mul(x, y, n, p); }
    2532             : INLINE GEN
    2533           0 : FqXn_sqr(GEN x, long n, GEN T, GEN p)
    2534           0 : { return T? FpXQXn_sqr(x,n,T,p): FpXn_sqr(x,n,p); }
    2535             : 
    2536             : /*FpXQ*/
    2537             : INLINE GEN
    2538           0 : FpXQ_add(GEN x,GEN y,GEN T/*unused*/,GEN p)
    2539           0 : { (void)T; return FpX_add(x,y,p); }
    2540             : INLINE GEN
    2541           0 : FpXQ_sub(GEN x,GEN y,GEN T/*unused*/,GEN p)
    2542           0 : { (void)T; return FpX_sub(x,y,p); }
    2543             : 
    2544             : /*Flxq*/
    2545             : INLINE GEN
    2546           0 : Flxq_add(GEN x,GEN y,GEN T/*unused*/,ulong p)
    2547           0 : { (void)T; return Flx_add(x,y,p); }
    2548             : INLINE GEN
    2549           0 : Flxq_sub(GEN x,GEN y,GEN T/*unused*/,ulong p)
    2550           0 : { (void)T; return Flx_sub(x,y,p); }
    2551             : 
    2552             : /* F2x */
    2553             : 
    2554             : INLINE ulong
    2555   666935695 : F2x_coeff(GEN x,long v)
    2556             : {
    2557   666935695 :    ulong u=(ulong)x[2+divsBIL(v)];
    2558   666935565 :    return (u>>remsBIL(v))&1UL;
    2559             : }
    2560             : 
    2561             : INLINE void
    2562    12143069 : F2x_clear(GEN x,long v)
    2563             : {
    2564    12143069 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2565    12143011 :    *u&=~(1UL<<remsBIL(v));
    2566    12142994 : }
    2567             : 
    2568             : INLINE void
    2569   124770438 : F2x_set(GEN x,long v)
    2570             : {
    2571   124770438 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2572   124766237 :    *u|=1UL<<remsBIL(v);
    2573   124765565 : }
    2574             : 
    2575             : INLINE void
    2576     1554457 : F2x_flip(GEN x,long v)
    2577             : {
    2578     1554457 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2579     1554457 :    *u^=1UL<<remsBIL(v);
    2580     1554457 : }
    2581             : 
    2582             : /* F2v */
    2583             : 
    2584             : INLINE ulong
    2585   660358862 : F2v_coeff(GEN x,long v) { return F2x_coeff(x,v-1); }
    2586             : 
    2587             : INLINE void
    2588    12143065 : F2v_clear(GEN x,long v) { F2x_clear(x,v-1); }
    2589             : 
    2590             : INLINE void
    2591   101378241 : F2v_set(GEN x,long v)   { F2x_set(x,v-1); }
    2592             : 
    2593             : INLINE void
    2594     1554457 : F2v_flip(GEN x,long v) { F2x_flip(x,v-1); }
    2595             : 
    2596             : /* F2m */
    2597             : 
    2598             : INLINE ulong
    2599     8073360 : F2m_coeff(GEN x, long a, long b) { return F2v_coeff(gel(x,b), a); }
    2600             : 
    2601             : INLINE void
    2602           0 : F2m_clear(GEN x, long a, long b) { F2v_clear(gel(x,b), a); }
    2603             : 
    2604             : INLINE void
    2605         798 : F2m_set(GEN x, long a, long b) { F2v_set(gel(x,b), a); }
    2606             : 
    2607             : INLINE void
    2608     1554457 : F2m_flip(GEN x, long a, long b) { F2v_flip(gel(x,b), a); }
    2609             : 
    2610             : /* F3m */
    2611             : 
    2612             : INLINE ulong
    2613     3206656 : F3m_coeff(GEN x, long a, long b) { return F3v_coeff(gel(x,b), a); }
    2614             : 
    2615             : INLINE void
    2616           0 : F3m_set(GEN x, long a, long b, ulong c) { F3v_set(gel(x,b), a, c); }
    2617             : 
    2618             : /* ARITHMETIC */
    2619             : INLINE GEN
    2620        3885 : matpascal(long n) { return matqpascal(n, NULL); }
    2621             : INLINE long
    2622      458558 : Z_issquare(GEN x) { return Z_issquareall(x, NULL); }
    2623             : INLINE long
    2624          98 : Z_ispower(GEN x, ulong k) { return Z_ispowerall(x, k, NULL); }
    2625             : INLINE GEN
    2626     6589883 : sqrti(GEN x) { return sqrtremi(x,NULL); }
    2627             : INLINE GEN
    2628   123137211 : gaddgs(GEN y, long s) { return gaddsg(s,y); }
    2629             : INLINE int
    2630      780380 : gcmpgs(GEN y, long s) { return -gcmpsg(s,y); }
    2631             : INLINE int
    2632       29176 : gequalgs(GEN y, long s) { return gequalsg(s,y); }
    2633             : INLINE GEN
    2634           0 : gmaxsg(long s, GEN y) { return gmaxgs(y,s); }
    2635             : INLINE GEN
    2636           0 : gminsg(long s, GEN y) { return gmings(y,s); }
    2637             : INLINE GEN
    2638    22014867 : gmulgs(GEN y, long s) { return gmulsg(s,y); }
    2639             : INLINE GEN
    2640   124173007 : gmulgu(GEN y, ulong s) { return gmulug(s,y); }
    2641             : INLINE GEN
    2642     1691647 : gsubgs(GEN y, long s) { return gaddgs(y, -s); }
    2643             : INLINE GEN
    2644      528210 : gdivsg(long s, GEN y) { return gdiv(stoi(s), y); }
    2645             : 
    2646             : INLINE GEN
    2647    13509935 : gmax_shallow(GEN x, GEN y) { return gcmp(x,y)<0? y: x; }
    2648             : INLINE GEN
    2649      868577 : gmin_shallow(GEN x, GEN y) { return gcmp(x,y)<0? x: y; }
    2650             : 
    2651             : /* x t_COMPLEX */
    2652             : INLINE GEN
    2653    90669546 : cxnorm(GEN x) { return gadd(gsqr(gel(x,1)), gsqr(gel(x,2))); }
    2654             : /* q t_QUAD */
    2655             : INLINE GEN
    2656       69860 : quadnorm(GEN q)
    2657             : {
    2658       69860 :   GEN X = gel(q,1), b = gel(X,3), c = gel(X,2);
    2659       69860 :   GEN z, u = gel(q,3), v = gel(q,2);
    2660       69860 :   if (typ(u) == t_INT && typ(v) == t_INT) /* generic case */
    2661             :   {
    2662       69671 :     z = signe(b)? mulii(v, addii(u,v)): sqri(v);
    2663       69671 :     return addii(z, mulii(c, sqri(u)));
    2664             :   }
    2665             :   else
    2666             :   {
    2667         189 :     z = signe(b)? gmul(v, gadd(u,v)): gsqr(v);
    2668         189 :     return gadd(z, gmul(c, gsqr(u)));
    2669             :   }
    2670             : }
    2671             : /* x a t_QUAD, return the attached discriminant */
    2672             : INLINE GEN
    2673        1078 : quad_disc(GEN x)
    2674             : {
    2675        1078 :   GEN Q = gel(x,1), b = gel(Q,3), c = gel(Q,2), c4 = shifti(c,2);
    2676        1078 :   if (is_pm1(b)) return subsi(1, c4);
    2677         154 :   togglesign_safe(&c4); return c4;
    2678             : }
    2679             : INLINE GEN
    2680     4848011 : qfb_disc3(GEN x, GEN y, GEN z) { return subii(sqri(y), shifti(mulii(x,z),2)); }
    2681             : INLINE GEN
    2682    18474990 : qfb_disc(GEN x) { return gel(x,4); }
    2683             : 
    2684             : INLINE GEN
    2685     4140310 : sqrfrac(GEN x)
    2686             : {
    2687     4140310 :   GEN z = cgetg(3,t_FRAC);
    2688     4140308 :   gel(z,1) = sqri(gel(x,1));
    2689     4140285 :   gel(z,2) = sqri(gel(x,2)); return z;
    2690             : }
    2691             : 
    2692             : INLINE void
    2693    16693566 : normalize_frac(GEN z) {
    2694    16693566 :   if (signe(gel(z,2)) < 0) { togglesign(gel(z,1)); setabssign(gel(z,2)); }
    2695    16693566 : }
    2696             : 
    2697             : INLINE GEN
    2698    42911404 : powii(GEN x, GEN n)
    2699             : {
    2700    42911404 :   long ln = lgefint(n);
    2701    42911404 :   if (ln == 3) {
    2702             :     GEN z;
    2703    42888512 :     if (signe(n) > 0) return powiu(x, n[2]);
    2704       74539 :     z = cgetg(3, t_FRAC);
    2705       74551 :     gel(z,1) = gen_1;
    2706       74551 :     gel(z,2) = powiu(x, n[2]);
    2707       74551 :     return z;
    2708             :   }
    2709       22892 :   if (ln == 2) return gen_1; /* rare */
    2710             :   /* should never happen */
    2711           0 :   return powgi(x, n); /* overflow unless x = 0, 1, -1 */
    2712             : }
    2713             : INLINE GEN
    2714        1561 : powIs(long n) {
    2715        1561 :   switch(n & 3)
    2716             :   {
    2717          63 :     case 1: return mkcomplex(gen_0,gen_1);
    2718         385 :     case 2: return gen_m1;
    2719         707 :     case 3: return mkcomplex(gen_0,gen_m1);
    2720             :   }
    2721         406 :   return gen_1;
    2722             : }
    2723             : 
    2724             : /*******************************************************************/
    2725             : /*                                                                 */
    2726             : /*                             ASSIGNMENTS                         */
    2727             : /*                                                                 */
    2728             : /*******************************************************************/
    2729           0 : INLINE void mpexpz(GEN x, GEN z)
    2730           0 : { pari_sp av = avma; gaffect(mpexp(x), z); set_avma(av); }
    2731           0 : INLINE void mplogz(GEN x, GEN z)
    2732           0 : { pari_sp av = avma; gaffect(mplog(x), z); set_avma(av); }
    2733           0 : INLINE void mpcosz(GEN x, GEN z)
    2734           0 : { pari_sp av = avma; gaffect(mpcos(x), z); set_avma(av); }
    2735           0 : INLINE void mpsinz(GEN x, GEN z)
    2736           0 : { pari_sp av = avma; gaffect(mpsin(x), z); set_avma(av); }
    2737           0 : INLINE void gnegz(GEN x, GEN z)
    2738           0 : { pari_sp av = avma; gaffect(gneg(x), z); set_avma(av); }
    2739           0 : INLINE void gabsz(GEN x, long prec, GEN z)
    2740           0 : { pari_sp av = avma; gaffect(gabs(x,prec), z); set_avma(av); }
    2741           0 : INLINE void gaddz(GEN x, GEN y, GEN z)
    2742           0 : { pari_sp av = avma; gaffect(gadd(x,y), z); set_avma(av); }
    2743           0 : INLINE void gsubz(GEN x, GEN y, GEN z)
    2744           0 : { pari_sp av = avma; gaffect(gsub(x,y), z); set_avma(av); }
    2745           0 : INLINE void gmulz(GEN x, GEN y, GEN z)
    2746           0 : { pari_sp av = avma; gaffect(gmul(x,y), z); set_avma(av); }
    2747           0 : INLINE void gdivz(GEN x, GEN y, GEN z)
    2748           0 : { pari_sp av = avma; gaffect(gdiv(x,y), z); set_avma(av); }
    2749           0 : INLINE void gdiventz(GEN x, GEN y, GEN z)
    2750           0 : { pari_sp av = avma; gaffect(gdivent(x,y), z); set_avma(av); }
    2751           0 : INLINE void gmodz(GEN x, GEN y, GEN z)
    2752           0 : { pari_sp av = avma; gaffect(gmod(x,y), z); set_avma(av); }
    2753           0 : INLINE void gmul2nz(GEN x, long s, GEN z)
    2754           0 : { pari_sp av = avma; gaffect(gmul2n(x,s), z); set_avma(av); }
    2755           0 : INLINE void gshiftz(GEN x, long s, GEN z)
    2756           0 : { pari_sp av = avma; gaffect(gshift(x,s), z); set_avma(av); }
    2757             : 
    2758             : /*******************************************************************/
    2759             : /*                                                                 */
    2760             : /*                       ELLIPTIC CURVES                           */
    2761             : /*                                                                 */
    2762             : /*******************************************************************/
    2763     7133652 : INLINE GEN ell_get_a1(GEN e) { return gel(e,1); }
    2764     5716571 : INLINE GEN ell_get_a2(GEN e) { return gel(e,2); }
    2765     6922445 : INLINE GEN ell_get_a3(GEN e) { return gel(e,3); }
    2766     6526084 : INLINE GEN ell_get_a4(GEN e) { return gel(e,4); }
    2767     7959670 : INLINE GEN ell_get_a6(GEN e) { return gel(e,5); }
    2768     5432104 : INLINE GEN ell_get_b2(GEN e) { return gel(e,6); }
    2769     2135457 : INLINE GEN ell_get_b4(GEN e) { return gel(e,7); }
    2770     3054739 : INLINE GEN ell_get_b6(GEN e) { return gel(e,8); }
    2771     2608999 : INLINE GEN ell_get_b8(GEN e) { return gel(e,9); }
    2772     8021739 : INLINE GEN ell_get_c4(GEN e) { return gel(e,10); }
    2773     8850714 : INLINE GEN ell_get_c6(GEN e) { return gel(e,11); }
    2774    11280238 : INLINE GEN ell_get_disc(GEN e) { return gel(e,12); }
    2775     1296377 : INLINE GEN ell_get_j(GEN e) { return gel(e,13); }
    2776    11591968 : INLINE long ell_get_type(GEN e) { return mael(e,14,1); }
    2777     2036495 : INLINE GEN ellff_get_field(GEN x) { return gmael(x, 15, 1); }
    2778      799916 : INLINE GEN ellff_get_a4a6(GEN x)  { return gmael(x, 15, 2); }
    2779        1463 : INLINE GEN ellQp_get_zero(GEN x) { return gmael(x, 15, 1); }
    2780         308 : INLINE long ellQp_get_prec(GEN E) { GEN z = ellQp_get_zero(E); return valp(z); }
    2781        1134 : INLINE GEN ellQp_get_p(GEN E) { GEN z = ellQp_get_zero(E); return gel(z,2); }
    2782      232652 : INLINE long ellR_get_prec(GEN x) { return nbits2prec(mael3(x, 15, 1, 1)); }
    2783      370819 : INLINE long ellR_get_sign(GEN x) { return mael3(x, 15, 1, 2); }
    2784     2029444 : INLINE GEN ellnf_get_nf(GEN x) { return checknf_i(gmael(x,15,1)); }
    2785         126 : INLINE GEN ellnf_get_bnf(GEN x) { return checkbnf_i(gmael(x,15,1)); }
    2786             : 
    2787     4680653 : INLINE int checkell_i(GEN e) { return typ(e) == t_VEC && lg(e) == 17; }
    2788    51344051 : INLINE int ell_is_inf(GEN z) { return lg(z) == 2; }
    2789     1874410 : INLINE GEN ellinf(void) { return mkvec(gen_0); }
    2790             : 
    2791             : /*******************************************************************/
    2792             : /*                                                                 */
    2793             : /*                    ALGEBRAIC NUMBER THEORY                      */
    2794             : /*                                                                 */
    2795             : /*******************************************************************/
    2796    32093495 : INLINE GEN modpr_get_pr(GEN x)  { return gel(x,3); }
    2797     1888117 : INLINE GEN modpr_get_p(GEN x)  { return pr_get_p(modpr_get_pr(x)); }
    2798    13920852 : INLINE GEN modpr_get_T(GEN x)  { return lg(x) == 4? NULL: gel(x,4); }
    2799             : 
    2800    91458042 : INLINE GEN pr_get_p(GEN pr)  { return gel(pr,1); }
    2801    11508483 : INLINE GEN pr_get_gen(GEN pr){ return gel(pr,2); }
    2802             : /* .[2] instead of itos works: e and f are small positive integers */
    2803    15752638 : INLINE long pr_get_e(GEN pr) { return gel(pr,3)[2]; }
    2804    25352398 : INLINE long pr_get_f(GEN pr) { return gel(pr,4)[2]; }
    2805    47869462 : INLINE GEN pr_get_tau(GEN pr){ return gel(pr,5); }
    2806             : INLINE int
    2807    16405188 : pr_is_inert(GEN P) { return typ(pr_get_tau(P)) == t_INT; }
    2808             : INLINE GEN
    2809     1067255 : pr_norm(GEN pr) { return powiu(pr_get_p(pr), pr_get_f(pr)); }
    2810             : INLINE ulong
    2811      343930 : upr_norm(GEN pr) { return upowuu(pr_get_p(pr)[2], pr_get_f(pr)); }
    2812             : 
    2813             : /* assume nf a genuine nf */
    2814             : INLINE long
    2815     1166920 : nf_get_varn(GEN nf) { return varn(gel(nf,1)); }
    2816             : INLINE GEN
    2817   109051617 : nf_get_pol(GEN nf) { return gel(nf,1); }
    2818             : INLINE long
    2819    81961001 : nf_get_degree(GEN nf) { return degpol( nf_get_pol(nf) ); }
    2820             : INLINE long
    2821    22158322 : nf_get_r1(GEN nf) { GEN x = gel(nf,2); return itou(gel(x,1)); }
    2822             : INLINE long
    2823        4140 : nf_get_r2(GEN nf) { GEN x = gel(nf,2); return itou(gel(x,2)); }
    2824             : INLINE GEN
    2825      456399 : nf_get_disc(GEN nf) { return gel(nf,3); }
    2826             : INLINE GEN
    2827     3580956 : nf_get_index(GEN nf) { return gel(nf,4); }
    2828             : INLINE GEN
    2829    20771923 : nf_get_M(GEN nf) { return gmael(nf,5,1); }
    2830             : INLINE GEN
    2831      301228 : nf_get_G(GEN nf) { return gmael(nf,5,2); }
    2832             : INLINE GEN
    2833     1685534 : nf_get_roundG(GEN nf) { return gmael(nf,5,3); }
    2834             : INLINE GEN
    2835       22084 : nf_get_Tr(GEN nf) { return gmael(nf,5,4); }
    2836             : INLINE GEN
    2837        4458 : nf_get_diff(GEN nf) { return gmael(nf,5,5); }
    2838             : INLINE GEN
    2839       59183 : nf_get_ramified_primes(GEN nf) { return gmael(nf,5,8); }
    2840             : INLINE GEN
    2841     1509032 : nf_get_roots(GEN nf) { return gel(nf,6); }
    2842             : INLINE GEN
    2843        4382 : nf_get_zk(GEN nf)
    2844             : {
    2845        4382 :   GEN y = gel(nf,7), D = gel(y, 1);
    2846        4382 :   if (typ(D) == t_POL) D = gel(D, 2);
    2847        4382 :   if (!equali1(D)) y = gdiv(y, D);
    2848        4382 :   return y;
    2849             : }
    2850             : INLINE GEN
    2851     5011385 : nf_get_zkprimpart(GEN nf)
    2852             : {
    2853     5011385 :   GEN y = gel(nf,7);
    2854             :   /* test for old format of nf.zk: non normalized */
    2855     5011385 :   if (!equali1(gel(nf,4)) && gequal1(gel(y,1))) y = Q_remove_denom(y,NULL);
    2856     5011396 :   return y;
    2857             : }
    2858             : INLINE GEN
    2859     5057508 : nf_get_zkden(GEN nf)
    2860             : {
    2861     5057508 :   GEN y = gel(nf,7), D = gel(y,1);
    2862     5057508 :   if (typ(D) == t_POL) D = gel(D,2);
    2863             :   /* test for old format of nf.zk: non normalized */
    2864     5057508 :   if (!equali1(gel(nf,4)) && equali1(D)) D = Q_denom(y);
    2865     5057491 :   return D;
    2866             : }
    2867             : INLINE GEN
    2868     9891074 : nf_get_invzk(GEN nf) { return gel(nf,8); }
    2869             : INLINE void
    2870      516469 : nf_get_sign(GEN nf, long *r1, long *r2)
    2871             : {
    2872      516469 :   GEN x = gel(nf,2);
    2873      516469 :   *r1 = itou(gel(x,1));
    2874      516469 :   *r2 = itou(gel(x,2));
    2875      516469 : }
    2876             : 
    2877             : INLINE GEN
    2878     2521805 : cyc_get_expo(GEN c) { return lg(c) == 1? gen_1: gel(c,1); }
    2879             : INLINE GEN
    2880      391986 : abgrp_get_no(GEN x) { return gel(x,1); }
    2881             : INLINE GEN
    2882    11549584 : abgrp_get_cyc(GEN x) { return gel(x,2); }
    2883             : INLINE GEN
    2884     1653756 : abgrp_get_gen(GEN x) { return gel(x,3); }
    2885             : INLINE GEN
    2886     9426230 : bnf_get_nf(GEN bnf) { return gel(bnf,7); }
    2887             : INLINE GEN
    2888     5097814 : bnf_get_clgp(GEN bnf) { return gmael(bnf,8,1); }
    2889             : INLINE GEN
    2890        8379 : bnf_get_no(GEN bnf) { return abgrp_get_no(bnf_get_clgp(bnf)); }
    2891             : INLINE GEN
    2892     3509290 : bnf_get_cyc(GEN bnf) { return abgrp_get_cyc(bnf_get_clgp(bnf)); }
    2893             : INLINE GEN
    2894     1579983 : bnf_get_gen(GEN bnf)  { return abgrp_get_gen(bnf_get_clgp(bnf)); }
    2895             : INLINE GEN
    2896         641 : bnf_get_reg(GEN bnf) { return gmael(bnf,8,2); }
    2897             : INLINE GEN
    2898     2702244 : bnf_get_logfu(GEN bnf) { return gel(bnf,3); }
    2899             : INLINE GEN
    2900     1278422 : bnf_get_sunits(GEN bnf)
    2901     1278422 : { GEN s = gmael(bnf,8,3); return typ(s) == t_INT? NULL: s; }
    2902             : INLINE GEN
    2903      290505 : bnf_get_tuU(GEN bnf) { return gmael3(bnf,8,4,2); }
    2904             : INLINE long
    2905      265161 : bnf_get_tuN(GEN bnf) { return gmael3(bnf,8,4,1)[2]; }
    2906             : INLINE GEN
    2907      288153 : bnf_get_fu_nocheck(GEN bnf) { return gmael(bnf,8,5); }
    2908             : INLINE GEN
    2909       26293 : nfV_to_scalar_or_alg(GEN nf, GEN x)
    2910       63435 : { pari_APPLY_same(nf_to_scalar_or_alg(nf, gel(x,i))) }
    2911             : INLINE GEN
    2912       25852 : bnf_get_fu(GEN bnf) {
    2913       25852 :   GEN fu = bnf_build_units(bnf), nf = bnf_get_nf(bnf);
    2914       25852 :   if (typ(fu) == t_MAT) pari_err(e_MISC,"missing units in bnf");
    2915       25852 :   return nfV_to_scalar_or_alg(nf, vecslice(fu, 2, lg(fu)-1));
    2916             : }
    2917             : 
    2918             : INLINE GEN
    2919     3632382 : bnr_get_bnf(GEN bnr) { return gel(bnr,1); }
    2920             : INLINE GEN
    2921     1937030 : bnr_get_bid(GEN bnr) { return gel(bnr,2); }
    2922             : INLINE GEN
    2923      141041 : bnr_get_mod(GEN bnr) { return gmael(bnr,2,1); }
    2924             : INLINE GEN
    2925     1260077 : bnr_get_nf(GEN bnr) { return gmael(bnr,1,7); }
    2926             : INLINE GEN
    2927     2728724 : bnr_get_clgp(GEN bnr) { return gel(bnr,5); }
    2928             : INLINE GEN
    2929      314588 : bnr_get_no(GEN bnr) { return abgrp_get_no(bnr_get_clgp(bnr)); }
    2930             : INLINE GEN
    2931     2396526 : bnr_get_cyc(GEN bnr) { return abgrp_get_cyc(bnr_get_clgp(bnr)); }
    2932             : INLINE GEN
    2933          70 : bnr_get_gen_nocheck(GEN bnr) { return abgrp_get_gen(bnr_get_clgp(bnr)); }
    2934             : INLINE GEN
    2935        7847 : bnr_get_gen(GEN bnr) {
    2936        7847 :   GEN G = bnr_get_clgp(bnr);
    2937        7847 :   if (lg(G) !=  4)
    2938           0 :     pari_err(e_MISC,"missing bnr generators: please use bnrinit(,,1)");
    2939        7847 :   return gel(G,3);
    2940             : }
    2941             : 
    2942             : /* localstar, used in gchar */
    2943             : INLINE GEN
    2944       51954 : locs_get_cyc(GEN locs) { return gel(locs,1); }
    2945             : INLINE GEN
    2946      191695 : locs_get_Lsprk(GEN locs) { return gel(locs,2); }
    2947             : INLINE GEN
    2948        1260 : locs_get_Lgenfil(GEN locs) { return gel(locs,3); }
    2949             : INLINE GEN
    2950        8225 : locs_get_mod(GEN locs) { return gel(locs,4); }
    2951             : /* pr dividing the modulus N of locs, 0 <= i < v_pr(N)
    2952             :  * return a t_MAT whose columns are the logs
    2953             :  * of generators of U_i(pr)/U_{i+1}(pr). */
    2954             : INLINE GEN
    2955        1260 : locs_get_famod(GEN locs) { return gmael(locs,4,1); }
    2956             : INLINE GEN
    2957      207235 : locs_get_m_infty(GEN locs) { return gmael(locs,4,2); }
    2958             : 
    2959             : /* G a grossenchar group */
    2960             : INLINE GEN
    2961       32639 : gchar_get_basis(GEN gc)  { return  gel(gc, 1); }
    2962             : INLINE GEN
    2963      203105 : gchar_get_bnf(GEN gc)    { return  gel(gc, 2); }
    2964             : INLINE GEN
    2965      241464 : gchar_get_nf(GEN gc)    { return  gel(gc, 3); }
    2966             : INLINE GEN
    2967      279433 : gchar_get_zm(GEN gc)     { return  gel(gc, 4); }
    2968             : INLINE GEN
    2969        8225 : gchar_get_mod(GEN gc)    { return  locs_get_mod(gchar_get_zm(gc)); }
    2970             : INLINE GEN
    2971        4095 : gchar_get_modP(GEN gc)    { return gmael(gchar_get_mod(gc),1,1); }
    2972             : INLINE GEN
    2973       36864 : gchar_get_S(GEN gc)      { return  gel(gc, 5); }
    2974             : INLINE GEN
    2975      188468 : gchar_get_DLdata(GEN gc)   { return  gel(gc, 6); }
    2976             : INLINE GEN
    2977        1747 : gchar_get_sfu(GEN gc) { return  gel(gc, 7); }
    2978             : INLINE GEN
    2979       16168 : gchar_get_cyc(GEN gc)    { return  gel(gc, 9); }
    2980             : INLINE GEN
    2981           0 : gchar_get_hnf(GEN gc)    { return  gmael(gc, 10, 1); }
    2982             : INLINE GEN
    2983           0 : gchar_get_U(GEN gc)      { return  gmael(gc, 10, 2); }
    2984             : INLINE GEN
    2985       10969 : gchar_get_Ui(GEN gc)     { return  gmael(gc, 10, 3); }
    2986             : INLINE GEN
    2987        3320 : gchar_get_m0(GEN gc)     { return gel(gc, 11); }
    2988             : INLINE GEN
    2989        4266 : gchar_get_u0(GEN gc)     { return gel(gc, 12); }
    2990             : INLINE long
    2991       17416 : gchar_get_r1(GEN gc)     { return nf_get_r1(gchar_get_nf(gc)); }
    2992             : INLINE long
    2993         623 : gchar_get_r2(GEN gc)     { return nf_get_r2(gchar_get_nf(gc)); }
    2994             : INLINE GEN
    2995       50346 : gchar_get_loccyc(GEN gc) { return locs_get_cyc(gchar_get_zm(gc)); }
    2996             : INLINE long
    2997       37130 : gchar_get_nc(GEN gc)     { return lg(gchar_get_loccyc(gc))-1; }
    2998             : INLINE long
    2999       36864 : gchar_get_ns(GEN gc)     { return lg(gchar_get_S(gc))-1; }
    3000             : INLINE long
    3001        1841 : gchar_get_nm(GEN gc)     { return lg(gchar_get_basis(gc))-1; }
    3002             : INLINE long
    3003        4011 : gchar_get_evalprec(GEN gc)   { return  gmael(gc, 8, 1)[1]; }
    3004             : INLINE long
    3005       18732 : gchar_get_prec(GEN gc)   { return  gmael(gc, 8, 1)[2]; }
    3006             : INLINE long
    3007       13419 : gchar_get_nfprec(GEN gc) { return  gmael(gc, 8, 1)[3]; }
    3008             : INLINE void
    3009        1785 : gchar_set_evalprec(GEN gc, long prec) { gmael(gc, 8, 1)[1] = prec; }
    3010             : INLINE void
    3011        1202 : gchar_set_prec(GEN gc, long prec) { gmael(gc, 8, 1)[2] = prec; }
    3012             : INLINE void
    3013        1202 : gchar_copy_precs(GEN gc, GEN gc2)
    3014             : {
    3015        1202 :   gel(gc2, 8) = shallowcopy(gel(gc,8));
    3016        1202 :   gmael(gc2, 8, 1) = shallowcopy(gmael(gc, 8, 1));
    3017        1202 : }
    3018             : INLINE void
    3019        2949 : gchar_set_nfprec(GEN gc, long prec) { gmael(gc, 8, 1)[3] = prec; }
    3020             : INLINE long
    3021         322 : gchar_get_ntors(GEN gc)   { return  gmael(gc, 8, 2)[1]; }
    3022             : INLINE long
    3023         322 : gchar_get_nfree(GEN gc)   { return  gmael(gc, 8, 2)[2]; }
    3024             : INLINE long
    3025        2042 : gchar_get_nalg(GEN gc)   { return  gmael(gc, 8, 2)[3]; }
    3026             : INLINE void
    3027        1573 : gchar_set_basis(GEN gc, GEN m_inv)  { gel(gc, 1) = m_inv; }
    3028             : INLINE void
    3029        2076 : gchar_set_nf(GEN gc, GEN nf)      { gel(gc, 3) = nf; }
    3030             : INLINE void
    3031         623 : gchar_set_ntors(GEN gc, long n)    { gmael(gc, 8, 2)[1] = n; }
    3032             : INLINE void
    3033         623 : gchar_set_nfree(GEN gc, long n)    { gmael(gc, 8, 2)[2] = n; }
    3034             : INLINE void
    3035         623 : gchar_set_nalg(GEN gc, long n)    { gmael(gc, 8, 2)[3] = n; }
    3036             : INLINE void
    3037        1573 : gchar_set_cyc(GEN gc, GEN cyc)      { gel(gc, 9) = cyc; }
    3038             : INLINE void
    3039         623 : gchar_set_HUUi(GEN gc, GEN hnf, GEN U, GEN Ui) { gel(gc, 10) = mkvec3(hnf, U, Ui); }
    3040             : INLINE void
    3041         950 : gchar_set_m0(GEN gc, GEN m0)     { gel(gc, 11) = m0; }
    3042             : INLINE void
    3043        2093 : gchar_set_u0(GEN gc, GEN u0)     { gel(gc, 12) = u0; }
    3044             : 
    3045             : INLINE GEN
    3046     1386571 : bid_get_mod(GEN bid) { return gel(bid,1); }
    3047             : INLINE GEN
    3048       78295 : bid_get_ideal(GEN bid) { return gmael(bid,1,1); }
    3049             : INLINE GEN
    3050       35098 : bid_get_arch(GEN bid) { return gmael(bid,1,2); }
    3051             : INLINE GEN
    3052     5415578 : bid_get_grp(GEN bid) { return gel(bid,2); }
    3053             : INLINE GEN
    3054     2313955 : bid_get_fact(GEN bid) { return gmael(bid,3,1); }
    3055             : INLINE GEN
    3056     2025296 : bid_get_fact2(GEN bid) { return gmael(bid,3,2); }
    3057             : INLINE GEN
    3058     1990763 : bid_get_MOD(GEN bid) { GEN y = gel(bid,4); return lg(y) == 4? gel(y,3): NULL; }
    3059             : INLINE GEN
    3060     1991491 : bid_get_sprk(GEN bid) { return gmael(bid,4,1); }
    3061             : INLINE GEN
    3062       51226 : bid_get_sarch(GEN bid) { return gmael(bid,4,2); }
    3063             : INLINE GEN
    3064     2217807 : bid_get_archp(GEN bid) { return gmael3(bid,4,2,2); }
    3065             : INLINE GEN
    3066     3378387 : bid_get_U(GEN bid) { return gel(bid,5); }
    3067             : INLINE GEN
    3068           0 : bid_get_no(GEN bid) { return abgrp_get_no(bid_get_grp(bid)); }
    3069             : INLINE GEN
    3070     5361669 : bid_get_cyc(GEN bid) { return abgrp_get_cyc(bid_get_grp(bid)); }
    3071             : INLINE GEN
    3072           0 : bid_get_gen_nocheck(GEN bid)  { return abgrp_get_gen(bid_get_grp(bid)); }
    3073             : INLINE GEN
    3074       53326 : bid_get_gen(GEN bid) {
    3075       53326 :   GEN G = bid_get_grp(bid);
    3076       53326 :   if (lg(G) != 4) pari_err(e_MISC,"missing bid generators. Use idealstar(,,2)");
    3077       53326 :   return abgrp_get_gen(G);
    3078             : }
    3079             : 
    3080             : INLINE GEN
    3081    34543777 : znstar_get_N(GEN G) { return gmael(G,1,1); }
    3082             : INLINE GEN
    3083     7210394 : znstar_get_faN(GEN G) { return gel(G,3); }
    3084             : INLINE GEN
    3085          14 : znstar_get_no(GEN G) { return abgrp_get_no(gel(G,2)); }
    3086             : INLINE GEN
    3087      261948 : znstar_get_cyc(GEN G) { return abgrp_get_cyc(gel(G,2)); }
    3088             : INLINE GEN
    3089       16150 : znstar_get_gen(GEN G) { return abgrp_get_gen(gel(G,2)); }
    3090             : INLINE GEN
    3091     7823726 : znstar_get_conreycyc(GEN G) { return gmael(G,4,5); }
    3092             : INLINE GEN
    3093     3221793 : znstar_get_conreygen(GEN G) { return gmael(G,4,4); }
    3094             : INLINE GEN
    3095       46788 : znstar_get_Ui(GEN G) { return gmael(G,4,3); }
    3096             : INLINE GEN
    3097      176051 : znstar_get_U(GEN G) { return gel(G,5); }
    3098             : INLINE GEN
    3099     2820763 : znstar_get_pe(GEN G) { return gmael(G,4,1); }
    3100             : INLINE GEN
    3101       36050 : gal_get_pol(GEN gal) { return gel(gal,1); }
    3102             : INLINE GEN
    3103        6041 : gal_get_p(GEN gal) { return gmael(gal,2,1); }
    3104             : INLINE GEN
    3105          91 : gal_get_e(GEN gal) { return gmael(gal,2,2); }
    3106             : INLINE GEN
    3107       23744 : gal_get_mod(GEN gal) { return gmael(gal,2,3); }
    3108             : INLINE GEN
    3109       32487 : gal_get_roots(GEN gal) { return gel(gal,3); }
    3110             : INLINE GEN
    3111       27594 : gal_get_invvdm(GEN gal) { return gel(gal,4); }
    3112             : INLINE GEN
    3113       27587 : gal_get_den(GEN gal) { return gel(gal,5); }
    3114             : INLINE GEN
    3115       80134 : gal_get_group(GEN gal) { return gel(gal,6); }
    3116             : INLINE GEN
    3117       15456 : gal_get_gen(GEN gal) { return gel(gal,7); }
    3118             : INLINE GEN
    3119        6664 : gal_get_orders(GEN gal) { return gel(gal,8); }
    3120             : 
    3121             : /* assume rnf a genuine rnf */
    3122             : INLINE long
    3123     2466302 : rnf_get_degree(GEN rnf) { return degpol(rnf_get_pol(rnf)); }
    3124             : INLINE long
    3125       19957 : rnf_get_nfdegree(GEN rnf) { return degpol(nf_get_pol(rnf_get_nf(rnf))); }
    3126             : INLINE long
    3127     1377518 : rnf_get_absdegree(GEN rnf) { return degpol(gmael(rnf,11,1)); }
    3128             : INLINE GEN
    3129        1127 : rnf_get_idealdisc(GEN rnf) { return gmael(rnf,3,1); }
    3130             : INLINE GEN
    3131        1015 : rnf_get_k(GEN rnf) { return gmael(rnf,11,3); }
    3132             : INLINE GEN
    3133        1043 : rnf_get_alpha(GEN rnf) { return gmael(rnf, 11, 2); }
    3134             : INLINE GEN
    3135      697213 : rnf_get_nf(GEN rnf) { return gel(rnf,10); }
    3136             : INLINE GEN
    3137        5516 : rnf_get_nfzk(GEN rnf) { return gel(rnf,2); }
    3138             : INLINE GEN
    3139      287402 : rnf_get_polabs(GEN rnf) { return gmael(rnf,11,1); }
    3140             : INLINE GEN
    3141     2776606 : rnf_get_pol(GEN rnf) { return gel(rnf,1); }
    3142             : INLINE GEN
    3143         315 : rnf_get_disc(GEN rnf) { return gel(rnf,3); }
    3144             : INLINE GEN
    3145         105 : rnf_get_index(GEN rnf) { return gel(rnf,4); }
    3146             : INLINE GEN
    3147        2282 : rnf_get_ramified_primes(GEN rnf) { return gel(rnf,5); }
    3148             : INLINE long
    3149         574 : rnf_get_varn(GEN rnf) { return varn(gel(rnf,1)); }
    3150             : INLINE GEN
    3151      235999 : rnf_get_nfpol(GEN rnf) { return gmael(rnf,10,1); }
    3152             : INLINE long
    3153        3724 : rnf_get_nfvarn(GEN rnf) { return varn(gmael(rnf,10,1)); }
    3154             : INLINE GEN
    3155        4263 : rnf_get_zk(GEN rnf) { return gel(rnf,7); }
    3156             : INLINE GEN
    3157      124550 : rnf_get_map(GEN rnf) { return gel(rnf,11); }
    3158             : INLINE GEN
    3159        1225 : rnf_get_invzk(GEN rnf) { return gel(rnf,8); }
    3160             : 
    3161             : INLINE GEN
    3162      138591 : idealred(GEN nf, GEN id) { return idealred0(nf, id, NULL); }
    3163             : 
    3164             : INLINE GEN
    3165        4514 : idealchineseinit(GEN nf, GEN x)
    3166        4514 : { return idealchinese(nf,x,NULL); }
    3167             : 
    3168             : /*******************************************************************/
    3169             : /*                                                                 */
    3170             : /*                              CLOSURES                           */
    3171             : /*                                                                 */
    3172             : /*******************************************************************/
    3173   360857818 : INLINE long closure_arity(GEN C)          { return ((ulong)C[1])&ARITYBITS; }
    3174    39983683 : INLINE long closure_is_variadic(GEN C) { return !!(((ulong)C[1])&VARARGBITS); }
    3175   312214824 : INLINE const char *closure_codestr(GEN C)  { return GSTR(gel(C,2))-1; }
    3176           0 : INLINE GEN closure_get_code(GEN C)  { return gel(C,2); }
    3177   312197267 : INLINE GEN closure_get_oper(GEN C)  { return gel(C,3); }
    3178   312175360 : INLINE GEN closure_get_data(GEN C)  { return gel(C,4); }
    3179       13327 : INLINE GEN closure_get_dbg(GEN C)   { return gel(C,5); }
    3180       36456 : INLINE GEN closure_get_text(GEN C)  { return gel(C,6); }
    3181    12952532 : INLINE GEN closure_get_frame(GEN C) { return gel(C,7); }
    3182             : 
    3183             : /*******************************************************************/
    3184             : /*                                                                 */
    3185             : /*                               ERRORS                            */
    3186             : /*                                                                 */
    3187             : /*******************************************************************/
    3188             : INLINE long
    3189       61912 : err_get_num(GEN e) { return e[1]; }
    3190             : INLINE GEN
    3191         273 : err_get_compo(GEN e, long i) { return gel(e, i+1); }
    3192             : 
    3193             : INLINE void
    3194          14 : pari_err_BUG(const char *f) { pari_err(e_BUG,f); }
    3195             : INLINE void
    3196          21 : pari_err_CONSTPOL(const char *f) { pari_err(e_CONSTPOL, f); }
    3197             : INLINE void
    3198          84 : pari_err_COPRIME(const char *f, GEN x, GEN y) { pari_err(e_COPRIME, f,x,y); }
    3199             : INLINE void
    3200         711 : pari_err_DIM(const char *f) { pari_err(e_DIM, f); }
    3201             : INLINE void
    3202           0 : pari_err_FILE(const char *f, const char *g) { pari_err(e_FILE, f,g); }
    3203             : INLINE void
    3204          36 : pari_err_FILEDESC(const char *f, long n) { pari_err(e_FILEDESC, f,n); }
    3205             : INLINE void
    3206          98 : pari_err_FLAG(const char *f) { pari_err(e_FLAG,f); }
    3207             : INLINE void
    3208         525 : pari_err_IMPL(const char *f) { pari_err(e_IMPL,f); }
    3209             : INLINE void
    3210       19997 : pari_err_INV(const char *f, GEN x) { pari_err(e_INV,f,x); }
    3211             : INLINE void
    3212          63 : pari_err_IRREDPOL(const char *f, GEN x) { pari_err(e_IRREDPOL, f,x); }
    3213             : INLINE void
    3214        2750 : 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); }
    3215             : INLINE void
    3216         214 : pari_err_COMPONENT(const char *f, const char *op, GEN l, GEN x) { pari_err(e_COMPONENT, f,op,l,x); }
    3217             : INLINE void
    3218           0 : pari_err_MAXPRIME(ulong c) { pari_err(e_MAXPRIME, c); }
    3219             : INLINE void
    3220         406 : pari_err_OP(const char *f, GEN x, GEN y) { pari_err(e_OP, f,x,y); }
    3221             : INLINE void
    3222         156 : pari_err_OVERFLOW(const char *f) { pari_err(e_OVERFLOW, f); }
    3223             : INLINE void
    3224         238 : pari_err_PREC(const char *f) { pari_err(e_PREC,f); }
    3225             : INLINE void
    3226           0 : pari_err_PACKAGE(const char *f) { pari_err(e_PACKAGE,f); }
    3227             : INLINE void
    3228          98 : pari_err_PRIME(const char *f, GEN x) { pari_err(e_PRIME, f,x); }
    3229             : INLINE void
    3230        1316 : pari_err_MODULUS(const char *f, GEN x, GEN y) { pari_err(e_MODULUS, f,x,y); }
    3231             : INLINE void
    3232          63 : pari_err_ROOTS0(const char *f) { pari_err(e_ROOTS0, f); }
    3233             : INLINE void
    3234          84 : pari_err_SQRTN(const char *f, GEN x) { pari_err(e_SQRTN, f,x); }
    3235             : INLINE void
    3236       15251 : pari_err_TYPE(const char *f, GEN x) { pari_err(e_TYPE, f,x); }
    3237             : INLINE void
    3238        3493 : pari_err_TYPE2(const char *f, GEN x, GEN y) { pari_err(e_TYPE2, f,x,y); }
    3239             : INLINE void
    3240         371 : pari_err_VAR(const char *f, GEN x, GEN y) { pari_err(e_VAR, f,x,y); }
    3241             : INLINE void
    3242         245 : pari_err_PRIORITY(const char *f, GEN x, const char *op, long v)
    3243         245 : { pari_err(e_PRIORITY, f,x,op,v); }
    3244             : 

Generated by: LCOV version 1.16