ITK  4.8.0
Insight Segmentation and Registration Toolkit
Namespaces | Functions | Variables
itk::Math Namespace Reference

Namespaces

 Detail
 

Functions

template<typename TReturn , typename TInput >
TReturn CastWithRangeCheck (TInput x)
 
template<TReturn , typename TInput >
 Ceil (TInput x)
 
template<typename T >
bool FloatAlmostEqual (T x1, T x2, typename Detail::FloatIEEE< T >::IntType maxUlps=4, typename Detail::FloatIEEE< T >::FloatType maxAbsoluteDifference=0.1 *NumericTraits< T >::epsilon())
 
template<typename T >
Detail::FloatIEEE< T >::IntType FloatDifferenceULP (T x1, T x2)
 
template<TReturn , typename TInput >
 Floor (TInput x)
 
template<typename TReturn , typename TInput >
TReturn Round (TInput x)
 
template<TReturn , typename TInput >
 RoundHalfIntegerToEven (TInput x)
 
template<TReturn , typename TInput >
 RoundHalfIntegerUp (TInput x)
 
ITKCommon_EXPORT bool IsPrime (unsigned short n)
 
ITKCommon_EXPORT bool IsPrime (unsigned int n)
 
ITKCommon_EXPORT bool IsPrime (unsigned long n)
 
ITKCommon_EXPORT bool IsPrime (unsigned long long n)
 
ITKCommon_EXPORT unsigned short GreatestPrimeFactor (unsigned short n)
 
ITKCommon_EXPORT unsigned int GreatestPrimeFactor (unsigned int n)
 
ITKCommon_EXPORT unsigned long GreatestPrimeFactor (unsigned long n)
 
ITKCommon_EXPORT unsigned long long GreatestPrimeFactor (unsigned long long n)
 

Variables

static const double e = 2.7182818284590452354
 
static const double ln10 = 2.30258509299404568402
 
static const double ln2 = 0.69314718055994530942
 
static const double log10e = 0.43429448190325182765
 
static const double log2e = 1.4426950408889634074
 
static const double one_over_pi = 0.31830988618379067154
 
static const double one_over_sqrt2pi = 0.39894228040143267794
 
static const double pi = 3.14159265358979323846
 
static const double pi_over_2 = 1.57079632679489661923
 
static const double pi_over_4 = 0.78539816339744830962
 
static const double sqrt1_2 = 0.70710678118654752440
 
static const double sqrt2 = 1.41421356237309504880
 
static const double two_over_pi = 0.63661977236758134308
 
static const double two_over_sqrtpi = 1.12837916709551257390
 

Function Documentation

template<typename TReturn , typename TInput >
TReturn itk::Math::CastWithRangeCheck ( TInput  x)
inline

This class requires OnlyDefinedForIntegerTypes1 in the form of ( itk::Concept::IsInteger< TReturn > )

This class requires OnlyDefinedForIntegerTypes2 in the form of ( itk::Concept::IsInteger< TInput > )

Definition at line 180 of file itkMath.h.

References itk::NumericTraits< T >::IsPositive(), and itkConceptMacro.

template<TReturn , typename TInput >
itk::Math::Ceil ( TInput  x)

Round towards plus infinity.

The behavior of overflow is undefined due to numerous implementations.

Warning
argument absolute value must be less than INT_MAX/2 for vnl_math_ceil to be guaranteed to work.
We also assume that the rounding mode is not changed from the default one (or at least that it is always restored to the default one).
template<typename T >
bool itk::Math::FloatAlmostEqual ( x1,
x2,
typename Detail::FloatIEEE< T >::IntType  maxUlps = 4,
typename Detail::FloatIEEE< T >::FloatType  maxAbsoluteDifference = 0.1*NumericTraits<T>::epsilon() 
)
inline

Compare two floats and return if they are effectively equal.

Determining when floats are almost equal is difficult because of their IEEE bit representation. This function uses the integer representation of the float to determine if they are almost equal.

The implementation is based off the explanation in the white papers:

