[BACK]Return to paricom.h CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / pari-2.2 / src / headers

Annotation of OpenXM_contrib/pari-2.2/src/headers/paricom.h, Revision 1.1.1.1

1.1       noro        1: /* $Id: paricom.h,v 1.18 2001/09/30 23:29:58 karim Exp $
                      2:
                      3: Copyright (C) 2000  The PARI group.
                      4:
                      5: This file is part of the PARI/GP package.
                      6:
                      7: PARI/GP is free software; you can redistribute it and/or modify it under the
                      8: terms of the GNU General Public License as published by the Free Software
                      9: Foundation. It is distributed in the hope that it will be useful, but WITHOUT
                     10: ANY WARRANTY WHATSOEVER.
                     11:
                     12: Check the License for details. You should have received a copy of it, along
                     13: with the package; see the file 'COPYING'. If not, write to the Free Software
                     14: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
                     15:
                     16: /******************************************************************/
                     17: /*                                                                */
                     18: /*              PARI header file (common to all versions)         */
                     19: /*                                                                */
                     20: /******************************************************************/
                     21:
                     22: #define bit_accuracy(x) (((x)-2) << TWOPOTBITS_IN_LONG)
                     23:
                     24: #define GSTR(x) ((char*) (((GEN) (x)) + 1 ))
                     25:
                     26: /* For compatibility with 1.x.x */
                     27: #define err pari_err /* move to e.g paritr.h ? */
                     28: #define init pari_init
                     29: #define gen2str GENtostr
                     30: #define gpui gpow
                     31: #define gpuigs gpowgs
                     32: #define classno3 hclassno
                     33: #define strtoGEN flisexpr
                     34: #define permute numtoperm
                     35: #define permuteInv permtonum
                     36:
                     37: #define rcopy mpcopy
                     38: #define absr  mpabs
                     39: #define absi  mpabs
                     40: #define negi  mpneg
                     41: #define negr  mpneg
                     42: #define mpnegz(x,y)      {long av=avma;mpaff(mpneg(x),y);avma=av;}
                     43: #define mpabsz(x,y)      {long av=avma;mpaff(mpabs(x),y);avma=av;}
                     44: #define absrz(x,z)       mpabsz((x),(z))
                     45: #define negrz(x,z)       mpnegz((x),(z))
                     46:
                     47: /* Common global variables: */
                     48:
                     49: extern PariOUT *pariOut, *pariErr;
                     50: extern FILE    *pari_outfile, *logfile, *infile, *errfile;
                     51:
                     52: extern long  DEBUGFILES, DEBUGLEVEL, DEBUGMEM, precdl;
                     53: extern long  *ordvar;
                     54: extern GEN   bernzone,gpi,geuler;
                     55: extern GEN   polvar,*polun,*polx,primetab;
                     56: extern GEN   gun,gdeux,ghalf,gi,gzero;
                     57:
                     58: extern const long lontyp[];
                     59: extern void* global_err_data;
                     60:
                     61: #define MAXITERPOL  10 /* max #of prec increase in polredabs-type operations */
                     62:
                     63:                                                 /* let SL = sizeof(long) */
                     64: #define pariK  (9.632959862*(BYTES_IN_LONG/4))  /* SL*log(2)/log(10)     */
                     65: #define pariK1 (0.103810253/(BYTES_IN_LONG/4))  /* log(10)/(SL*log(2))   */
                     66: #define pariK2 (1.1239968)                      /* 1/(1-(log(2)/(2*pi))) */
                     67: #define pariK4 (17.079468445347/BITS_IN_LONG)   /* 2*e*pi/SL             */
                     68: #define LOG2   (0.69314718055994531)            /* log(2)                */
                     69: #define L2SL10 (0.301029995663981)              /* log(2)/log(10)        */
                     70: #define pariC1 (0.9189385332)                   /* log(2*pi)/2           */
                     71: #define pariC2 (22.18070978*(BYTES_IN_LONG/4))  /* SL*log(2)             */
                     72: #define pariC3 (0.0216950598/(BYTES_IN_LONG/4)) /* log((1+sqrt(5))/2)/C2 */
                     73:
                     74: #ifndef  PI
                     75: #  define PI (3.141592653589)
                     76: #endif
                     77:
                     78: #ifdef LONG_IS_64BIT
                     79: #  define VERYBIGINT (9223372036854775807L) /* 2^63-1 */
                     80: #  define EXP220 (1099511627776L)          /* 2^40   */
                     81: #  define BIGINT (2147483647)              /* 2^31-1 */
                     82: #else
                     83: #  define VERYBIGINT (2147483647L) /* 2^31-1 */
                     84: #  define EXP220 (1048576L)       /* 2^20   */
                     85: #  define BIGINT (32767)          /* 2^15-1 */
                     86: #endif
                     87:
                     88: #ifdef NOEXP2
                     89: #  ifdef __cplusplus
                     90:      inline double exp2(double x) {return exp(x*LOG2);}
                     91:      inline double log2(double x) {return log(x)/LOG2;}
                     92: #  else
                     93: #    define exp2(x) (exp((double)(x)*LOG2))
                     94: #    ifndef __CYGWIN32__
                     95: #      define log2(x) (log((double)(x))/LOG2)
                     96: #    endif
                     97: #  endif
                     98: #else
                     99:   BEGINEXTERN
                    100:     double exp2(double);
                    101:     double log2(double);
                    102:   ENDEXTERN
                    103: #endif
                    104:
                    105: #ifndef LONG_IS_64BIT
                    106: #  undef labs
                    107: #  define labs(x) abs(x)
                    108: #endif
                    109:
                    110: #ifdef min
                    111: #  undef min
                    112: #endif
                    113: #ifdef max
                    114: #  undef max
                    115: #endif
                    116: #define min(a,b) ((a)>(b)?(b):(a))
                    117: #define max(a,b) ((a)>(b)?(a):(b))
                    118:
                    119: #define gval(x,v) (ggval((x),polx[v]))
                    120:
                    121: #define ggrando(x,n) (grando0((x),(n),1))
                    122: #define ggrandocp(x,n) (grando0((x),(n),0))
                    123:
                    124: #define addis(x,s)  (addsi((s),(x)))
                    125: #define addrs(x,s)  (addsr((s),(x)))
                    126: #define mulis(x,s)  (mulsi((s),(x)))
                    127: #define muliu(x,s)  (mului((s),(x)))
                    128: #define mulri(x,s)  (mulir((s),(x)))
                    129: #define mulrs(x,s)  (mulsr((s),(x)))
                    130: #define gmulgs(y,s) (gmulsg((s),(y)))
                    131: #define lmulgs(y,s) ((long)gmulsg((s),(y)))
                    132:
                    133: #define mpmodz(x,y,z) (modiiz((x),(y),(z)))
                    134: #define mpresz(x,y,z) (resiiz((x),(y),(z)))
                    135: #define mpmod(x,y)    (modii((x),(y)))
                    136: #define mpres(x,y)    (resii((x),(y)))
                    137:
                    138: #define laddgs(y,s)    (lopsg2(gadd,(s),(y)))
                    139: #define laddsg(s,y)    (lopsg2(gadd,(s),(y)))
                    140: #define ldiventgs(y,s) (lopgs2(gdivent,(y),(s)))
                    141: #define ldiventsg(s,y) (lopsg2(gdivent,(s),(y)))
                    142: #define ldivsg(s,y)    (lopsg2(gdiv,(s),(y)))
                    143: #define lmaxgs(y,s)    (lopgs2(gmax,(y),(s)))
                    144: #define lmaxsg(s,y)    (lopsg2(gmax,(s),(y)))
                    145: #define lmings(y,s)    (lopgs2(gmin,(y),(s)))
                    146: #define lminsg(s,y)    (lopsg2(gmin,(s),(y)))
                    147: #define lmodgs(y,s)    (lopgs2(gmod,(y),(s)))
                    148: #define lmodsg(s,y)    (lopsg2(gmod,(s),(y)))
                    149: #define lsubgs(y,s)    (lopgs2(gsub,(y),(s)))
                    150: #define lsubsg(s,y)    (lopsg2(gsub,(s),(y)))
                    151:
                    152: #define mppiz(x)       (gop0z(mppi,(x)))
                    153: #define mpeulerz(x)    (gop0z(mpeuler,(x)))
                    154:
                    155: #define autz(x,y)      (gop1z(mpaut,(x),(y)))
                    156: #define mpsqrtz(x,y)   (gop1z(mpsqrt,(x),(y)))
                    157: #define mpexpz(x,y)    (gop1z(mpexp,(x),(y)))
                    158: #define mpexp1z(x,y)   (gop1z(mpexp1,(x),(y)))
                    159: #define mplogz(x,y)    (gop1z(mplog,(x),(y)))
                    160: #define mpcosz(x,y)    (gop1z(mpcos,(x),(y)))
                    161: #define mpsinz(x,y)    (gop1z(mpsin,(x),(y)))
                    162: #define mptanz(x,y)    (gop1z(mptan,(x),(y)))
                    163: #define mpatanz(x,y)   (gop1z(mpatan,(x),(y)))
                    164: #define mpasinz(x,y)   (gop1z(mpasin,(x),(y)))
                    165: #define mpacosz(x,y)   (gop1z(mpacos,(x),(y)))
                    166: #define mpchz(x,y)     (gop1z(mpch,(x),(y)))
                    167: #define mpshz(x,y)     (gop1z(mpsh,(x),(y)))
                    168: #define mpthz(x,y)     (gop1z(mpth,(x),(y)))
                    169: #define mpathz(x,y)    (gop1z(mpath,(x),(y)))
                    170: #define mpashz(x,y)    (gop1z(mpash,(x),(y)))
                    171: #define mpachz(x,y)    (gop1z(mpach,(x),(y)))
                    172: #define mpgammaz(x,y)  (gop1z(mpgamma,(x),(y)))
                    173: #define gredz(x,y)     (gop1z(gred,(x),(y)))
                    174: #define gnegz(x,y)     (gop1z(gneg,(x),(y)))
                    175:
                    176: #define mpargz(x,y,z)   (gop2z(mparg,(x),(y),(z)))
                    177: #define gabsz(x,prec,y) (gop2z(gabs,(x),(prec),(y)))
                    178: #define gmaxz(x,y,z)    (gop2z(gmax,(x),(y),(z)))
                    179: #define gminz(x,y,z)    (gop2z(gmin,(x),(y),(z)))
                    180: #define gaddz(x,y,z)    (gop2z(gadd,(x),(y),(z)))
                    181: #define gsubz(x,y,z)    (gop2z(gsub,(x),(y),(z)))
                    182: #define gmulz(x,y,z)    (gop2z(gmul,(x),(y),(z)))
                    183: #define gdivz(x,y,z)    (gop2z(gdiv,(x),(y),(z)))
                    184: #define gdiventz(x,y,z) (gop2z(gdivent,(x),(y),(z)))
                    185: #define gmodz(x,y,z)    (gop2z(gmod,(x),(y),(z)))
                    186:
                    187: #define gaddgs(y,s)     (gopsg2(gadd,(s),(y)))
                    188: #define gaddsg(s,y)     (gopsg2(gadd,(s),(y)))
                    189: #define gaddsmat(s,y)   (gopsg2(gaddmat,(s),(y)))
                    190: #define gdiventsg(s,y)  (gopsg2(gdivent,(s),(y)))
                    191: #define gdivsg(s,y)     (gopsg2(gdiv,(s),(y)))
                    192: #define gmaxsg(s,y)     (gopsg2(gmax,(s),(y)))
                    193: #define gminsg(s,y)     (gopsg2(gmin,(s),(y)))
                    194: #define gmodsg(s,y)     (gopsg2(gmod,(s),(y)))
                    195: #define gsubsg(s,y)     (gopsg2(gsub,(s),(y)))
                    196:
                    197: #define gdiventgs(y,s)  (gopgs2(gdivent,(y),(s)))
                    198: #define gmaxgs(y,s)     (gopgs2(gmax,(y),(s)))
                    199: #define gmings(y,s)     (gopgs2(gmin,(y),(s)))
                    200: #define gmodgs(y,s)     (gopgs2(gmod,(y),(s)))
                    201: #define gsubgs(y,s)     (gopgs2(gsub,(y),(s)))
                    202:
                    203: #define gcmpsg(s,y)     (-opgs2(gcmp,(y),(s)))
                    204: #define gcmpgs(y,s)     (opgs2(gcmp,(y),(s)))
                    205: #define gegalsg(s,y)    (opgs2(gegal,(y),(s)))
                    206: #define gegalgs(y,s)    (opgs2(gegal,(y),(s)))
                    207:
                    208: #define gaddgsz(y,s,z)    (gopsg2z(gadd,(s),(y),(z)))
                    209: #define gaddsgz(s,y,z)    (gopsg2z(gadd,(s),(y),(z)))
                    210: #define gdiventsgz(s,y,z) (gopsg2z(gdivent,(s),y),(z)))
                    211: #define gdivsgz(s,y,z)    (gopsg2z(gdiv,(s),(y),(z)))
                    212: #define gmaxsgz(s,y,z)    (gopsg2z(gmax,(s),(y),(z)))
                    213: #define gminsgz(s,y,z)    (gopsg2z(gmin,(s),(y),(z)))
                    214: #define gmodsgz(s,y,z)    (gopsg2z(gmod,(s),(y),(z)))
                    215: #define gsubsgz(s,y,z)    (gopsg2z(gsub,(s),(y),(z)))
                    216:
                    217: #define gdiventgsz(y,s,z) (gopgs2z(gdivent,(y),(s),(z)))
                    218: #define gmaxgsz(y,s,z)    (gopgs2z(gmax,(y),(s),(z)))
                    219: #define gmingsz(y,s,z)    (gopgs2z(gmin,(y),(s),(z)))
                    220: #define gmodgsz(y,s,z)    (gopgs2z(gmod,(y),(s),(z)))
                    221: #define gsubgsz(y,s,z)    (gopgs2z(gsub,(y),(s),(z)))
                    222:
                    223: #define gdivgsz(y,s,z)  (gops2gsz(gdivgs,(y),(s),(z)))
                    224: #define gmul2nz(x,s,z)  (gops2gsz(gmul2n,(x),(s),(z)))
                    225: #define gmulgsz(y,s,z)  (gops2sgz(gmulsg,(s),(y),(z)))
                    226: #define gmulsgz(s,y,z)  (gops2sgz(gmulsg,(s),(y),(z)))
                    227: #define gshiftz(x,s,z)  (gops2gsz(gshift,(x),(s),(z)))
                    228:
                    229: #define bern(i)       (bernzone + 3 + (i)*bernzone[2])
                    230:
                    231: /* works only for POSITIVE integers */
                    232: #define modBIL(x) (((x)[lgefint(x)-1]))
                    233: #define mod64(x)  (modBIL(x) & 63)
                    234: #define mod32(x)  (modBIL(x) & 31)
                    235: #define mod16(x)  (modBIL(x) & 15)
                    236: #define mod8(x)   (modBIL(x) & 7)
                    237: #define mod4(x)   (modBIL(x) & 3)
                    238: #define mod2(x)   (modBIL(x) & 1)
                    239: #define is_pm1(n)    ((lgefint(n)==3) && (((GEN)(n))[2]==1))
                    240: #define is_bigint(n) ((lgefint(n)>3) || \
                    241:                      ((lgefint(n)==3) && ((((GEN)(n))[2]) < 0)))
                    242:
                    243: #define leading_term(x) ((GEN)(((GEN)(x))[lgef(x)-1]))
                    244: #define constant_term(x) (signe(x)? ((GEN)(((GEN)(x))[2])): gzero)
                    245: #define degpol(a) (lgef(a)-3)
                    246: #define evaldeg(d) (evallgef(d+3))
                    247:
                    248: #define odd(x) ((x) & 1)
                    249: #define mpodd(x) (signe(x) && mod2(x))
                    250:
                    251: #define ONLY_REM ((GEN*)0x1L)
                    252: #define ONLY_DIVIDES ((GEN*)0x2L)
                    253: #define ONLY_DIVIDES_EXACT ((GEN*)0x3L)
                    254: #define gdeuc(x,y) (poldivres((x),(y),NULL))
                    255: #define gres(x,y) (poldivres((x),(y),ONLY_REM))
                    256: #define FpX_div(x,y,p) (FpX_divres((x),(y),(p), NULL))
                    257: #define FpX_res(x,y,p) (FpX_divres((x),(y),(p), ONLY_REM))
                    258: #define matpascal(n) matqpascal((n),NULL)
                    259: #define sturm(x) (sturmpart((x),NULL,NULL))
                    260: #define carreparfait(x) (carrecomplet((x),NULL))
                    261: #define subres(x,y) (subresall((x),(y),NULL))
                    262: /* #define subres(x,y) (resultantducos((x),(y))) */
                    263:
                    264: #define leadingcoeff(x) (pollead((x),-1))
                    265: #define lift_intern(x) (lift_intern0((x),-1))
                    266:
                    267: #define idealmullll(nf,x,y) (idealoplll(idealmul,(nf),(x),(y)))
                    268: #define idealdivlll(nf,x,y) (idealoplll(idealdiv,(nf),(x),(y)))
                    269:
                    270: #define invmat(a) (gauss((a),NULL))
                    271:
                    272: #define element_divmodideal(nf,x,y,ideal) (\
                    273:   nfreducemodideal((nf),\
                    274:     element_mul((nf),(x),element_invmodideal((nf),(y),(ideal)))\
                    275:     ,(ideal)\
                    276:   )\
                    277: )
                    278: #define element_mulmodideal(nf,x,y,ideal) (\
                    279:   nfreducemodideal((nf),element_mul((nf),(x),(y)),(ideal))\
                    280: )
                    281: #define element_mulmodpr(nf,x,y,prhall) (\
                    282:   nfreducemodpr((nf),element_mul((nf),(x),(y)),(prhall))\
                    283: )
                    284: #define element_sqrmodideal(nf,x,ideal) (\
                    285:   nfreducemodideal((nf),element_sqr((nf),(x)),(ideal))\
                    286: )
                    287: #define element_sqrmodpr(nf,x,prhall) (\
                    288:   nfreducemodpr((nf),element_sqr((nf),(x)),(prhall))\
                    289: )
                    290: #define buchgen(P,gcbach,gcbach2,prec) (\
                    291:   buchall((P),(gcbach),(gcbach2),stoi(5),gzero,4,3,0,(prec))\
                    292: )
                    293: #define buchgenfu(P,gcbach,gcbach2,prec) (\
                    294:   buchall((P),(gcbach),(gcbach2),stoi(5),gzero,4,3,2,(prec))\
                    295: )
                    296: #define buchinit(P,gcbach,gcbach2,prec) (\
                    297:   buchall((P),(gcbach),(gcbach2),stoi(5),gzero,4,3,-1,(prec))\
                    298: )
                    299: #define buchinitfu(P,gcbach,gcbach2,prec) (\
                    300:   buchall((P),(gcbach),(gcbach2),stoi(5),gzero,4,3,-2,(prec))\
                    301: )
                    302:
                    303: /* output of get_nf and get_bnf */
                    304: #define typ_NULL 0
                    305: #define typ_POL  1
                    306: #define typ_Q    2
                    307: #define typ_NF   3
                    308: #define typ_BNF  4
                    309: #define typ_BNR  5
                    310: #define typ_CLA  6 /* bnfclassunit   */
                    311: #define typ_ELL  7 /* elliptic curve */
                    312: #define typ_QUA  8 /* quadclassunit  */
                    313: #define typ_GAL  9 /* galoisinit     */
                    314: /* for gen_sort */
                    315: #define cmp_IND 1
                    316: #define cmp_LEX 2
                    317: #define cmp_REV 4
                    318: #define cmp_C   8

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>