[Insight-developers] Insight-developers Digest, Vol 63, Issue 23
Simon Warfield
simon.warfield at childrens.harvard.edu
Mon Jul 20 12:22:00 EDT 2009
> Date: Mon, 20 Jul 2009 16:13:43 +0200
> From: Tom Vercauteren <tom.vercauteren at gmail.com>
> Subject: [Insight-developers] Using Math::Floor in interpolation code?
> To: ITK <insight-developers at itk.org>
> Message-ID:
> <28392e8b0907200713i3f454abdh5375080b4700fd7b at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi All,
>
> I saw that several interpolators use the following piece of code:
>
> // The following "if" block is equivalent to the following line without
> // having to call floor.
> // baseIndex[dim] = (long) vcl_floor(index[dim] );
> if (index[dim] >= 0.0)
> {
> baseIndex[dim] = (long) index[dim];
> }
> else
> {
> long tIndex = (long) index[dim];
> if (double(tIndex) != index[dim])
> {
> tIndex--;
> }
> baseIndex[dim] = tIndex;
> }
>
>
> Anyone against changing this to a more efficient and cleaner call to
> Math::Floor?
>
> baseIndex[dim] = Math::Floor( index[dim] );
>
>
I am in favour of changing it to this.
> I guess the initial reason for not using vcl_floor was for
> performance. Math::Floor should be faster that both vcl_floor and the
> above code.
>
> The attached patch implements this proposal, on my setup, the
> experimental build turns out green except for one test that has been
> failing for some time when consistent centered pixels is turned on.
> http://www.cdash.org/CDash/buildSummary.php?buildid=382493
>
> Regards,
> Tom
>
> 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.
>
--
Simon
More information about the Insight-developers
mailing list