This function is not a cure-all, and reading those articles is important to understand its appropriate use in the context of ULPs, zeros, subnormals, infinities, and NANs. For example, it is preferable to use this function on two floats directly instead of subtracting them and comparing them to zero.

The tolerance is specified in ULPs (units in the last place), i.e. how many floats there are in between the numbers. Therefore, the tolerance depends on the magnitude of the values that are being compared. A second tolerance is a maximum difference allowed, which is important when comparing numbers close to zero.

A NAN compares as not equal to a number, but two NAN's may compare as equal to each other.

Parameters
x1first floating value to compare
x2second floating values to compare
maxUlpsmaximum units in the last place to be considered equal
maxAbsoluteDifferencemaximum absolute difference to be considered equal

Definition at line 259 of file itkMath.h.

References FloatDifferenceULP().

template<typename T >
Detail::FloatIEEE<T>::IntType itk::Math::FloatDifferenceULP ( x1,
x2 
)
inline

Return the signed distance in ULPs (units in the last place) between two floats.

This is the signed distance, i.e., if x1 > x2, then the result is positive.

See Also
FloatAlmostEqual

Definition at line 220 of file itkMath.h.

References itk::Math::Detail::FloatIEEE< T >::AsULP().

Referenced by FloatAlmostEqual().

template<TReturn , typename TInput >
itk::Math::Floor ( TInput  x)

Round towards minus infinity.

The behavior of overflow is undefined due to numerous implementations.

Warning
argument absolute value must be less than NumbericTraits<TReturn>::max()/2 for vnl_math_floor to be guaranteed to work.
We also assume that the rounding mode is not changed from the default one (or at least that it is always restored to the default one).
ITKCommon_EXPORT unsigned short itk::Math::GreatestPrimeFactor ( unsigned short  n)

Return the greatest factor of the decomposition in prime numbers

ITKCommon_EXPORT unsigned int itk::Math::GreatestPrimeFactor ( unsigned int  n)

Return the greatest factor of the decomposition in prime numbers

ITKCommon_EXPORT unsigned long itk::Math::GreatestPrimeFactor ( unsigned long  n)

Return the greatest factor of the decomposition in prime numbers

ITKCommon_EXPORT unsigned long long itk::Math::GreatestPrimeFactor ( unsigned long long  n)

Return the greatest factor of the decomposition in prime numbers

ITKCommon_EXPORT bool itk::Math::IsPrime ( unsigned short  n)

Return whether the number in a prime number or not.

Note
Negative numbers can not be prime.
ITKCommon_EXPORT bool itk::Math::IsPrime ( unsigned int  n)

Return whether the number in a prime number or not.

Note
Negative numbers can not be prime.
ITKCommon_EXPORT bool itk::Math::IsPrime ( unsigned long  n)

Return whether the number in a prime number or not.

Note
Negative numbers can not be prime.
ITKCommon_EXPORT bool itk::Math::IsPrime ( unsigned long long  n)

Return whether the number in a prime number or not.

Note
Negative numbers can not be prime.
template<typename TReturn , typename TInput >
TReturn itk::Math::Round ( TInput  x)
inline

Round towards nearest integer (This is a synonym for RoundHalfIntegerUp)

Template Parameters
TReturnmust be an integer type
TInputmust be float or double
See Also
RoundHalfIntegerUp<TReturn, TInput>()

Definition at line 149 of file itkMath.h.

template<TReturn , typename TInput >
itk::Math::RoundHalfIntegerToEven ( TInput  x)

Round towards nearest integer.

Template Parameters
TReturnmust be an integer type
TInputmust be float or double
    halfway cases are rounded towards the nearest even
    integer, e.g.
*

The behavior of overflow is undefined due to numerous implementations.

Warning
We assume that the rounding mode is not changed from the default one (or at least that it is always restored to the default one).
template<TReturn , typename TInput >
itk::Math::RoundHalfIntegerUp ( TInput  x)

Round towards nearest integer.

Template Parameters
TReturnmust be an integer type
TInputmust be float or double
    halfway cases are rounded upward, e.g.
* RoundHalfIntegerUp( 1.5) == 2
* RoundHalfIntegerUp(-1.5) == -1
* RoundHalfIntegerUp( 2.5) == 3
*

