two questions on GMP & C float
Marc Glisse
marc.glisse at normalesup.org
Sat May 16 20:04:30 CEST 2009
On Sat, 16 May 2009, Vincent Lefevre wrote:
> On 2009-05-16 17:53:00 +0200, Marc Glisse wrote:
>> Compared to (mpz,int) (and mpf), I think mpfr has alloc==size (this could
>> be changed in a compatible way (except for a couple macros that expose
>> too much internals), or allocated storage could be truncated (if
>> mpfr_free_func ignores size), so I may be mistaken), which makes a lot of
>> sense for fixed precision arithmetic, but may be a bit less convenient
>> here (I don't really know, it may not matter so much).
>
> What do you mean by alloc==size?
This is the "I may be mistaken" part ;-)
(I just looked at the code after your message)
Since the allocated size is not kept in mpfr_t, I thought the idea was to
have it be the same thing as the prec. But the allocated size can also be
kept just before the buffer pointed to by _mpfr_d, which is what I was
mentionning as a possible evolution, and it is actually already done. And
I don't really know what I meant about the macros, only the mpfr_custom*
macros do weird things, but they are supposed to.
It is a bit strange to have a different strategy to store the allocated
size in gmp and mpfr, but there is nothing wrong with that, there is a
compromise between what gets into the basic *_t type (at least a pointer
to the heap) and what gets to that malloced buffer (at least (most of) the
limbs).
--
Marc Glisse
More information about the gmp-discuss
mailing list