[Insight-developers] fast floor function

Tom Vercauteren tom.vercauteren at m4x.org
Fri Aug 1 06:07:41 EDT 2008


Hi all,

I'd like to fix the following issue but need some insight:
http://www.itk.org/Bug/view.php?id=2078
http://www.itk.org/Bug/view.php?id=5692

Basically, within itkBSplineInterpolationWeightFunction.txx there is a
(private) fast floor function that kind of works on easy tasks but
fails on some others, e.g. BSplineFloor(0.999999) returns 1 instead of
0.


I need feedback on several points:

1) Since this function is only defined in an anonymous namespace
itkBSplineInterpolationWeightFunction.txx, it cannot be tested in a
unit test. We should at least be able to test it.

2) The potential scope of such a function is way broader that is
actual use. I therefore think it should be placed in a place where
anybody can access it. I would vote for vnl but don't know if it is
easy to do that. Where else could it be placed?

3) In our local source code we have a fast floor function based on
http://ldesoras.free.fr/doc/articles/rounding_en.pdf that we tested on
a only few platforms. It works quite well but has some known
limitations (A: The absolute value of the argument must be less than
INT_MAX/2   B: It expects that the FPU rounding mode is the default
one, i.e. if someone changes it we assume that he then restores the
initial state). I would be happy to share it but it may need some
additional compatibility work.

Best regards,
Tom


More information about the Insight-developers mailing list