comp.lang.ada
 help / color / mirror / Atom feed
* Ada binding to GMP and MPFR
@ 2009-05-20 14:19 vincent.diemunsch
  2009-05-20 14:30 ` Ludovic Brenta
  2009-05-29 16:55 ` Pascal Obry
  0 siblings, 2 replies; 12+ messages in thread
From: vincent.diemunsch @ 2009-05-20 14:19 UTC (permalink / raw)


Hello everybody,

As the libraries GMP ( http://gmplib.org/ ) and MPFR ( http://www.mpfr.org/
) 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 Internet and found two old binding but non convinced me
and they seemed to have been droped
out. Therefore, I have undertaken to write my own binding for GMP and
MPFR in Ada 2005, and I have just managed to successfuly test basic
operations for them such, as adding or multiplying MPFR_Floats of
different precision...

Now I wonder if someone could be interested in hosting the sources on
an Internet page, so that anybody could
download them and test them and eventually make improvements...

The Binding is as follows :

* A THIN BINDING composed of two files :
- gmp.ads
- mpfr.ads

It basically translates in Ada most functions of gmp.h and mpfr.h but
it's not exhaustive.
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.


I know that some work needs to be done to :
- complete the gmp.ads and mpfr.ads files
- fully test the binding
- have a good integration in the Ada "spirit".

Therfore, I require your help :
- Where may i found a place to put the files (or a SVN repository ;-)
- Would you be interested in giving comments on implementation
especially for MPFR_Types ?

Thanks a lot for your help.
Regards,

Vincent

EXTRACT OF MPFR-FLOAT.ADS :

-- Copyright (c) 2009 Vincent DIEMUNSCH.
-- GNU General Public License.
--
-- This file 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 license for more details.
--
--------------------------------------------------------------------------------
-- This package is a thick Ada binding to the Multiple Precision
Floating Point
-- Reliable Library. See : http://www.mpfr.org/
--
-- It declares a new private type : MPFR_Float, that is an abstraction
of a
-- floating point value of arbitrary precision.
--
-- This packages uses a new approach to dynamically adjust the
precision of a
-- MPFR_Float, everytime a value is computed (and not, as mpfr does,
at the
-- initialization of the mpfr_t variable). Before any operation,
-- the precision required for the result is set according to the
following rules:
--    1) if the result is exact, then precision is the default
precision
--       for instance : , "1/3", "pi/4", "10.5", "1.45e-3".
--    2) for a unary operation, the precision of the result is the
precision
--       of the operand.
--       for instance : "abs(x)", "1/x", "x+n" where n is an integer.
--    3) for a binary multipliying operation the precision of the
result is the
--       smallest precision of the two operands.
--       for instance : "x*y", "x mod y", etc.
--    4) for a binary adding operation, the precision of the result is
the
--       smallest precision of :
--        * the greatest operand in absolute value,
--        * the smallest operand in absolute value, adjusted to the
difference
--          of exponants.
--       for instance : "1.111111 + 1.0e-5" (resp. a precision of 7
digits and
--                       2 digits) will give "1.111121" (7 digits = 2
- (0-5))
--                       and not "1.1" (2 digits).
--
-- If, an adjustement of precision is required, in a computation, for
instance
-- when the result is computed through the use of a convergent
sequence, one
-- can use the functions "Unchecked_Pecision_Adjustement", with 2
variants :
--   1) an absolute precision expressed in digits
--   2) a relative precision, throug the comparison to another value :
--      new precision = exponant(x) - exponant(x - value) + n digits
(n > 3).
--      for instance :
--          u(n) = 1/u(n-1) + 1   (Computing the golden number)
--          u(n) = 1.615 (4 digits) and u(n-1) = 1.625, error : 1e-2,
--          then the precision will be set to 0 - (-2) + n digits, at
least
--          5 digits ("1.6150")


with Ada.Finalization;
with GMP.Integers;

package MPFR.Floats is

   type MPFR_Float is private;

   -- Private type so that all the following functions are NOT
primitive
   -- operations.

   -- PRECISION :
