You are looking at historical revision 9271 of this page. It may differ significantly from its current revision.
A chicken scheme interface to GNU MP 4.1
Requires the syntax-case egg.
The library is split into several parts, which may be loaded/required separately:
- Utility procedures
- Integer routines
- Float routines
- Rational arithmetic routines
- Random numbers
The library used finalizers to free storage associated with unreferenced GMP data.
In addition to the library, a validation program will be built and installed, named chicken_gmp_test. To test the GMP extension just enter
This is a release of the GNU MP library version 4.1 interface for chicken scheme. It is a pretty comprehensive interface, but without any of the lowlevel functions (mpn_*).
Since the validation code is pretty extensive, it shouldn't take too much work to fix when later revisions of the MP library comes out.
Here is a tiny example of the interface usage:
<example> <init>(require-extension gmp)</init> <expr> (let ( (mpz1 (make-mpz_t))
(mpz2 (make-mpz_t)) (mpz3 (make-mpz_t)))
(mpz_init mpz1) (mpz_init mpz2) (mpz_init mpz3)
(mpz_set_ui mpz2 6) (mpz_set_str mpz3 "7" 10) (mpz_mul mpz1 mpz2 mpz3)
(print "The answer to " (mpz_get_str #f 10 mpz2) " times " (mpz_get_str #f 10 mpz3) " is " (mpz_get_str #f 10 mpz1) ".") (mpz_clear mpz1) (mpz_clear mpz2) (mpz_clear mpz3))
For the high level functions that I have not implemented: mpf_get_d_2exp mpz_array_init _mpz_realloc mpz_get_d_2exp mpz_getlimbm mpz_import mpz_export mpf_random2, there exists a function that will warn you to stdout when you accidentily use them.
Here is an example of how the special function mpf_get_str is handled:
<example> <expr> (let ( (mpf1 (make-mpf_t))
(mpf_init mpf1) (mpf_set_ui mpf1 42)
;; get a string representation placing the exponent into exp_p (mpf_get_str #f exp_p 10 10 mpf1)
;; The ONLY way to see the exponent is to dereference the "pointer" ;; that is exp_p (print "The exponent is " (deref-mp_exp_t_p exp_p) ".")
- 0.0.5 Fixed a bug in the setup script [Thanks to Rafael Cavallaro and Dale Jordan]
- 0.0.4 Replaced use of (end-of-file) with #!eof
- 0.0.3 Initial release
Copyright (C) 2002 Peter K. Keller This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
All files in this package are copyrighted (C) 2002 Peter K. Keller regardless if they actually say it or not at the top of the file.