The behavior of overflow is undefined due to numerous implementations.

Warning
The argument absolute value must be less than NumbericTraits<TReturn>::max()/2 for RoundHalfIntegerUp to be guaranteed to work.
We also assume that the rounding mode is not changed from the default one (or at least that it is always restored to the default one).

Variable Documentation

const double itk::Math::e = 2.7182818284590452354
static

\[e\]

The base of the natural logarithm or Euler's number

Examples:
Examples/Filtering/CompositeFilterExample.cxx, Examples/IO/DicomImageReadChangeHeaderWrite.cxx, Examples/IO/DicomImageReadWrite.cxx, Examples/IO/IOPlugin.cxx, Examples/IO/XML/itkParticleSwarmOptimizerDOMReader.cxx, Examples/IO/XML/itkParticleSwarmOptimizerSAXReader.cxx, Examples/IO/XML/itkParticleSwarmOptimizerSAXWriter.cxx, Examples/RegistrationITKv3/DeformableRegistration1.cxx, Examples/RegistrationITKv3/DeformableRegistration10.cxx, Examples/RegistrationITKv3/DeformableRegistration11.cxx, Examples/RegistrationITKv3/DeformableRegistration12.cxx, Examples/RegistrationITKv3/DeformableRegistration7.cxx, Examples/RegistrationITKv3/DeformableRegistration8.cxx, Examples/RegistrationITKv3/DeformableRegistration9.cxx, Examples/RegistrationITKv3/ImageRegistration11.cxx, Examples/RegistrationITKv3/ImageRegistration14.cxx, Examples/RegistrationITKv3/ImageRegistration15.cxx, Examples/RegistrationITKv3/ImageRegistration18.cxx, Examples/RegistrationITKv3/ImageRegistration19.cxx, Examples/RegistrationITKv3/IterativeClosestPoint1.cxx, Examples/RegistrationITKv3/IterativeClosestPoint2.cxx, Examples/RegistrationITKv3/IterativeClosestPoint3.cxx, Examples/RegistrationITKv4/DeformableRegistration1.cxx, Examples/RegistrationITKv4/DeformableRegistration10.cxx, Examples/RegistrationITKv4/DeformableRegistration11.cxx, Examples/RegistrationITKv4/DeformableRegistration12.cxx, Examples/RegistrationITKv4/DeformableRegistration4.cxx, Examples/RegistrationITKv4/DeformableRegistration7.cxx, Examples/RegistrationITKv4/DeformableRegistration8.cxx, Examples/RegistrationITKv4/DeformableRegistration9.cxx, Examples/RegistrationITKv4/ImageRegistration11.cxx, Examples/RegistrationITKv4/ImageRegistration14.cxx, Examples/RegistrationITKv4/ImageRegistration15.cxx, Examples/RegistrationITKv4/ImageRegistration18.cxx, Examples/RegistrationITKv4/ImageRegistration19.cxx, Examples/RegistrationITKv4/IterativeClosestPoint1.cxx, Examples/RegistrationITKv4/IterativeClosestPoint2.cxx, Examples/RegistrationITKv4/IterativeClosestPoint3.cxx, Examples/RegistrationITKv4/MultiStageImageRegistration1.cxx, Examples/RegistrationITKv4/MultiStageImageRegistration2.cxx, Examples/Segmentation/GeodesicActiveContourShapePriorLevelSetImageFilter.cxx, Examples/Segmentation/WatershedSegmentation1.cxx, Examples/Statistics/ScalarImageMarkovRandomField1.cxx, SphinxExamples/src/Core/QuadEdgeMesh/CutMesh/Code.cxx, SphinxExamples/src/Core/QuadEdgeMesh/ExtractVertexOnMeshBoundaries/Code.cxx, SphinxExamples/src/Core/QuadEdgeMesh/GetListOfFacesAroundAGivenVertex/Code.cxx, SphinxExamples/src/Core/QuadEdgeMesh/PrintVertexNeighbors/Code.cxx, SphinxExamples/src/Filtering/BinaryMathematicalMorphology/ErodeABinaryImage/Code.cxx, SphinxExamples/src/Filtering/ImageFeature/DetectEdgesWithCannyFilter/Code.cxx, SphinxExamples/src/Filtering/ImageFeature/LaplacianRecursiveGaussianImageFilter/Code.cxx, SphinxExamples/src/Filtering/ImageFilterBase/CastAnImageToAnotherType/Code.cxx, SphinxExamples/src/Filtering/ImageGrid/Create3DVolume/Code.cxx, SphinxExamples/src/Filtering/MathematicalMorphology/ErodeAGrayscaleImage/Code.cxx, SphinxExamples/src/Filtering/Thresholding/ThresholdAnImageUsingBinary/Code.cxx, SphinxExamples/src/Filtering/Thresholding/ThresholdAnImageUsingOtsu/Code.cxx, SphinxExamples/src/ImageCompareCommand.cxx, and SphinxExamples/src/IO/ImageBase/ReadUnknownImageType/Code.cxx.

