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

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

Revision 1.1, Tue Oct 2 11:16:56 2001 UTC (22 years, 7 months ago) by noro
Branch: MAIN

Initial revision

% $Id: appc.tex,v 1.8 2000/11/06 18:59:00 karim Exp $
% Copyright (c) 2000  The PARI Group
%
% This file is part of the PARI/GP documentation
%
% Permission is granted to copy, distribute and/or modify this document
% under the terms of the GNU Free Documentation License
\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{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:

\fun{void}{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.

\tet{geuler}. This is Euler's constant. It is initialized by the first call
to \tet{mpeuler} (see \secref{se:euler}).

\tet{gpi}. This is the number $\pi$.  It is initialized by the first call to
\tet{mppi} (see \secref{se:pi}).

The use of both \tet{geuler} and \tet{gpi} is deprecated since it's always
possible that some library function increases the precision of the constant
{\it after} you've computed it, hence modifying the computation accuracy
without your asking for it and increasing your running times for no good
reason. You should always use \tet{mpeuler} and \tet{mppi} (note that only
the first call will actually compute the constant, unless a higher precision
is required).

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

\fun{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}). \tet{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 largest prime computable using this table is
available as the output of

\fun{ulong}{maxprime}{}

\noindent Here's a small example:
%
\bprog
byteptr d = diffptr;
ulong p = 0;

if (maxprime() < goal) err(primer1); /*@Ccom not enough primes */
while (p <= goal) /*@Ccom run through all primes up to \kbd{goal} */
{
  p += *d++;
  ...
}
@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