Annotation of OpenXM_contrib/pari-2.2/src/headers/parigen.h, Revision 1.1
1.1 ! noro 1: /* $Id: parigen.h,v 1.5 2000/11/03 21:00:25 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: /* This file defines the parameters of the GEN type */
! 17:
! 18: typedef long *GEN;
! 19: typedef int (*QSCOMP)(const void *, const void *);
! 20:
! 21: #ifdef ULONG_NOT_DEFINED
! 22: typedef unsigned long ulong;
! 23: #endif
! 24:
! 25: #ifdef __M68K__
! 26: # define OLD_CODES
! 27: #endif
! 28:
! 29: #ifdef LONG_IS_64BIT
! 30: # define MAXULONG (0xffffffffffffffffUL)
! 31: # define MAXHALFULONG (0x00000000ffffffffUL)
! 32: # define HIGHBIT (0x8000000000000000UL)
! 33: # define HIGHMASK (0xffffffff00000000UL)
! 34: # define LOWMASK (0x00000000ffffffffUL)
! 35: # define SMALL_MASK (0x4000000000000000UL)
! 36:
! 37: # define DEFAULTPREC 3
! 38: # define MEDDEFAULTPREC 4
! 39: # define BIGDEFAULTPREC 5
! 40: # define TWOPOTBYTES_IN_LONG 3
! 41: # define TWOPOTBITS_IN_LONG 6
! 42: # define BYTES_IN_LONG 8
! 43: # define BITS_IN_LONG 64
! 44: # define BITS_IN_HALFULONG 32
! 45: /* For a 64-bit random generator, change the following 32 to 64 */
! 46: # define BITS_IN_RANDOM 32
! 47:
! 48: #else
! 49:
! 50: # define MAXULONG (0xffffffffUL)
! 51: # define MAXHALFULONG (0x0000ffffUL)
! 52: # define HIGHBIT (0x80000000UL)
! 53: # define HIGHMASK (0xffff0000UL)
! 54: # define LOWMASK (0x0000ffffUL)
! 55: # define SMALL_MASK (0x40000000UL)
! 56:
! 57: # define DEFAULTPREC 4
! 58: # define MEDDEFAULTPREC 6
! 59: # define BIGDEFAULTPREC 8
! 60: # define TWOPOTBYTES_IN_LONG 2
! 61: # define TWOPOTBITS_IN_LONG 5
! 62: # define BYTES_IN_LONG 4
! 63: # define BITS_IN_LONG 32
! 64: # define BITS_IN_HALFULONG 16
! 65: # define BITS_IN_RANDOM 32
! 66: #endif
! 67:
! 68: #ifndef LONG_IS_64BIT
! 69: /* second codeword x[1], for types: INT,REAL,PADIC,POL,SER */
! 70: # define EXPOBITS (0x00ffffffUL)
! 71: # define HIGHEXPOBIT (0x00800000L)
! 72: # define LGEFBITS (0x0000ffffUL)
! 73: # define VALPBITS (0x0000ffffUL) /* used only for type PADIC */
! 74: # define HIGHVALPBIT (0x00008000L) /* used only for type PADIC, SER */
! 75: # define PRECPBITS (0xffff0000UL) /* used only for type PADIC */
! 76: # define PRECPSHIFT 16
! 77: # define VARNSHIFT 16
! 78:
! 79: # ifndef OLD_CODES
! 80: # define SIGNBITS (0xc0000000UL)
! 81: # define VARNBITS (0x3fff0000UL)
! 82: # define LGEFINTBITS (0x00ffffffUL)
! 83: # define SIGNSHIFT 30
! 84: # define MAXVARN 16383
! 85: # else
! 86: # define SIGNBITS (0xff000000UL)
! 87: # define VARNBITS (0x00ff0000UL)
! 88: # define LGEFINTBITS (0x0000ffffUL)
! 89: # define SIGNSHIFT 24
! 90: # define MAXVARN 255
! 91: # endif
! 92:
! 93: /* first codeword x[0] */
! 94: # ifndef OLD_CODES
! 95: # define TYPBITS (0xfe000000UL)
! 96: # define CLONEBIT (0x01000000UL)
! 97: # define LGBITS (0x00ffffffUL)
! 98: # define TYPSHIFT 25
! 99: # else
! 100: # define TYPBITS (0xff000000UL)
! 101: # define CLONEBIT (0x00010000UL)
! 102: # define LGBITS (0x0000ffffUL)
! 103: # define TYPSHIFT 24
! 104: # endif
! 105: #endif
! 106:
! 107: #ifdef LONG_IS_64BIT
! 108: /* first codeword x[0] */
! 109: # define TYPBITS (0xffff000000000000UL)
! 110: # define CLONEBIT (0x0000000100000000UL)
! 111: # define LGBITS (0x00000000ffffffffUL)
! 112: # define TYPSHIFT 48
! 113:
! 114: /* second codeword x[1] */
! 115: # define SIGNBITS (0xffff000000000000UL)
! 116: # define VARNBITS (0x0000ffff00000000UL)
! 117: # define LGEFBITS (0x00000000ffffffffUL)
! 118: # define SIGNSHIFT 48
! 119: # define MAXVARN 65535
! 120:
! 121: # define EXPOBITS (0x0000ffffffffffffUL)
! 122: # define HIGHEXPOBIT (0x0000800000000000L)
! 123: # define LGEFINTBITS (0x00000000ffffffffUL)
! 124: # define VALPBITS (0x00000000ffffffffUL)
! 125: # define HIGHVALPBIT (0x0000000080000000L)
! 126: # define PRECPBITS (0xffffffff00000000UL)
! 127: # define PRECPSHIFT 32
! 128: # define VARNSHIFT 32
! 129: #endif
! 130:
! 131: #define evaltyp(x) (((ulong)(x)) << TYPSHIFT)
! 132: #define evalvarn(x) (((ulong)(x)) << VARNSHIFT)
! 133: #define evalsigne(x) (((long)(x)) << SIGNSHIFT)
! 134: #define evalprecp(x) (((long)(x)) << PRECPSHIFT)
! 135: #define m_evalexpo(x) (HIGHEXPOBIT + (x))
! 136: #define m_evalvalp(x) (HIGHVALPBIT + (x))
! 137: #define evallgefint(x) (x)
! 138: #define m_evallg(x) (x)
! 139: #define m_evallgef(x) (x)
! 140:
! 141: #define typ(x) ((((long)(x))&1)? t_SMALL: (((ulong) ((GEN) (x))[0]) >> TYPSHIFT))
! 142: #define settyp(x,s) (((GEN)(x))[0]=\
! 143: (((GEN)(x))[0]&(~TYPBITS)) | evaltyp(s))
! 144: #define smalltos(x) (((long)(x))>>1)
! 145:
! 146: #define isclone(x) (((GEN) (x))[0] & CLONEBIT)
! 147: #define setisclone(x) (((GEN) (x))[0] |= CLONEBIT)
! 148: #define unsetisclone(x) (((GEN) (x))[0] &= (~CLONEBIT))
! 149:
! 150: #define lg(x) ((((long)(x))&1)?1: ((long) (((GEN) (x))[0] & LGBITS)))
! 151: #define setlg(x,s) (((GEN)(x))[0]=\
! 152: (((GEN)(x))[0]&(~LGBITS)) | evallg(s))
! 153:
! 154: #define signe(x) (((long) ((GEN) (x))[1]) >> SIGNSHIFT)
! 155: #define setsigne(x,s) (((GEN)(x))[1]=\
! 156: (((GEN)(x))[1]&(~SIGNBITS)) | evalsigne(s))
! 157:
! 158: #define lgef(x) ((long) (((GEN) (x))[1] & LGEFBITS))
! 159: #define setlgef(x,s) (((GEN)(x))[1]=\
! 160: (((GEN)(x))[1]&(~LGEFBITS)) | evallgef(s))
! 161:
! 162: #define lgefint(x) ((long) (((GEN) (x))[1] & LGEFINTBITS))
! 163: #define setlgefint(x,s) (((GEN)(x))[1]=\
! 164: (((GEN)(x))[1]&(~LGEFINTBITS)) | evallgefint(s))
! 165:
! 166: #define expo(x) ((long) ((((GEN) (x))[1] & EXPOBITS) - HIGHEXPOBIT))
! 167: #define setexpo(x,s) (((GEN)(x))[1]=\
! 168: (((GEN)(x))[1]&(~EXPOBITS)) | evalexpo(s))
! 169:
! 170: #define valp(x) ((long) ((((GEN)(x))[1] & VALPBITS) - HIGHVALPBIT))
! 171: #define setvalp(x,s) (((GEN)(x))[1]=\
! 172: (((GEN)(x))[1]&(~VALPBITS)) | evalvalp(s))
! 173:
! 174: #define precp(x) ((long) (((ulong) ((GEN) (x))[1]) >> PRECPSHIFT))
! 175: #define setprecp(x,s) (((GEN)(x))[1]=\
! 176: (((GEN)(x))[1]&(~PRECPBITS)) | evalprecp(s))
! 177:
! 178: #define varn(x) ((long) ((((GEN) (x))[1]&VARNBITS) >> VARNSHIFT))
! 179: #define setvarn(x,s) (((GEN)(x))[1]=\
! 180: (((GEN)(x))[1]&(~VARNBITS)) | evalvarn(s))
! 181:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>