mini-gmp and mpq

Marco Bodrato bodrato at
Sat Feb 17 22:24:44 UTC 2018


Il Mer, 14 Febbraio 2018 10:08 pm, Niels Möller ha scritto:
>> Il Mer, 14 Febbraio 2018 7:53 pm, Marco Bodrato ha scritto:
>>> It shouldn't be too difficoult to add the mpq layer; at least if you
>>> don't
>>> need to deal with floats types nor strings.
> I'm not sure what the use case was. I guess one could add an mpq.c
> source file to the mini-gmp directory with mpq functions (that seems

Mee too, I'm not sure about the use case... but a mini-mpq.[ch] couple of
files seems easy to write. And should be easy to use.

> But another alternative with less code duplication might be to try to
> build the existing mpq code, using mini-gmp for the underlying integer

Is code duplication always bad? If mini-gmp is a library for prototype,
embedded, fallback purposes, then it can contain a specially crafted,
compact and easy to use mpq layer.

> the code uses very few mpn
> functions, mpn_cmp, mpn_mul, mpn_tdiv_qr, mpn_get_d, mpn_rshift. Of
> these, mpn_get_d and mpn_tdiv_qr are not provided by mini-gmp.

But it also uses macros as MPZ_TMP_INIT, count_trailing_zeros...
And I don't think it's a good idea to have code in GMP that, if changed,
can brake a use of mini-gmp.



More information about the gmp-devel mailing list