[Insight-developers] Numeric Constants

Bradley Lowekamp blowekamp at mail.nih.gov
Thu Aug 6 10:40:58 EDT 2009


Hello,

	I was looking at:

BasicFilters/itkBilateralImageFilter.txx:  rangeGaussianDenom =  
m_RangeSigma*vcl_sqrt(2.0*3.1415927);

It took me a little bit to figure out that we most likely should be  
using vnl_math::pi, along with their "e and all that". I do wonder if  
these constants were in itk::Math and in doxygen if it would help with  
increased usage.

So I began greping in the "Code" directory and came up with the  
following:

grep -r 3.1415 *
BasicFilters/itkBilateralImageFilter.txx:  rangeGaussianDenom =  
m_RangeSigma*vcl_sqrt(2.0*3.1415927);
BasicFilters/itkVectorGradientMagnitudeImageFilter.txx:  const double  
dpi = 3.14159265358979323846;
Common/itkGaussianDerivativeSpatialFunction.txx:    prefixDenom *=  
2*vcl_pow( 2 * 3.1415927, VImageDimension / 2.0);
Common/itkMersenneTwisterRandomVariateGenerator.h:  double phi = 2.0 *  
3.14159265358979323846264338328
Numerics/itkCumulativeGaussianOptimizer.cxx:  m_ComputedAmplitude =   
sum / (m_ComputedStandardDeviation * vcl_sqrt(2*3.14159265));

grep -r 0.707 *
BasicFilters/itkBSplineResampleImageFilterBase.txx:      m_G[0]  =   
0.707107;

grep -r 1.414 *
Numerics/Statistics/itkGaussianDistribution.cxx:    dq  = 0.5e+0 *  
vnl_erfc( dx / 1.414213562373095e+0 ) - dp;
Review/Statistics/itkGaussianDistribution.cxx:    dq  = 0.5e+0 *  
vnl_erfc( dx / 1.414213562373095e+0 ) - dp;

grep -r vnl_math:: * | wc
       69     571    7652

Well I guess that is almost 90% usage of the numeric constants, so its  
not bad at all.

I'll work on a patch tonight, and likely commit something tomorrow if  
no one sees a problem with this.

Brad


More information about the Insight-developers mailing list