Testing latest pari + WASM + node.js... and it works?! Wow.
License: GPL3
ubuntu2004
/* Copyright (C) 2000 The PARI group.12This file is part of the PARI/GP package.34PARI/GP is free software; you can redistribute it and/or modify it under the5terms of the GNU General Public License as published by the Free Software6Foundation; either version 2 of the License, or (at your option) any later7version. It is distributed in the hope that it will be useful, but WITHOUT8ANY WARRANTY WHATSOEVER.910Check the License for details. You should have received a copy of it, along11with the package; see the file 'COPYING'. If not, write to the Free Software12Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */1314/* This file defines the parameters of the GEN type */1516#ifdef _WIN6417typedef unsigned long long pari_ulong;18#define long long long19#define labs llabs20#else21typedef unsigned long pari_ulong;22#endif23#define ulong pari_ulong24typedef long *GEN;2526#undef ULONG_MAX27#undef LONG_MAX2829#ifdef LONG_IS_64BIT30# define BITS_IN_LONG 6431# define TWOPOTBITS_IN_LONG 632# define LONG_MAX (9223372036854775807L) /* 2^63-1 */33# define SMALL_ULONG(p) ((ulong)p <= 3037000493UL)34#else35# define BITS_IN_LONG 3236# define TWOPOTBITS_IN_LONG 537# define LONG_MAX (2147483647L) /* 2^31-1 */38# define SMALL_ULONG(p) ((ulong)p <= 46337UL) /* 2p^2 < 2^BITS_IN_LONG */39#endif40#define ULONG_MAX (~0x0UL)4142#define DEFAULTPREC (2 + (long)(8/sizeof(long)))43#define MEDDEFAULTPREC (2 + (long)(16/sizeof(long)))44#define BIGDEFAULTPREC (2 + (long)(24/sizeof(long)))45#define LOWDEFAULTPREC 346#define EXTRAPRECWORD 147#define EXTRAPREC64 ((long)(8/sizeof(long)))48#define HIGHBIT (1UL << (BITS_IN_LONG-1))49#define BITS_IN_HALFULONG (BITS_IN_LONG>>1)5051#define LOWMASK ((1UL<<BITS_IN_HALFULONG) - 1)52#define HIGHMASK (~LOWMASK)5354#define HIGHWORD(a) ((a) >> BITS_IN_HALFULONG)55#define LOWWORD(a) ((a) & LOWMASK)5657/* Order of bits in codewords:58* x[0] TYPBITS, CLONEBIT, LGBITS59* x[1].real SIGNBITS, EXPOBITS60* int SIGNBITS, LGBITS61* pol SIGNBITS, VARNBITS62* ser SIGNBITS, VARNBITS, VALPBITS63* padic VALPBITS, PRECPBITS */64#define TYPnumBITS 765#define SIGNnumBITS 26667#ifdef LONG_IS_64BIT68# define VARNnumBITS 16 /* otherwise MAXVARN too large */69#else70# define VARNnumBITS 1471#endif7273/* no user serviceable parts below :-) */74#define LGnumBITS (BITS_IN_LONG - 1 - TYPnumBITS)75#define VALPnumBITS (BITS_IN_LONG - SIGNnumBITS - VARNnumBITS)76#define EXPOnumBITS (BITS_IN_LONG - SIGNnumBITS)77#define PRECPSHIFT VALPnumBITS78#define VARNSHIFT VALPnumBITS79#define TYPSHIFT (BITS_IN_LONG - TYPnumBITS)80#define SIGNSHIFT (BITS_IN_LONG - SIGNnumBITS)8182#define EXPOBITS ((1UL<<EXPOnumBITS)-1)83#define SIGNBITS (~((1UL<<SIGNSHIFT) - 1))84#define TYPBITS (~((1UL<< TYPSHIFT) - 1))85#define PRECPBITS (~VALPBITS)86#define LGBITS ((1UL<<LGnumBITS)-1)87#define VALPBITS ((1UL<<VALPnumBITS)-1)88#define VARNBITS (MAXVARN<<VARNSHIFT)89#define MAXVARN ((1UL<<VARNnumBITS)-1)90#define NO_VARIABLE (-1)91#define VARARGBITS HIGHBIT92#define ARITYBITS (~VARARGBITS)9394#define HIGHEXPOBIT (1UL<<(EXPOnumBITS-1))95#define HIGHVALPBIT (1UL<<(VALPnumBITS-1))96#define CLONEBIT (1UL<<LGnumBITS)9798#define evaltyp(x) (((ulong)(x)) << TYPSHIFT)99#define evalvarn(x) (((ulong)(x)) << VARNSHIFT)100#define evalsigne(x) (((ulong)(x)) << SIGNSHIFT)101#define _evalexpo(x) (HIGHEXPOBIT + (x))102#define _evalvalp(x) (HIGHVALPBIT + (x))103#define _evalprecp(x) (((long)(x)) << PRECPSHIFT)104#define evallgefint(x) (x)105#define evallgeflist(x) (x)106#define _evallg(x) (x)107108#define typ(x) ((long)(((ulong)((x)[0])) >> TYPSHIFT))109#define settyp(x,s) (((ulong*)(x))[0]=\110(((ulong*)(x))[0]&(~TYPBITS)) | evaltyp(s))111112#define isclone(x) (((ulong*) (x))[0] & CLONEBIT)113#define setisclone(x) (((ulong*) (x))[0] |= CLONEBIT)114#define unsetisclone(x) (((ulong*) (x))[0] &= (~CLONEBIT))115116#define lg(x) ((long)(((ulong)((x)[0])) & LGBITS))117#define setlg(x,s) (((ulong*)(x))[0]=\118(((ulong*)(x))[0]&(~LGBITS)) | evallg(s))119120#define signe(x) (((long)((x)[1])) >> SIGNSHIFT)121#define setsigne(x,s) (((ulong*)(x))[1]=\122(((ulong*)(x))[1]&(~SIGNBITS)) | (ulong)evalsigne(s))123124#define lgefint(x) ((long)(((ulong)((x)[1])) & LGBITS))125#define setlgefint(x,s) (((ulong*)(x))[1]=\126(((ulong*)(x))[1]&(~LGBITS)) | (ulong)evallgefint(s))127128#define realprec(x) ((long)(((ulong)((x)[0])) & LGBITS))129#define setprec(x,s) (((ulong*)(x))[0]=\130(((ulong*)(x))[0]&(~LGBITS)) | evallg(s))131#define incrprec(x) ((x)++)132133#define expo(x) ((long) ((((ulong)((x)[1])) & EXPOBITS) - HIGHEXPOBIT))134#define setexpo(x,s) (((ulong*)(x))[1]=\135(((ulong*)(x))[1]&(~EXPOBITS)) | (ulong)evalexpo(s))136137#define valp(x) ((long) ((((ulong)((x)[1])) & VALPBITS) - HIGHVALPBIT))138#define setvalp(x,s) (((ulong*)(x))[1]=\139(((ulong*)(x))[1]&(~VALPBITS)) | (ulong)evalvalp(s))140141#define precp(x) ((long) (((ulong)((x)[1])) >> PRECPSHIFT))142#define setprecp(x,s) (((ulong*)(x))[1]=\143(((ulong*)(x))[1]&(~PRECPBITS)) | (ulong)evalprecp(s))144145#define varn(x) ((long)((((ulong)((x)[1]))&VARNBITS) >> VARNSHIFT))146#define setvarn(x,s) (((ulong*)(x))[1]=\147(((ulong*)(x))[1]&(~VARNBITS)) | (ulong)evalvarn(s))148149/* t_LIST */150151#define list_typ(x) ((long)(((ulong)((x)[1])) >> TYPSHIFT))152#define list_nmax(x) ((long)(((ulong)((x)[1])) & LGBITS))153#define list_data(x) ((GEN*)x)[2]154enum {155t_LIST_RAW = 0,156t_LIST_MAP = 1157};158159/* DO NOT REORDER THESE160* actual values can be changed. Adapt lontyp in gen2.c */161enum {162t_INT = 1,163t_REAL = 2,164t_INTMOD = 3,165t_FRAC = 4,166t_FFELT = 5,167t_COMPLEX= 6,168t_PADIC = 7,169t_QUAD = 8,170t_POLMOD = 9,171t_POL = 10,172t_SER = 11,173t_RFRAC = 13,174t_QFB = 15,175t_VEC = 17,176t_COL = 18,177t_MAT = 19,178t_LIST = 20,179t_STR = 21,180t_VECSMALL= 22,181t_CLOSURE = 23,182t_ERROR = 24,183t_INFINITY= 25184};185186187