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