Definition at line 45 of file itkMath.h.

Referenced by itk::TreeChangeEvent< TTreeType >::CheckEvent(), itk::TreeNodeChangeEvent< TTreeType >::CheckEvent(), itk::ProgressReporter::CompletedPixel(), ComputeHash(), itk::DiscretePrincipalCurvaturesQuadEdgeMeshFilter< TInputMesh, TOutputMesh >::ComputeMeanAndGaussianCurvatures(), itk::Concept::AdditiveOperators< T1, T2, T3 >::Constraints::const_constraints(), itk::Concept::MultiplyOperator< T1, T2, T3 >::Constraints::const_constraints(), itk::Concept::DivisionOperators< T1, T2, T3 >::Constraints::const_constraints(), itk::Concept::BitwiseOperators< T1, T2, T3 >::Constraints::const_constraints(), itk::Concept::BracketOperator< T1, T2, T3 >::Constraints::const_constraints(), itk::Functor::DivideOrZeroOut< TInputImage1::PixelType, TInputImage2::PixelType, TOutputImage::PixelType >::DivideOrZeroOut(), itk::Versor< TParametersValueType >::Epsilon(), itk::DiscreteMeanCurvatureQuadEdgeMeshFilter< TInputMesh, TOutputMesh >::EstimateCurvature(), HashTestImage(), itk::ConstNeighborhoodIterator< TSparseImageType >::IsAtEnd(), itk::Functor::Sigmoid< TInputImage::PixelType, TOutputImage::PixelType >::operator()(), itk::operator<<(), RegressionTestImage(), itk::fem::LoadLandmark::SetContainedElement(), itk::fem::ImageMetricLoad< TMoving, TFixed >::SetCurrentEnergy(), itk::fem::FEMRegistrationFilter< TMovingImage, TFixedImage, TFemObjectType >::SetElement(), itk::GPUPDEDeformableRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >::SetEnergy(), itk::PDEDeformableRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >::SetEnergy(), itk::LevelSetFunction< TImageType >::SetEpsilonMagnitude(), itk::PDEDeformableRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >::SetGradientStep(), itk::GPUPDEDeformableRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >::SetGradientStep(), itk::PDEDeformableRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >::SetNormalizeGradient(), and itk::GPUPDEDeformableRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >::SetNormalizeGradient().

const double itk::Math::ln10 = 2.30258509299404568402
static

\[ \log_e 10 \]

Definition at line 53 of file itkMath.h.

const double itk::Math::ln2 = 0.69314718055994530942
static

\[ \log_e 2 \]

Definition at line 51 of file itkMath.h.

const double itk::Math::log10e = 0.43429448190325182765
static

\[ \log_{10} e \]

Definition at line 49 of file itkMath.h.

const double itk::Math::log2e = 1.4426950408889634074
static

\[ \log_2 e \]

Definition at line 47 of file itkMath.h.

const double itk::Math::one_over_pi = 0.31830988618379067154
static

\[ \frac{1}{\pi} \]

Definition at line 61 of file itkMath.h.

const double itk::Math::one_over_sqrt2pi = 0.39894228040143267794
static

