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

Annotation of OpenXM_contrib/pari-2.2/doc/appc.tex, Revision 1.2

1.2     ! noro        1: % $Id: appc.tex,v 1.9 2002/07/15 13:24:57 karim Exp $
1.1       noro        2: % Copyright (c) 2000  The PARI Group
                      3: %
                      4: % This file is part of the PARI/GP documentation
                      5: %
                      6: % Permission is granted to copy, distribute and/or modify this document
                      7: % under the terms of the GNU Free Documentation License
                      8: \appendix{Summary of Available Constants}
                      9:
                     10: In this appendix we give the list of predefined constants available in the
                     11: PARI library. All of them are in the \idx{heap} and {\it not\/} on the PARI
                     12: \idx{stack}. We start by recalling the \idx{universal object}s introduced in
                     13: \secref{se:intro4}:
                     14: %
                     15: \bprog
                     16: t_INT: gzero (zero), gun (un), gdeux (deux)
                     17: t_FRAC: ghalf (lhalf)
                     18: t_COMPLEX: gi
                     19: t_POL: polun[..] (lpolun[..]), polx[..] (lpolx[..])
                     20: @eprog
                     21: \noindent Only polynomials in the variables \kbd{0} and \kbd{MAXVARN} are
                     22: defined initially. Use \kbd{fetch\_var()} (see \secref{se:fetch_var}) to
                     23: create new ones.
                     24:
                     25: \noindent The other objects are not initialized by default:
                     26:
                     27: \tet{bern}(i). This is the $2i$-th Bernoulli number ($B_0=1$, $B_2=1/6$,
                     28: $B_4=-1/30$, etc\dots). To initialize them, use the function:
                     29:
                     30: \fun{void}{mpbern}{long n, long prec}
                     31:
                     32: This creates the even numbered Bernoulli numbers up to $B_{2n-2}$ {\it as
                     33: real numbers\/} of precision \kbd{prec}. They can then be used with the macro
                     34: \kbd{bern(i)}. Note that this is not a function but simply an abbreviation,
                     35: hence care must be taken that \kbd{i} is inside the right bounds (i.e. $0\le
                     36: \kbd{i}\le n-1$) before using it, since no checking is done by PARI itself.
                     37:
                     38: \tet{geuler}. This is Euler's constant. It is initialized by the first call
                     39: to \tet{mpeuler} (see \secref{se:euler}).
                     40:
                     41: \tet{gpi}. This is the number $\pi$.  It is initialized by the first call to
                     42: \tet{mppi} (see \secref{se:pi}).
                     43:
                     44: The use of both \tet{geuler} and \tet{gpi} is deprecated since it's always
                     45: possible that some library function increases the precision of the constant
                     46: {\it after} you've computed it, hence modifying the computation accuracy
                     47: without your asking for it and increasing your running times for no good
                     48: reason. You should always use \tet{mpeuler} and \tet{mppi} (note that only
                     49: the first call will actually compute the constant, unless a higher precision
                     50: is required).
                     51:
1.2     ! noro       52: In addition, some single or double-precision real numbers (like \kbd{PI}) are
        !            53: predefined, and their list is in the file \kbd{paricom.h}.
        !            54:
1.1       noro       55: Finally, one has access to a table of (differences of) primes through the
                     56: pointer \tet{diffptr}. This is used as follows: when
                     57:
1.2     ! noro       58: \fun{void}{pari_init}{long size, ulong maxprime}
1.1       noro       59:
                     60: \noindent is called, this table is initialized with the successive
                     61: differences of primes up to (just a little beyond) \kbd{maxprime}
1.2     ! noro       62: (see \secref{se:intro4}). The prime table will occupy roughly
        !            63: $\kbd{maxprime}/\log(\kbd{maxprime})$ bytes in memory, so be sensible when
        !            64: choosing \kbd{maxprime} (it is $500000$ by default under \kbd{gp}). In any case,
        !            65: the implementation requires that $\tet{maxprime} < 4294965248$
        !            66: (resp.~$18446744073709549568$) on 32-bit (resp.~64-bit) machines, whatever memory
        !            67: is available.
        !            68:
        !            69: The largest prime computable using this table is available as the output of
1.1       noro       70:
                     71: \fun{ulong}{maxprime}{}
                     72:
1.2     ! noro       73: After the following initializations (the names $p$ and \var{ptr} are arbitrary of
        !            74: course)
        !            75: \bprog
        !            76: byteptr ptr = diffptr;
        !            77: ulong p = 0;
        !            78: @eprog
        !            79: \noindent calling the macro \tet{NEXT_PRIME_VIADIFF_CHECK(p, ptr)} repeatedly will
        !            80: assign the successive prime numbers to $p$. Overrunning the prime table boundary
        !            81: will raise the error \tet{primer1}, which will just print the error message:
        !            82:
        !            83: \kbd{*** not enough precomputed primes}
        !            84:
        !            85: \noindent and then abort the computations. The alternative macro
        !            86: \tet{NEXT_PRIME_VIADIFF} operates in the same way, but will omit that check, and
        !            87: is slightly faster. It should be used in the following way:
1.1       noro       88: %
                     89: \bprog
1.2     ! noro       90: byteptr ptr = diffptr;
1.1       noro       91: ulong p = 0;
                     92:
                     93: if (maxprime() < goal) err(primer1); /*@Ccom not enough primes */
                     94: while (p <= goal) /*@Ccom run through all primes up to \kbd{goal} */
                     95: {
1.2     ! noro       96:   NEXT_PRIME_VIADIFF(p, ptr);
1.1       noro       97:   ...
                     98: }
                     99: @eprog\noindent
                    100: Here, we use the general error handling function \kbd{err} (see
1.2     ! noro      101: \secref{se:err}), with the codeword \kbd{primer1}, raising the ``not enough
        !           102: primes'' error.
1.1       noro      103:
                    104: You can use the function \kbd{initprimes} from the file \kbd{arith2.c} to
                    105: compute a new table on the fly and assign it to \kbd{diffptr} or to a
                    106: similar variable of your own. Beware that before changing \kbd{diffptr},
                    107: you should really free the (\kbd{malloc}ed) precomputed table first, and then
                    108: all pointers into the old table will become invalid.
                    109:
                    110: PARI currently guarantees that the first 6547 primes, up to and including
                    111: 65557, will be present in the table, even if you set \kbd{maxnum} to zero.
                    112: \vfill\eject

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>