Jump to page: 1 2
Thread overview
libgmp deimos library
Jan 11, 2017
Andrew Hall
Jan 11, 2017
Guillaume Chatelet
Jan 11, 2017
Andrew Hall
Jan 11, 2017
Guillaume Chatelet
Jan 11, 2017
Jacob Carlborg
Jan 11, 2017
Nordlöw
Jan 11, 2017
Andrew Hall
Jan 11, 2017
Nordlöw
Jan 11, 2017
Andrew Hall
Jan 11, 2017
Nordlöw
Jan 11, 2017
Andrew Hall
Jan 11, 2017
Andrew Hall
Jan 11, 2017
Nordlöw
Jan 12, 2017
Mike Parker
Jan 12, 2017
Mike Parker
Jan 12, 2017
Andrew Hall
Jan 12, 2017
Russel Winder
Jan 12, 2017
Nordlöw
Jan 15, 2017
Andrew Hall
Jan 16, 2017
Nordlöw
January 11, 2017
I've been writing D bindings for GMP and I was wondering if they warrant inclusion in the Deimos git repo. I know Dlang has bignum, but GMP is still the fastest library for extremely large numbers.

The repos is in 'Deimos' format so if you care to use it, please tell me how to proceed.
https://github.com/andrew-m-h/libgmp
January 11, 2017
On Wednesday, 11 January 2017 at 10:29:26 UTC, Andrew Hall wrote:
> I've been writing D bindings for GMP and I was wondering if they warrant inclusion in the Deimos git repo. I know Dlang has bignum, but GMP is still the fastest library for extremely large numbers.
>
> The repos is in 'Deimos' format so if you care to use it, please tell me how to proceed.
> https://github.com/andrew-m-h/libgmp

FYI I wrote a MPFR Deimos binding:
https://github.com/gchatelet/deimos-mpfr

MPFR relies on GMP so I had to create this file:
https://github.com/gchatelet/deimos-mpfr/blob/master/source/deimos/gmp.d

If you register your project on https://code.dlang.org/ I'll be able to depend on your project and reuse your bindings.
January 11, 2017
On Wednesday, 11 January 2017 at 10:52:40 UTC, Guillaume Chatelet wrote:
> On Wednesday, 11 January 2017 at 10:29:26 UTC, Andrew Hall wrote:
>> I've been writing D bindings for GMP and I was wondering if they warrant inclusion in the Deimos git repo. I know Dlang has bignum, but GMP is still the fastest library for extremely large numbers.
>>
>> The repos is in 'Deimos' format so if you care to use it, please tell me how to proceed.
>> https://github.com/andrew-m-h/libgmp
>
> FYI I wrote a MPFR Deimos binding:
> https://github.com/gchatelet/deimos-mpfr
>
> MPFR relies on GMP so I had to create this file:
> https://github.com/gchatelet/deimos-mpfr/blob/master/source/deimos/gmp.d
>
> If you register your project on https://code.dlang.org/ I'll be able to depend on your project and reuse your bindings.

Cheers, I've done as you suggest, and 'libgmp' is registered under DUB. Feel free to have a look at the code because this is the first binding I've written in D. That said, it does have a test suite (unit tests) that do work. What is the procedure for being accepted by Deimos?
January 11, 2017
On Wednesday, 11 January 2017 at 11:34:55 UTC, Andrew Hall wrote:
> Cheers, I've done as you suggest, and 'libgmp' is registered under DUB. Feel free to have a look at the code because this is the first binding I've written in D. That said, it does have a test suite (unit tests) that do work. What is the procedure for being accepted by Deimos?

Can you add the dub component to the "Development library" -> "D language binding" category?

Also you should probably post about your library on the "Announce" list.

I'm not at all an expert on D bindings, I found the following links:
- This page explains the procedure: http://wiki.dlang.org/D_binding_for_C
- But this one too: http://dlang.org/spec/interfaceToC.html
- This page seems out of date: https://wiki.dlang.org/Bindings.
- And most bindings are discoverable through https://code.dlang.org/?sort=updated&category=library.binding

The old way seems to gather all bindings under https://github.com/D-Programming-Deimos.
The new way seems to use https://code.dlang.org/.

Is someone aware of an official position on this?


January 11, 2017
On Wednesday, 11 January 2017 at 10:29:26 UTC, Andrew Hall wrote:
> https://github.com/andrew-m-h/libgmp

Nice. I'll make use of it in my high-level wrapper at

https://github.com/nordlow/phobos-next/blob/master/src/gmp.d

instead of my hand-coded externs.

It is currently well tested (unittests give 100 % code coverage) but not completed. Majority of integer support is there. Nothing else.

I'll put up a DUB package soon. I guess gmp-d would be a good name.