\[ \frac{2}{\sqrt{2\pi}} \]

Definition at line 67 of file itkMath.h.

const double itk::Math::pi = 3.14159265358979323846
static

\[ \pi \]

Examples:
Examples/DataRepresentation/Mesh/PointSetWithVectors.cxx, Examples/DataRepresentation/Mesh/RGBPointSet.cxx, Examples/Filtering/SpatialObjectToImage1.cxx, Examples/Filtering/SpatialObjectToImage2.cxx, Examples/Filtering/SpatialObjectToImage3.cxx, Examples/RegistrationITKv3/ChangeInformationImageFilter.cxx, Examples/RegistrationITKv3/ImageRegistration13.cxx, Examples/RegistrationITKv3/ImageRegistration14.cxx, Examples/RegistrationITKv3/ImageRegistration5.cxx, Examples/RegistrationITKv3/ImageRegistration6.cxx, Examples/RegistrationITKv3/ImageRegistration7.cxx, Examples/RegistrationITKv3/ImageRegistration9.cxx, Examples/RegistrationITKv4/ChangeInformationImageFilter.cxx, Examples/RegistrationITKv4/ImageRegistration13.cxx, Examples/RegistrationITKv4/ImageRegistration14.cxx, Examples/RegistrationITKv4/ImageRegistration5.cxx, Examples/RegistrationITKv4/ImageRegistration6.cxx, Examples/RegistrationITKv4/ImageRegistration7.cxx, Examples/RegistrationITKv4/ImageRegistration9.cxx, Examples/Segmentation/HoughTransform2DCirclesImageFilter.cxx, SphinxExamples/src/Filtering/ImageGrid/ChangeImageOriginSpacingOrDirection/Code.cxx, WikiExamples/ImageProcessing/UnaryFunctorImageFilter.cxx, WikiExamples/ImageSegmentation/ExtractContourWithSnakes.cxx, WikiExamples/Math/Pi.cxx, WikiExamples/Morphology/FlatStructuringElementRadiusIsParametric.cxx, and WikiExamples/Statistics/TextureFeatures.cxx.

Definition at line 55 of file itkMath.h.

Referenced by itk::DiscretePrincipalCurvaturesQuadEdgeMeshFilter< TInputMesh, TOutputMesh >::ComputeMeanAndGaussianCurvatures(), itk::DelaunayConformingQuadEdgeMeshFilter< TInputMesh, TOutputMesh >::Dyer07Criterion(), itk::DiscreteGaussianCurvatureQuadEdgeMeshFilter< TInputMesh, TOutputMesh >::EstimateCurvature(), itk::GaborKernelFunction< TRealValueType >::Evaluate(), itk::Statistics::MersenneTwisterRandomVariateGenerator::GetNormalVariate(), itk::PhasedArray3DSpecialCoordinatesImage< TPixel >::PhasedArray3DSpecialCoordinatesImage(), itk::WindowedSincInterpolateImageFunction< TInputImage, VRadius, TWindowFunction, TBoundaryCondition, TCoordRep >::Sinc(), and itk::STLMeshIO::WritePointsTyped().

const double itk::Math::pi_over_2 = 1.57079632679489661923
static

\[ \frac{\pi}{2} \]

Definition at line 57 of file itkMath.h.

const double itk::Math::pi_over_4 = 0.78539816339744830962
static

\[ \frac{\pi}{4} \]

Definition at line 59 of file itkMath.h.

const double itk::Math::sqrt1_2 = 0.70710678118654752440
static

\[ \sqrt{ \frac{1}{2}} \]

Definition at line 71 of file itkMath.h.

const double itk::Math::sqrt2 = 1.41421356237309504880
static

\[ \sqrt{2} \]

Definition at line 69 of file itkMath.h.

const double itk::Math::two_over_pi = 0.63661977236758134308
static

\[ \frac{2}{\pi} \]

Definition at line 63 of file itkMath.h.

const double itk::Math::two_over_sqrtpi = 1.12837916709551257390
static

\[ \frac{2}{\sqrt{\pi}} \]

Definition at line 65 of file itkMath.h.