--------------------------------------------------------------

   procedure Set_Default_Precision (Decimal_Digits : Positive);
   -- Set the default precision whenever it is used.
   -- Note : if you want to precisely set this precision in bits
simply use the
   --        procedure mpfr_set_default_prec (prec : mpfr_prec_t) from
the
   --        MPFR package.

   procedure Unchecked_Precision_Adjustement
     (x              : in out MPFR_Float;
      Decimal_Digits : Positive);

   procedure Unchecked_Precision_Adjustement
     (x              : in out MPFR_Float;
      Error          : in     MPFR_Float;
      Decimal_Digits : Positive := 3);

   -- Return the value of x, either rounded or extended with trailing
zeros.
   -- Adjust the precision either to the absolute precision given in
digits, or
   -- by adjusting it to the given digits plus the order of magnitude
of the
   -- the difference between x and the reference value.

   type Rounding_Mode_Kind is (Round_to_Nearest,
                               Round_Toward_Zero,
                               Round_Toward_Plus_Infinity,
                               Round_Toward_Minus_Infinity);
   -- we declare here exactly the same type as the mpfr_rnd_t from the
   -- MPFR package, but for the sake of clarity and simplicity of the
user.

   procedure Set_Default_Rounding_Mode (Rounding :
Rounding_Mode_Kind);
   -- Set the default rounding used by this package, every time an
operation
   -- is done on a MPFR_Float. The default rounding mode is
   -- to nearest initially.

   procedure Set_Precision_Check (Decimal_Digits : Positive);
   procedure Inhibate_Precision_Check;
   -- These functions enable or inhibate the checking during
assignement to a
   -- variable, that the value has a precision above the curret
minimal required
   -- precision.
   -- If needed, the Not_Accurate exception is raised.


   -- INITIALISATION :
---------------------------------------------------------
   function To_MPFR_Float (Image          : String;
                           Decimal_Digits : Natural := 0 )
                           return MPFR_Float;

   -- This function creates Floating Point from a value given by a
string
   -- that must conform to the Ada Standard for Float literals
(decimal literals
   -- and base literals), and whose precision is at least the number
of
   -- decimal_digits given, or if this value is nul the
Default_Precision.
   -- The base can be above 16, but it must be under (or equal to) 36
(And in
   -- that case we use digits from 0 .. 9, A .. Z).
   -- We tolerate a negative value (i.e. the '-' at the beginning),
even if in
   -- Ada the '-' is seen as a unary operator and not part of the
literal.
   -- Exemples :
   --      Decimal literals : 12.0   0.0   0.456  3.14159_26
   --      Based   literals : 16#F.FF#E+2   2#1.1111_1111_1110#E11  =
4095.0

   Data_Error : Exception;

   subtype Base_Range is Integer range 2 .. 36;

   function Image (Item : MPFR_Float;
                   Base : Base_Range := 10)   return String;
   -- This function return a Float literal (decimal literal or base
literal)
   -- that conform to the Ada Standard except the '-' at the beginning
