[Insight-developers] Optimized floor implementation in
itkBilateralImageFilter/itkBSplineInterpolationWeightFunction
Lydia Ng
lydiang at gmail.com
Fri Nov 11 17:35:46 EST 2005
Skipped content of type multipart/alternative-------------- next part --------------
#include <iostream>
#include <math.h>
int BSplineFloor(double x)
{
#if defined mips || defined sparc || defined __ppc__
return (int)((unsigned int)(x + 2147483648.0) - 2147483648U);
#elif defined i386 || defined _M_IX86
unsigned int hilo[2];
*((double *)hilo) = x + 103079215104.0; // (2**(52-16))*1.5
return (int)((hilo[1]<<16)|(hilo[0]>>16));
#else
return int(floor(x));
#endif
}
int main ( int argc, char * argv[] )
{
double inputValue = 6.9999985811165137;
double outputValue1 = floor( inputValue );
double outputValue2 = BSplineFloor( inputValue );
std::cout << inputValue << std::endl;
std::cout << outputValue1 << std::endl;
std::cout << outputValue2 << std::endl;
return 0;
}
-------------- next part --------------
PROJECT(Floored)
#-----------------------
# Define executables
#-----------------------
ADD_EXECUTABLE( TestFastFloor TestFastFloor.cxx )
TARGET_LINK_LIBRARIES( TestFastFloor )
More information about the Insight-developers
mailing list