mpz_combit

bodrato at mail.dm.unipi.it bodrato at mail.dm.unipi.it
Sun Dec 30 09:08:43 CET 2012


Ciao,

Il Ven, 28 Dicembre 2012 12:03 am, Niels Möller ha scritto:
> bodrato at mail.dm.unipi.it writes:
>> About mpz_combit code, may I suggest replacing the two lines
>> 	  MPN_NORMALIZE (dp, dsize);
>> 	  ASSERT (dsize > 0);
>> with
>> 	  MPN_NORMALIZE_NOT_ZERO (dp, dsize);

> Conciseness is nice. Is that equivalent? I had some impression that the
> latter is less safe, but that may be completely wrong.

It's not a matter of conciseness, the latter is faster, but you are right:
it is not safe if the ASSERT is based on false assumptions.

In that branch, MPN_NORMALIZE_NOT_ZERO is safe (and the ASSERT is correct).

Looking deeper into, I realised that the branch-less normalization of at
most one limb is even better. The patch (for 5.2) is attached, I already
pushed specific checking code, as it can not introduce new bugs (in the
library).

Regards,
m

-- 
http://bodrato.it/software/combinatorics.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: combit.diff
Type: text/x-patch
Size: 543 bytes
Desc: not available
URL: <http://gmplib.org/list-archives/gmp-devel/attachments/20121230/cdfa33c3/attachment.bin>


More information about the gmp-devel mailing list