Efficiently importing/export GMP floats

Marc Glisse marc.glisse at inria.fr
Mon Jan 17 11:09:28 CET 2011

On Sun, 16 Jan 2011, Jack Poulson wrote:

> I have been scouring the manual and related archived conversations, but I
> can't seem to find a sufficient means of importing/exporting a large
> collection of mpf_t's as a binary format without a loss in precision (e.g.,
> converting to double-precision).

The closest I can see is mpf_inp_str/mpf_out_str, which in base 16 or 32 
shouldn't be too slow (but still not suited for your use).

I guess you'll have to implement it yourself relying on the internal 
representation (after all that's just copying 3 integers and an array) and 
hope that representation doesn't change. Depending on your use, you may 
actually want something similar to mpz_array_init (I haven't checked the 
implementation, but it seems like it should be easier to make it work for 
mpf_t than mpz_t).

I do hope your cluster is composed of homogeneous machines, or that will 
make things much harder.

Marc Glisse

More information about the gmp-discuss mailing list