Code coverage tests

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

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

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

LCOV - code coverage report
Current view: top level - headers - pariinl.h (source / functions) Hit Total Coverage
Test: PARI/GP v2.16.2 lcov report (development 29394-d854966656) Lines: 1441 1584 91.0 %
Date: 2024-06-13 09:03:54 Functions: 646 717 90.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* Copyright (C) 2000-2010  The PARI group.
       2             : 
       3             : This file is part of the PARI/GP package.
       4             : 
       5             : PARI/GP is free software; you can redistribute it and/or modify it under the
       6             : terms of the GNU General Public License as published by the Free Software
       7             : Foundation; either version 2 of the License, or (at your option) any later
       8             : version. It is distributed in the hope that it will be useful, but WITHOUT
       9             : ANY WARRANTY WHATSOEVER.
      10             : 
      11             : Check the License for details. You should have received a copy of it, along
      12             : with the package; see the file 'COPYING'. If not, write to the Free Software
      13             : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
      14             : 
      15             : 
      16             : /*********************************************************************/
      17             : /*                       MALLOC/FREE WRAPPERS                        */
      18             : /*********************************************************************/
      19             : #define BLOCK_SIGALRM_START          \
      20             : {                                    \
      21             :   int block=PARI_SIGINT_block;       \
      22             :   PARI_SIGINT_block = 2;             \
      23             :   MT_SIGINT_BLOCK(block);
      24             : 
      25             : #define BLOCK_SIGINT_START           \
      26             : {                                    \
      27             :   int block=PARI_SIGINT_block;       \
      28             :   PARI_SIGINT_block = 1;             \
      29             :   MT_SIGINT_BLOCK(block);
      30             : 
      31             : #define BLOCK_SIGINT_END             \
      32             :   PARI_SIGINT_block = block;         \
      33             :   MT_SIGINT_UNBLOCK(block);          \
      34             :   if (!block && PARI_SIGINT_pending) \
      35             :   {                                  \
      36             :     int sig = PARI_SIGINT_pending;   \
      37             :     PARI_SIGINT_pending = 0;         \
      38             :     raise(sig);                      \
      39             :   }                                  \
      40             : }
      41             : 
      42             : /*******************************************************************/
      43             : /*                                                                 */
      44             : /*                          CONSTRUCTORS                           */
      45             : /*                                                                 */
      46             : /*******************************************************************/
      47             : #define retmkfrac(x,y)\
      48             :   do { GEN _v = cgetg(3, t_FRAC);\
      49             :        gel(_v,1) = (x);\
      50             :        gel(_v,2) = (y); return _v; } while(0)
      51             : #define retmkrfrac(x,y)\
      52             :   do { GEN _v = cgetg(3, t_RFRAC);\
      53             :        gel(_v,1) = (x);\
      54             :        gel(_v,2) = (y); return _v; } while(0)
      55             : #define retmkintmod(x,y)\
      56             :   do { GEN _v = cgetg(3, t_INTMOD);\
      57             :        gel(_v,1) = (y);\
      58             :        gel(_v,2) = (x); return _v; } while(0)
      59             : #define retmkcomplex(x,y)\
      60             :   do { GEN _v = cgetg(3, t_COMPLEX);\
      61             :        gel(_v,1) = (x);\
      62             :        gel(_v,2) = (y); return _v; } while(0)
      63             : #define retmkpolmod(x,y)\
      64             :   do { GEN _v = cgetg(3, t_POLMOD);\
      65             :        gel(_v,1) = (y);\
      66             :        gel(_v,2) = (x); return _v; } while(0)
      67             : #define retmkvec(x)\
      68             :   do { GEN _v = cgetg(2, t_VEC);\
      69             :        gel(_v,1) = (x); return _v; } while(0)
      70             : #define retmkvec2(x,y)\
      71             :   do { GEN _v = cgetg(3, t_VEC);\
      72             :        gel(_v,1) = (x);\
      73             :        gel(_v,2) = (y); return _v; } while(0)
      74             : #define retmkvec3(x,y,z)\
      75             :   do { GEN _v = cgetg(4, t_VEC);\
      76             :        gel(_v,1) = (x);\
      77             :        gel(_v,2) = (y);\
      78             :        gel(_v,3) = (z); return _v; } while(0)
      79             : #define 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     8201286 : mkintmod(GEN x, GEN y) { retmkintmod(x,y); }
     167             : INLINE GEN
     168        1806 : mkintmodu(ulong x, ulong y) {
     169        1806 :   GEN v = cgetg(3,t_INTMOD);
     170        1806 :   gel(v,1) = utoipos(y);
     171        1806 :   gel(v,2) = utoi(x); return v;
     172             : }
     173             : INLINE GEN
     174     2813517 : mkpolmod(GEN x, GEN y) { retmkpolmod(x,y); }
     175             : INLINE GEN
     176    33047459 : mkfrac(GEN x, GEN y) { retmkfrac(x,y); }
     177             : INLINE GEN
     178     1209507 : 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       19257 : Qtoss(GEN q, long *n, long *d)
     182             : {
     183       19257 :   if (typ(q) == t_INT) { *n = itos(q); *d = 1; }
     184        5719 :   else { *n = itos(gel(q,1)); *d = itou(gel(q,2)); }
     185       19257 : }
     186             : INLINE GEN
     187      869113 : sstoQ(long n, long d)
     188             : {
     189             :   ulong r;
     190             :   long g, q;
     191      869113 :   if (!n)
     192             :   {
     193       92554 :     if (!d) pari_err_INV("sstoQ",gen_0);
     194       92554 :     return gen_0;
     195             :   }
     196      776559 :   if (d < 0) { d = -d; n = -n; }
     197      776559 :   if (d == 1) return stoi(n);
     198      757134 :   r = labs(n);
     199      757134 :   if (r == 1) retmkfrac(n > 0? gen_1: gen_m1, utoipos(d));
     200      707644 :   q = udivuu_rem(r, d, &r);
     201      707644 :   if (!r) return n > 0? utoipos(q): utoineg(q);
     202      652589 :   g = ugcd(d,r); /* gcd(n,d) */
     203      652589 :   if (g != 1) { n /= g; d /= g; }
     204      652589 :   retmkfrac(stoi(n), utoipos(d));
     205             : }
     206             : 
     207             : INLINE GEN
     208   158054726 : uutoQ(ulong n, ulong d)
     209             : {
     210             :   ulong r;
     211             :   long g, q;
     212   158054726 :   if (!n)
     213             :   {
     214       38108 :     if (!d) pari_err_INV("uutoQ",gen_0);
     215       38108 :     return gen_0;
     216             :   }
     217   158016618 :   if (d == 1) return utoipos(n);
     218   158005516 :   if (n == 1) retmkfrac(gen_1, utoipos(d));
     219   157916589 :   q = udivuu_rem(n,d,&r);
     220   157916589 :   if (!r) return utoipos(q);
     221     5178542 :   g = ugcd(d,r); /* gcd(n,d) */
     222     5178542 :   if (g != 1) { n /= g; d /= g; }
     223     5178542 :   retmkfrac(utoipos(n), utoipos(d));
     224             : }
     225             : 
     226             : INLINE GEN
     227     4736585 : mkfraccopy(GEN x, GEN y) { retmkfrac(icopy(x), icopy(y)); }
     228             : INLINE GEN
     229      698138 : mkrfrac(GEN x, GEN y) { GEN v = cgetg(3, t_RFRAC);
     230      698138 :   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    89864073 : mkcomplex(GEN x, GEN y) { retmkcomplex(x,y); }
     236             : INLINE GEN
     237     1266737 : gen_I(void) { return mkcomplex(gen_0, gen_1); }
     238             : INLINE GEN
     239      981714 : cgetc(long l) { retmkcomplex(cgetr(l), cgetr(l)); }
     240             : INLINE GEN
     241       69132 : mkquad(GEN n, GEN x, GEN y) { GEN v = cgetg(4, t_QUAD);
     242       69132 :   gel(v,1) = n; gel(v,2) = x; gel(v,3) = y; return v; }
     243             : /* vecsmall */
     244             : INLINE GEN
     245   125964854 : mkvecsmall(long x) { GEN v = cgetg(2, t_VECSMALL); v[1] = x; return v; }
     246             : INLINE GEN
     247   221304926 : mkvecsmall2(long x,long y) { GEN v = cgetg(3, t_VECSMALL);
     248   221318283 :   v[1]=x; v[2]=y; return v; }
     249             : INLINE GEN
     250    94457577 : mkvecsmall3(long x,long y,long z) { GEN v = cgetg(4, t_VECSMALL);
     251    94454771 :   v[1]=x; v[2]=y; v[3]=z; return v; }
     252             : INLINE GEN
     253    15280313 : mkvecsmall4(long x,long y,long z,long t) { GEN v = cgetg(5, t_VECSMALL);
     254    15284947 :   v[1]=x; v[2]=y; v[3]=z; v[4]=t; return v; }
     255             : INLINE GEN
     256      669618 : mkvecsmall5(long x,long y,long z,long t,long u) { GEN v = cgetg(6, t_VECSMALL);
     257      669620 :   v[1]=x; v[2]=y; v[3]=z; v[4]=t; v[5]=u; return v; }
     258             : 
     259             : INLINE GEN
     260    27654484 : mkqfb(GEN x, GEN y, GEN z, GEN d) { retmkqfb(x,y,z,d); }
     261             : /* vec */
     262             : INLINE GEN
     263    67843718 : mkvec(GEN x) { retmkvec(x); }
     264             : INLINE GEN
     265   179291413 : mkvec2(GEN x, GEN y) { retmkvec2(x,y); }
     266             : INLINE GEN
     267   115621510 : mkvec3(GEN x, GEN y, GEN z) { retmkvec3(x,y,z); }
     268             : INLINE GEN
     269     6553822 : mkvec4(GEN x, GEN y, GEN z, GEN t) { retmkvec4(x,y,z,t); }
     270             : INLINE GEN
     271    14160441 : 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      213237 : 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      121947 : mkveccopy(GEN x) { GEN v = cgetg(2, t_VEC); gel(v,1) = gcopy(x); return v; }
     282             : INLINE GEN
     283      119999 : mkvec2copy(GEN x, GEN y) {
     284      119999 :   GEN v = cgetg(3,t_VEC); gel(v,1) = gcopy(x); gel(v,2) = gcopy(y); return v; }
     285             : /* col */
     286             : INLINE GEN
     287     9802665 : mkcol(GEN x) { retmkcol(x); }
     288             : INLINE GEN
     289   154273146 : mkcol2(GEN x, GEN y) { retmkcol2(x,y); }
     290             : INLINE GEN
     291       87642 : mkcol3(GEN x, GEN y, GEN z) { retmkcol3(x,y,z); }
     292             : INLINE GEN
     293      102935 : mkcol4(GEN x, GEN y, GEN z, GEN t) { retmkcol4(x,y,z,t); }
     294             : INLINE GEN
     295         101 : mkcol5(GEN x, GEN y, GEN z, GEN t, GEN u) { retmkcol5(x,y,z,t,u); }
     296             : INLINE GEN
     297      232050 : 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     4414032 : mkcol2s(long x, long y) { retmkcol2(stoi(x),stoi(y)); }
     302             : INLINE GEN
     303         308 : 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       29494 : mkcolcopy(GEN x) { GEN v = cgetg(2, t_COL); gel(v,1) = gcopy(x); return v; }
     308             : /* mat */
     309             : INLINE GEN
     310     4575001 : mkmat(GEN x) { retmkmat(x); }
     311             : INLINE GEN
     312    31658687 : mkmat2(GEN x, GEN y) { retmkmat2(x,y); }
     313             : INLINE GEN
     314       16777 : mkmat3(GEN x, GEN y, GEN z) { retmkmat3(x,y,z); }
     315             : INLINE GEN
     316           0 : 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      112274 : 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      200958 : mkoo(void) { GEN v = cgetg(2, t_INFINITY); gel(v,1) = gen_1; return v; }
     325             : INLINE GEN
     326      103545 : mkmoo(void) { GEN v = cgetg(2, t_INFINITY); gel(v,1) = gen_m1; return v; }
     327             : INLINE long
     328      316821 : inf_get_sign(GEN x) { return signe(gel(x,1)); }
     329             : INLINE GEN
     330      206822 : mkmat22s(long a, long b, long c, long d) {retmkmat2(mkcol2s(a,c),mkcol2s(b,d));}
     331             : INLINE GEN
     332    50564549 : mkmat22(GEN a, GEN b, GEN c, GEN d) { retmkmat2(mkcol2(a,c),mkcol2(b,d)); }
     333             : 
     334             : /* pol */
     335             : INLINE GEN
     336     2688470 : pol_x(long v) {
     337     2688470 :   GEN p = cgetg(4, t_POL);
     338     2688471 :   p[1] = evalsigne(1)|evalvarn(v);
     339     2688471 :   gel(p,2) = gen_0;
     340     2688471 :   gel(p,3) = gen_1; return p;
     341             : }
     342             : /* x^n, assume n >= 0 */
     343             : INLINE GEN
     344     2222567 : pol_xn(long n, long v) {
     345     2222567 :   long i, a = n+2;
     346     2222567 :   GEN p = cgetg(a+1, t_POL);
     347     2222567 :   p[1] = evalsigne(1)|evalvarn(v);
     348     5327733 :   for (i = 2; i < a; i++) gel(p,i) = gen_0;
     349     2222567 :   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     4465952 : pol_1(long v) {
     369     4465952 :   GEN p = cgetg(3, t_POL);
     370     4465948 :   p[1] = evalsigne(1)|evalvarn(v);
     371     4465948 :   gel(p,2) = gen_1; return p;
     372             : }
     373             : INLINE GEN
     374    35201371 : pol_0(long v)
     375             : {
     376    35201371 :   GEN x = cgetg(2,t_POL);
     377    35201369 :   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   231184229 : 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    37239813 : const_col(long n, GEN x) { retconst_col(n, x); }
     393             : INLINE GEN
     394    18633312 : const_vecsmall(long n, long c)
     395             : {
     396             :   long i;
     397    18633312 :   GEN V = cgetg(n+1,t_VECSMALL);
     398   750722957 :   for(i=1;i<=n;i++) V[i] = c;
     399    18633872 :   return V;
     400             : }
     401             : 
     402             : /***   ZERO   ***/
     403             : /* O(p^e) */
     404             : INLINE GEN
     405      846304 : zeropadic(GEN p, long e)
     406             : {
     407      846304 :   GEN y = cgetg(5,t_PADIC);
     408      846291 :   gel(y,4) = gen_0;
     409      846291 :   gel(y,3) = gen_1;
     410      846291 :   gel(y,2) = icopy(p);
     411      846253 :   y[1] = evalvalp(e) | _evalprecp(0);
     412      846239 :   return y;
     413             : }
     414             : INLINE GEN
     415       10338 : zeropadic_shallow(GEN p, long e)
     416             : {
     417       10338 :   GEN y = cgetg(5,t_PADIC);
     418       10338 :   gel(y,4) = gen_0;
     419       10338 :   gel(y,3) = gen_1;
     420       10338 :   gel(y,2) = p;
     421       10338 :   y[1] = evalvalp(e) | _evalprecp(0);
     422       10338 :   return y;
     423             : }
     424             : /* O(pol_x(v)^e) */
     425             : INLINE GEN
     426      138712 : zeroser(long v, long e)
     427             : {
     428      138712 :   GEN x = cgetg(2, t_SER);
     429      138712 :   x[1] = evalvalser(e) | evalvarn(v); return x;
     430             : }
     431             : INLINE int
     432    10106625 : ser_isexactzero(GEN x)
     433             : {
     434    10106625 :   if (!signe(x)) switch(lg(x))
     435             :   {
     436      132769 :     case 2: return 1;
     437        4641 :     case 3: return isexactzero(gel(x,2));
     438             :   }
     439     9969215 :   return 0;
     440             : }
     441             : /* 0 * pol_x(v) */
     442             : INLINE GEN
     443    14735435 : zeropol(long v) { return pol_0(v); }
     444             : /* vector(n) */
     445             : INLINE GEN
     446   118662131 : zerocol(long n)
     447             : {
     448   118662131 :   GEN y = cgetg(n+1,t_COL);
     449   795173968 :   long i; for (i=1; i<=n; i++) gel(y,i) = gen_0;
     450   118663102 :   return y;
     451             : }
     452             : /* vectorv(n) */
     453             : INLINE GEN
     454    25907320 : zerovec(long n)
     455             : {
     456    25907320 :   GEN y = cgetg(n+1,t_VEC);
     457   344835997 :   long i; for (i=1; i<=n; i++) gel(y,i) = gen_0;
     458    25907317 :   return y;
     459             : }
     460             : /* matrix(m, n) */
     461             : INLINE GEN
     462       90518 : zeromat(long m, long n)
     463             : {
     464       90518 :   GEN y = cgetg(n+1,t_MAT);
     465       90517 :   GEN v = zerocol(m);
     466      308432 :   long i; for (i=1; i<=n; i++) gel(y,i) = v;
     467       90517 :   return y;
     468             : }
     469             : /* = zero_zx, sv is a evalvarn()*/
     470             : INLINE GEN
     471     1334600 : zero_Flx(long sv) { return pol0_Flx(sv); }
     472             : INLINE GEN
     473    60642645 : zero_Flv(long n)
     474             : {
     475    60642645 :   GEN y = cgetg(n+1,t_VECSMALL);
     476   961750812 :   long i; for (i=1; i<=n; i++) y[i] = 0;
     477    60642837 :   return y;
     478             : }
     479             : /* matrix(m, n) */
     480             : INLINE GEN
     481     2684194 : zero_Flm(long m, long n)
     482             : {
     483     2684194 :   GEN y = cgetg(n+1,t_MAT);
     484     2684185 :   GEN v = zero_Flv(m);
     485    17062238 :   long i; for (i=1; i<=n; i++) gel(y,i) = v;
     486     2684176 :   return y;
     487             : }
     488             : /* matrix(m, n) */
     489             : INLINE GEN
     490      231823 : zero_Flm_copy(long m, long n)
     491             : {
     492      231823 :   GEN y = cgetg(n+1,t_MAT);
     493     2396214 :   long i; for (i=1; i<=n; i++) gel(y,i) = zero_Flv(m);
     494      231814 :   return y;
     495             : }
     496             : 
     497             : INLINE GEN
     498     3516119 : zero_F2v(long m)
     499             : {
     500     3516119 :   long l = nbits2nlong(m);
     501     3516096 :   GEN v  = zero_Flv(l+1);
     502     3516065 :   v[1] = m;
     503     3516065 :   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      833994 : zero_F2m_copy(long m, long n)
     520             : {
     521             :   long i;
     522      833994 :   GEN M = cgetg(n+1, t_MAT);
     523     1982845 :   for (i = 1; i <= n; i++)
     524     1148855 :     gel(M,i)= zero_F2v(m);
     525      833990 :   return M;
     526             : }
     527             : 
     528             : /* matrix(m, n) */
     529             : INLINE GEN
     530    13877608 : zeromatcopy(long m, long n)
     531             : {
     532    13877608 :   GEN y = cgetg(n+1,t_MAT);
     533    70221811 :   long i; for (i=1; i<=n; i++) gel(y,i) = zerocol(m);
     534    13877606 :   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     5624777 : col_ei(long n, long i) { GEN e = zerocol(n); gel(e,i) = gen_1; return e; }
     550             : INLINE GEN
     551     1699625 : 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       50058 : vecsmall_ei(long n, long i) { GEN e = zero_zv(n); e[i] = 1; return e; }
     556             : INLINE GEN
     557     1243362 : Rg_col_ei(GEN x, long n, long i) { GEN e = zerocol(n); gel(e,i) = x; return e; }
     558             : 
     559             : INLINE GEN
     560    19514302 : shallowcopy(GEN x)
     561    19514302 : { return typ(x) == t_MAT ? RgM_shallowcopy(x): leafcopy(x); }
     562             : 
     563             : /* routines for naive growarrays */
     564             : INLINE GEN
     565    11707681 : vectrunc_init(long l)
     566             : {
     567    11707681 :   GEN z = new_chunk(l);
     568    11707488 :   z[0] = evaltyp(t_VEC) | _evallg(1); return z;
     569             : }
     570             : INLINE GEN
     571      391664 : coltrunc_init(long l)
     572             : {
     573      391664 :   GEN z = new_chunk(l);
     574      391664 :   z[0] = evaltyp(t_COL) | _evallg(1); return z;
     575             : }
     576             : INLINE void
     577   310841437 : lg_increase(GEN x) { x[0]++; }
     578             : INLINE void
     579    15231019 : 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   187162863 : vecsmalltrunc_init(long l)
     590             : {
     591   187162863 :   GEN z = new_chunk(l);
     592   187168795 :   z[0] = evaltyp(t_VECSMALL) | _evallg(1); return z;
     593             : }
     594             : INLINE void
     595    99889806 : 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     2641954 : hash_str(const char *str)
     604             : {
     605     2641954 :   ulong hash = 5381UL, c;
     606    27364056 :   while ( (c = (ulong)*str++) )
     607    24722102 :     hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
     608     2641954 :   return hash;
     609             : }
     610             : INLINE ulong
     611    18160714 : hash_str_len(const char *str, long len)
     612             : {
     613    18160714 :   ulong hash = 5381UL;
     614             :   long i;
     615   164924412 :   for (i = 0; i < len; i++)
     616             :   {
     617   146763698 :     ulong c = (ulong)*str++;
     618   146763698 :     hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
     619             :   }
     620    18160714 :   return hash;
     621             : }
     622             : 
     623             : /*******************************************************************/
     624             : /*                                                                 */
     625             : /*                        VEC / COL / VECSMALL                     */
     626             : /*                                                                 */
     627             : /*******************************************************************/
     628             : /* shallow*/
     629             : INLINE GEN
     630       11543 : vec_shorten(GEN v, long n)
     631             : {
     632       11543 :   GEN V = cgetg(n+1, t_VEC);
     633             :   long i;
     634       12999 :   for(i = 1; i <= n; i++) gel(V,i) = gel(v,i);
     635       11543 :   return V;
     636             : }
     637             : /* shallow*/
     638             : INLINE GEN
     639       18927 : vec_lengthen(GEN v, long n)
     640             : {
     641       18927 :   GEN V = cgetg(n+1, t_VEC);
     642       18927 :   long i, l = lg(v);
     643     1935611 :   for(i = 1; i < l; i++) gel(V,i) = gel(v,i);
     644       18927 :   return V;
     645             : }
     646             : /* shallow*/
     647             : INLINE GEN
     648     3426733 : vec_append(GEN V, GEN s)
     649             : {
     650     3426733 :   long i, l2 = lg(V);
     651     3426733 :   GEN res = cgetg(l2+1, typ(V));
     652    10712719 :   for (i = 1; i < l2; i++) gel(res, i) = gel(V,i);
     653     3426730 :   gel(res,l2) = s; return res;
     654             : }
     655             : /* shallow*/
     656             : INLINE GEN
     657      300755 : vec_prepend(GEN v, GEN s)
     658             : {
     659      300755 :   long i, l = lg(v);
     660      300755 :   GEN w = cgetg(l+1, typ(v));
     661      300755 :   gel(w,1) = s;
     662      768487 :   for (i = 2; i <= l; i++) gel(w,i) = gel(v,i-1);
     663      300755 :   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       72477 : vecsmall_shorten(GEN v, long n)
     675             : {
     676       72477 :   GEN V = cgetg(n+1,t_VECSMALL);
     677             :   long i;
     678      889590 :   for(i = 1; i <= n; i++) V[i] = v[i];
     679       72477 :   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     4013249 : vec_to_vecsmall(GEN x)
     692    18852219 : { pari_APPLY_long(itos(gel(x,i))) }
     693             : INLINE GEN
     694      509052 : vecsmall_to_vec(GEN x)
     695     7065140 : { pari_APPLY_type(t_VEC, stoi(x[i])) }
     696             : INLINE GEN
     697        3262 : vecsmall_to_vec_inplace(GEN z)
     698             : {
     699        3262 :   long i, l = lg(z);
     700       79436 :   for (i=1; i<l; i++) gel(z,i) = stoi(z[i]);
     701        3262 :   settyp(z, t_VEC); return z;
     702             : }
     703             : INLINE GEN
     704     7687569 : vecsmall_to_col(GEN x)
     705    59425729 : { pari_APPLY_type(t_COL, stoi(x[i])) }
     706             : 
     707             : INLINE int
     708     7073318 : vecsmall_lexcmp(GEN x, GEN y)
     709             : {
     710             :   long lx,ly,l,i;
     711     7073318 :   lx = lg(x);
     712     7073318 :   ly = lg(y); l = minss(lx,ly);
     713    30509250 :   for (i=1; i<l; i++)
     714    28882386 :     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      184938 : vecsmall_prepend(GEN V, long s)
     731             : {
     732      184938 :   long i, l2 = lg(V);
     733      184938 :   GEN res = cgetg(l2+1, typ(V));
     734      184938 :   res[1] = s;
     735      619564 :   for (i = 2; i <= l2; ++i) res[i] = V[i - 1];
     736      184938 :   return res;
     737             : }
     738             : 
     739             : INLINE GEN
     740     4061511 : vecsmall_append(GEN V, long s)
     741             : {
     742     4061511 :   long i, l2 = lg(V);
     743     4061511 :   GEN res = cgetg(l2+1, t_VECSMALL);
     744     5979279 :   for (i = 1; i < l2; ++i) res[i] = V[i];
     745     4061510 :   res[l2] = s; return res;
     746             : }
     747             : 
     748             : INLINE GEN
     749     1481011 : vecsmall_concat(GEN u, GEN v)
     750             : {
     751     1481011 :   long i, l1 = lg(u)-1, l2 = lg(v)-1;
     752     1481011 :   GEN res = cgetg(l1+l2+1, t_VECSMALL);
     753    11746401 :   for (i = 1; i <= l1; ++i) res[i]    = u[i];
     754    15034463 :   for (i = 1; i <= l2; ++i) res[i+l1] = v[i];
     755     1481010 :   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         125 :   for (i = 1; i < l; i++)
     774          82 :     if (v[i] == x) return i;
     775          43 :   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      927800 : vecsmall_max(GEN x)
     797             : {
     798      927800 :   long i, t = x[1], lx = lg(x);
     799     2547828 :   for (i=2; i<lx; i++)
     800     1620028 :     if (x[i] > t) t = x[i];
     801      927800 :   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    24490750 : ZV_isscalar(GEN x)
     824             : {
     825    24490750 :   long l = lg(x);
     826    56020205 :   while (--l > 1)
     827    55597021 :     if (signe(gel(x, l))) return 0;
     828      423184 :   return 1;
     829             : }
     830             : INLINE int
     831    63373041 : QV_isscalar(GEN x)
     832             : {
     833    63373041 :   long lx = lg(x),i;
     834    79233843 :   for (i=2; i<lx; i++)
     835    75349739 :     if (!isintzero(gel(x, i))) return 0;
     836     3884104 :   return 1;
     837             : }
     838             : INLINE int
     839     1140309 : RgV_isscalar(GEN x)
     840             : {
     841     1140309 :   long lx = lg(x),i;
     842     1166497 :   for (i=2; i<lx; i++)
     843     1162782 :     if (!gequal0(gel(x, i))) return 0;
     844        3715 :   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    26749180 : 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       66834 : RgX_is_rational(GEN x)
     861             : {
     862             :   long i;
     863      305358 :   for (i = lg(x)-1; i > 1; i--)
     864      289988 :     if (!is_rational_t(typ(gel(x,i)))) return 0;
     865       15370 :   return 1;
     866             : }
     867             : INLINE int
     868    14593269 : RgX_is_ZX(GEN x)
     869             : {
     870             :   long i;
     871    60941074 :   for (i = lg(x)-1; i > 1; i--)
     872    46409717 :     if (typ(gel(x,i)) != t_INT) return 0;
     873    14531357 :   return 1;
     874             : }
     875             : INLINE int
     876      362074 : RgX_is_QX(GEN x)
     877             : {
     878      362074 :   long k = lg(x)-1;
     879     1378857 :   for ( ; k>1; k--)
     880     1017070 :     if (!is_rational_t(typ(gel(x,k)))) return 0;
     881      361787 :   return 1;
     882             : }
     883             : INLINE int
     884     2943644 : RgX_is_monomial(GEN x)
     885             : {
     886             :   long i;
     887     2943644 :   if (!signe(x)) return 0;
     888     6920509 :   for (i=lg(x)-2; i>1; i--)
     889     4551704 :     if (!isexactzero(gel(x,i))) return 0;
     890     2368805 :   return 1;
     891             : }
     892             : INLINE int
     893    31331739 : RgV_is_ZV(GEN x)
     894             : {
     895             :   long i;
     896   124570338 :   for (i = lg(x)-1; i > 0; i--)
     897    93270295 :     if (typ(gel(x,i)) != t_INT) return 0;
     898    31300043 :   return 1;
     899             : }
     900             : INLINE int
     901      139425 : RgV_is_QV(GEN x)
     902             : {
     903             :   long i;
     904      615851 :   for (i = lg(x)-1; i > 0; i--)
     905      479380 :     if (!is_rational_t(typ(gel(x,i)))) return 0;
     906      136471 :   return 1;
     907             : }
     908             : INLINE long
     909      109073 : RgV_isin_i(GEN v, GEN x, long n)
     910             : {
     911             :   long i;
     912     1031386 :   for (i = 1; i <= n; i++)
     913     1025597 :     if (gequal(gel(v,i), x)) return i;
     914        5789 :   return 0;
     915             : }
     916             : INLINE long
     917      109073 : 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   694296704 : pari_stack_base(pari_stack *s) { return s->data; }
     926             : 
     927             : INLINE void
     928     5519593 : pari_stack_init(pari_stack *s, size_t size, void **data)
     929             : {
     930     5519593 :   s->data = data;
     931     5519593 :   *data = NULL;
     932     5519593 :   s->n = 0;
     933     5519593 :   s->alloc = 0;
     934     5519593 :   s->size = size;
     935     5519593 : }
     936             : 
     937             : INLINE void
     938   689234081 : pari_stack_alloc(pari_stack *s, long nb)
     939             : {
     940   689234081 :   void **sdat = pari_stack_base(s);
     941   689233116 :   long alloc = s->alloc;
     942   689233116 :   if (s->n+nb <= alloc) return;
     943     2060769 :   if (!alloc)
     944     1963927 :     alloc = nb;
     945             :   else
     946             :   {
     947      196374 :     while (s->n+nb > alloc) alloc <<= 1;
     948             :   }
     949     2060769 :   pari_realloc_ip(sdat,alloc*s->size);
     950     2060850 :   s->alloc = alloc;
     951             : }
     952             : 
     953             : INLINE long
     954   596383699 : pari_stack_new(pari_stack *s) { pari_stack_alloc(s, 1); return s->n++; }
     955             : 
     956             : INLINE void
     957     5061644 : pari_stack_delete(pari_stack *s)
     958             : {
     959     5061644 :   void **sdat = pari_stack_base(s);
     960     5047711 :   if (*sdat) pari_free(*sdat);
     961     5085812 : }
     962             : 
     963             : INLINE void
     964        5704 : pari_stack_pushp(pari_stack *s, void *u)
     965             : {
     966        5704 :   long n = pari_stack_new(s);
     967        5704 :   void **sdat =(void**) *pari_stack_base(s);
     968        5704 :   sdat[n] = u;
     969        5704 : }
     970             : 
     971             : /*******************************************************************/
     972             : /*                                                                 */
     973             : /*                            EXTRACT                              */
     974             : /*                                                                 */
     975             : /*******************************************************************/
     976             : INLINE GEN
     977   589959187 : vecslice(GEN A, long y1, long y2)
     978             : {
     979   589959187 :   long i,lB = y2 - y1 + 2;
     980   589959187 :   GEN B = cgetg(lB, typ(A));
     981  2625238000 :   for (i=1; i<lB; i++) B[i] = A[y1-1+i];
     982   589954686 :   return B;
     983             : }
     984             : INLINE GEN
     985     2422708 : vecslicepermute(GEN A, GEN p, long y1, long y2)
     986             : {
     987     2422708 :   long i,lB = y2 - y1 + 2;
     988     2422708 :   GEN B = cgetg(lB, typ(A));
     989    28186695 :   for (i=1; i<lB; i++) B[i] = A[p[y1-1+i]];
     990     2422708 :   return B;
     991             : }
     992             : /* rowslice(rowpermute(A,p), x1, x2) */
     993             : INLINE GEN
     994      129588 : rowslicepermute(GEN x, GEN p, long j1, long j2)
     995      576746 : { pari_APPLY_same(vecslicepermute(gel(x,i),p,j1,j2)) }
     996             : 
     997             : INLINE GEN
     998    75621171 : rowslice(GEN x, long j1, long j2)
     999   605418933 : { pari_APPLY_same(vecslice(gel(x,i), j1, j2)) }
    1000             : 
    1001             : INLINE GEN
    1002    16017055 : matslice(GEN A, long x1, long x2, long y1, long y2)
    1003    16017055 : { return rowslice(vecslice(A, y1, y2), x1, x2); }
    1004             : 
    1005             : /* shallow, remove coeff of index j */
    1006             : INLINE GEN
    1007         210 : rowsplice(GEN x, long j)
    1008        1036 : { pari_APPLY_same(vecsplice(gel(x,i), j)) }
    1009             : 
    1010             : /* shallow, remove coeff of index j */
    1011             : INLINE GEN
    1012      354175 : vecsplice(GEN a, long j)
    1013             : {
    1014      354175 :   long i, k, l = lg(a);
    1015             :   GEN b;
    1016      354175 :   if (l == 1) pari_err(e_MISC, "incorrect component in vecsplice");
    1017      354175 :   b = cgetg(l-1, typ(a));
    1018     1499155 :   for (i = k = 1; i < l; i++)
    1019     1144980 :     if (i != j) gel(b, k++) = gel(a,i);
    1020      354175 :   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      759811 : row(GEN x, long j)
    1035     6676200 : { pari_APPLY_type(t_VEC, gcoeff(x, j, i)) }
    1036             : INLINE GEN
    1037     7818316 : Flm_row(GEN x, long j)
    1038   203684536 : { 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      697018 : vecreverse(GEN A)
    1055             : {
    1056             :   long i, l;
    1057      697018 :   GEN B = cgetg_copy(A, &l);
    1058     2407741 :   for (i=1; i<l; i++) gel(B, i) = gel(A, l-i);
    1059      697018 :   return B;
    1060             : }
    1061             : 
    1062             : INLINE GEN
    1063        3003 : vecsmall_reverse(GEN A)
    1064             : {
    1065             :   long i, l;
    1066        3003 :   GEN B = cgetg_copy(A, &l);
    1067       12523 :   for (i=1; i<l; i++) B[i] = A[l-i];
    1068        3003 :   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    74199766 : vecsmallpermute(GEN A, GEN p) { return perm_mul(A, p); }
    1085             : 
    1086             : INLINE GEN
    1087    18756337 : vecpermute(GEN A, GEN x)
    1088   106034187 : { pari_APPLY_type(typ(A), gel(A, x[i])) }
    1089             : 
    1090             : INLINE GEN
    1091     6925660 : veclast(GEN A) { return gel(A, lg(A)-1); }
    1092             : 
    1093             : INLINE GEN
    1094    13854979 : rowpermute(GEN x, GEN p)
    1095    95881382 : { 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     2762757 : identity_zv(long n)
    1105             : {
    1106     2762757 :   GEN v = cgetg(n+1, t_VECSMALL);
    1107             :   long i;
    1108    30108542 :   for (i = 1; i <= n; i++) v[i] = i;
    1109     2762744 :   return v;
    1110             : }
    1111             : INLINE GEN
    1112        4249 : identity_ZV(long n)
    1113             : {
    1114        4249 :   GEN v = cgetg(n+1, t_VEC);
    1115             :   long i;
    1116       51569 :   for (i = 1; i <= n; i++) gel(v,i) = utoipos(i);
    1117        4249 :   return v;
    1118             : }
    1119             : /* identity permutation */
    1120             : INLINE GEN
    1121     2738421 : identity_perm(long n) { return identity_zv(n); }
    1122             : 
    1123             : /* assume d <= n */
    1124             : INLINE GEN
    1125       99547 : cyclic_perm(long n, long d)
    1126             : {
    1127       99547 :   GEN perm = cgetg(n+1, t_VECSMALL);
    1128             :   long i;
    1129      507640 :   for (i = 1; i <= n-d; i++) perm[i] = i+d;
    1130      226338 :   for (     ; i <= n;   i++) perm[i] = i-n+d;
    1131       99547 :   return perm;
    1132             : }
    1133             : 
    1134             : /* Multiply (compose) two permutations */
    1135             : INLINE GEN
    1136    76191769 : perm_mul(GEN s, GEN x)
    1137   948599279 : { 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     2671871 : perm_inv(GEN x)
    1146             : {
    1147             :   long i, lx;
    1148     2671871 :   GEN y = cgetg_copy(x, &lx);
    1149    34488740 :   for (i=1; i<lx; i++) y[ x[i] ] = i;
    1150     2671871 :   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   461933651 : pari_free(void *pointer)
    1164             : {
    1165   461933651 :   BLOCK_SIGINT_START;
    1166   462004787 :   free(pointer);
    1167   462004787 :   BLOCK_SIGINT_END;
    1168   461999568 : }
    1169             : INLINE void*
    1170   692227855 : pari_malloc(size_t size)
    1171             : {
    1172   692227855 :   if (size)
    1173             :   {
    1174             :     char *tmp;
    1175   692230448 :     BLOCK_SIGINT_START;
    1176   692299751 :     tmp = (char*)malloc(size);
    1177   692299751 :     BLOCK_SIGINT_END;
    1178   692303248 :     if (!tmp) pari_err(e_MEM);
    1179   692307365 :     return tmp;
    1180             :   }
    1181           0 :   return NULL;
    1182             : }
    1183             : INLINE void*
    1184        1841 : pari_realloc(void *pointer, size_t size)
    1185             : {
    1186             :   char *tmp;
    1187             : 
    1188        1841 :   BLOCK_SIGINT_START;
    1189        1841 :   if (!pointer) tmp = (char *) malloc(size);
    1190        1841 :   else tmp = (char *) realloc(pointer,size);
    1191        1841 :   BLOCK_SIGINT_END;
    1192        1841 :   if (!tmp) pari_err(e_MEM);
    1193        1841 :   return tmp;
    1194             : }
    1195             : INLINE void
    1196     2063074 : pari_realloc_ip(void **pointer, size_t size)
    1197             : {
    1198             :   char *tmp;
    1199     2063074 :   BLOCK_SIGINT_START;
    1200     2063036 :   if (!*pointer) tmp = (char *) malloc(size);
    1201       99481 :   else tmp = (char *) realloc(*pointer,size);
    1202     2063036 :   if (!tmp) pari_err(e_MEM);
    1203     2063036 :   *pointer = tmp;
    1204     2063036 :   BLOCK_SIGINT_END;
    1205     2062543 : }
    1206             : 
    1207             : INLINE void*
    1208       45536 : pari_calloc(size_t size)
    1209             : {
    1210       45536 :   void *t = pari_malloc(size);
    1211       45536 :   memset(t, 0, size); return t;
    1212             : }
    1213             : INLINE GEN
    1214        8171 : cgetalloc(size_t l, long t)
    1215             : { /* evallg may raise e_OVERFLOW, which would leak x */
    1216        8171 :   ulong x0 = evaltyp(t) | evallg(l);
    1217        8171 :   GEN x = (GEN)pari_malloc(l * sizeof(long));
    1218        8171 :   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  7655899242 : icopy_avma(GEN x, pari_sp av)
    1229             : {
    1230  7655899242 :   long i = lgefint(x), lx = i;
    1231  7655899242 :   GEN y = ((GEN)av) - i;
    1232 52226879059 :   while (--i > 0) y[i] = x[i];
    1233  7655899242 :   y[0] = evaltyp(t_INT)|evallg(lx);
    1234  7659153909 :   return y;
    1235             : }
    1236             : /* copy leaf x as if we had set_avma(av) */
    1237             : INLINE GEN
    1238   531395960 : leafcopy_avma(GEN x, pari_sp av)
    1239             : {
    1240   531395960 :   long i = lg(x);
    1241   531395960 :   GEN y = ((GEN)av) - i;
    1242  2940261663 :   while (--i > 0) y[i] = x[i];
    1243   531395960 :   y[0] = x[0] & (~CLONEBIT);
    1244   531395960 :   return y;
    1245             : }
    1246             : INLINE GEN
    1247  1063519567 : gerepileuptoleaf(pari_sp av, GEN x)
    1248             : {
    1249             :   long lx;
    1250             :   GEN q;
    1251             : 
    1252  1063519567 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1253  1062313881 :   lx = lg(x);
    1254  1062313881 :   q = ((GEN)av) - lx;
    1255  1062313881 :   set_avma((pari_sp)q);
    1256 10799540408 :   while (--lx >= 0) q[lx] = x[lx];
    1257  1061926266 :   return q;
    1258             : }
    1259             : INLINE GEN
    1260  3876773709 : gerepileuptoint(pari_sp av, GEN x)
    1261             : {
    1262  3876773709 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1263  3464721009 :   set_avma((pari_sp)icopy_avma(x, av));
    1264  3468421512 :   return (GEN)avma;
    1265             : }
    1266             : INLINE GEN
    1267  1777258689 : gerepileupto(pari_sp av, GEN x)
    1268             : {
    1269  1777258689 :   if (!isonstack(x) || (GEN)av<=x) return gc_const(av,x);
    1270  1604046669 :   switch(typ(x))
    1271             :   { /* non-default = !is_recursive_t(tq) */
    1272   473081641 :     case t_INT: return gerepileuptoint(av, x);
    1273   333302929 :     case t_REAL:
    1274             :     case t_STR:
    1275   333302929 :     case t_VECSMALL: return gerepileuptoleaf(av,x);
    1276   797662546 :     default:
    1277             :       /* NB: x+i --> ((long)x) + i*sizeof(long) */
    1278   797662546 :       return gerepile(av, (pari_sp) (x+lg(x)), x);
    1279             :   }
    1280             : }
    1281             : 
    1282             : /* gerepileupto(av, gcopy(x)) */
    1283             : INLINE GEN
    1284   204204742 : gerepilecopy(pari_sp av, GEN x)
    1285             : {
    1286   204204742 :   if (is_recursive_t(typ(x)))
    1287             :   {
    1288   194226199 :     GENbin *p = copy_bin(x);
    1289   194244833 :     set_avma(av); return bin_copy(p);
    1290             :   }
    1291             :   else
    1292             :   {
    1293     9977914 :     set_avma(av);
    1294     9978926 :     if (x < (GEN)av) {
    1295     8052957 :       if (x < (GEN)pari_mainstack->bot) new_chunk(lg(x));
    1296     8052963 :       x = leafcopy_avma(x, av);
    1297     8052992 :       set_avma((pari_sp)x);
    1298             :     } else
    1299     1925970 :       x = leafcopy(x);
    1300     9978960 :     return x;
    1301             :   }
    1302             : }
    1303             : 
    1304             : INLINE void
    1305    49124522 : guncloneNULL(GEN x) { if (x) gunclone(x); }
    1306             : INLINE void
    1307     1304230 : 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      983987 : gerepilemany(pari_sp av, GEN* gptr[], int n)
    1314             : {
    1315             :   int i;
    1316     3909461 :   for (i=0; i<n; i++) *gptr[i] = (GEN)copy_bin(*gptr[i]);
    1317      983872 :   set_avma(av);
    1318     3910017 :   for (i=0; i<n; i++) *gptr[i] = bin_copy((GENbin*)*gptr[i]);
    1319      984111 : }
    1320             : 
    1321             : INLINE void
    1322    19532438 : gerepileall(pari_sp av, int n, ...)
    1323             : {
    1324             :   int i;
    1325    19532438 :   va_list a; va_start(a, n);
    1326    19532438 :   if (n < 10)
    1327             :   {
    1328             :     GEN *gptr[10];
    1329    59235594 :     for (i=0; i<n; i++)
    1330    39702332 :     { gptr[i] = va_arg(a,GEN*); *gptr[i] = (GEN)copy_bin(*gptr[i]); }
    1331    19533262 :     set_avma(av);
    1332    59236819 :     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    19533828 :   va_end(a);
    1345    19533828 : }
    1346             : 
    1347             : /* assume 1 <= n < 10 */
    1348             : INLINE GEN
    1349    79464477 : gc_all(pari_sp av, int n, ...)
    1350             : {
    1351             :   int i;
    1352             :   GEN *v[10];
    1353    79464477 :   va_list a; va_start(a, n);
    1354   267509349 :   for (i=0; i<n; i++) { v[i] = va_arg(a,GEN*); *v[i] = (GEN)copy_bin(*v[i]); }
    1355    79464749 :   set_avma(av);
    1356   267510021 :   for (i=0; i<n; i++) *v[i] = bin_copy((GENbin*)*v[i]);
    1357    79464849 :   return *v[0];
    1358             : }
    1359             : 
    1360             : INLINE void
    1361     2185666 : gerepilecoeffs(pari_sp av, GEN x, int n)
    1362             : {
    1363             :   int i;
    1364    26040756 :   for (i=0; i<n; i++) gel(x,i) = (GEN)copy_bin(gel(x,i));
    1365     2186171 :   set_avma(av);
    1366    26041999 :   for (i=0; i<n; i++) gel(x,i) = bin_copy((GENbin*)x[i]);
    1367     2185834 : }
    1368             : 
    1369             : /* p from copy_bin. Copy p->x back to stack, then destroy p */
    1370             : INLINE GEN
    1371   448814392 : bin_copy(GENbin *p)
    1372             : {
    1373             :   GEN x, y, base;
    1374             :   long dx, len;
    1375             : 
    1376   448814392 :   x   = p->x; if (!x) { pari_free(p); return gen_0; }
    1377   422754552 :   len = p->len;
    1378   422754552 :   base= p->base; dx = x - base;
    1379   422754552 :   y = (GEN)memcpy((void*)new_chunk(len), (void*)GENbinbase(p), len*sizeof(long));
    1380   422747867 :   y += dx;
    1381   422747867 :   p->rebase(y, ((ulong)y-(ulong)x));
    1382   422747592 :   pari_free(p); return y;
    1383             : }
    1384             : 
    1385             : INLINE GEN
    1386   871566479 : GENbinbase(GENbin *p) { return (GEN)(p + 1); }
    1387             : 
    1388             : INLINE void
    1389   117841113 : cgiv(GEN x)
    1390             : {
    1391   117841113 :   pari_sp av = (pari_sp)(x+lg(x));
    1392   117841113 :   if (isonstack((GEN)av)) set_avma(av);
    1393   117859091 : }
    1394             : 
    1395             : INLINE void
    1396     1847609 : killblock(GEN x) { gunclone(x); }
    1397             : 
    1398             : INLINE int
    1399   290355053 : 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    17897777 : cxcompotor(GEN z, long prec)
    1409             : {
    1410    17897777 :   switch(typ(z))
    1411             :   {
    1412    11752620 :     case t_INT:  return itor(z, prec);
    1413      293104 :     case t_FRAC: return fractor(z, prec);
    1414     5852276 :     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     8933007 : cxtofp(GEN x, long prec)
    1421     8933007 : { retmkcomplex(cxcompotor(gel(x,1),prec), cxcompotor(gel(x,2),prec)); }
    1422             : 
    1423             : INLINE GEN
    1424      384524 : cxtoreal(GEN q)
    1425      384524 : { return (typ(q) == t_COMPLEX && gequal0(gel(q,2)))? gel(q,1): q; }
    1426             : 
    1427             : INLINE double
    1428    60250107 : gtodouble(GEN x)
    1429             : {
    1430    60250107 :   if (typ(x)!=t_REAL) {
    1431     8155991 :     pari_sp av = avma;
    1432     8155991 :     x = gtofp(x, DEFAULTPREC);
    1433     8155305 :     if (typ(x)!=t_REAL) pari_err_TYPE("gtodouble [t_REAL expected]", x);
    1434     8155305 :     set_avma(av);
    1435             :   }
    1436    60249311 :   return rtodbl(x);
    1437             : }
    1438             : 
    1439             : INLINE int
    1440     2713357 : gisdouble(GEN x, double *g)
    1441             : {
    1442     2713357 :   if (typ(x)!=t_REAL) {
    1443       56052 :     pari_sp av = avma;
    1444       56052 :     x = gtofp(x, DEFAULTPREC);
    1445       56051 :     if (typ(x)!=t_REAL) pari_err_TYPE("gisdouble [t_REAL expected]", x);
    1446       56051 :     set_avma(av);
    1447             :   }
    1448     2713358 :   if (expo(x) >= 0x3ff) return 0;
    1449     2713358 :   *g = rtodbl(x); return 1;
    1450             : }
    1451             : 
    1452             : INLINE long
    1453    85757600 : gtos(GEN x) {
    1454    85757600 :   if (typ(x) != t_INT) pari_err_TYPE("gtos [integer expected]",x);
    1455    85757586 :   return itos(x);
    1456             : }
    1457             : 
    1458             : INLINE ulong
    1459      107431 : gtou(GEN x) {
    1460      107431 :   if (typ(x) != t_INT || signe(x)<0)
    1461           7 :     pari_err_TYPE("gtou [integer >=0 expected]",x);
    1462      107425 :   return itou(x);
    1463             : }
    1464             : 
    1465             : INLINE GEN
    1466    43987753 : absfrac(GEN x)
    1467             : {
    1468    43987753 :   GEN y = cgetg(3, t_FRAC);
    1469    43987784 :   gel(y,1) = absi(gel(x,1));
    1470    43987819 :   gel(y,2) = icopy(gel(x,2)); return y;
    1471             : }
    1472             : INLINE GEN
    1473       46738 : absfrac_shallow(GEN x)
    1474       46738 : { return signe(gel(x,1))>0? x: mkfrac(negi(gel(x,1)), gel(x,2)); }
    1475             : INLINE GEN
    1476     7513969 : Q_abs(GEN x) { return (typ(x) == t_INT)? absi(x): absfrac(x); }
    1477             : INLINE GEN
    1478      169271 : Q_abs_shallow(GEN x)
    1479      169271 : { 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   250429985 : gtofp(GEN z, long prec)
    1490             : {
    1491   250429985 :   switch(typ(z))
    1492             :   {
    1493   211813345 :     case t_INT:  return itor(z, prec);
    1494     4097202 :     case t_FRAC: return fractor(z, prec);
    1495    25846618 :     case t_REAL: return rtor(z, prec);
    1496     8680274 :     case t_COMPLEX: {
    1497     8680274 :       GEN a = gel(z,1), b = gel(z,2);
    1498     8680274 :       if (isintzero(b)) return cxcompotor(a, prec);
    1499     8680277 :       if (isintzero(a)) {
    1500        9112 :         GEN y = cgetg(3, t_COMPLEX);
    1501        9112 :         b = cxcompotor(b, prec);
    1502        9112 :         gel(y,1) = real_0_bit(expo(b) - prec);
    1503        9112 :         gel(y,2) = b; return y;
    1504             :       }
    1505     8671132 :       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     7088488 : RgX_gtofp(GEN x, long prec)
    1530             : {
    1531             :   long l;
    1532     7088488 :   GEN y = cgetg_copy(x, &l);
    1533    36968821 :   while (--l > 1) gel(y,l) = gtofp(gel(x,l), prec);
    1534     7087567 :   y[1] = x[1]; return y;
    1535             : }
    1536             : INLINE GEN
    1537    33559362 : RgC_gtofp(GEN x, long prec)
    1538   215465680 : { pari_APPLY_type(t_COL, gtofp(gel(x,i), prec)) }
    1539             : 
    1540             : INLINE GEN
    1541          56 : RgV_gtofp(GEN x, long prec)
    1542        4781 : { pari_APPLY_type(t_VEC, gtofp(gel(x,i), prec)) }
    1543             : 
    1544             : INLINE GEN
    1545     8154823 : RgM_gtofp(GEN x, long prec)
    1546    41086329 : { pari_APPLY_same(RgC_gtofp(gel(x,i), prec)) }
    1547             : 
    1548             : INLINE GEN
    1549         574 : RgC_gtomp(GEN x, long prec)
    1550       23002 : { pari_APPLY_type(t_COL, gtomp(gel(x,i), prec)) }
    1551             : 
    1552             : INLINE GEN
    1553          21 : RgM_gtomp(GEN x, long prec)
    1554         595 : { pari_APPLY_same(RgC_gtomp(gel(x,i), prec)) }
    1555             : 
    1556             : INLINE GEN
    1557       60021 : RgX_fpnorml2(GEN x, long prec)
    1558             : {
    1559       60021 :   pari_sp av = avma;
    1560       60021 :   return gerepileupto(av, gnorml2(RgX_gtofp(x, prec)));
    1561             : }
    1562             : INLINE GEN
    1563      616886 : RgC_fpnorml2(GEN x, long prec)
    1564             : {
    1565      616886 :   pari_sp av = avma;
    1566      616886 :   return gerepileupto(av, gnorml2(RgC_gtofp(x, prec)));
    1567             : }
    1568             : INLINE GEN
    1569       21647 : RgM_fpnorml2(GEN x, long prec)
    1570             : {
    1571       21647 :   pari_sp av = avma;
    1572       21647 :   return gerepileupto(av, gnorml2(RgM_gtofp(x, prec)));
    1573             : }
    1574             : 
    1575             : /* y a t_REAL */
    1576             : INLINE void
    1577      220528 : affgr(GEN x, GEN y)
    1578             : {
    1579             :   pari_sp av;
    1580      220528 :   switch(typ(x)) {
    1581        5992 :     case t_INT:  affir(x,y); break;
    1582      214536 :     case t_REAL: affrr(x,y); break;
    1583           0 :     case t_FRAC: rdiviiz(gel(x,1),gel(x,2), y); break;
    1584           0 :     case t_QUAD: av = avma; affgr(quadtofp(x,realprec(y)), y); set_avma(av); break;
    1585           0 :     default: pari_err_TYPE2("=",x,y);
    1586             :   }
    1587      220528 : }
    1588             : 
    1589             : INLINE GEN
    1590      239486 : affc_fixlg(GEN x, GEN res)
    1591             : {
    1592      239486 :   if (typ(x) == t_COMPLEX)
    1593             :   {
    1594      206773 :     affrr_fixlg(gel(x,1), gel(res,1));
    1595      206773 :     affrr_fixlg(gel(x,2), gel(res,2));
    1596             :   }
    1597             :   else
    1598             :   {
    1599       32713 :     set_avma((pari_sp)(res+3));
    1600       32712 :     res = cgetr(realprec(gel(res,1)));
    1601       32712 :     affrr_fixlg(x, res);
    1602             :   }
    1603      239487 :   return res;
    1604             : }
    1605             : 
    1606             : INLINE GEN
    1607           0 : trunc_safe(GEN x) { long e; return gcvtoi(x,&e); }
    1608             : 
    1609             : /*******************************************************************/
    1610             : /*                                                                 */
    1611             : /*                          LENGTH CONVERSIONS                     */
    1612             : /*                                                                 */
    1613             : /*******************************************************************/
    1614             : INLINE long
    1615       40170 : ndec2nlong(long x) { return 1 + (long)((x)*(LOG2_10/BITS_IN_LONG)); }
    1616             : INLINE long
    1617       31914 : ndec2prec(long x) { return ndec2nlong(x) << TWOPOTBITS_IN_LONG; }
    1618             : INLINE long
    1619        8256 : ndec2nbits(long x) { return ndec2nlong(x) << TWOPOTBITS_IN_LONG; }
    1620             : /* Fast implementation of ceil(x / (8*sizeof(long))); typecast to (ulong)
    1621             :  * to avoid overflow. Faster than 1 + ((x-1)>>TWOPOTBITS_IN_LONG)) :
    1622             :  *   addl, shrl instead of subl, sarl, addl */
    1623             : INLINE long
    1624    12167372 : nbits2nlong(long x) {
    1625    12167372 :   return (long)(((ulong)x+BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1626             : }
    1627             : 
    1628             : INLINE long
    1629  1473806237 : nbits2extraprec(long x) {
    1630  1473806237 :   return (((ulong)x+BITS_IN_LONG-1)>>TWOPOTBITS_IN_LONG) << TWOPOTBITS_IN_LONG;
    1631             : }
    1632             : 
    1633             : INLINE long
    1634   185353740 : nbits2prec(long x) {
    1635   185353740 :   return (((ulong)x+BITS_IN_LONG-1)>>TWOPOTBITS_IN_LONG) << TWOPOTBITS_IN_LONG;
    1636             : }
    1637             : 
    1638             : INLINE long
    1639  4433318587 : prec2lg(long x) {
    1640  4433318587 :   return (long)(((ulong)x+3*BITS_IN_LONG-1) >> TWOPOTBITS_IN_LONG);
    1641             : }
    1642             : /* ceil(x / sizeof(long)) */
    1643             : INLINE long
    1644   119090003 : nchar2nlong(long x) {
    1645   119090003 :   return (long)(((ulong)x+sizeof(long)-1) >> (TWOPOTBITS_IN_LONG-3L));
    1646             : }
    1647             : INLINE long
    1648   104394090 : prec2nbits(long x) { return x; }
    1649             : INLINE double
    1650     3177770 : bit_accuracy_mul(long x, double y) { return (x-2) * (BITS_IN_LONG*y); }
    1651             : INLINE double
    1652      570813 : prec2nbits_mul(long x, double y) { return x * y; }
    1653             : INLINE long
    1654   141162912 : bit_prec(GEN x) { return realprec(x); }
    1655             : INLINE long
    1656  2761836560 : bit_accuracy(long x) { return (x-2) * BITS_IN_LONG; }
    1657             : INLINE long
    1658        9750 : prec2ndec(long x) { return (long)(x * LOG10_2); }
    1659             : INLINE long
    1660         214 : nbits2ndec(long x) { return prec2ndec(x); }
    1661             : INLINE long
    1662      472906 : precdbl(long x) {return x << 1;}
    1663             : INLINE long
    1664  8000199108 : divsBIL(long n) { return n >> TWOPOTBITS_IN_LONG; }
    1665             : INLINE long
    1666  7914422841 : remsBIL(long n) { return n & (BITS_IN_LONG-1); }
    1667             : 
    1668             : /*********************************************************************/
    1669             : /**                                                                 **/
    1670             : /**                      OPERATIONS MODULO m                        **/
    1671             : /**                                                                 **/
    1672             : /*********************************************************************/
    1673             : /* Assume m > 0, more efficient if 0 <= a, b < m */
    1674             : 
    1675             : INLINE GEN
    1676    85542733 : Fp_red(GEN a, GEN m) { return modii(a, m); }
    1677             : INLINE GEN
    1678   170340140 : Fp_add(GEN a, GEN b, GEN m)
    1679             : {
    1680   170340140 :   pari_sp av=avma;
    1681   170340140 :   GEN p = addii(a,b);
    1682   169868196 :   long s = signe(p);
    1683   169868196 :   if (!s) return p; /* = gen_0 */
    1684   158376198 :   if (s > 0) /* general case */
    1685             :   {
    1686   158115499 :     GEN t = subii(p, m);
    1687   158051164 :     s = signe(t);
    1688   158051164 :     if (!s) return gc_const(av, gen_0);
    1689   150068073 :     if (s < 0) return gc_const((pari_sp)p, p);
    1690    72359248 :     if (cmpii(t, m) < 0) return gerepileuptoint(av, t); /* general case ! */
    1691     3303668 :     p = remii(t, m);
    1692             :   }
    1693             :   else
    1694      265268 :     p = modii(p, m);
    1695     3569044 :   return gerepileuptoint(av, p);
    1696             : }
    1697             : INLINE GEN
    1698    20968306 : Fp_double(GEN x, GEN N)
    1699             : {
    1700    20968306 :   GEN z = shifti(x, 1);
    1701    20664162 :   return cmpii(z, N) >= 0? subii(z, N): z;
    1702             : }
    1703             : INLINE GEN
    1704   135632411 : Fp_sub(GEN a, GEN b, GEN m)
    1705             : {
    1706   135632411 :   pari_sp av=avma;
    1707   135632411 :   GEN p = subii(a,b);
    1708   134539161 :   long s = signe(p);
    1709   134539161 :   if (!s) return p; /* = gen_0 */
    1710   124899506 :   if (s > 0)
    1711             :   {
    1712    62708884 :     if (cmpii(p, m) < 0) return p; /* general case ! */
    1713     1453048 :     p = remii(p, m);
    1714             :   }
    1715             :   else
    1716             :   {
    1717    62190622 :     GEN t = addii(p, m);
    1718    63773097 :     if (!s) return gc_const(av, gen_0);
    1719    63773591 :     if (s > 0) return gerepileuptoint(av, t); /* general case ! */
    1720    63773591 :     p = modii(t, m);
    1721             :   }
    1722    65534692 :   return gerepileuptoint(av, p);
    1723             : }
    1724             : INLINE GEN
    1725    28264280 : Fp_neg(GEN b, GEN m)
    1726             : {
    1727    28264280 :   pari_sp av = avma;
    1728    28264280 :   long s = signe(b);
    1729             :   GEN p;
    1730    28264280 :   if (!s) return gen_0;
    1731    23835201 :   if (s > 0)
    1732             :   {
    1733    22712962 :     p = subii(m, b);
    1734    22712577 :     if (signe(p) >= 0) return p; /* general case ! */
    1735      385318 :     p = modii(p, m);
    1736             :   } else
    1737     1122705 :     p = remii(negi(b), m);
    1738     1508277 :   return gerepileuptoint(av, p);
    1739             : }
    1740             : 
    1741             : INLINE GEN
    1742      252540 : Fp_halve(GEN a, GEN p)
    1743             : {
    1744      252540 :   if (mpodd(a)) a = addii(a,p);
    1745      252540 :   return shifti(a,-1);
    1746             : }
    1747             : 
    1748             : /* assume 0 <= u < p and ps2 = p>>1 */
    1749             : INLINE GEN
    1750    75157631 : Fp_center(GEN u, GEN p, GEN ps2)
    1751    75157631 : { return abscmpii(u,ps2)<=0? icopy(u): subii(u,p); }
    1752             : /* same without copy */
    1753             : INLINE GEN
    1754    13554201 : Fp_center_i(GEN u, GEN p, GEN ps2)
    1755    13554201 : { return abscmpii(u,ps2)<=0? u: subii(u,p); }
    1756             : 
    1757             : /* x + y*z mod p */
    1758             : INLINE GEN
    1759    11224989 : Fp_addmul(GEN x, GEN y, GEN z, GEN p)
    1760             : {
    1761             :   pari_sp av;
    1762    11224989 :   if (!signe(y) || !signe(z)) return Fp_red(x, p);
    1763    10876605 :   if (!signe(x)) return Fp_mul(z,y, p);
    1764     9876856 :   av = avma;
    1765     9876856 :   return gerepileuptoint(av, modii(addii(x, mulii(y,z)), p));
    1766             : }
    1767             : 
    1768             : INLINE GEN
    1769   177017522 : Fp_mul(GEN a, GEN b, GEN m)
    1770             : {
    1771   177017522 :   pari_sp av=avma;
    1772             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1773   177017522 :   (void)new_chunk(lg(a)+lg(b)+(lg(m)<<1));
    1774   177093657 :   p = mulii(a,b);
    1775   176953243 :   set_avma(av); return modii(p,m);
    1776             : }
    1777             : INLINE GEN
    1778    63796801 : Fp_sqr(GEN a, GEN m)
    1779             : {
    1780    63796801 :   pari_sp av=avma;
    1781             :   GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1782    63796801 :   (void)new_chunk((lg(a)+lg(m))<<1);
    1783    64126333 :   p = sqri(a);
    1784    62707343 :   set_avma(av); return remii(p,m); /*Use remii: p >= 0 */
    1785             : }
    1786             : INLINE GEN
    1787    67885674 : Fp_mulu(GEN a, ulong b, GEN m)
    1788             : {
    1789    67885674 :   long l = lgefint(m);
    1790    67885674 :   if (l == 3)
    1791             :   {
    1792    45815695 :     ulong mm = m[2];
    1793    45815695 :     return utoi( Fl_mul(umodiu(a, mm), b, mm) );
    1794             :   } else {
    1795    22069979 :     pari_sp av = avma;
    1796             :     GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1797    22069979 :     (void)new_chunk(lg(a)+1+(l<<1));
    1798    22044860 :     p = muliu(a,b);
    1799    21879354 :     set_avma(av); return modii(p,m);
    1800             :   }
    1801             : }
    1802             : INLINE GEN
    1803       17780 : Fp_muls(GEN a, long b, GEN m)
    1804             : {
    1805       17780 :   long l = lgefint(m);
    1806       17780 :   if (l == 3)
    1807             :   {
    1808        3578 :     ulong mm = m[2];
    1809        3578 :     if (b < 0)
    1810             :     {
    1811        3578 :       ulong t = Fl_mul(umodiu(a, mm), -b, mm);
    1812        3578 :       return t? utoipos(mm - t): gen_0;
    1813             :     }
    1814             :     else
    1815           0 :       return utoi( Fl_mul(umodiu(a, mm), b, mm) );
    1816             :   } else {
    1817       14202 :     pari_sp av = avma;
    1818             :     GEN p; /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1819       14202 :     (void)new_chunk(lg(a)+1+(l<<1));
    1820       14202 :     p = mulis(a,b);
    1821       14202 :     set_avma(av); return modii(p,m);
    1822             :   }
    1823             : }
    1824             : 
    1825             : INLINE GEN
    1826    25500694 : Fp_inv(GEN a, GEN m)
    1827             : {
    1828             :   GEN res;
    1829    25500694 :   if (! invmod(a,m,&res)) pari_err_INV("Fp_inv", mkintmod(res,m));
    1830    25500872 :   return res;
    1831             : }
    1832             : INLINE GEN
    1833     1181920 : Fp_invsafe(GEN a, GEN m)
    1834             : {
    1835             :   GEN res;
    1836     1181920 :   if (! invmod(a,m,&res)) return NULL;
    1837     1181859 :   return res;
    1838             : }
    1839             : INLINE GEN
    1840     1614021 : Fp_div(GEN a, GEN b, GEN m)
    1841             : {
    1842     1614021 :   pari_sp av = avma;
    1843             :   GEN p;
    1844     1614021 :   if (lgefint(b) == 3)
    1845             :   {
    1846      659606 :     a = Fp_divu(a, b[2], m);
    1847      659606 :     if (signe(b) < 0) a = Fp_neg(a, m);
    1848      659606 :     return a;
    1849             :   }
    1850             :   /*HACK: assume modii use <=lg(p)+(lg(m)<<1) space*/
    1851      954415 :   (void)new_chunk(lg(a)+(lg(m)<<1));
    1852      954415 :   p = mulii(a, Fp_inv(b,m));
    1853      954415 :   set_avma(av); return modii(p,m);
    1854             : }
    1855             : INLINE GEN
    1856     1906473 : Fp_divu(GEN x, ulong a, GEN p)
    1857             : {
    1858     1906473 :   pari_sp av = avma;
    1859             :   ulong b;
    1860     1906473 :   if (lgefint(p) == 3)
    1861             :   {
    1862     1508653 :     ulong pp = p[2], xp = umodiu(x, pp);
    1863     1508653 :     return xp? utoipos(Fl_div(xp, a % pp, pp)): gen_0;
    1864             :   }
    1865      397820 :   x = Fp_red(x, p);
    1866      397821 :   b = Fl_neg(Fl_div(umodiu(x,a), umodiu(p,a), a), a); /* x + pb = 0 (mod a) */
    1867      397821 :   return gerepileuptoint(av, diviuexact(addmuliu(x, p, b), a));
    1868             : }
    1869             : 
    1870             : INLINE GEN
    1871     1086038 : Flx_mulu(GEN x, ulong a, ulong p) { return Flx_Fl_mul(x,a%p,p); }
    1872             : 
    1873             : INLINE GEN
    1874     2518062 : get_F2x_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1875             : 
    1876             : INLINE long
    1877     2533443 : get_F2x_var(GEN T) { return typ(T)==t_VEC? mael(T,2,1): T[1]; }
    1878             : 
    1879             : INLINE long
    1880     1933466 : get_F2x_degree(GEN T) { return typ(T)==t_VEC? F2x_degree(gel(T,2)): F2x_degree(T); }
    1881             : 
    1882             : INLINE GEN
    1883         399 : get_F2xqX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1884             : 
    1885             : INLINE long
    1886      376978 : get_F2xqX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1887             : 
    1888             : INLINE long
    1889      201663 : get_F2xqX_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1890             : 
    1891             : INLINE GEN
    1892    25858383 : get_Flx_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1893             : 
    1894             : INLINE long
    1895    67357179 : get_Flx_var(GEN T) { return typ(T)==t_VEC? mael(T,2,1): T[1]; }
    1896             : 
    1897             : INLINE long
    1898    85329730 : get_Flx_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1899             : 
    1900             : INLINE GEN
    1901        8040 : get_FlxqX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1902             : 
    1903             : INLINE long
    1904      265620 : get_FlxqX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1905             : 
    1906             : INLINE long
    1907      318850 : get_FlxqX_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1908             : 
    1909             : INLINE GEN
    1910     3473570 : get_FpX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1911             : 
    1912             : INLINE long
    1913     7019251 : get_FpX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1914             : 
    1915             : INLINE long
    1916     5820449 : get_FpX_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1917             : 
    1918             : INLINE GEN
    1919      146583 : get_FpXQX_mod(GEN T) { return typ(T)==t_VEC? gel(T,2): T; }
    1920             : 
    1921             : INLINE long
    1922       51837 : get_FpXQX_var(GEN T) { return typ(T)==t_VEC? varn(gel(T,2)): varn(T); }
    1923             : 
    1924             : INLINE long
    1925        3686 : get_FpXQX_degree(GEN T) { return typ(T)==t_VEC? degpol(gel(T,2)): degpol(T); }
    1926             : 
    1927             : /*******************************************************************/
    1928             : /*                                                                 */
    1929             : /*                        ADDMULII / SUBMULII                      */
    1930             : /*                                                                 */
    1931             : /*******************************************************************/
    1932             : /* x - y*z */
    1933             : INLINE GEN
    1934    32717233 : submulii(GEN x, GEN y, GEN z)
    1935             : {
    1936    32717233 :   long lx = lgefint(x), ly, lz;
    1937             :   pari_sp av;
    1938             :   GEN t;
    1939    32717233 :   if (lx == 2) { t = mulii(z,y); togglesign(t); return t; }
    1940    30242753 :   ly = lgefint(y);
    1941    30242753 :   if (ly == 2) return icopy(x);
    1942    28977682 :   lz = lgefint(z);
    1943    28977682 :   av = avma; (void)new_chunk(lx+ly+lz); /* HACK */
    1944    28977682 :   t = mulii(z, y);
    1945    28977682 :   set_avma(av); return subii(x,t);
    1946             : }
    1947             : /* y*z - x */
    1948             : INLINE GEN
    1949     3800752 : mulsubii(GEN y, GEN z, GEN x)
    1950             : {
    1951     3800752 :   long lx = lgefint(x), ly, lz;
    1952             :   pari_sp av;
    1953             :   GEN t;
    1954     3800752 :   if (lx == 2) return mulii(z,y);
    1955     2403062 :   ly = lgefint(y);
    1956     2403062 :   if (ly == 2) return negi(x);
    1957     2129904 :   lz = lgefint(z);
    1958     2129904 :   av = avma; (void)new_chunk(lx+ly+lz); /* HACK */
    1959     2129928 :   t = mulii(z, y);
    1960     2129897 :   set_avma(av); return subii(t,x);
    1961             : }
    1962             : 
    1963             : /* x - u*y */
    1964             : INLINE GEN
    1965        7693 : submuliu(GEN x, GEN y, ulong u)
    1966             : {
    1967             :   pari_sp av;
    1968        7693 :   long ly = lgefint(y);
    1969        7693 :   if (ly == 2) return icopy(x);
    1970        7693 :   av = avma;
    1971        7693 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1972        7693 :   y = mului(u,y);
    1973        7693 :   set_avma(av); return subii(x, y);
    1974             : }
    1975             : /* x + u*y */
    1976             : INLINE GEN
    1977      405889 : addmuliu(GEN x, GEN y, ulong u)
    1978             : {
    1979             :   pari_sp av;
    1980      405889 :   long ly = lgefint(y);
    1981      405889 :   if (ly == 2) return icopy(x);
    1982      405889 :   av = avma;
    1983      405889 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1984      405889 :   y = mului(u,y);
    1985      405889 :   set_avma(av); return addii(x, y);
    1986             : }
    1987             : /* x - u*y */
    1988             : INLINE GEN
    1989    59738041 : submuliu_inplace(GEN x, GEN y, ulong u)
    1990             : {
    1991             :   pari_sp av;
    1992    59738041 :   long ly = lgefint(y);
    1993    59738041 :   if (ly == 2) return x;
    1994    37832052 :   av = avma;
    1995    37832052 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    1996    37836646 :   y = mului(u,y);
    1997    37836502 :   set_avma(av); return subii(x, y);
    1998             : }
    1999             : /* x + u*y */
    2000             : INLINE GEN
    2001    59236131 : addmuliu_inplace(GEN x, GEN y, ulong u)
    2002             : {
    2003             :   pari_sp av;
    2004    59236131 :   long ly = lgefint(y);
    2005    59236131 :   if (ly == 2) return x;
    2006    37741127 :   av = avma;
    2007    37741127 :   (void)new_chunk(3+ly+lgefint(x)); /* HACK */
    2008    37745390 :   y = mului(u,y);
    2009    37745083 :   set_avma(av); return addii(x, y);
    2010             : }
    2011             : /* ux + vy */
    2012             : INLINE GEN
    2013    36918293 : lincombii(GEN u, GEN v, GEN x, GEN y)
    2014             : {
    2015    36918293 :   long lx = lgefint(x), ly;
    2016             :   GEN p1, p2;
    2017             :   pari_sp av;
    2018    36918293 :   if (lx == 2) return mulii(v,y);
    2019    23171252 :   ly = lgefint(y);
    2020    23171252 :   if (ly == 2) return mulii(u,x);
    2021    20551561 :   av = avma; (void)new_chunk(lx+ly+lgefint(u)+lgefint(v)); /* HACK */
    2022    20554312 :   p1 = mulii(u,x);
    2023    20553443 :   p2 = mulii(v,y);
    2024    20553342 :   set_avma(av); return addii(p1,p2);
    2025             : }
    2026             : 
    2027             : /*******************************************************************/
    2028             : /*                                                                 */
    2029             : /*                          GEN SUBTYPES                           */
    2030             : /*                                                                 */
    2031             : /*******************************************************************/
    2032             : 
    2033             : INLINE int
    2034  4753858687 : is_const_t(long t) { return (t < t_POLMOD); }
    2035             : INLINE int
    2036        6946 : is_extscalar_t(long t) { return (t <= t_POL); }
    2037             : INLINE int
    2038     9600563 : is_intreal_t(long t) { return (t <= t_REAL); }
    2039             : INLINE int
    2040   601829189 : is_matvec_t(long t) { return (t >= t_VEC && t <= t_MAT); }
    2041             : INLINE int
    2042    94579153 : is_noncalc_t(long tx) { return (tx) >= t_LIST; }
    2043             : INLINE int
    2044           0 : is_qfb_t(long t) { return (t == t_QFB); }
    2045             : INLINE int
    2046     5028787 : is_rational_t(long t) { return (t == t_INT || t == t_FRAC); }
    2047             : INLINE int
    2048    62699434 : is_real_t(long t) { return (t == t_INT || t == t_REAL || t == t_FRAC); }
    2049             : INLINE int
    2050  8185823922 : is_recursive_t(long t) { return lontyp[t]; }
    2051             : INLINE int
    2052   320018590 : is_scalar_t(long t) { return (t < t_POL); }
    2053             : INLINE int
    2054     1884548 : is_vec_t(long t) { return (t == t_VEC || t == t_COL); }
    2055             : 
    2056             : INLINE int
    2057    59609765 : qfb_is_qfi(GEN q) { return signe(gel(q,4)) < 0; }
    2058             : 
    2059             : /*******************************************************************/
    2060             : /*                                                                 */
    2061             : /*                         TRANSCENDENTAL                          */
    2062             : /*                                                                 */
    2063             : /*******************************************************************/
    2064             : INLINE GEN
    2065    79682141 : sqrtr(GEN x) {
    2066    79682141 :   long s = signe(x);
    2067    79682141 :   if (s == 0) return real_0_bit(expo(x) >> 1);
    2068    79649033 :   if (s >= 0) return sqrtr_abs(x);
    2069      429978 :   retmkcomplex(gen_0, sqrtr_abs(x));
    2070             : }
    2071             : INLINE GEN
    2072           0 : cbrtr_abs(GEN x) { return sqrtnr_abs(x, 3); }
    2073             : INLINE GEN
    2074           0 : cbrtr(GEN x) {
    2075           0 :   long s = signe(x);
    2076             :   GEN r;
    2077           0 :   if (s == 0) return real_0_bit(expo(x) / 3);
    2078           0 :   r = cbrtr_abs(x);
    2079           0 :   if (s < 0) togglesign(r);
    2080           0 :   return r;
    2081             : }
    2082             : INLINE GEN
    2083     2725450 : sqrtnr(GEN x, long n) {
    2084     2725450 :   long s = signe(x);
    2085             :   GEN r;
    2086     2725450 :   if (s == 0) return real_0_bit(expo(x) / n);
    2087     2725450 :   r = sqrtnr_abs(x, n);
    2088     2725457 :   if (s < 0) pari_err_IMPL("sqrtnr for x < 0");
    2089     2725456 :   return r;
    2090             : }
    2091             : INLINE long
    2092      747848 : logint(GEN B, GEN y) { return logintall(B,y,NULL); }
    2093             : INLINE ulong
    2094     1716834 : ulogint(ulong B, ulong y)
    2095             : {
    2096             :   ulong r;
    2097             :   long e;
    2098     1716834 :   if (y == 2) return expu(B);
    2099     1669163 :   r = y;
    2100     5045458 :   for (e=1;; e++)
    2101             :   { /* here, r = y^e, r2 = y^(e-1) */
    2102     5045458 :     if (r >= B) return r == B? e: e-1;
    2103     3377768 :     r = umuluu_or_0(y, r);
    2104     3377810 :     if (!r) return e;
    2105             :   }
    2106             : }
    2107             : 
    2108             : /*******************************************************************/
    2109             : /*                                                                 */
    2110             : /*                         MISCELLANEOUS                           */
    2111             : /*                                                                 */
    2112             : /*******************************************************************/
    2113     9600451 : INLINE int ismpzero(GEN x) { return is_intreal_t(typ(x)) && !signe(x); }
    2114  2816060705 : INLINE int isintzero(GEN x) { return typ(x) == t_INT && !signe(x); }
    2115    16091954 : INLINE int isint1(GEN x) { return typ(x)==t_INT && equali1(x); }
    2116     5944847 : INLINE int isintm1(GEN x){ return typ(x)==t_INT && equalim1(x);}
    2117  1164592464 : INLINE int equali1(GEN n)
    2118  1164592464 : { return (ulong) n[1] == (evallgefint(3UL) | evalsigne(1)) && n[2] == 1; }
    2119   138649382 : INLINE int equalim1(GEN n)
    2120   138649382 : { return (ulong) n[1] == (evallgefint(3UL) | evalsigne(-1)) && n[2] == 1; }
    2121             : /* works only for POSITIVE integers */
    2122  2167666843 : INLINE int is_pm1(GEN n)
    2123  2167666843 : { return lgefint(n) == 3 && n[2] == 1; }
    2124   554884754 : INLINE int is_bigint(GEN n)
    2125   554884754 : { long l = lgefint(n); return l > 3 || (l == 3 && (n[2] & HIGHBIT)); }
    2126             : 
    2127  2019779809 : INLINE int odd(long x) { return x & 1; }
    2128    66299180 : INLINE int both_odd(long x, long y) { return x & y & 1; }
    2129             : 
    2130             : INLINE int
    2131  7769057585 : isonstack(GEN x)
    2132  7769057585 : { return ((pari_sp)x >= pari_mainstack->bot
    2133  7769057585 :        && (pari_sp)x <  pari_mainstack->top); }
    2134             : 
    2135             : /* assume x != 0 and x t_REAL, return an approximation to log2(|x|) */
    2136             : INLINE double
    2137    90493625 : dbllog2r(GEN x)
    2138    90493625 : { return log2((double)(ulong)x[2]) + (double)(expo(x) - (BITS_IN_LONG-1)); }
    2139             : 
    2140             : INLINE GEN
    2141     2462177 : mul_content(GEN cx, GEN cy)
    2142             : {
    2143     2462177 :   if (!cx) return cy;
    2144      519579 :   if (!cy) return cx;
    2145      336708 :   return gmul(cx,cy);
    2146             : }
    2147             : INLINE GEN
    2148           0 : inv_content(GEN c) { return c? ginv(c): NULL; }
    2149             : INLINE GEN
    2150       56394 : div_content(GEN cx, GEN cy)
    2151             : {
    2152       56394 :   if (!cy) return cx;
    2153       55302 :   if (!cx) return ginv(cy);
    2154       25388 :   return gdiv(cx,cy);
    2155             : }
    2156             : INLINE GEN
    2157    10331653 : mul_denom(GEN dx, GEN dy)
    2158             : {
    2159    10331653 :   if (!dx) return dy;
    2160     2560746 :   if (!dy) return dx;
    2161     1543774 :   return mulii(dx,dy);
    2162             : }
    2163             : 
    2164             : /* POLYNOMIALS */
    2165             : INLINE GEN
    2166     1433053 : constant_coeff(GEN x) { return signe(x)? gel(x,2): gen_0; }
    2167             : INLINE GEN
    2168   162679561 : leading_coeff(GEN x) { return lg(x) == 2? gen_0: gel(x,lg(x)-1); }
    2169             : INLINE ulong
    2170      772729 : Flx_lead(GEN x) { return lg(x) == 2? 0: x[lg(x)-1]; }
    2171             : INLINE ulong
    2172      137787 : Flx_constant(GEN x) { return lg(x) == 2? 0: x[2]; }
    2173             : INLINE long
    2174  4939192472 : degpol(GEN x) { return lg(x)-3; }
    2175             : INLINE long
    2176  2503814919 : lgpol(GEN x) { return lg(x)-2; }
    2177             : INLINE long
    2178   337883600 : lgcols(GEN x) { return lg(gel(x,1)); }
    2179             : INLINE long
    2180   151738807 : nbrows(GEN x) { return lg(gel(x,1))-1; }
    2181             : INLINE GEN
    2182           0 : truecoef(GEN x, long n) { return polcoef(x,n,-1); }
    2183             : 
    2184             : INLINE GEN
    2185     2139731 : ZXQ_mul(GEN y, GEN x, GEN T) { return ZX_rem(ZX_mul(y, x), T); }
    2186             : INLINE GEN
    2187      959419 : ZXQ_sqr(GEN x, GEN T) { return ZX_rem(ZX_sqr(x), T); }
    2188             : 
    2189             : INLINE GEN
    2190   103032954 : RgX_copy(GEN x)
    2191             : {
    2192             :   long lx, i;
    2193   103032954 :   GEN y = cgetg_copy(x, &lx); y[1] = x[1];
    2194   375573943 :   for (i = 2; i<lx; i++) gel(y,i) = gcopy(gel(x,i));
    2195   103032962 :   return y;
    2196             : }
    2197             : /* have to use ulong to avoid silly warnings from gcc "assuming signed
    2198             :  * overflow does not occur" */
    2199             : INLINE GEN
    2200     2543693 : RgX_coeff(GEN x, long n)
    2201             : {
    2202     2543693 :   ulong l = lg(x);
    2203     2543693 :   return (n < 0 || ((ulong)n+3) > l)? gen_0: gel(x,n+2);
    2204             : }
    2205             : INLINE GEN
    2206      347497 : RgX_renormalize(GEN x) { return RgX_renormalize_lg(x, lg(x)); }
    2207             : INLINE GEN
    2208     6917089 : RgX_div(GEN x, GEN y) { return RgX_divrem(x,y,NULL); }
    2209             : INLINE GEN
    2210        1904 : RgXQX_div(GEN x, GEN y, GEN T) { return RgXQX_divrem(x,y,T,NULL); }
    2211             : INLINE GEN
    2212      107489 : RgXQX_rem(GEN x, GEN y, GEN T) { return RgXQX_divrem(x,y,T,ONLY_REM); }
    2213             : INLINE GEN
    2214     5412744 : FpX_div(GEN x, GEN y, GEN p) { return FpX_divrem(x,y,p, NULL); }
    2215             : INLINE GEN
    2216     1985575 : Flx_div(GEN x, GEN y, ulong p) { return Flx_divrem(x,y,p, NULL); }
    2217             : INLINE GEN
    2218    21260925 : Flx_div_pre(GEN x, GEN y, ulong p, ulong pi)
    2219    21260925 : { return Flx_divrem_pre(x,y,p,pi, NULL); }
    2220             : INLINE GEN
    2221     1516496 : F2x_div(GEN x, GEN y) { return F2x_divrem(x,y, NULL); }
    2222             : INLINE GEN
    2223           0 : FpV_FpC_mul(GEN x, GEN y, GEN p) { return FpV_dotproduct(x,y,p); }
    2224             : INLINE GEN
    2225    98827223 : pol0_Flx(long sv) { return mkvecsmall(sv); }
    2226             : INLINE GEN
    2227    55344055 : pol1_Flx(long sv) { return mkvecsmall2(sv, 1); }
    2228             : INLINE GEN
    2229    35882961 : polx_Flx(long sv) { return mkvecsmall3(sv, 0, 1); }
    2230             : INLINE GEN
    2231           0 : zero_zx(long sv) { return zero_Flx(sv); }
    2232             : INLINE GEN
    2233           0 : polx_zx(long sv) { return polx_Flx(sv); }
    2234             : INLINE GEN
    2235           0 : zx_shift(GEN x, long n) { return Flx_shift(x,n); }
    2236             : INLINE GEN
    2237       14049 : zx_renormalize(GEN x, long l) { return Flx_renormalize(x,l); }
    2238             : INLINE GEN
    2239        1350 : zero_F2x(long sv) { return zero_Flx(sv); }
    2240             : INLINE GEN
    2241    13080845 : pol0_F2x(long sv) { return pol0_Flx(sv); }
    2242             : INLINE GEN
    2243     3966091 : pol1_F2x(long sv) { return pol1_Flx(sv); }
    2244             : INLINE GEN
    2245     1059379 : polx_F2x(long sv) { return mkvecsmall2(sv, 2); }
    2246             : INLINE int
    2247     2870232 : F2x_equal1(GEN x) { return Flx_equal1(x); }
    2248             : INLINE int
    2249     4507487 : F2x_equal(GEN V, GEN W) { return Flx_equal(V,W); }
    2250             : INLINE GEN
    2251    60047951 : F2x_copy(GEN x) { return leafcopy(x); }
    2252             : INLINE GEN
    2253        4074 : F2v_copy(GEN x) { return leafcopy(x); }
    2254             : INLINE GEN
    2255     2384795 : Flv_copy(GEN x) { return leafcopy(x); }
    2256             : INLINE GEN
    2257   171342094 : Flx_copy(GEN x) { return leafcopy(x); }
    2258             : INLINE GEN
    2259     3943327 : vecsmall_copy(GEN x) { return leafcopy(x); }
    2260             : INLINE int
    2261     9975979 : Flx_equal1(GEN x) { return degpol(x)==0 && x[2] == 1; }
    2262             : INLINE int
    2263       14136 : ZX_equal1(GEN x) { return degpol(x)==0 && equali1(gel(x,2)); }
    2264             : INLINE int
    2265     6952760 : ZX_is_monic(GEN x) { return equali1(leading_coeff(x)); }
    2266             : 
    2267             : INLINE GEN
    2268   149664415 : ZX_renormalize(GEN x, long lx)    { return ZXX_renormalize(x,lx); }
    2269             : INLINE GEN
    2270   143467858 : FpX_renormalize(GEN x, long lx)   { return ZXX_renormalize(x,lx); }
    2271             : INLINE GEN
    2272      853096 : FpXX_renormalize(GEN x, long lx)  { return ZXX_renormalize(x,lx); }
    2273             : INLINE GEN
    2274     4702262 : FpXQX_renormalize(GEN x, long lx) { return ZXX_renormalize(x,lx); }
    2275             : INLINE GEN
    2276   119295300 : F2x_renormalize(GEN x, long lx)   { return Flx_renormalize(x,lx); }
    2277             : 
    2278             : INLINE GEN
    2279           0 : F2xX_shift(GEN a, long n, long vs) { return FlxX_shift(a, n, vs); }
    2280             : 
    2281             : INLINE GEN
    2282       37510 : F2v_to_F2x(GEN x, long sv) {
    2283       37510 :   GEN y = leafcopy(x);
    2284       37509 :   y[1] = sv; F2x_renormalize(y, lg(y)); return y;
    2285             : }
    2286             : 
    2287             : INLINE long
    2288         385 : sturm(GEN x) { return sturmpart(x, NULL, NULL); }
    2289             : 
    2290             : INLINE long
    2291        5782 : gval(GEN x, long v)
    2292        5782 : { pari_sp av = avma; return gc_long(av, gvaluation(x, pol_x(v))); }
    2293             : 
    2294             : INLINE void
    2295      480471 : RgX_shift_inplace_init(long v)
    2296      480471 : { if (v) (void)cgetg(v, t_VECSMALL); }
    2297             : /* shift polynomial in place. assume v free cells have been left before x */
    2298             : INLINE GEN
    2299      480471 : RgX_shift_inplace(GEN x, long v)
    2300             : {
    2301             :   long i, lx;
    2302             :   GEN z;
    2303      480471 :   if (!v) return x;
    2304      253169 :   lx = lg(x);
    2305      253169 :   if (lx == 2) return x;
    2306      253169 :   z = x + lx;
    2307             :   /* stackdummy's from normalizepol */
    2308      253169 :   while (lg(z) != v) z += lg(z);
    2309      253169 :   z += v;
    2310     4654514 :   for (i = lx-1; i >= 2; i--) gel(--z,0) = gel(x,i);
    2311      675895 :   for (i = 0;  i < v; i++) gel(--z,0) = gen_0;
    2312      253169 :   z -= 2;
    2313      253169 :   z[1] = x[1];
    2314      253169 :   z[0] = evaltyp(t_POL) | evallg(lx+v);
    2315      253169 :   stackdummy((pari_sp)z, (pari_sp)x); return z;
    2316             : }
    2317             : 
    2318             : 
    2319             : /* LINEAR ALGEBRA */
    2320             : INLINE GEN
    2321      500491 : zv_to_ZV(GEN x) { return vecsmall_to_vec(x); }
    2322             : INLINE GEN
    2323     7673471 : zc_to_ZC(GEN x) { return vecsmall_to_col(x); }
    2324             : INLINE GEN
    2325     3189435 : ZV_to_zv(GEN x) { return vec_to_vecsmall(x); }
    2326             : INLINE GEN
    2327           0 : zx_to_zv(GEN x, long N) { return Flx_to_Flv(x,N); }
    2328             : INLINE GEN
    2329      104139 : zv_to_zx(GEN x, long sv) { return Flv_to_Flx(x,sv); }
    2330             : INLINE GEN
    2331           0 : zm_to_zxV(GEN x, long sv) { return Flm_to_FlxV(x,sv); }
    2332             : INLINE GEN
    2333           0 : zero_zm(long x, long y) { return zero_Flm(x,y); }
    2334             : INLINE GEN
    2335    36967229 : zero_zv(long x) { return zero_Flv(x); }
    2336             : INLINE GEN
    2337         266 : zm_transpose(GEN x) { return Flm_transpose(x); }
    2338             : INLINE GEN
    2339           0 : zm_copy(GEN x) { return Flm_copy(x); }
    2340             : INLINE GEN
    2341     2157528 : zv_copy(GEN x) { return Flv_copy(x); }
    2342             : INLINE GEN
    2343           0 : zm_row(GEN x, long i) { return Flm_row(x,i); }
    2344             : 
    2345             : INLINE GEN
    2346    10630040 : ZC_hnfrem(GEN x, GEN y) { return ZC_hnfremdiv(x,y,NULL); }
    2347             : INLINE GEN
    2348      326466 : ZM_hnfrem(GEN x, GEN y) { return ZM_hnfdivrem(x,y,NULL); }
    2349             : INLINE GEN
    2350     6857147 : ZM_lll(GEN x, double D, long f) { return ZM_lll_norms(x,D,f,NULL); }
    2351             : INLINE void
    2352     9243832 : RgM_dimensions(GEN x, long *m, long *n) { *n = lg(x)-1; *m = *n? nbrows(x): 0; }
    2353             : INLINE GEN
    2354    20542506 : RgM_shallowcopy(GEN x)
    2355             : {
    2356             :   long l;
    2357    20542506 :   GEN y = cgetg_copy(x, &l);
    2358    89180868 :   while (--l > 0) gel(y,l) = leafcopy(gel(x,l));
    2359    20541839 :   return y;
    2360             : }
    2361             : INLINE GEN
    2362      195736 : F2m_copy(GEN x) { return RgM_shallowcopy(x); }
    2363             : 
    2364             : INLINE GEN
    2365           0 : F3m_copy(GEN x) { return RgM_shallowcopy(x); }
    2366             : 
    2367             : INLINE GEN
    2368     6179641 : Flm_copy(GEN x) { return RgM_shallowcopy(x); }
    2369             : 
    2370             : /* divisibility: return 1 if y[i] | x[i] for all i, 0 otherwise. Assume
    2371             :  * x,y are ZV of the same length */
    2372             : INLINE int
    2373       23485 : ZV_dvd(GEN x, GEN y)
    2374             : {
    2375       23485 :   long i, l = lg(x);
    2376       37856 :   for (i=1; i < l; i++)
    2377       30464 :     if ( ! dvdii( gel(x,i), gel(y,i) ) ) return 0;
    2378        7392 :   return 1;
    2379             : }
    2380             : INLINE GEN
    2381      538687 : ZM_ZV_mod(GEN x, GEN y)
    2382     1536720 : { pari_APPLY_same(ZV_ZV_mod(gel(x,i), y)) }
    2383             : INLINE GEN
    2384     7319701 : ZV_ZV_mod(GEN x, GEN y)
    2385    18910436 : { pari_APPLY_same(modii(gel(x,i), gel(y,i))) }
    2386             : INLINE GEN
    2387           0 : vecmodii(GEN x, GEN y) { return ZV_ZV_mod(x,y); }
    2388             : INLINE GEN
    2389      174881 : vecmoduu(GEN x, GEN y) { pari_APPLY_ulong(((ulong*)x)[i] % ((ulong*)y)[i]) }
    2390             : 
    2391             : /* Fq */
    2392             : INLINE GEN
    2393     3413125 : Fq_red(GEN x, GEN T, GEN p)
    2394     3413125 : { return typ(x)==t_INT? Fp_red(x,p): FpXQ_red(x,T,p); }
    2395             : INLINE GEN
    2396      110255 : Fq_to_FpXQ(GEN x, GEN T, GEN p /*unused*/)
    2397             : {
    2398             :   (void) p;
    2399      110255 :   return typ(x)==t_INT ? scalarpol(x, get_FpX_var(T)): x;
    2400             : }
    2401             : INLINE GEN
    2402         756 : Rg_to_Fq(GEN x, GEN T, GEN p) { return T? Rg_to_FpXQ(x,T,p): Rg_to_Fp(x,p); }
    2403             : 
    2404             : INLINE GEN
    2405       14581 : gener_Fq_local(GEN T, GEN p, GEN L)
    2406           0 : { return T? gener_FpXQ_local(T,p, L)
    2407       14581 :           : pgener_Fp_local(p, L); }
    2408             : 
    2409             : INLINE GEN
    2410           0 : random_Fq(GEN T, GEN p)
    2411           0 : { return T ? random_FpX(get_FpX_degree(T), get_FpX_var(T), p): randomi(p); }
    2412             : 
    2413             : /* FpXQX */
    2414             : INLINE GEN
    2415        4546 : FpXQX_div(GEN x, GEN y, GEN T, GEN p) { return FpXQX_divrem(x, y, T, p, NULL); }
    2416             : INLINE GEN
    2417           0 : FlxqX_div(GEN x, GEN y, GEN T, ulong p) { return FlxqX_divrem(x, y, T, p, NULL); }
    2418             : INLINE GEN
    2419      165311 : FlxqX_div_pre(GEN x, GEN y, GEN T, ulong p, ulong pi) { return FlxqX_divrem_pre(x, y, T, p, pi, NULL); }
    2420             : INLINE GEN
    2421       33243 : F2xqX_div(GEN x, GEN y, GEN T) { return F2xqX_divrem(x, y, T, NULL); }
    2422             : 
    2423             : INLINE GEN
    2424       20587 : FpXY_Fq_evaly(GEN Q, GEN y, GEN T, GEN p, long vx)
    2425       20587 : { return T ? FpXY_FpXQ_evaly(Q, y, T, p, vx): FpXY_evaly(Q, y, p, vx); }
    2426             : 
    2427             : /* FqX */
    2428             : INLINE GEN
    2429       25354 : FqX_red(GEN z, GEN T, GEN p) { return T? FpXQX_red(z, T, p): FpX_red(z, p); }
    2430             : INLINE GEN
    2431      127694 : FqX_add(GEN x,GEN y,GEN T,GEN p) { return T? FpXX_add(x,y,p): FpX_add(x,y,p); }
    2432             : INLINE GEN
    2433       24956 : FqX_neg(GEN x,GEN T,GEN p) { return T? FpXX_neg(x,p): FpX_neg(x,p); }
    2434             : INLINE GEN
    2435       68607 : FqX_sub(GEN x,GEN y,GEN T,GEN p) { return T? FpXX_sub(x,y,p): FpX_sub(x,y,p); }
    2436             : INLINE GEN
    2437      565086 : FqX_Fp_mul(GEN P, GEN u, GEN T, GEN p)
    2438      565086 : { return T? FpXX_Fp_mul(P, u, p): FpX_Fp_mul(P, u, p); }
    2439             : INLINE GEN
    2440      426833 : FqX_Fq_mul(GEN P, GEN U, GEN T, GEN p)
    2441      426833 : { return typ(U)==t_INT ? FqX_Fp_mul(P, U, T, p): FpXQX_FpXQ_mul(P, U, T, p); }
    2442             : INLINE GEN
    2443      367891 : FqX_mul(GEN x, GEN y, GEN T, GEN p)
    2444      367891 : { return T? FpXQX_mul(x, y, T, p): FpX_mul(x, y, p); }
    2445             : INLINE GEN
    2446       21942 : FqX_mulu(GEN x, ulong y, GEN T, GEN p)
    2447       21942 : { return T? FpXX_mulu(x, y, p): FpX_mulu(x, y, p); }
    2448             : INLINE GEN
    2449       71855 : FqX_sqr(GEN x, GEN T, GEN p)
    2450       71855 : { return T? FpXQX_sqr(x, T, p): FpX_sqr(x, p); }
    2451             : INLINE GEN
    2452        1295 : FqX_powu(GEN x, ulong n, GEN T, GEN p)
    2453        1295 : { return T? FpXQX_powu(x, n, T, p): FpX_powu(x, n, p); }
    2454             : INLINE GEN
    2455       19411 : FqX_halve(GEN x, GEN T, GEN p)
    2456       19411 : { return T? FpXX_halve(x, p): FpX_halve(x, p); }
    2457             : INLINE GEN
    2458       39755 : FqX_div(GEN x, GEN y, GEN T, GEN p)
    2459       39755 : { return T? FpXQX_divrem(x,y,T,p,NULL): FpX_divrem(x,y,p,NULL); }
    2460             : INLINE GEN
    2461        6090 : FqX_get_red(GEN S, GEN T, GEN p)
    2462        6090 : { return T? FpXQX_get_red(S,T,p): FpX_get_red(S,p); }
    2463             : INLINE GEN
    2464       37743 : FqX_rem(GEN x, GEN y, GEN T, GEN p)
    2465       37743 : { return T? FpXQX_rem(x,y,T,p): FpX_rem(x,y,p); }
    2466             : INLINE GEN
    2467           0 : FqX_divrem(GEN x, GEN y, GEN T, GEN p, GEN *z)
    2468           0 : { return T? FpXQX_divrem(x,y,T,p,z): FpX_divrem(x,y,p,z); }
    2469             : INLINE GEN
    2470       71939 : FqX_div_by_X_x(GEN x, GEN y, GEN T, GEN p, GEN *z)
    2471       71939 : { return T? FpXQX_div_by_X_x(x,y,T,p,z): FpX_div_by_X_x(x,y,p,z); }
    2472             : INLINE GEN
    2473           0 : FqX_halfgcd(GEN P,GEN Q,GEN T,GEN p)
    2474           0 : {return T? FpXQX_halfgcd(P,Q,T,p): FpX_halfgcd(P,Q,p);}
    2475             : INLINE GEN
    2476      692594 : FqX_gcd(GEN P,GEN Q,GEN T,GEN p)
    2477      692594 : {return T? FpXQX_gcd(P,Q,T,p): FpX_gcd(P,Q,p);}
    2478             : INLINE GEN
    2479      440619 : FqX_extgcd(GEN P,GEN Q,GEN T,GEN p, GEN *U, GEN *V)
    2480      440619 : { return T? FpXQX_extgcd(P,Q,T,p,U,V): FpX_extgcd(P,Q,p,U,V); }
    2481             : INLINE GEN
    2482        4487 : FqX_normalize(GEN z, GEN T, GEN p)
    2483        4487 : { return T? FpXQX_normalize(z, T, p): FpX_normalize(z, p); }
    2484             : INLINE GEN
    2485      723681 : FqX_deriv(GEN f, GEN T, GEN p) { return T? FpXX_deriv(f, p): FpX_deriv(f, p); }
    2486             : INLINE GEN
    2487           0 : FqX_integ(GEN f, GEN T, GEN p) { return T? FpXX_integ(f, p): FpX_integ(f, p); }
    2488             : INLINE GEN
    2489      141254 : FqX_factor(GEN f, GEN T, GEN p)
    2490      141254 : { return T?FpXQX_factor(f, T, p): FpX_factor(f, p); }
    2491             : INLINE GEN
    2492           7 : FqX_factor_squarefree(GEN f, GEN T, GEN p)
    2493           7 : { return T ? FpXQX_factor_squarefree(f, T, p): FpX_factor_squarefree(f, p); }
    2494             : INLINE GEN
    2495           7 : FqX_ddf(GEN f, GEN T, GEN p)
    2496           7 : { return T ? FpXQX_ddf(f, T, p): FpX_ddf(f, p); }
    2497             : INLINE GEN
    2498       47786 : FqX_degfact(GEN f, GEN T, GEN p)
    2499       47786 : { return T?FpXQX_degfact(f, T, p): FpX_degfact(f, p); }
    2500             : INLINE GEN
    2501        7273 : FqX_roots(GEN f, GEN T, GEN p)
    2502        7273 : { return T?FpXQX_roots(f, T, p): FpX_roots(f, p); }
    2503             : INLINE GEN
    2504         175 : FqX_to_mod(GEN f, GEN T, GEN p)
    2505         175 : { return T?FpXQX_to_mod(f, T, p): FpX_to_mod(f, p); }
    2506             : 
    2507             : /*FqXQ*/
    2508             : INLINE GEN
    2509           0 : FqXQ_add(GEN x, GEN y, GEN S/*unused*/, GEN T, GEN p)
    2510           0 : { (void)S; return T? FpXX_add(x,y,p): FpX_add(x,y,p); }
    2511             : INLINE GEN
    2512           0 : FqXQ_sub(GEN x, GEN y, GEN S/*unused*/, GEN T, GEN p)
    2513           0 : { (void)S; return T? FpXX_sub(x,y,p): FpX_sub(x,y,p); }
    2514             : INLINE GEN
    2515           0 : FqXQ_div(GEN x, GEN y, GEN S, GEN T, GEN p)
    2516           0 : { return T? FpXQXQ_div(x,y,S,T,p): FpXQ_div(x,y,S,p); }
    2517             : INLINE GEN
    2518           0 : FqXQ_inv(GEN x, GEN S, GEN T, GEN p)
    2519           0 : { return T? FpXQXQ_inv(x,S,T,p): FpXQ_inv(x,S,p); }
    2520             : INLINE GEN
    2521           0 : FqXQ_invsafe(GEN x, GEN S, GEN T, GEN p)
    2522           0 : { return T? FpXQXQ_invsafe(x,S,T,p): FpXQ_inv(x,S,p); }
    2523             : INLINE GEN
    2524       22766 : FqXQ_mul(GEN x, GEN y, GEN S, GEN T, GEN p)
    2525       22766 : { return T? FpXQXQ_mul(x,y,S,T,p): FpXQ_mul(x,y,S,p); }
    2526             : INLINE GEN
    2527           0 : FqXQ_sqr(GEN x, GEN S, GEN T, GEN p)
    2528           0 : { return T? FpXQXQ_sqr(x,S,T,p): FpXQ_sqr(x,S,p); }
    2529             : INLINE GEN
    2530           0 : FqXQ_pow(GEN x, GEN n, GEN S, GEN T, GEN p)
    2531           0 : { return T? FpXQXQ_pow(x,n,S,T,p): FpXQ_pow(x,n,S,p); }
    2532             : 
    2533             : /*FqXn*/
    2534             : INLINE GEN
    2535        6590 : FqXn_expint(GEN x, long n, GEN T, GEN p)
    2536        6590 : { return T? FpXQXn_expint(x,n,T,p): FpXn_expint(x,n,p); }
    2537             : INLINE GEN
    2538           0 : FqXn_exp(GEN x, long n, GEN T, GEN p)
    2539           0 : { return T? FpXQXn_exp(x,n,T,p): FpXn_exp(x,n,p); }
    2540             : INLINE GEN
    2541        7126 : FqXn_inv(GEN x, long n, GEN T, GEN p)
    2542        7126 : { return T? FpXQXn_inv(x,n,T,p): FpXn_inv(x,n,p); }
    2543             : INLINE GEN
    2544      263403 : FqXn_mul(GEN x, GEN y, long n, GEN T, GEN p)
    2545      263403 : { return T? FpXQXn_mul(x, y, n, T, p): FpXn_mul(x, y, n, p); }
    2546             : INLINE GEN
    2547           0 : FqXn_sqr(GEN x, long n, GEN T, GEN p)
    2548           0 : { return T? FpXQXn_sqr(x,n,T,p): FpXn_sqr(x,n,p); }
    2549             : 
    2550             : /*FpXQ*/
    2551             : INLINE GEN
    2552           0 : FpXQ_add(GEN x,GEN y,GEN T/*unused*/,GEN p)
    2553           0 : { (void)T; return FpX_add(x,y,p); }
    2554             : INLINE GEN
    2555           0 : FpXQ_sub(GEN x,GEN y,GEN T/*unused*/,GEN p)
    2556           0 : { (void)T; return FpX_sub(x,y,p); }
    2557             : 
    2558             : /*Flxq*/
    2559             : INLINE GEN
    2560           0 : Flxq_add(GEN x,GEN y,GEN T/*unused*/,ulong p)
    2561           0 : { (void)T; return Flx_add(x,y,p); }
    2562             : INLINE GEN
    2563           0 : Flxq_sub(GEN x,GEN y,GEN T/*unused*/,ulong p)
    2564           0 : { (void)T; return Flx_sub(x,y,p); }
    2565             : 
    2566             : /* F2x */
    2567             : 
    2568             : INLINE ulong
    2569   652018602 : F2x_coeff(GEN x,long v)
    2570             : {
    2571   652018602 :    ulong u=(ulong)x[2+divsBIL(v)];
    2572   652018200 :    return (u>>remsBIL(v))&1UL;
    2573             : }
    2574             : 
    2575             : INLINE void
    2576    11707588 : F2x_clear(GEN x,long v)
    2577             : {
    2578    11707588 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2579    11707530 :    *u&=~(1UL<<remsBIL(v));
    2580    11707532 : }
    2581             : 
    2582             : INLINE void
    2583   127466678 : F2x_set(GEN x,long v)
    2584             : {
    2585   127466678 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2586   127465065 :    *u|=1UL<<remsBIL(v);
    2587   127465601 : }
    2588             : 
    2589             : INLINE void
    2590     1557085 : F2x_flip(GEN x,long v)
    2591             : {
    2592     1557085 :    ulong* u=(ulong*)&x[2+divsBIL(v)];
    2593     1557085 :    *u^=1UL<<remsBIL(v);
    2594     1557085 : }
    2595             : 
    2596             : /* F2v */
    2597             : 
    2598             : INLINE ulong
    2599   645498292 : F2v_coeff(GEN x,long v) { return F2x_coeff(x,v-1); }
    2600             : 
    2601             : INLINE void
    2602    11707603 : F2v_clear(GEN x,long v) { F2x_clear(x,v-1); }
    2603             : 
    2604             : INLINE void
    2605   101269776 : F2v_set(GEN x,long v)   { F2x_set(x,v-1); }
    2606             : 
    2607             : INLINE void
    2608     1557084 : F2v_flip(GEN x,long v) { F2x_flip(x,v-1); }
    2609             : 
    2610             : /* F2m */
    2611             : 
    2612             : INLINE ulong
    2613     7544311 : F2m_coeff(GEN x, long a, long b) { return F2v_coeff(gel(x,b), a); }
    2614             : 
    2615             : INLINE void
    2616           0 : F2m_clear(GEN x, long a, long b) { F2v_clear(gel(x,b), a); }
    2617             : 
    2618             : INLINE void
    2619         686 : F2m_set(GEN x, long a, long b) { F2v_set(gel(x,b), a); }
    2620             : 
    2621             : INLINE void
    2622     1557084 : F2m_flip(GEN x, long a, long b) { F2v_flip(gel(x,b), a); }
    2623             : 
    2624             : /* F3m */
    2625             : 
    2626             : INLINE ulong
    2627     1807415 : F3m_coeff(GEN x, long a, long b) { return F3v_coeff(gel(x,b), a); }
    2628             : 
    2629             : INLINE void
    2630           0 : F3m_set(GEN x, long a, long b, ulong c) { F3v_set(gel(x,b), a, c); }
    2631             : 
    2632             : /* ARITHMETIC */
    2633             : INLINE GEN
    2634       35812 : matpascal(long n) { return matqpascal(n, NULL); }
    2635             : INLINE long
    2636      458584 : Z_issquare(GEN x) { return Z_issquareall(x, NULL); }
    2637             : INLINE long
    2638          98 : Z_ispower(GEN x, ulong k) { return Z_ispowerall(x, k, NULL); }
    2639             : INLINE GEN
    2640     6567176 : sqrti(GEN x) { return sqrtremi(x,NULL); }
    2641             : INLINE GEN
    2642   120747451 : gaddgs(GEN y, long s) { return gaddsg(s,y); }
    2643             : INLINE int
    2644      616064 : gcmpgs(GEN y, long s) { return -gcmpsg(s,y); }
    2645             : INLINE int
    2646       29176 : gequalgs(GEN y, long s) { return gequalsg(s,y); }
    2647             : INLINE GEN
    2648           0 : gmaxsg(long s, GEN y) { return gmaxgs(y,s); }
    2649             : INLINE GEN
    2650           0 : gminsg(long s, GEN y) { return gmings(y,s); }
    2651             : INLINE GEN
    2652    20351435 : gmulgs(GEN y, long s) { return gmulsg(s,y); }
    2653             : INLINE GEN
    2654   124149795 : gmulgu(GEN y, ulong s) { return gmulug(s,y); }
    2655             : INLINE GEN
    2656     1541970 : gsubgs(GEN y, long s) { return gaddgs(y, -s); }
    2657             : INLINE GEN
    2658      522388 : gdivsg(long s, GEN y) { return gdiv(stoi(s), y); }
    2659             : 
    2660             : INLINE GEN
    2661    13509609 : gmax_shallow(GEN x, GEN y) { return gcmp(x,y)<0? y: x; }
    2662             : INLINE GEN
    2663      893207 : gmin_shallow(GEN x, GEN y) { return gcmp(x,y)<0? x: y; }
    2664             : 
    2665             : /* x t_COMPLEX */
    2666             : INLINE GEN
    2667    91908763 : cxnorm(GEN x) { return gadd(gsqr(gel(x,1)), gsqr(gel(x,2))); }
    2668             : /* q t_QUAD */
    2669             : INLINE GEN
    2670       69860 : quadnorm(GEN q)
    2671             : {
    2672       69860 :   GEN X = gel(q,1), b = gel(X,3), c = gel(X,2);
    2673       69860 :   GEN z, u = gel(q,3), v = gel(q,2);
    2674       69860 :   if (typ(u) == t_INT && typ(v) == t_INT) /* generic case */
    2675             :   {
    2676       69671 :     z = signe(b)? mulii(v, addii(u,v)): sqri(v);
    2677       69671 :     return addii(z, mulii(c, sqri(u)));
    2678             :   }
    2679             :   else
    2680             :   {
    2681         189 :     z = signe(b)? gmul(v, gadd(u,v)): gsqr(v);
    2682         189 :     return gadd(z, gmul(c, gsqr(u)));
    2683             :   }
    2684             : }
    2685             : /* x a t_QUAD, return the attached discriminant */
    2686             : INLINE GEN
    2687        1078 : quad_disc(GEN x)
    2688             : {
    2689        1078 :   GEN Q = gel(x,1), b = gel(Q,3), c = gel(Q,2), c4 = shifti(c,2);
    2690        1078 :   if (is_pm1(b)) return subsi(1, c4);
    2691         154 :   togglesign_safe(&c4); return c4;
    2692             : }
    2693             : INLINE GEN
    2694     4777574 : qfb_disc3(GEN x, GEN y, GEN z) { return subii(sqri(y), shifti(mulii(x,z),2)); }
    2695             : INLINE GEN
    2696    18474831 : qfb_disc(GEN x) { return gel(x,4); }
    2697             : 
    2698             : INLINE GEN
    2699     4008161 : sqrfrac(GEN x)
    2700             : {
    2701     4008161 :   GEN z = cgetg(3,t_FRAC);
    2702     4008161 :   gel(z,1) = sqri(gel(x,1));
    2703     4008161 :   gel(z,2) = sqri(gel(x,2)); return z;
    2704             : }
    2705             : 
    2706             : INLINE void
    2707    16517171 : normalize_frac(GEN z) {
    2708    16517171 :   if (signe(gel(z,2)) < 0) { togglesign(gel(z,1)); setabssign(gel(z,2)); }
    2709    16517171 : }
    2710             : 
    2711             : INLINE GEN
    2712    37985646 : powii(GEN x, GEN n)
    2713             : {
    2714    37985646 :   long ln = lgefint(n);
    2715    37985646 :   if (ln == 3) {
    2716             :     GEN z;
    2717    37962903 :     if (signe(n) > 0) return powiu(x, n[2]);
    2718       73704 :     z = cgetg(3, t_FRAC);
    2719       73718 :     gel(z,1) = gen_1;
    2720       73718 :     gel(z,2) = powiu(x, n[2]);
    2721       73716 :     return z;
    2722             :   }
    2723       22743 :   if (ln == 2) return gen_1; /* rare */
    2724             :   /* should never happen */
    2725           0 :   return powgi(x, n); /* overflow unless x = 0, 1, -1 */
    2726             : }
    2727             : INLINE GEN
    2728        1561 : powIs(long n) {
    2729        1561 :   switch(n & 3)
    2730             :   {
    2731          63 :     case 1: return mkcomplex(gen_0,gen_1);
    2732         385 :     case 2: return gen_m1;
    2733         707 :     case 3: return mkcomplex(gen_0,gen_m1);
    2734             :   }
    2735         406 :   return gen_1;
    2736             : }
    2737             : 
    2738             : /*******************************************************************/
    2739             : /*                                                                 */
    2740             : /*                             ASSIGNMENTS                         */
    2741             : /*                                                                 */
    2742             : /*******************************************************************/
    2743           0 : INLINE void mpexpz(GEN x, GEN z)
    2744           0 : { pari_sp av = avma; gaffect(mpexp(x), z); set_avma(av); }
    2745           0 : INLINE void mplogz(GEN x, GEN z)
    2746           0 : { pari_sp av = avma; gaffect(mplog(x), z); set_avma(av); }
    2747           0 : INLINE void mpcosz(GEN x, GEN z)
    2748           0 : { pari_sp av = avma; gaffect(mpcos(x), z); set_avma(av); }
    2749           0 : INLINE void mpsinz(GEN x, GEN z)
    2750           0 : { pari_sp av = avma; gaffect(mpsin(x), z); set_avma(av); }
    2751           0 : INLINE void gnegz(GEN x, GEN z)
    2752           0 : { pari_sp av = avma; gaffect(gneg(x), z); set_avma(av); }
    2753           0 : INLINE void gabsz(GEN x, long prec, GEN z)
    2754           0 : { pari_sp av = avma; gaffect(gabs(x,prec), z); set_avma(av); }
    2755           0 : INLINE void gaddz(GEN x, GEN y, GEN z)
    2756           0 : { pari_sp av = avma; gaffect(gadd(x,y), z); set_avma(av); }
    2757           0 : INLINE void gsubz(GEN x, GEN y, GEN z)
    2758           0 : { pari_sp av = avma; gaffect(gsub(x,y), z); set_avma(av); }
    2759           0 : INLINE void gmulz(GEN x, GEN y, GEN z)
    2760           0 : { pari_sp av = avma; gaffect(gmul(x,y), z); set_avma(av); }
    2761           0 : INLINE void gdivz(GEN x, GEN y, GEN z)
    2762           0 : { pari_sp av = avma; gaffect(gdiv(x,y), z); set_avma(av); }
    2763           0 : INLINE void gdiventz(GEN x, GEN y, GEN z)
    2764           0 : { pari_sp av = avma; gaffect(gdivent(x,y), z); set_avma(av); }
    2765           0 : INLINE void gmodz(GEN x, GEN y, GEN z)
    2766           0 : { pari_sp av = avma; gaffect(gmod(x,y), z); set_avma(av); }
    2767           0 : INLINE void gmul2nz(GEN x, long s, GEN z)
    2768           0 : { pari_sp av = avma; gaffect(gmul2n(x,s), z); set_avma(av); }
    2769           0 : INLINE void gshiftz(GEN x, long s, GEN z)
    2770           0 : { pari_sp av = avma; gaffect(gshift(x,s), z); set_avma(av); }
    2771             : 
    2772             : /*******************************************************************/
    2773             : /*                                                                 */
    2774             : /*                       ELLIPTIC CURVES                           */
    2775             : /*                                                                 */
    2776             : /*******************************************************************/
    2777     7133461 : INLINE GEN ell_get_a1(GEN e) { return gel(e,1); }
    2778     5716404 : INLINE GEN ell_get_a2(GEN e) { return gel(e,2); }
    2779     6922268 : INLINE GEN ell_get_a3(GEN e) { return gel(e,3); }
    2780     6525917 : INLINE GEN ell_get_a4(GEN e) { return gel(e,4); }
    2781     7959531 : INLINE GEN ell_get_a6(GEN e) { return gel(e,5); }
    2782     5432031 : INLINE GEN ell_get_b2(GEN e) { return gel(e,6); }
    2783     2135394 : INLINE GEN ell_get_b4(GEN e) { return gel(e,7); }
    2784     3054676 : INLINE GEN ell_get_b6(GEN e) { return gel(e,8); }
    2785     2608971 : INLINE GEN ell_get_b8(GEN e) { return gel(e,9); }
    2786     8020924 : INLINE GEN ell_get_c4(GEN e) { return gel(e,10); }
    2787     8849848 : INLINE GEN ell_get_c6(GEN e) { return gel(e,11); }
    2788    11280240 : INLINE GEN ell_get_disc(GEN e) { return gel(e,12); }
    2789     1296342 : INLINE GEN ell_get_j(GEN e) { return gel(e,13); }
    2790    11379679 : INLINE long ell_get_type(GEN e) { return mael(e,14,1); }
    2791     2037167 : INLINE GEN ellff_get_field(GEN x) { return gmael(x, 15, 1); }
    2792      800236 : INLINE GEN ellff_get_a4a6(GEN x)  { return gmael(x, 15, 2); }
    2793        1484 : INLINE GEN ellQp_get_zero(GEN x) { return gmael(x, 15, 1); }
    2794         315 : INLINE long ellQp_get_prec(GEN E) { GEN z = ellQp_get_zero(E); return valp(z); }
    2795        1134 : INLINE GEN ellQp_get_p(GEN E) { GEN z = ellQp_get_zero(E); return gel(z,2); }
    2796      249641 : INLINE long ellR_get_prec(GEN x) { return nbits2prec(mael3(x, 15, 1, 1)); }
    2797      370840 : INLINE long ellR_get_sign(GEN x) { return mael3(x, 15, 1, 2); }
    2798     1888731 : INLINE GEN ellnf_get_nf(GEN x) { return checknf_i(gmael(x,15,1)); }
    2799         126 : INLINE GEN ellnf_get_bnf(GEN x) { return checkbnf_i(gmael(x,15,1)); }
    2800             : 
    2801     4682663 : INLINE int checkell_i(GEN e) { return typ(e) == t_VEC && lg(e) == 17; }
    2802    47551168 : INLINE int ell_is_inf(GEN z) { return lg(z) == 2; }
    2803     1232352 : INLINE GEN ellinf(void) { return mkvec(gen_0); }
    2804             : 
    2805             : /*******************************************************************/
    2806             : /*                                                                 */
    2807             : /*                    ALGEBRAIC NUMBER THEORY                      */
    2808             : /*                                                                 */
    2809             : /*******************************************************************/
    2810    32021520 : INLINE GEN modpr_get_pr(GEN x)  { return gel(x,3); }
    2811     1887277 : INLINE GEN modpr_get_p(GEN x)  { return pr_get_p(modpr_get_pr(x)); }
    2812    13884785 : INLINE GEN modpr_get_T(GEN x)  { return lg(x) == 4? NULL: gel(x,4); }
    2813             : 
    2814    91248653 : INLINE GEN pr_get_p(GEN pr)  { return gel(pr,1); }
    2815    11411702 : INLINE GEN pr_get_gen(GEN pr){ return gel(pr,2); }
    2816             : /* .[2] instead of itos works: e and f are small positive integers */
    2817    15510299 : INLINE long pr_get_e(GEN pr) { return gel(pr,3)[2]; }
    2818    25207606 : INLINE long pr_get_f(GEN pr) { return gel(pr,4)[2]; }
    2819    47889351 : INLINE GEN pr_get_tau(GEN pr){ return gel(pr,5); }
    2820             : INLINE int
    2821    16409314 : pr_is_inert(GEN P) { return typ(pr_get_tau(P)) == t_INT; }
    2822             : INLINE GEN
    2823     1000380 : pr_norm(GEN pr) { return powiu(pr_get_p(pr), pr_get_f(pr)); }
    2824             : INLINE ulong
    2825      343931 : upr_norm(GEN pr) { return upowuu(pr_get_p(pr)[2], pr_get_f(pr)); }
    2826             : 
    2827             : /* assume nf a genuine nf */
    2828             : INLINE long
    2829     1163584 : nf_get_varn(GEN nf) { return varn(gel(nf,1)); }
    2830             : INLINE GEN
    2831   106065382 : nf_get_pol(GEN nf) { return gel(nf,1); }
    2832             : INLINE long
    2833    80177632 : nf_get_degree(GEN nf) { return degpol( nf_get_pol(nf) ); }
    2834             : INLINE long
    2835    22515736 : nf_get_r1(GEN nf) { GEN x = gel(nf,2); return itou(gel(x,1)); }
    2836             : INLINE long
    2837        4231 : nf_get_r2(GEN nf) { GEN x = gel(nf,2); return itou(gel(x,2)); }
    2838             : INLINE GEN
    2839      452807 : nf_get_disc(GEN nf) { return gel(nf,3); }
    2840             : INLINE GEN
    2841     3569489 : nf_get_index(GEN nf) { return gel(nf,4); }
    2842             : INLINE GEN
    2843    22662751 : nf_get_M(GEN nf) { return gmael(nf,5,1); }
    2844             : INLINE GEN
    2845      238321 : nf_get_G(GEN nf) { return gmael(nf,5,2); }
    2846             : INLINE GEN
    2847     1618848 : nf_get_roundG(GEN nf) { return gmael(nf,5,3); }
    2848             : INLINE GEN
    2849       22084 : nf_get_Tr(GEN nf) { return gmael(nf,5,4); }
    2850             : INLINE GEN
    2851        4444 : nf_get_diff(GEN nf) { return gmael(nf,5,5); }
    2852             : INLINE GEN
    2853       58050 : nf_get_ramified_primes(GEN nf) { return gmael(nf,5,8); }
    2854             : INLINE GEN
    2855     1398969 : nf_get_roots(GEN nf) { return gel(nf,6); }
    2856             : INLINE GEN
    2857        1848 : nf_get_zk(GEN nf)
    2858             : {
    2859        1848 :   GEN y = gel(nf,7), D = gel(y, 1);
    2860        1848 :   if (typ(D) == t_POL) D = gel(D, 2);
    2861        1848 :   if (!equali1(D)) y = gdiv(y, D);
    2862        1848 :   return y;
    2863             : }
    2864             : INLINE GEN
    2865     4080236 : nf_get_zkprimpart(GEN nf)
    2866             : {
    2867     4080236 :   GEN y = gel(nf,7);
    2868             :   /* test for old format of nf.zk: non normalized */
    2869     4080236 :   if (!equali1(gel(nf,4)) && gequal1(gel(y,1))) y = Q_remove_denom(y,NULL);
    2870     4080241 :   return y;
    2871             : }
    2872             : INLINE GEN
    2873     4126707 : nf_get_zkden(GEN nf)
    2874             : {
    2875     4126707 :   GEN y = gel(nf,7), D = gel(y,1);
    2876     4126707 :   if (typ(D) == t_POL) D = gel(D,2);
    2877             :   /* test for old format of nf.zk: non normalized */
    2878     4126707 :   if (!equali1(gel(nf,4)) && equali1(D)) D = Q_denom(y);
    2879     4126700 :   return D;
    2880             : }
    2881             : INLINE GEN
    2882     9831237 : nf_get_invzk(GEN nf) { return gel(nf,8); }
    2883             : INLINE void
    2884      516144 : nf_get_sign(GEN nf, long *r1, long *r2)
    2885             : {
    2886      516144 :   GEN x = gel(nf,2);
    2887      516144 :   *r1 = itou(gel(x,1));
    2888      516144 :   *r2 = itou(gel(x,2));
    2889      516144 : }
    2890             : 
    2891             : INLINE GEN
    2892     2521259 : cyc_get_expo(GEN c) { return lg(c) == 1? gen_1: gel(c,1); }
    2893             : INLINE GEN
    2894      391808 : abgrp_get_no(GEN x) { return gel(x,1); }
    2895             : INLINE GEN
    2896    11548279 : abgrp_get_cyc(GEN x) { return gel(x,2); }
    2897             : INLINE GEN
    2898     1653398 : abgrp_get_gen(GEN x) { return gel(x,3); }
    2899             : INLINE GEN
    2900     9424615 : bnf_get_nf(GEN bnf) { return gel(bnf,7); }
    2901             : INLINE GEN
    2902     5097121 : bnf_get_clgp(GEN bnf) { return gmael(bnf,8,1); }
    2903             : INLINE GEN
    2904        8379 : bnf_get_no(GEN bnf) { return abgrp_get_no(bnf_get_clgp(bnf)); }
    2905             : INLINE GEN
    2906     3508925 : bnf_get_cyc(GEN bnf) { return abgrp_get_cyc(bnf_get_clgp(bnf)); }
    2907             : INLINE GEN
    2908     1579656 : bnf_get_gen(GEN bnf)  { return abgrp_get_gen(bnf_get_clgp(bnf)); }
    2909             : INLINE GEN
    2910         641 : bnf_get_reg(GEN bnf) { return gmael(bnf,8,2); }
    2911             : INLINE GEN
    2912     2702012 : bnf_get_logfu(GEN bnf) { return gel(bnf,3); }
    2913             : INLINE GEN
    2914     1278264 : bnf_get_sunits(GEN bnf)
    2915     1278264 : { GEN s = gmael(bnf,8,3); return typ(s) == t_INT? NULL: s; }
    2916             : INLINE GEN
    2917      290327 : bnf_get_tuU(GEN bnf) { return gmael3(bnf,8,4,2); }
    2918             : INLINE long
    2919      264988 : bnf_get_tuN(GEN bnf) { return gmael3(bnf,8,4,1)[2]; }
    2920             : INLINE GEN
    2921      287990 : bnf_get_fu_nocheck(GEN bnf) { return gmael(bnf,8,5); }
    2922             : INLINE GEN
    2923       26279 : nfV_to_scalar_or_alg(GEN nf, GEN x)
    2924       63406 : { pari_APPLY_same(nf_to_scalar_or_alg(nf, gel(x,i))) }
    2925             : INLINE GEN
    2926       25838 : bnf_get_fu(GEN bnf) {
    2927       25838 :   GEN fu = bnf_build_units(bnf), nf = bnf_get_nf(bnf);
    2928       25838 :   if (typ(fu) == t_MAT) pari_err(e_MISC,"missing units in bnf");
    2929       25838 :   return nfV_to_scalar_or_alg(nf, vecslice(fu, 2, lg(fu)-1));
    2930             : }
    2931             : 
    2932             : INLINE GEN
    2933     3631891 : bnr_get_bnf(GEN bnr) { return gel(bnr,1); }
    2934             : INLINE GEN
    2935     1936763 : bnr_get_bid(GEN bnr) { return gel(bnr,2); }
    2936             : INLINE GEN
    2937      140821 : bnr_get_mod(GEN bnr) { return gmael(bnr,2,1); }
    2938             : INLINE GEN
    2939     1259702 : bnr_get_nf(GEN bnr) { return gmael(bnr,1,7); }
    2940             : INLINE GEN
    2941     2728069 : bnr_get_clgp(GEN bnr) { return gel(bnr,5); }
    2942             : INLINE GEN
    2943      314411 : bnr_get_no(GEN bnr) { return abgrp_get_no(bnr_get_clgp(bnr)); }
    2944             : INLINE GEN
    2945     2396048 : bnr_get_cyc(GEN bnr) { return abgrp_get_cyc(bnr_get_clgp(bnr)); }
    2946             : INLINE GEN
    2947          70 : bnr_get_gen_nocheck(GEN bnr) { return abgrp_get_gen(bnr_get_clgp(bnr)); }
    2948             : INLINE GEN
    2949        7847 : bnr_get_gen(GEN bnr) {
    2950        7847 :   GEN G = bnr_get_clgp(bnr);
    2951        7847 :   if (lg(G) !=  4)
    2952           0 :     pari_err(e_MISC,"missing bnr generators: please use bnrinit(,,1)");
    2953        7847 :   return gel(G,3);
    2954             : }
    2955             : 
    2956             : /* localstar, used in gchar */
    2957             : INLINE GEN
    2958       51956 : locs_get_cyc(GEN locs) { return gel(locs,1); }
    2959             : INLINE GEN
    2960      191695 : locs_get_Lsprk(GEN locs) { return gel(locs,2); }
    2961             : INLINE GEN
    2962        1260 : locs_get_Lgenfil(GEN locs) { return gel(locs,3); }
    2963             : INLINE GEN
    2964        8225 : locs_get_mod(GEN locs) { return gel(locs,4); }
    2965             : /* pr dividing the modulus N of locs, 0 <= i < v_pr(N)
    2966             :  * return a t_MAT whose columns are the logs
    2967             :  * of generators of U_i(pr)/U_{i+1}(pr). */
    2968             : INLINE GEN
    2969        1260 : locs_get_famod(GEN locs) { return gmael(locs,4,1); }
    2970             : INLINE GEN
    2971      207235 : locs_get_m_infty(GEN locs) { return gmael(locs,4,2); }
    2972             : 
    2973             : /* G a grossenchar group */
    2974             : INLINE GEN
    2975       32639 : gchar_get_basis(GEN gc)  { return  gel(gc, 1); }
    2976             : INLINE GEN
    2977      203105 : gchar_get_bnf(GEN gc)    { return  gel(gc, 2); }
    2978             : INLINE GEN
    2979      241405 : gchar_get_nf(GEN gc)    { return  gel(gc, 3); }
    2980             : INLINE GEN
    2981      279435 : gchar_get_zm(GEN gc)     { return  gel(gc, 4); }
    2982             : INLINE GEN
    2983        8225 : gchar_get_mod(GEN gc)    { return  locs_get_mod(gchar_get_zm(gc)); }
    2984             : INLINE GEN
    2985        4095 : gchar_get_modP(GEN gc)    { return gmael(gchar_get_mod(gc),1,1); }
    2986             : INLINE GEN
    2987       36866 : gchar_get_S(GEN gc)      { return  gel(gc, 5); }
    2988             : INLINE GEN
    2989      188468 : gchar_get_DLdata(GEN gc)   { return  gel(gc, 6); }
    2990             : INLINE GEN
    2991        1749 : gchar_get_sfu(GEN gc) { return  gel(gc, 7); }
    2992             : INLINE GEN
    2993       16168 : gchar_get_cyc(GEN gc)    { return  gel(gc, 9); }
    2994             : INLINE GEN
    2995           0 : gchar_get_hnf(GEN gc)    { return  gmael(gc, 10, 1); }
    2996             : INLINE GEN
    2997           0 : gchar_get_U(GEN gc)      { return  gmael(gc, 10, 2); }
    2998             : INLINE GEN
    2999       10969 : gchar_get_Ui(GEN gc)     { return  gmael(gc, 10, 3); }
    3000             : INLINE GEN
    3001        3322 : gchar_get_m0(GEN gc)     { return gel(gc, 11); }
    3002             : INLINE GEN
    3003        4272 : gchar_get_u0(GEN gc)     { return gel(gc, 12); }
    3004             : INLINE long
    3005       17416 : gchar_get_r1(GEN gc)     { return nf_get_r1(gchar_get_nf(gc)); }
    3006             : INLINE long
    3007         623 : gchar_get_r2(GEN gc)     { return nf_get_r2(gchar_get_nf(gc)); }
    3008             : INLINE GEN
    3009       50348 : gchar_get_loccyc(GEN gc) { return locs_get_cyc(gchar_get_zm(gc)); }
    3010             : INLINE long
    3011       37132 : gchar_get_nc(GEN gc)     { return lg(gchar_get_loccyc(gc))-1; }
    3012             : INLINE long
    3013       36866 : gchar_get_ns(GEN gc)     { return lg(gchar_get_S(gc))-1; }
    3014             : INLINE long
    3015        1841 : gchar_get_nm(GEN gc)     { return lg(gchar_get_basis(gc))-1; }
    3016             : INLINE long
    3017        4011 : gchar_get_evalprec(GEN gc)   { return  gmael(gc, 8, 1)[1]; }
    3018             : INLINE long
    3019       18732 : gchar_get_prec(GEN gc)   { return  gmael(gc, 8, 1)[2]; }
    3020             : INLINE long
    3021       13419 : gchar_get_nfprec(GEN gc) { return  gmael(gc, 8, 1)[3]; }
    3022             : INLINE void
    3023        1785 : gchar_set_evalprec(GEN gc, long prec) { gmael(gc, 8, 1)[1] = prec; }
    3024             : INLINE void
    3025        1202 : gchar_set_prec(GEN gc, long prec) { gmael(gc, 8, 1)[2] = prec; }
    3026             : INLINE void
    3027        1202 : gchar_copy_precs(GEN gc, GEN gc2)
    3028             : {
    3029        1202 :   gel(gc2, 8) = shallowcopy(gel(gc,8));
    3030        1202 :   gmael(gc2, 8, 1) = shallowcopy(gmael(gc, 8, 1));
    3031        1202 : }
    3032             : INLINE void
    3033        2951 : gchar_set_nfprec(GEN gc, long prec) { gmael(gc, 8, 1)[3] = prec; }
    3034             : INLINE long
    3035         322 : gchar_get_ntors(GEN gc)   { return  gmael(gc, 8, 2)[1]; }
    3036             : INLINE long
    3037         322 : gchar_get_nfree(GEN gc)   { return  gmael(gc, 8, 2)[2]; }
    3038             : INLINE long
    3039        2042 : gchar_get_nalg(GEN gc)   { return  gmael(gc, 8, 2)[3]; }
    3040             : INLINE void
    3041        1573 : gchar_set_basis(GEN gc, GEN m_inv)  { gel(gc, 1) = m_inv; }
    3042             : INLINE void
    3043        2078 : gchar_set_nf(GEN gc, GEN nf)      { gel(gc, 3) = nf; }
    3044             : INLINE void
    3045         623 : gchar_set_ntors(GEN gc, long n)    { gmael(gc, 8, 2)[1] = n; }
    3046             : INLINE void
    3047         623 : gchar_set_nfree(GEN gc, long n)    { gmael(gc, 8, 2)[2] = n; }
    3048             : INLINE void
    3049         623 : gchar_set_nalg(GEN gc, long n)    { gmael(gc, 8, 2)[3] = n; }
    3050             : INLINE void
    3051        1573 : gchar_set_cyc(GEN gc, GEN cyc)      { gel(gc, 9) = cyc; }
    3052             : INLINE void
    3053         623 : gchar_set_HUUi(GEN gc, GEN hnf, GEN U, GEN Ui) { gel(gc, 10) = mkvec3(hnf, U, Ui); }
    3054             : INLINE void
    3055         950 : gchar_set_m0(GEN gc, GEN m0)     { gel(gc, 11) = m0; }
    3056             : INLINE void
    3057        2093 : gchar_set_u0(GEN gc, GEN u0)     { gel(gc, 12) = u0; }
    3058             : 
    3059             : INLINE GEN
    3060     1386659 : bid_get_mod(GEN bid) { return gel(bid,1); }
    3061             : INLINE GEN
    3062       78295 : bid_get_ideal(GEN bid) { return gmael(bid,1,1); }
    3063             : INLINE GEN
    3064       35091 : bid_get_arch(GEN bid) { return gmael(bid,1,2); }
    3065             : INLINE GEN
    3066     5415191 : bid_get_grp(GEN bid) { return gel(bid,2); }
    3067             : INLINE GEN
    3068     2313522 : bid_get_fact(GEN bid) { return gmael(bid,3,1); }
    3069             : INLINE GEN
    3070     2025071 : bid_get_fact2(GEN bid) { return gmael(bid,3,2); }
    3071             : INLINE GEN
    3072     1990544 : bid_get_MOD(GEN bid) { GEN y = gel(bid,4); return lg(y) == 4? gel(y,3): NULL; }
    3073             : INLINE GEN
    3074     1991259 : bid_get_sprk(GEN bid) { return gmael(bid,4,1); }
    3075             : INLINE GEN
    3076       51226 : bid_get_sarch(GEN bid) { return gmael(bid,4,2); }
    3077             : INLINE GEN
    3078     2217441 : bid_get_archp(GEN bid) { return gmael3(bid,4,2,2); }
    3079             : INLINE GEN
    3080     3378253 : bid_get_U(GEN bid) { return gel(bid,5); }
    3081             : INLINE GEN
    3082           0 : bid_get_no(GEN bid) { return abgrp_get_no(bid_get_grp(bid)); }
    3083             : INLINE GEN
    3084     5361282 : bid_get_cyc(GEN bid) { return abgrp_get_cyc(bid_get_grp(bid)); }
    3085             : INLINE GEN
    3086           0 : bid_get_gen_nocheck(GEN bid)  { return abgrp_get_gen(bid_get_grp(bid)); }
    3087             : INLINE GEN
    3088       53326 : bid_get_gen(GEN bid) {
    3089       53326 :   GEN G = bid_get_grp(bid);
    3090       53326 :   if (lg(G) != 4) pari_err(e_MISC,"missing bid generators. Use idealstar(,,2)");
    3091       53326 :   return abgrp_get_gen(G);
    3092             : }
    3093             : 
    3094             : INLINE GEN
    3095    33820236 : znstar_get_N(GEN G) { return gmael(G,1,1); }
    3096             : INLINE GEN
    3097     7205872 : znstar_get_faN(GEN G) { return gel(G,3); }
    3098             : INLINE GEN
    3099          14 : znstar_get_no(GEN G) { return abgrp_get_no(gel(G,2)); }
    3100             : INLINE GEN
    3101      261920 : znstar_get_cyc(GEN G) { return abgrp_get_cyc(gel(G,2)); }
    3102             : INLINE GEN
    3103       16150 : znstar_get_gen(GEN G) { return abgrp_get_gen(gel(G,2)); }
    3104             : INLINE GEN
    3105     7818252 : znstar_get_conreycyc(GEN G) { return gmael(G,4,5); }
    3106             : INLINE GEN
    3107     3219560 : znstar_get_conreygen(GEN G) { return gmael(G,4,4); }
    3108             : INLINE GEN
    3109       46788 : znstar_get_Ui(GEN G) { return gmael(G,4,3); }
    3110             : INLINE GEN
    3111      176051 : znstar_get_U(GEN G) { return gel(G,5); }
    3112             : INLINE GEN
    3113     2819363 : znstar_get_pe(GEN G) { return gmael(G,4,1); }
    3114             : INLINE GEN
    3115       35875 : gal_get_pol(GEN gal) { return gel(gal,1); }
    3116             : INLINE GEN
    3117        6006 : gal_get_p(GEN gal) { return gmael(gal,2,1); }
    3118             : INLINE GEN
    3119          91 : gal_get_e(GEN gal) { return gmael(gal,2,2); }
    3120             : INLINE GEN
    3121       23660 : gal_get_mod(GEN gal) { return gmael(gal,2,3); }
    3122             : INLINE GEN
    3123       32319 : gal_get_roots(GEN gal) { return gel(gal,3); }
    3124             : INLINE GEN
    3125       27461 : gal_get_invvdm(GEN gal) { return gel(gal,4); }
    3126             : INLINE GEN
    3127       27454 : gal_get_den(GEN gal) { return gel(gal,5); }
    3128             : INLINE GEN
    3129       79462 : gal_get_group(GEN gal) { return gel(gal,6); }
    3130             : INLINE GEN
    3131        8638 : gal_get_gen(GEN gal) { return gel(gal,7); }
    3132             : INLINE GEN
    3133        6636 : gal_get_orders(GEN gal) { return gel(gal,8); }
    3134             : 
    3135             : /* assume rnf a genuine rnf */
    3136             : INLINE long
    3137     1224663 : rnf_get_degree(GEN rnf) { return degpol(rnf_get_pol(rnf)); }
    3138             : INLINE long
    3139       17493 : rnf_get_nfdegree(GEN rnf) { return degpol(nf_get_pol(rnf_get_nf(rnf))); }
    3140             : INLINE long
    3141      768035 : rnf_get_absdegree(GEN rnf) { return degpol(gmael(rnf,11,1)); }
    3142             : INLINE GEN
    3143         819 : rnf_get_idealdisc(GEN rnf) { return gmael(rnf,3,1); }
    3144             : INLINE GEN
    3145         805 : rnf_get_k(GEN rnf) { return gmael(rnf,11,3); }
    3146             : INLINE GEN
    3147         903 : rnf_get_alpha(GEN rnf) { return gmael(rnf, 11, 2); }
    3148             : INLINE GEN
    3149      459753 : rnf_get_nf(GEN rnf) { return gel(rnf,10); }
    3150             : INLINE GEN
    3151        4760 : rnf_get_nfzk(GEN rnf) { return gel(rnf,2); }
    3152             : INLINE GEN
    3153      227315 : rnf_get_polabs(GEN rnf) { return gmael(rnf,11,1); }
    3154             : INLINE GEN
    3155     1486912 : rnf_get_pol(GEN rnf) { return gel(rnf,1); }
    3156             : INLINE GEN
    3157         280 : rnf_get_disc(GEN rnf) { return gel(rnf,3); }
    3158             : INLINE GEN
    3159         105 : rnf_get_index(GEN rnf) { return gel(rnf,4); }
    3160             : INLINE GEN
    3161        1904 : rnf_get_ramified_primes(GEN rnf) { return gel(rnf,5); }
    3162             : INLINE long
    3163         574 : rnf_get_varn(GEN rnf) { return varn(gel(rnf,1)); }
    3164             : INLINE GEN
    3165      199417 : rnf_get_nfpol(GEN rnf) { return gmael(rnf,10,1); }
    3166             : INLINE long
    3167        3388 : rnf_get_nfvarn(GEN rnf) { return varn(gmael(rnf,10,1)); }
    3168             : INLINE GEN
    3169        3885 : rnf_get_zk(GEN rnf) { return gel(rnf,7); }
    3170             : INLINE GEN
    3171      107826 : rnf_get_map(GEN rnf) { return gel(rnf,11); }
    3172             : INLINE GEN
    3173        1225 : rnf_get_invzk(GEN rnf) { return gel(rnf,8); }
    3174             : 
    3175             : INLINE GEN
    3176      138543 : idealred(GEN nf, GEN I) { return idealred0(nf, I, NULL); }
    3177             : 
    3178             : INLINE GEN
    3179        3415 : idealchineseinit(GEN nf, GEN x)
    3180        3415 : { return idealchinese(nf,x,NULL); }
    3181             : 
    3182             : /*******************************************************************/
    3183             : /*                                                                 */
    3184             : /*                              CLOSURES                           */
    3185             : /*                                                                 */
    3186             : /*******************************************************************/
    3187   360595941 : INLINE long closure_arity(GEN C)          { return ((ulong)C[1])&ARITYBITS; }
    3188    40018719 : INLINE long closure_is_variadic(GEN C) { return !!(((ulong)C[1])&VARARGBITS); }
    3189   311975988 : INLINE const char *closure_codestr(GEN C)  { return GSTR(gel(C,2))-1; }
    3190           0 : INLINE GEN closure_get_code(GEN C)  { return gel(C,2); }
    3191   311946893 : INLINE GEN closure_get_oper(GEN C)  { return gel(C,3); }
    3192   311916088 : INLINE GEN closure_get_data(GEN C)  { return gel(C,4); }
    3193       12865 : INLINE GEN closure_get_dbg(GEN C)   { return gel(C,5); }
    3194       35546 : INLINE GEN closure_get_text(GEN C)  { return gel(C,6); }
    3195    12958536 : INLINE GEN closure_get_frame(GEN C) { return gel(C,7); }
    3196             : 
    3197             : /*******************************************************************/
    3198             : /*                                                                 */
    3199             : /*                               ERRORS                            */
    3200             : /*                                                                 */
    3201             : /*******************************************************************/
    3202             : INLINE long
    3203       61010 : err_get_num(GEN e) { return e[1]; }
    3204             : INLINE GEN
    3205         273 : err_get_compo(GEN e, long i) { return gel(e, i+1); }
    3206             : 
    3207             : INLINE void
    3208          14 : pari_err_BUG(const char *f) { pari_err(e_BUG,f); }
    3209             : INLINE void
    3210          21 : pari_err_CONSTPOL(const char *f) { pari_err(e_CONSTPOL, f); }
    3211             : INLINE void
    3212          84 : pari_err_COPRIME(const char *f, GEN x, GEN y) { pari_err(e_COPRIME, f,x,y); }
    3213             : INLINE void
    3214         690 : pari_err_DIM(const char *f) { pari_err(e_DIM, f); }
    3215             : INLINE void
    3216           0 : pari_err_FILE(const char *f, const char *g) { pari_err(e_FILE, f,g); }
    3217             : INLINE void
    3218          36 : pari_err_FILEDESC(const char *f, long n) { pari_err(e_FILEDESC, f,n); }
    3219             : INLINE void
    3220          98 : pari_err_FLAG(const char *f) { pari_err(e_FLAG,f); }
    3221             : INLINE void
    3222         518 : pari_err_IMPL(const char *f) { pari_err(e_IMPL,f); }
    3223             : INLINE void
    3224       19997 : pari_err_INV(const char *f, GEN x) { pari_err(e_INV,f,x); }
    3225             : INLINE void
    3226          63 : pari_err_IRREDPOL(const char *f, GEN x) { pari_err(e_IRREDPOL, f,x); }
    3227             : INLINE void
    3228        2736 : 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); }
    3229             : INLINE void
    3230         214 : pari_err_COMPONENT(const char *f, const char *op, GEN l, GEN x) { pari_err(e_COMPONENT, f,op,l,x); }
    3231             : INLINE void
    3232           0 : pari_err_MAXPRIME(ulong c) { pari_err(e_MAXPRIME, c); }
    3233             : INLINE void
    3234         406 : pari_err_OP(const char *f, GEN x, GEN y) { pari_err(e_OP, f,x,y); }
    3235             : INLINE void
    3236         156 : pari_err_OVERFLOW(const char *f) { pari_err(e_OVERFLOW, f); }
    3237             : INLINE void
    3238         238 : pari_err_PREC(const char *f) { pari_err(e_PREC,f); }
    3239             : INLINE void
    3240           0 : pari_err_PACKAGE(const char *f) { pari_err(e_PACKAGE,f); }
    3241             : INLINE void
    3242          98 : pari_err_PRIME(const char *f, GEN x) { pari_err(e_PRIME, f,x); }
    3243             : INLINE void
    3244        1316 : pari_err_MODULUS(const char *f, GEN x, GEN y) { pari_err(e_MODULUS, f,x,y); }
    3245             : INLINE void
    3246          63 : pari_err_ROOTS0(const char *f) { pari_err(e_ROOTS0, f); }
    3247             : INLINE void
    3248          84 : pari_err_SQRTN(const char *f, GEN x) { pari_err(e_SQRTN, f,x); }
    3249             : INLINE void
    3250       14796 : pari_err_TYPE(const char *f, GEN x) { pari_err(e_TYPE, f,x); }
    3251             : INLINE void
    3252        3500 : pari_err_TYPE2(const char *f, GEN x, GEN y) { pari_err(e_TYPE2, f,x,y); }
    3253             : INLINE void
    3254         364 : pari_err_VAR(const char *f, GEN x, GEN y) { pari_err(e_VAR, f,x,y); }
    3255             : INLINE void
    3256         245 : pari_err_PRIORITY(const char *f, GEN x, const char *op, long v)
    3257         245 : { pari_err(e_PRIORITY, f,x,op,v); }
    3258             : 

Generated by: LCOV version 1.16