It's worth mentioning that compile-and-link of gmp.d of a debug-build including unittests take 0.07 seconds on my machine :)
January 11, 2017
On 2017-01-11 13:33, Guillaume Chatelet wrote:

> I'm not at all an expert on D bindings, I found the following links:
> - This page explains the procedure: http://wiki.dlang.org/D_binding_for_C
> - But this one too: http://dlang.org/spec/interfaceToC.html
> - This page seems out of date: https://wiki.dlang.org/Bindings.
> - And most bindings are discoverable through
> https://code.dlang.org/?sort=updated&category=library.binding
>
> The old way seems to gather all bindings under
> https://github.com/D-Programming-Deimos.
> The new way seems to use https://code.dlang.org/.
>
> Is someone aware of an official position on this?

Nothing official but I would say:

* Use DStep [1] to generate the bindings automatically

* Use code.dlang.org instead of Deimos. On code.dlang.org you can have your own repository and don't need to be dependent on someone from the core team to merge pull requests. Anything on code.dlang.org will be easily accessible to other projects using Dub

[1] https://github.com/jacob-carlborg/dstep

-- 
/Jacob Carlborg
January 11, 2017
On Wednesday, 11 January 2017 at 12:50:15 UTC, Nordlöw wrote:
> On Wednesday, 11 January 2017 at 10:29:26 UTC, Andrew Hall wrote:
>> https://github.com/andrew-m-h/libgmp
>
> Nice. I'll make use of it in my high-level wrapper at
>
> https://github.com/nordlow/phobos-next/blob/master/src/gmp.d
>
> instead of my hand-coded externs.
>
> It is currently well tested (unittests give 100 % code coverage) but not completed. Majority of integer support is there. Nothing else.
>
> I'll put up a DUB package soon. I guess gmp-d would be a good name.
>
> It's worth mentioning that compile-and-link of gmp.d of a debug-build including unittests take 0.07 seconds on my machine :)

If you would like some test cases that I wrote for my mpz_t wrapper, you should look in https://github.com/andrew-m-h/libgmp/blob/master/source/deimos/gmp/operators.d and take the bottom two unittests.
The test cases are more complex than just your usual a + b:
- a verification of Fermat's Little Theorem for mersenne primes M(p) p < 200
- a 'rediscovery' of Lander & Parkin's counter example to Euler's Sum of Powers Conjecture.
 i.e. finding: 27^5 + 84^5 + 110^5 + 133^5 = 144^5

They should be trivially translateable to your interface, and test out your library for speed ;)

I was planning on extending this wrapper but since you have one, you may as well have the test cases.
January 11, 2017
On Wednesday, 11 January 2017 at 13:53:18 UTC, Andrew Hall wrote:

> I was planning on extending this wrapper but since you have one, you may as well have the test cases.

Great. I'll merge mine and your's stuff and put it in

https://github.com/nordlow/gmp-d.git

Could you please give some suggestions on the repo directory structure and contents of dub.sdl for specifying deps to the deimos C wrappers?
January 11, 2017
On Wednesday, 11 January 2017 at 18:32:36 UTC, Nordlöw wrote:
> On Wednesday, 11 January 2017 at 13:53:18 UTC, Andrew Hall wrote:
>
>> I was planning on extending this wrapper but since you have one, you may as well have the test cases.
>
> Great. I'll merge mine and your's stuff and put it in
>
> https://github.com/nordlow/gmp-d.git
>
> Could you please give some suggestions on the repo directory structure and contents of dub.sdl for specifying deps to the deimos C wrappers?

Basically, gmp.h is split up into 4 files:
gmp.d, integer.d, floating.d & rational.d.
these are all public import'd by package.d so if you would like the contents of all of gmp.h,
import deimos.gmp. However if you only need the integer stuff, you could just import deimos.gmp.gmp, deimos.gmp.integer;

operators.d contains my first wrapper of the mpz_t type.
January 11, 2017
On Wednesday, 11 January 2017 at 21:52:57 UTC, Andrew Hall wrote:
> Basically, gmp.h is split up into 4 files:
> gmp.d, integer.d, floating.d & rational.d.
> these are all public import'd by package.d so if you would like the contents of all of gmp.h,
> import deimos.gmp. However if you only need the integer stuff, you could just import deimos.gmp.gmp, deimos.gmp.integer;
>
> operators.d contains my first wrapper of the mpz_t type.

Thanks.

One important thing...you've forgotten to qualify the D wrapper functions as `pure @nogc`. All should be `@nogc` and most should be `pure`. I'm not sure which of them that aren't pure, that is which modify global state. Maybe you can look that up in the GMP manual. I find the pdf version the easiest to search.
« First   ‹ Prev
1 2