[Numpy-discussion] Bug in logaddexp2.reduce

David Cournapeau david@silveregg.co...
Thu Apr 1 02:15:11 CDT 2010


Anne Archibald wrote:

> 
> Particularly given the comments in the boost source code, I'm leery of
> this fix; who knows what an optimizing compiler will do with it?

But the current code *is* wrong: it is not true that u == 1 implies u - 
1 == 0 (and that (u-1) != 0 -> u != 1), because the spacing between two 
consecutive floats is much bigger at 1 than at 0. And the current code 
relies on this wrong assumption: at least with the correction, we test 
for what we care about.

So I would say the code correction I suggest is at least better in that 
respect.

> Now the
> "correction" is completely bogus.

I am not sure to understand why ? It is at least not worse than the 
current code.

> Since this is a subtle issue, I vote for delegating it (and log10_1p)
> to log1p. If *that* has trouble, well, at least it'll only be on
> non-C99 machines, and we can try compiler gymnastics.

Yes, we could do that. I note that on glibc, the function called is an 
intrinsic for log1p (FYL2XP1) if x is sufficiently small.

> Clearly the optimizing compiler is inserting the DRDB (drain David's
> battery) opcode.

:)

David


More information about the NumPy-Discussion mailing list