Annotation of OpenXM_contrib/pari/doc/appc.tex, Revision 1.1
1.1 ! maekawa 1: \appendix{Summary of Available Constants}
! 2:
! 3: In this appendix we give the list of predefined constants available in the
! 4: PARI library. All of them are in the \idx{heap} and {\it not\/} on the PARI
! 5: \idx{stack}. We start by recalling the \idx{universal object}s introduced in
! 6: \secref{se:intro4}:
! 7: %
! 8: \bprog%
! 9: t\_INT: gzero (zero), gun (un), gdeux (deux)
! 10: t\_FRAC: ghalf (lhalf)
! 11: t\_COMPLEX: gi
! 12: t\_POL: polun[..] (lpolun[..]), polx[..] (lpolx[..])
! 13: \eprog
! 14: \noindent Only polynomials in the variables \kbd{0} and \kbd{MAXVARN} are
! 15: defined initially. Use \kbd{fetch\_var()} (see \secref{se:fetch_var}) to
! 16: create new ones.
! 17:
! 18: \noindent The other objects are not initialized by default:
! 19:
! 20: \tet{geuler}. This is Euler's constant. To initialize it, call
! 21: {\tt\idx{consteuler}(prec)} (see \secref{se:euler}).
! 22:
! 23: \tet{gpi}. This is the number $\pi$. To initialize it, call
! 24: {\tt\idx{constpi}(prec)} (see \secref{se:pi}).
! 25:
! 26: \tet{bern}(i). This is the $2i$-th Bernoulli number ($B_0=1$, $B_2=1/6$,
! 27: $B_4=-1/30$, etc\dots). To initialize them, use the function:
! 28:
! 29: \kbd{void \idx{mpbern}(long n, long prec);}
! 30:
! 31: This creates the even numbered Bernoulli numbers up to $B_{2n-2}$ {\it as
! 32: real numbers\/} of precision \kbd{prec}. They can then be used with the macro
! 33: \kbd{bern(i)}. Note that this is not a function but simply an abbreviation,
! 34: hence care must be taken that \kbd{i} is inside the right bounds (i.e. $0\le
! 35: \kbd{i}\le n-1$) before using it, since no checking is done by PARI itself.
! 36:
! 37: Finally, one has access to a table of (differences of) primes through the
! 38: pointer \tet{diffptr}. This is used as follows: when
! 39:
! 40: \kbd{void pari\_init(long size, long maxprime);}
! 41:
! 42: \noindent is called, this table is initialized with the successive
! 43: differences of primes up to (just a little beyond) \kbd{maxprime}
! 44: (see \secref{se:intro4}). \kbd{maxprime} has to be less than $436272744$,
! 45: whatever memory is available. A
! 46: difference of $0$ means we have reached the end of the table. The following
! 47: example illustrates its use.
! 48: %
! 49: \bprog%
! 50: byteptr d = diffptr;
! 51: long p = 0;
! 52: \h
! 53: while (p <= p\_goal) /* {\rm run through all primes up to \kbd{p\_goal}} */
! 54: \obr
! 55: \q p += *d;
! 56: \q if (*d == 0) err(primer1); /* {\rm not enough primes} */
! 57: \q d++;
! 58: \q ...
! 59: \cbr
! 60: \eprog\noindent
! 61: Here, we use the general error handling function \kbd{err} (see
! 62: \secref{se:err}), with the codeword \kbd{primer1}. This will just print
! 63: the error message:
! 64:
! 65: \kbd{*** not enough precomputed primes}
! 66:
! 67: \noindent and then abort the computations.
! 68:
! 69: You can use the function \kbd{initprimes} from the file \kbd{arith2.c} to
! 70: compute a new table on the fly and assign it to \kbd{diffptr} or to a
! 71: similar variable of your own. Beware that before changing \kbd{diffptr},
! 72: you should really free the (\kbd{malloc}ed) precomputed table first, and then
! 73: all pointers into the old table will become invalid.
! 74:
! 75: PARI currently guarantees that the first 6547 primes, up to and including
! 76: 65557, will be present in the table, even if you set \kbd{maxnum} to zero.
! 77:
! 78: In addition, some single or double-precision real numbers are predefined,
! 79: and their list is in the file \kbd{paricom.h}.
! 80: \vfill\eject
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>