My favorites | Sign in
Project Logo
                
Links:
Feeds:
Groups:
People details
Project owners:
  vincent.diemunsch

As the GNU libraries GMP and MPFR becomes part of the GNAT free compiler (since they are part of the new GCC) and since these libraries have excellent performances, I thought it could be interesting to create an Ada binding for them.

I searched on the Internet and found two old bindings but none convinced me and moreover they seemed to have been droped out. Therefore, I have undertaken to write my own binding for GMP and MPFR in Ada 2005.

The Binding is as follows :

A THIN BINDING mainly composed of two files : gmp.ads and mpfr.ads

They basically translate in Ada most functions of gmp.h and mpfr.h but they are not exhaustive yet. There are also some specific files for target dependent types: mp_x86_32bits.ads, mp_x86_64bits.ads...

A THICK BINDING with the following specification files : gmp.Integers.ads, gmp.Rationals.ads, mpfr.Floats.ads.

These files declare the following types: Unbounded_Integer, Unbounded_Fraction, MPFR_Float that can be seen as extensions of the typical Ada Integer and Float, with operator overloading ("+", "-", ...) and elementary functions.

Differences between the two bindings :

If you want to keep a full control on precision and rounding, at bit level, then the thin binding to MPFR is needed. But in most cases, if you accept to use accuracy expressed in decimal digits and the rounding of all operations "to nearest", (in fact exactly as it is for classical floating point types in Ada) then the Thick Ada Binding with operator overloading and no C-dependent types is really much easier to use !

Note for Mac OS X users (thanks John) : GNAT from MACADA looks for MPFR and GMP in /usr/local/lib. The libraries may be conveniently built from source using MACPORTS.









Hosted by Google Code