[BACK]Return to appc.tex CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / pari / doc

File: [local] / OpenXM_contrib / pari / doc / Attic / appc.tex (download)

Revision 1.1.1.1 (vendor branch), Sun Jan 9 17:35:29 2000 UTC (24 years, 5 months ago) by maekawa
Branch: PARI_GP
CVS Tags: maekawa-ipv6, VERSION_2_0_17_BETA, RELEASE_20000124, RELEASE_1_2_3, RELEASE_1_2_2_KNOPPIX_b, RELEASE_1_2_2_KNOPPIX, RELEASE_1_2_2, RELEASE_1_2_1, RELEASE_1_1_3, RELEASE_1_1_2
Changes since 1.1: +0 -0 lines

Import PARI/GP 2.0.17 beta.

\appendix{Summary of Available Constants}

In this appendix we give the list of predefined constants available in the
PARI library. All of them are in the \idx{heap} and {\it not\/} on the PARI
\idx{stack}. We start by recalling the \idx{universal object}s introduced in
\secref{se:intro4}:
%
\bprog%
t\_INT: gzero (zero), gun (un), gdeux (deux)
t\_FRAC: ghalf (lhalf)
t\_COMPLEX: gi
t\_POL: polun[..] (lpolun[..]), polx[..] (lpolx[..])
\eprog
\noindent Only polynomials in the variables \kbd{0} and \kbd{MAXVARN} are
defined initially. Use \kbd{fetch\_var()} (see \secref{se:fetch_var}) to
create new ones.

\noindent The other objects are not initialized by default:

\tet{geuler}. This is Euler's constant. To initialize it, call
{\tt\idx{consteuler}(prec)} (see \secref{se:euler}).

\tet{gpi}. This is the number $\pi$. To initialize it, call
{\tt\idx{constpi}(prec)} (see \secref{se:pi}).

\tet{bern}(i). This is the $2i$-th Bernoulli number ($B_0=1$, $B_2=1/6$,
$B_4=-1/30$, etc\dots). To initialize them, use the function:

\kbd{void \idx{mpbern}(long n, long prec);}

This creates the even numbered Bernoulli numbers up to $B_{2n-2}$ {\it as
real numbers\/} of precision \kbd{prec}. They can then be used with the macro
\kbd{bern(i)}. Note that this is not a function but simply an abbreviation,
hence care must be taken that \kbd{i} is inside the right bounds (i.e. $0\le
\kbd{i}\le n-1$) before using it, since no checking is done by PARI itself.

Finally, one has access to a table of (differences of) primes through the
pointer \tet{diffptr}. This is used as follows: when

\kbd{void pari\_init(long size, long maxprime);}

\noindent is called, this table is initialized with the successive
differences of primes up to (just a little beyond) \kbd{maxprime}
(see \secref{se:intro4}). \kbd{maxprime} has to be less than $436272744$,
whatever memory is available. A
difference of $0$ means we have reached the end of the table. The following
example illustrates its use.
%
\bprog%
byteptr d = diffptr;
long p = 0;
\h
while (p <= p\_goal) /* {\rm run through all primes up to \kbd{p\_goal}} */
\obr
\q  p += *d;
\q  if (*d == 0) err(primer1); /* {\rm not enough primes} */
\q  d++;
\q  ...
\cbr
\eprog\noindent
Here, we use the general error handling function \kbd{err} (see
\secref{se:err}), with the codeword \kbd{primer1}. This will just print
the error message:

\kbd{*** not enough precomputed primes}

\noindent and then abort the computations.

You can use the function \kbd{initprimes} from the file \kbd{arith2.c} to
compute a new table on the fly and assign it to \kbd{diffptr} or to a
similar variable of your own. Beware that before changing \kbd{diffptr},
you should really free the (\kbd{malloc}ed) precomputed table first, and then
all pointers into the old table will become invalid.

PARI currently guarantees that the first 6547 primes, up to and including
65557, will be present in the table, even if you set \kbd{maxnum} to zero.

In addition, some single or double-precision real numbers are predefined,
and their list is in the file \kbd{paricom.h}.
\vfill\eject