[Insight-developers] itk::Math:: limitations (was: Using Math::Floor in interpolation code?)

Bradley Lowekamp blowekamp at mail.nih.gov
Mon Jul 20 14:12:50 EDT 2009


Hello Tom,

What do I mean? That is a good question. Looking at the code you  
posted, it performed the floor operation to "long" precisions. (Which  
can be 32 or 64 bits of precision. )  The itk::Image's Index'  
ValueType (the precisions of indexs) is type long also. So I think  
ideally we need an tik::Floor methods to support long type....

But as the discussion from a couple of weeks ago reveled the size of  
long is not consistent. Specifically on windows 64-bit it's only 32  
bits. This can cause some problems and limitation, which still need to  
be sorted out.

In summary, I think that the code should be replaces with a version of  
floor which supports the same type as we are using for index types.  
(Which currently is long, but may be changed to a portable 64-bit type  
in the future.

Brad

On Jul 20, 2009, at 12:29 PM, Tom Vercauteren wrote:

> Hi Brad,
>
>
> On Mon, Jul 20, 2009 at 17:40, Bradley  
> Lowekamp<blowekamp at mail.nih.gov> wrote:
>>
>> On Jul 20, 2009, at 10:13 AM, Tom Vercauteren wrote:
>>
>> P.S.: As for the other itk::Math:: routines, the limitations are that
>> itk::Math::Floor is only guaranteed to work for arguments less than
>> INT_MAX/2. Also it expects the FPU rounding mode to be the default
>> one.
>> <itk-InterpolateFloor-2009-07-20.patch><ATT00001.txt>
>>
>> Is it limited to INT_MAX/2 for 64-bit integers too?
>
> I am not sure what you mean by "for 64-bit integers" since the
> itk::Math:: routines take a float or double as input and produce an
> int as output and, as far as I know, int is usually 32 bits even on 64
> bit platforms.
>
> That being said, it is true that the INT_MAX/2 limitation also holds
> on 64 bits systems. Actually, for almost all itk::Math:: routines, one
> should currently assume that they only work for arguments that have an
> absolute value less than INT_MAX/2-1 *. The main exception being
> RoundHalfIntegerToEven that works up to INT_MAX.
>
> When I initially started working on those rounding functions for ITK,
> the discussions on the list led to a consensus that these limitations
> were not a problem. Do you think otherwise? Would you be in favor for
> adding an assert in these rounding functions for this INT_MAX/2
> limitation so that errors might be caught in a debug mode?
>
> Tom
>
>
> * The actual implementation of the itk::Math:: routines depend on the
> architecture and compiler so in some cases, it might work but I
> definitely wouldn't rely on that.

========================================================
Bradley Lowekamp
Lockheed Martin Contractor for
Office of High Performance Computing and Communications
National Library of Medicine
blowekamp at mail.nih.gov


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20090720/3c1cbadd/attachment.htm>


More information about the Insight-developers mailing list