[vtk-developers] More on infinity and NaN in VTK

Philippe Pébay pppebay at sandia.gov
Mon May 23 18:22:32 EDT 2011


Ken,

Thanks for the answer. Yes, I agree, in fact I did not mean to change anything vtkMath.cxx, but was wondering whether I 
was missing something else.

Rather if something had to be changed (notice the conditional here!) I would venture to say that it would be 
vtkMathConfigure, not vtkMath. I am wondering whether there could be a way to detect precisely what is available rather 
than assuming it, the way it is currently done in vtkMathConfigure.in

A related question regards how FPE signal (8) is going to be raised, or not, when a division by 0 occurs. On some 
platforms it is not the case (such as, for instance, my version (4.4.4) of g++ with FC12), and on some others (such as 
Debian4-unknow-compiler on the Dashboard) it is the case. This results in varying outcomes for the test harness, even 
for cases which we could treat in a uniform, predictable way (specifically, a degenerate covariance matrix which yet has 
at least one non-singular eigenvalue).

So, my main goal at this point is to try to understand some underlying assumptions of the code has it exists today with 
respect to floating point exceptions and numeric limits, and not to recommend any change. Sorry if I gave a different 
impression with my earlier message.

Philippe


On 05/23/2011 03:14 PM, Moreland, Kenneth wrote:
> This looks like defensive programming to me.  It's dangerous to assume
> that VTK_HAS_STD_NUMERIC_LIMITS == !__BORLANDC__.  It could also be that
> the implementation for neither case was for some other older compiler that
> is no longer supported.  In either case, I would leave the code how it is.
>   You could replace the "return vtkMathNanBits.d" with something like
> "#error Can't figure out NaN for current compiler", but I would definitely
> leave the third condition there.
>
> -Ken
>
>     ****      Kenneth Moreland
>      ***      Sandia National Laboratories
> ***********
> *** *** ***  email: kmorel at sandia.gov
> **  ***  **  phone: (505) 844-8919
>      ***      web:   http://www.cs.unm.edu/~kmorel
>
>
>
>
> On 5/23/11 5:59 PM, "Philippe Pébay"<pppebay at sandia.gov>  wrote:
>
>> Hello,
>>
>> Following the message which I posted last week (no response so far)
>> regarding infinity and NaN in VTK, I looked a bit
>> deeper into the issue and noticed the following apparent contradiction:
>>
>> 1. In vtkMathConfigure.in we have the following:
>>
>> // We pretty much assume that all compilers are going to provide
>> // std::numeric_limits methods in the limits header.  On of the Borland
>> // dashboard compilers failed to link in the methods, so we have a special
>> // case here.  If we find more platforms that do not support it correctly,
>> // then we should probably implement a TRY_COMPILE in the CMakeLists.txt.
>> #ifndef __BORLANDC__
>> # define VTK_HAS_STD_NUMERIC_LIMITS
>> #endif
>>
>> which means that for all platforms save Borland, we will assume that
>> numeric_limits are present.
>>
>> 2. However, in vtkMath.cxx we have for Nan() (and something similar for
>> Inf()):
>>
>> double vtkMath::Nan()
>> {
>> #if defined(VTK_HAS_STD_NUMERIC_LIMITS)
>>    return vtkstd::numeric_limits<double>::quiet_NaN();
>> #elif defined(__BORLANDC__)
>>    return *reinterpret_cast<double*>(&vtkMathNanBits);
>> #else
>>    return vtkMathNanBits.d;
>> #endif
>> }
>>
>> with the effect that the first if statement is rendered useless by the
>> definitions in vtkMathConfigure.
>>
>> Is this done on purpose? Am I missing something else in the picture?
>>
>> Thanks
>> Philippe
>>
>>
>> On 05/23/2011 02:18 PM, Brad King wrote:
>>> On Mon, May 23, 2011 at 4:13 PM, Philippe Pébay<pppebay at sandia.gov>
>>> wrote:
>>>> If you have a few minutes, I would like to discuss the issue of
>>>> infinity and NaN in VTK.
>>>
>>> The most I've ever done with that type of thing is investigate the
>>> portability of isnan and isinf tests, but that was probably 5 years
>>> ago.  Hopefully someone will respond on the vtk or titan lists.
>>> Otherwise I suggest proposing a more specific plan.
>>>
>>> -Brad
>>>
>>
>>
>> --
>> Philippe Pébay
>> Sandia National Laboratories
>>
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtk-developers
>>
>>
>


-- 
Philippe Pébay
Sandia National Laboratories





More information about the vtk-developers mailing list