[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

C++ wrapper for GMP

From: Gerardo Ballabio
Subject: C++ wrapper for GMP
Date: Thu, 30 Nov 2000 12:41:35 +0100

Dear GMP people,
I've written a C++ wrapper for the GMP library, and I'd like to send
it to you. Actually, I talked about this with Torbjorn Granlund some
months ago, but then I was absorbed by other things and I let it down
for some time. Recently I resumed working, and now it's almost
complete, except that at present there's no support for the new random
number generation mechanism (but one can always call the relevant C
functions directly); I plan to work on this too.
I have been thinking for quite a long time about the design of the
wrapper, and I believe I have found the right one. I use "expression
templates" to avoid defining unnecessary temporaries, and the overhead
on direct calls to the underlying C functions should be
negligible. Canonicalization of mpq_t numbers is also taken care of
efficiently and transparently, and so is access to numerators and
The wrapper is a single (rather huge, about 100K) header file to be
#include'd into user programs; there's nothing to compile when
building the library. It requires a C++ compiler that handles "member
templates" and "partial template specialization": for GCC, this means
version 2.8 or later. I've also had it work on a MIPSpro compiler,
version 7.30 (but not 7.20).
I think it would be good if the wrapper is bundled (as "experimental"
and/or "unsupported", if you wish) in the next GMP release coming (GMP
3.2?), so that anyone who's interested can try it and send feedback
(I'm willing to maintain it if you want).
Furthermore, I have also implemented the exponential and logarithm
functions for mpf_t. The computation time theoretically goes as M(n)
log(n), M(n) being the time for multiplication, but the functions are
rather slow at small precision ("small" here means "up to several
thousand digits"!). I think that faster algorithms can be implemented
for not-so-large arguments (I tested my functions against those in the
MPFR library: while mine have a better asymptotical behavior, theirs
are considerably faster at small precision), so there's still a lot of
work to do, but I can send you what I have done, at least.

Please let me know.

Dr. Gerardo Ballabio
Scuola Internazionale Superiore di Studi Avanzati
International School for Advanced Studies
via Beirut 2-4
34013 Trieste Miramare-Grignano (Italy)
room 217 - tel. +39/0403787429
E-mail: address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]