and the
   -- fact that base can be any integer between 2 and 36.


   function Not_A_Number   return MPFR_Float;
   function Plus_Infinity  return MPFR_Float;
   function Minus_Infinity return MPFR_Float;

   function Pi return MPFR_Float;
   -- Pi at the current default precision.

   ----------------------------
   -- "Standard" description --
   ----------------------------

   -- (Mimics Standard package)
   -- The predefined operators for this type are as follows:

   function "="   (Left, Right : MPFR_Float) return Boolean;
   function "<"   (Left, Right : MPFR_Float) return Boolean;
   function "<="  (Left, Right : MPFR_Float) return Boolean;
   function ">"   (Left, Right : MPFR_Float) return Boolean;
   function ">="  (Left, Right : MPFR_Float) return Boolean;
   pragma Inline ("=", "<", "<=", ">", ">=");


   function "abs" (Right : MPFR_Float) return MPFR_Float;
   function "-"   (Right : MPFR_Float) return MPFR_Float;
   pragma Inline ("abs", "-");

   function "+"   (Left, Right : MPFR_Float) return MPFR_Float;
   function "-"   (Left, Right : MPFR_Float) return MPFR_Float;
   function "*"   (Left, Right : MPFR_Float) return MPFR_Float;
   function "/"   (Left, Right : MPFR_Float) return MPFR_Float;

   function "**"  (Left : MPFR_Float; Right : Integer'Base) return
MPFR_Float;

   -- The specification of each operator for the type root_real, or
for
   -- any additional predefined floating point type, is obtained by
   -- replacing Float by the name of the type in the specification of
the
   -- corresponding operator of the type Float.

   -- In addition, the following operators are predefined for the root
   -- numeric types:
   function "*" (Left : MPFR_Float;   Right : Integer'Base) return
MPFR_Float;
   function "*" (Left : Integer'Base; Right : MPFR_Float)   return
MPFR_Float;
   function "/" (Left : MPFR_Float;   Right : Integer'Base) return
MPFR_Float;

   -- and we add :
   function "+" (Left : MPFR_Float;   Right : Integer'Base) return
MPFR_Float;
   function "+" (Left : Integer'Base; Right : MPFR_Float)   return
MPFR_Float;
   function "-" (Left : MPFR_Float;   Right : Integer'Base) return
MPFR_Float;
   function "-" (Left : Integer'Base; Right : MPFR_Float)   return
MPFR_Float;
   function "/" (Left : Integer'Base; Right : MPFR_Float)   return
MPFR_Float;

   --------------------------
   -- with Standard Floats --
   --------------------------
   -- use Float'Image and Float'Digits to create the MPFR_Float

   -----------------------------
   -- with Unbounded_Integers --
   -----------------------------

   subtype Unbounded_Integer is GMP.Integers.Unbounded_Integer;
   function To_MPFR_Float (Value : Unbounded_Integer) return
MPFR_Float;

   function Round_To_Unbounded_Integer(Item     : MPFR_Float)
                                       return Unbounded_Integer;
   function Round_To_Unbounded_Integer(Item     : MPFR_Float;
                                       Rounding : Rounding_Mode_Kind)
                                       return Unbounded_Integer;
   -- Round to an unbounded integer, using either the default rounding
mode
   -- or the specified mode.


   --------------------------
   -- Elementary functions --
   --------------------------

   function Sqrt (X    : MPFR_Float)        return MPFR_Float;
   function Log  (X    : MPFR_Float)        return MPFR_Float;
   function Log  (X    : MPFR_Float;
                  Base : Integer'Base)      return MPFR_Float;
   function Exp  (X    : MPFR_Float)        return MPFR_Float;
   function "**" (Left : MPFR_Float;
                  Right: Unbounded_Integer) return MPFR_Float;
   function "**" (Left, Right : MPFR_Float) return MPFR_Float;

   function Sin    (X : MPFR_Float) return MPFR_Float;
   function Cos    (X : MPFR_Float) return MPFR_Float;
   function Tan    (X : MPFR_Float) return MPFR_Float;
   function Sec    (X : MPFR_Float) return MPFR_Float;
   function Csc    (X : MPFR_Float) return MPFR_Float;
   function Cot    (X : MPFR_Float) return MPFR_Float;

   function Arcsin (X : MPFR_Float) return MPFR_Float;
   function Arccos (X : MPFR_Float) return MPFR_Float;
   function Arctan (X : MPFR_Float) return MPFR_Float;

   function Sinh   (X : MPFR_Float) return MPFR_Float;
   function Cosh   (X : MPFR_Float) return MPFR_Float;
   function Tanh   (X : MPFR_Float) return MPFR_Float;
   function Sech   (X : MPFR_Float) return MPFR_Float;
   function Csch   (X : MPFR_Float) return MPFR_Float;
   function Coth   (X : MPFR_Float) return MPFR_Float;
   function Arcsinh(X : MPFR_Float) return MPFR_Float;
   function Arccosh(X : MPFR_Float) return MPFR_Float;
   function Arctanh(X : MPFR_Float) return MPFR_Float;

   function Factorial (N : Natural'Base) return MPFR_Float;
   function Gamma     (X : MPFR_Float)   return MPFR_Float;

   ------------------
   -- Exceptions : --
   ------------------

   MPFR_Underflow    : exception;
   -- occurs when the exact result of a function is a non-zero real
number and
   -- the result obtained after the rounding, assuming an unbounded
exponent
   -- range (for the rounding), has an exponent smaller than the
minimum exponent
   -- of the current range. In the round-to-nearest mode, the halfway
case is
   -- rounded toward zero.
   MPFR_Overflow     : exception;
   -- occurs when the exact result of a function is a non-zero real
number and
   -- the result obtained after the rounding, assuming an unbounded
exponent
   -- range (for the rounding), has an exponent larger than the
maximum exponent
   -- of the current range. In the round-to-nearest mode, the result
is infinite.
   MPFR_Not_a_Number : exception;
   -- occurs when the result of a function is a NaN.
   MPFR_Inexact      : exception;
   -- occurs when the result of a function cannot be represented
exactly and must
   -- be rounded.
   MPFR_Range_Error  : exception;
   -- occurs when a function that does not return a MPFR number (such
as
   -- comparisons and conversions to an integer) has an invalid
result.

   Not_Accurate : exception;
   -- This exception might be raised by the "Precision_Check".
   -- It is not a MPFR exception in fact !


private

   type MPFR_Float is new Ada.Finalization.Controlled with record
      Value    : MPFR.mpfr_t;
   end record;

   overriding procedure Initialize (Object: in out MPFR_Float);
   overriding procedure Adjust     (Object: in out MPFR_Float);
   overriding procedure Finalize   (Object: in out MPFR_Float);

end MPFR.Floats;






^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada binding to GMP and MPFR
  2009-05-20 14:19 Ada binding to GMP and MPFR vincent.diemunsch
@ 2009-05-20 14:30 ` Ludovic Brenta
  2009-05-20 15:24   ` qunying
  2009-05-29 12:01   ` vincent.diemunsch
  2009-05-29 16:55 ` Pascal Obry
  1 sibling, 2 replies; 12+ messages in thread
From: Ludovic Brenta @ 2009-05-20 14:30 UTC (permalink / raw)


Vincent Diemunsch wrote on comp.lang.ada:
> Hello everybody,
>
> As the libraries GMP (http://gmplib.org/) and MPFR (http://www.mpfr.org/
> ) 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.
[...]
> Now I wonder if someone could be interested in hosting the sources on
> an Internet page, so that anybody could
> download them and test them and eventually make improvements...
>
> The Binding is as follows :
[...]
> Therfore, I require your help :
> - Where may i found a place to put the files (or a SVN repository ;-)
> - Would you be interested in giving comments on implementation
> especially for MPFR_Types ?
[...]
> -- Copyright (c) 2009 Vincent DIEMUNSCH.
> -- GNU General Public License.
[...]

I can offer hosting on the Ada-France monotone server[1,2] but I think
it would be more productive if you would assign your copyright to the
FSF[3] and submit your binding for inclusion in GCC. That way, your
bindings would become part of GCC along with the libraries themselves
and would be packaged along with GCC into most distributions. This
requires that you use the same license, i.e. GPL version 3 or later
with an additional clause permitting use in proprietary programs.

[1] http://www.ada-france.org/article130.html (French version)
[2] http://www.ada-france.org/article131.html (English version)
[3] http://gcc.gnu.org/contribute.html

--
Ludovic Brenta.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada binding to GMP and MPFR
  2009-05-20 14:30 ` Ludovic Brenta
@ 2009-05-20 15:24   ` qunying
  2009-05-27 15:35     ` vincent.diemunsch
  2009-05-29 12:01   ` vincent.diemunsch
  1 sibling, 1 reply; 12+ messages in thread
From: qunying @ 2009-05-20 15:24 UTC (permalink / raw)


> [...]
>
> I can offer hosting on the Ada-France monotone server[1,2] but I think
> it would be more productive if you would assign your copyright to the
> FSF[3] and submit your binding for inclusion in GCC. That way, your
> bindings would become part of GCC along with the libraries themselves
> and would be packaged along with GCC into most distributions. This
> requires that you use the same license, i.e. GPL version 3 or later
> with an additional clause permitting use in proprietary programs.
>
> [1]http://www.ada-france.org/article130.html(French version)
> [2]http://www.ada-france.org/article131.html(English version)
> [3]http://gcc.gnu.org/contribute.html
>
> --
> Ludovic Brenta.

What Ludovic suggested is the best way. In case you don't want that
route, as you are
using an gmail account, I think the most easy route for you is to host
it in
http://code.google.com/projecthosting/ as long as it uses the selected
few open sources
licenses,  no pre-approval is required. The drawback is that it only
support svn so far,
and the Mercurial support is still not open to all.

Others required approval from the hosting site:
http://sourceforge.net/
http://savannah.gnu.org/
http://github.com/
.etc.




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada binding to GMP and MPFR
  2009-05-20 15:24   ` qunying
@ 2009-05-27 15:35     ` vincent.diemunsch
  2009-05-27 17:47       ` John B. Matthews
  0 siblings, 1 reply; 12+ messages in thread
From: vincent.diemunsch @ 2009-05-27 15:35 UTC (permalink / raw)


On 20 mai, 17:24, qunying <zhu.quny...@gmail.com> wrote:
> > [...]
>
> > I can offer hosting on the Ada-France monotone server[1,2] but I think
> > it would be more productive if you would assign your copyright to the
> > FSF[3] and submit your binding for inclusion in GCC. That way, your
> > bindings would become part of GCC along with the libraries themselves
> > and would be packaged along with GCC into most distributions. This
> > requires that you use the same license, i.e. GPL version 3 or later
> > with an additional clause permitting use in proprietary programs.
>
> > [1]http://www.ada-france.org/article130.html(Frenchversion)
> > [2]http://www.ada-france.org/article131.html(Englishversion)
> > [3]http://gcc.gnu.org/contribute.html
>
> > --
> > Ludovic Brenta.
>
> What Ludovic suggested is the best way. In case you don't want that
> route, as you are
> using an gmail account, I think the most easy route for you is to host
> it inhttp://code.google.com/projecthosting/as long as it uses the selected
> few open sources
> licenses,  no pre-approval is required. The drawback is that it only
> support svn so far,
> and the Mercurial support is still not open to all.
>
> Others required approval from the hosting site:http://sourceforge.net/http://savannah.gnu.org/http://github.com/
> .etc.

Thanks for your response. I have tried to host in GOOGLE Source :
http://code.google.com/p/adabindinggmpmpfr/
I will now continue to test it. I would be very interested to recieve
comments on it :
- on the specification, if it is easy to use and clear,
- on the implementation,
etc.

Vincent



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada binding to GMP and MPFR
  2009-05-27 15:35     ` vincent.diemunsch
@ 2009-05-27 17:47       ` John B. Matthews
  2009-05-28 12:47         ` vincent.diemunsch
  0 siblings, 1 reply; 12+ messages in thread
From: John B. Matthews @ 2009-05-27 17:47 UTC (permalink / raw)


In article 
<0d5120bf-7581-4d4b-bdb4-e9d758e3a963@z5g2000yqn.googlegroups.com>,
 "vincent.diemunsch@gmail.com" <vincent.diemunsch@gmail.com> wrote:

[...]
> Thanks for your response. I have tried to host in GOOGLE Source :
> http://code.google.com/p/adabindinggmpmpfr/
> I will now continue to test it. I would be very interested to recieve
> comments on it :
> - on the specification, if it is easy to use and clear,
> - on the implementation,
> etc.

Um, the source tree appears to be empty at present; the same is true for 
svn checkout:

<http://code.google.com/p/adabindinggmpmpfr/source/browse/>

Somewhat tangentially, on Mac OS X, GNAT from MacAda looks for mpfr and 
gmp in /usr/local/lib. Users may wish to know that the libraries may be 
conveniently built from source using MacPorts:

<http://www.macports.org/>:
<http://trac.macports.org/browser/trunk/dports/devel/mpfr/Portfile>
<http://trac.macports.org/browser/trunk/dports/devel/gmp/Portfile>
<http://www.macada.org/>

See also,

<http://trac.macports.org/browser/trunk/dports/lang/gnat-gcc/Portfile>

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada binding to GMP and MPFR
  2009-05-27 17:47       ` John B. Matthews
@ 2009-05-28 12:47         ` vincent.diemunsch
  2009-05-28 19:41           ` John B. Matthews
  0 siblings, 1 reply; 12+ messages in thread
From: vincent.diemunsch @ 2009-05-28 12:47 UTC (permalink / raw)


On 27 mai, 19:47, "John B. Matthews" <nos...@nospam.invalid> wrote:
> In article
> <0d5120bf-7581-4d4b-bdb4-e9d758e3a...@z5g2000yqn.googlegroups.com>,
>
>  "vincent.diemun...@gmail.com" <vincent.diemun...@gmail.com> wrote:
>
> [...]
>
> > Thanks for your response. I have tried to host in GOOGLE Source :
> >http://code.google.com/p/adabindinggmpmpfr/
> > I will now continue to test it. I would be very interested to recieve
> > comments on it :
> > - on the specification, if it is easy to use and clear,
> > - on the implementation,
> > etc.
>
> Um, the source tree appears to be empty at present; the same is true for
> svn checkout:
>
> <http://code.google.com/p/adabindinggmpmpfr/source/browse/>
>
> Somewhat tangentially, on Mac OS X, GNAT from MacAda looks formpfrand
> gmp in /usr/local/lib. Users may wish to know that the libraries may be
> conveniently built from source using MacPorts:
>
> <http://www.macports.org/>:
> <http://trac.macports.org/browser/trunk/dports/devel/mpfr/Portfile>
> <http://trac.macports.org/browser/trunk/dports/devel/gmp/Portfile>
> <http://www.macada.org/>
>
> See also,
>
> <http://trac.macports.org/browser/trunk/dports/lang/gnat-gcc/Portfile>
>
> --
> John B. Matthews
> trashgod at gmail dot com
> <http://sites.google.com/site/drjohnbmatthews>

Hello John,

I have now added the files in the svn source tree !
I will add a little comment for Mac OS X users.
I still have a little trouble in my sample program for the
"translation"
of the C sample program, with the function mpfr_out_str BUT I find the
example of the Thick Ada Binding quite convincing :

   -- 1) Thick binding version :
   -- Note that we use Integers because they are EXACT values, to
initialize
   -- Multiple precision floats or in computations with the latters
   -- and not float values, that are approximations of real values
with a too
   -- small precision.
   declare
      use MPFR.Floats;
      Fact, Sum : MPFR_Float;
   begin
      Set_Default_Precision (Decimal_Digits => 62);
      Fact := To_MPFR_Float(1);
      Sum  := To_MPFR_Float(1);
      for i in 1 .. 100 loop
         Fact := i * Fact;
         Sum  := Sum + 1 / Fact;
      end loop;
      Put_Line ("Sum is " & Image(Sum));
   end;


Regards.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada binding to GMP and MPFR
  2009-05-28 12:47         ` vincent.diemunsch
@ 2009-05-28 19:41           ` John B. Matthews
  2009-05-28 20:23             ` vincent.diemunsch
  0 siblings, 1 reply; 12+ messages in thread
From: John B. Matthews @ 2009-05-28 19:41 UTC (permalink / raw)


In article 
<b7a9794d-9973-4d85-9e09-c3c0e14b5c4d@v4g2000vba.googlegroups.com>,
 "vincent.diemunsch@gmail.com" <vincent.diemunsch@gmail.com> wrote:

[...]

<http://code.google.com/p/adabindinggmpmpfr/source/browse/>

> I have now added the files in the svn source tree !

It's visible now.

> I will add a little comment for Mac OS X users.

Excellent!

> I still have a little trouble in my sample program for the 
> "translation" of the C sample program, with the function mpfr_out_str 
> BUT I find the example of the Thick Ada Binding quite convincing :

Looks good. I saw only two anomalies:

1) In mpfr_example.adb, line 75 should perhaps invoke New_Line, rather 
than Skip_Line.

2) In mpfr.ads, line 686, I had to specify a different external name:

   pragma Import (C, mpfr_out_str, "__gmpfr_out_str");

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada binding to GMP and MPFR
  2009-05-28 19:41           ` John B. Matthews
@ 2009-05-28 20:23             ` vincent.diemunsch
  2009-05-29  0:30               ` John B. Matthews
  0 siblings, 1 reply; 12+ messages in thread
From: vincent.diemunsch @ 2009-05-28 20:23 UTC (permalink / raw)


On 28 mai, 21:41, "John B. Matthews" <nos...@nospam.invalid> wrote:
> In article
> <b7a9794d-9973-4d85-9e09-c3c0e14b5...@v4g2000vba.googlegroups.com>,
>
>  "vincent.diemun...@gmail.com" <vincent.diemun...@gmail.com> wrote:
>
> [...]
>
> <http://code.google.com/p/adabindinggmpmpfr/source/browse/>
>
> > I have now added the files in the svn source tree !
>
> It's visible now.
>
> > I will add a little comment for Mac OS X users.
>
> Excellent!
>
> > I still have a little trouble in my sample program for the
> > "translation" of the C sample program, with the function mpfr_out_str
> > BUT I find the example of the Thick Ada Binding quite convincing :
>
> Looks good. I saw only two anomalies:
>
> 1) In mpfr_example.adb, line 75 should perhaps invoke New_Line, rather
> than Skip_Line.
>
> 2) Inmpfr.ads, line 686, I had to specify a different external name:
>
>    pragma Import (C, mpfr_out_str, "__gmpfr_out_str");
>
> --
> John B. Matthews
> trashgod at gmail dot com
> <http://sites.google.com/site/drjohnbmatthews>


Thanks John for your help ! ;-)
I have corrected the sources and added some little improvements.

Vincent



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada binding to GMP and MPFR
  2009-05-28 20:23             ` vincent.diemunsch
@ 2009-05-29  0:30               ` John B. Matthews
  0 siblings, 0 replies; 12+ messages in thread
From: John B. Matthews @ 2009-05-29  0:30 UTC (permalink / raw)


In article 
<e3f56e11-e04b-41ce-9eb9-6d9a48cc73ad@n4g2000vba.googlegroups.com>,
 "vincent.diemunsch@gmail.com" <vincent.diemunsch@gmail.com> wrote:

> On 28 mai, 21:41, "John B. Matthews" <nos...@nospam.invalid> wrote:
> > In article
> > <b7a9794d-9973-4d85-9e09-c3c0e14b5...@v4g2000vba.googlegroups.com>,
> >
> >  "vincent.diemun...@gmail.com" <vincent.diemun...@gmail.com> wrote:
> >
> > [...]
> >
> > <http://code.google.com/p/adabindinggmpmpfr/source/browse/>
> >
> > > I have now added the files in the svn source tree !
> >
> > It's visible now.
> >
> > > I will add a little comment for Mac OS X users.
> >
> > Excellent!
> >
> > > I still have a little trouble in my sample program for the
> > > "translation" of the C sample program, with the function mpfr_out_str
> > > BUT I find the example of the Thick Ada Binding quite convincing :
> >
> > Looks good. I saw only two anomalies:
> >
> > 1) In mpfr_example.adb, line 75 should perhaps invoke New_Line, rather
> > than Skip_Line.
> >
> > 2) Inmpfr.ads, line 686, I had to specify a different external name:
> >
> >    pragma Import (C, mpfr_out_str, "__gmpfr_out_str");
[...]
> Thanks John for your help ! ;-)
> I have corrected the sources and added some little improvements.

Looks good. Thank you for your fine binding. Here is a simple Makefile 
I've  been using; feel free to adapt it to your project:

TARG = mpfr_example

CARGS = -cargs -O2
BARGS = -bargs -shared
LARGS = -largs -dead_strip -lmpfr -lgmp

UNAME = $(shell uname)
GCCV = $(shell gcc -dumpversion)

.SUFFIXES:
.PHONY: clean cleaner debug run

$(TARG): $(TARG).ad[bs]
    @echo $(UNAME): gcc $(GCCV)
    gnatmake $(TARG) $(CARGS) $(BARGS) $(LARGS)

debug: $(TARG).ad[bs]
    gnatmake -g $(TARG) $(LARGS)

run:$(TARG)
    ./$(TARG)

clean:
    rm -f *.o *.ali b~* core

cleaner: clean
    rm -f *.s $(TARG)

[Note, make requires tab for indent.]
-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada binding to GMP and MPFR
  2009-05-20 14:30 ` Ludovic Brenta
  2009-05-20 15:24   ` qunying
@ 2009-05-29 12:01   ` vincent.diemunsch
  2009-05-29 17:08     ` qunying
  1 sibling, 1 reply; 12+ messages in thread
From: vincent.diemunsch @ 2009-05-29 12:01 UTC (permalink / raw)


On 20 mai, 16:30, Ludovic Brenta <ludo...@ludovic-brenta.org> wrote:
> Vincent Diemunsch wrote on comp.lang.ada:
>
> > Hello everybody,
>
> > As the libraries GMP (http://gmplib.org/) and MPFR (http://www.mpfr.org/
> > ) 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.
> [...]
> > Now I wonder if someone could be interested in hosting the sources on
> > an Internet page, so that anybody could
> > download them and test them and eventually make improvements...
>
> > The Binding is as follows :
> [...]
> > Therfore, I require your help :
> > - Where may i found a place to put the files (or a SVN repository ;-)
> > - Would you be interested in giving comments on implementation
> > especially for MPFR_Types ?
> [...]
> > -- Copyright (c) 2009 Vincent DIEMUNSCH.
> > -- GNU General Public License.
>
> [...]
>
> I can offer hosting on the Ada-France monotone server[1,2] but I think
> it would be more productive if you would assign your copyright to the
> FSF[3] and submit your binding for inclusion in GCC. That way, your
> bindings would become part of GCC along with the libraries themselves
> and would be packaged along with GCC into most distributions. This
> requires that you use the same license, i.e. GPL version 3 or later
> with an additional clause permitting use in proprietary programs.
>
> [1]http://www.ada-france.org/article130.html(French version)
> [2]http://www.ada-france.org/article131.html(English version)
> [3]http://gcc.gnu.org/contribute.html
>
> --
> Ludovic Brenta.

Hi Ludovic,

I have put the license FSF version 3 on all the files and created a
projet
in : http://code.google.com/p/adabindinggmpmpfr/
Now I would like to test it a bit more before submitting it to GCC.
And by the way, what do I have to do to submit it ?
Regards,

Vincent



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada binding to GMP and MPFR
  2009-05-20 14:19 Ada binding to GMP and MPFR vincent.diemunsch
  2009-05-20 14:30 ` Ludovic Brenta
@ 2009-05-29 16:55 ` Pascal Obry
  1 sibling, 0 replies; 12+ messages in thread
From: Pascal Obry @ 2009-05-29 16:55 UTC (permalink / raw)
  To: vincent.diemunsch@gmail.com


Vincent,

Great contribution! Thanks!

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Ada binding to GMP and MPFR
  2009-05-29 12:01   ` vincent.diemunsch
@ 2009-05-29 17:08     ` qunying
  0 siblings, 0 replies; 12+ messages in thread
From: qunying @ 2009-05-29 17:08 UTC (permalink / raw)


Just some thought, it is mostly personal style taste. For mpfr.ads/
gmp.ads, you are using a style of gathering all pragma Import /
Convention statements into one place. Does moving those part more
close to the declaration itself make maintenance more easy?



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-05-29 17:08 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-20 14:19 Ada binding to GMP and MPFR vincent.diemunsch
2009-05-20 14:30 ` Ludovic Brenta
2009-05-20 15:24   ` qunying
2009-05-27 15:35     ` vincent.diemunsch
2009-05-27 17:47       ` John B. Matthews
2009-05-28 12:47         ` vincent.diemunsch
2009-05-28 19:41           ` John B. Matthews
2009-05-28 20:23             ` vincent.diemunsch
2009-05-29  0:30               ` John B. Matthews
2009-05-29 12:01   ` vincent.diemunsch
2009-05-29 17:08     ` qunying
2009-05-29 16:55 ` Pascal Obry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox