Demonstration Programs (GNU MP 6.2.1)
Description: How to install and use the GNU multiple precision arithmetic library, version 6.2.1.

Next: Efficiency, Previous: Compatibility with older versions, Up: GMP Basics [Index]

### 3.10 Demonstration programs

The `demos` subdirectory has some sample programs using GMP. These aren’t built or installed, but there’s a `Makefile` with rules for them. For instance,

    make pexpr
    ./pexpr 68^975+10

The following programs are provided

- ‘`pexpr`’ is an expression evaluator, the program used on the GMP web page.
- The ‘`calc`’ subdirectory has a similar but simpler evaluator using `lex` and `yacc`.
- The ‘`expr`’ subdirectory is yet another expression evaluator, a library designed for ease of use within a C program. See `demos/expr/README` for more information.
- ‘`factorize`’ is a Pollard-Rho factorization program.
- ‘`isprime`’ is a command-line interface to the `mpz_probab_prime_p` function.
- ‘`primes`’ counts or lists primes in an interval, using a sieve.
- ‘`qcn`’ is an example use of `mpz_kronecker_ui` to estimate quadratic class numbers.
- The ‘`perl`’ subdirectory is a comprehensive perl interface to GMP. See `demos/perl/INSTALL` for more information. Documentation is in POD format in `demos/perl/GMP.pm`.

As an aside, consideration has been given at various times to some sort of expression evaluation within the main GMP library. Going beyond something minimal quickly leads to matters like user-defined functions, looping, fixnums for control variables, etc, which are considered outside the scope of GMP (much closer to language interpreters or compilers, See Language Bindings.) Something simple for program input convenience may yet be a possibility, a combination of the `expr` demo and the `pexpr` tree back-end perhaps. But for now the above evaluators are offered as illustrations.

Next: Efficiency, Previous: Compatibility with older versions, Up: GMP Basics [Index]