[Numpy-discussion] Bug in logaddexp2.reduce

David Cournapeau david at silveregg.co.jp
Thu Apr 1 05:52:43 EDT 2010


Anne Archibald wrote:
> On 1 April 2010 03:15, David Cournapeau <david at silveregg.co.jp> wrote:
>> 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.
> 
> I don't think this is true for IEEE floats, at least in the case we're
> interested in where u is approximately 1.


Yes, sorry, you're right.

For log1p, we can use the msun code, it is claimed to be such as the 
error is bounded by 1 ulp, does not rely on ASM, and we already have all 
the necessary macros in npymath so that the code should be easy to 
integrate for single and double precision. I don't see code for the long 
double version, though.

We can use the boost test data to see if we get something sensible there .

 > Who knows
> which one gets used for which operations? -ffloat-store is supposed to
> force the constant discarding of extra digits, but we certainly don't
> want to apply that to all of numpy.

I think relying on -ffloat-store is buggy anyway, and it would be a 
maintenance hell. It is useful to know when it makes a difference, though.

cheers,

David



More information about the NumPy-Discussion mailing list