ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itk::Math Namespace Reference

Namespaces

namespace  Detail
 
namespace  detail
 

Classes

struct  FixedSquareSVDResult
 
struct  SVDResult
 

Functions

template<typename T>
auto Absolute (const std::complex< T > &x) noexcept
 
template<typename T>
constexpr auto Absolute (T x) noexcept
 
template<typename T1, typename T2>
bool AlmostEquals (T1 x1, T2 x2)
 
double angle_0_to_2pi (double angle)
 
double angle_minuspi_to_pi (double angle)
 
TInput TInput auto CastWithRangeCheck (TInput x)
 
TInput Ceil (TInput x) template< typename TReturn
 
int ceil (double x)
 
int ceil (float x)
 
template<typename T>
vnl_matrix< T > CholeskyLowerTriangle (const vnl_matrix< T > &A)
 
constexpr bool cube (bool x)
 
template<typename T, std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
constexpr T cube (T x)
 
template<typename TInput1, typename TInput2>
constexpr bool ExactlyEquals (const TInput1 &x1, const TInput2 &x2)
 
template<typename T>
constexpr T FloatAddULP (T x, typename Detail::FloatIEEE< T >::IntType ulps)
 
template<typename T>
bool FloatAlmostEqual (T x1, T x2, typename Detail::FloatIEEE< T >::IntType maxUlps=4, typename Detail::FloatIEEE< T >::FloatType maxAbsoluteDifference=0.1 *itk::NumericTraits< T >::epsilon())
 
template<typename T>
constexpr Detail::FloatIEEE< T >::IntType FloatDifferenceULP (T x1, T x2)
 
template<TReturn, typename TInput>
 Floor (TInput x) template< TReturn
 
int floor (double x)
 
int floor (float x)
 
template<typename TReal>
TReal IncompleteGammaP (TReal a, TReal x)
 
template<typename T, unsigned int VRows, unsigned int VColumns>
Matrix< T, VRows, VColumns > MatrixExponential (const Matrix< T, VRows, VColumns > &A)
 
template<typename T>
vnl_matrix< T > MatrixExponential (const vnl_matrix< T > &A)
 
template<typename T, unsigned int VRows, unsigned int VColumns>
vnl_matrix_fixed< T, VRows, VColumns > MatrixExponential (const vnl_matrix_fixed< T, VRows, VColumns > &A)
 
template<typename T1, typename T2>
bool NotAlmostEquals (T1 x1, T2 x2)
 
template<typename TInput1, typename TInput2>
constexpr bool NotExactlyEquals (const TInput1 &x1, const TInput2 &x2)
 
template<typename TReal>
TReal RegularizedIncompleteBeta (TReal a, TReal b, TReal x)
 
double remainder_floored (double x, double y)
 
float remainder_floored (float x, float y)
 
long double remainder_floored (long double x, long double y)
 
template<typename T, std::enable_if_t< std::is_integral_v< T > &&std::is_signed_v< T >, int > = 0>
constexpr T remainder_floored (T x, T y)
 
double remainder_truncated (double x, double y)
 
float remainder_truncated (float x, float y)
 
long double remainder_truncated (long double x, long double y)
 
template<typename T, std::enable_if_t< std::is_integral_v< T >, int > = 0>
constexpr T remainder_truncated (T x, T y)
 
int rnd (double x)
 
int rnd (float x)
 
int rnd_halfinttoeven (double x)
 
int rnd_halfinttoeven (float x)
 
int rnd_halfintup (double x)
 
int rnd_halfintup (float x)
 
TInput TInput constexpr auto Round (TInput x)
 
template<TReturn, typename TInput>
 RoundHalfIntegerToEven (TInput x) template< TReturn
 
TInput RoundHalfIntegerUp (TInput x) template< typename TReturn
 
template<typename T, std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
constexpr int sgn (T x)
 
template<typename T, std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
constexpr int sgn0 (T x)
 
template<typename T>
vnl_vector< T > SolveSymmetricPositiveDefinite (const vnl_matrix< T > &A, const vnl_vector< T > &b)
 
constexpr bool sqr (bool x)
 
template<typename T, std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
constexpr T sqr (T x)
 
constexpr unsigned int squared_magnitude (char x)
 
constexpr double squared_magnitude (double x)
 
constexpr float squared_magnitude (float x)
 
constexpr unsigned int squared_magnitude (int x)
 
constexpr long double squared_magnitude (long double x)
 
constexpr unsigned long long squared_magnitude (long long x)
 
constexpr unsigned long squared_magnitude (long x)
 
constexpr unsigned int squared_magnitude (unsigned char x)
 
constexpr unsigned int squared_magnitude (unsigned int x)
 
constexpr unsigned long long squared_magnitude (unsigned long long x)
 
constexpr unsigned long squared_magnitude (unsigned long x)
 
template<typename TReal, unsigned int VDim>
FixedSquareSVDResult< TReal, VDim > SVD (const Matrix< TReal, VDim, VDim > &A, bool canonicalizeSigns=true)
 
template<typename TReal>
SVDResult< TReal > SVD (const vnl_matrix< TReal > &A, bool canonicalizeSigns=true)
 
template<typename TReal, unsigned int VDim>
FixedSquareSVDResult< TReal, VDim > SVD (const vnl_matrix_fixed< TReal, VDim, VDim > &A, bool canonicalizeSigns=true)
 
template<typename TReturnType = uintmax_t>
constexpr auto UnsignedPower (const uintmax_t base, const uintmax_t exponent) noexcept -> TReturnType
 
template<typename TReturnType = uintmax_t>
constexpr auto UnsignedProduct (const uintmax_t a, const uintmax_t b) noexcept
 
template<typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
constexpr bool IsPrime (T n)
 
template<typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
constexpr T GreatestPrimeFactor (T n)
 

Variables

constexpr double deg_per_rad = 57.2957795130823208768
 
constexpr double e = 2.71828182845904523536
 
constexpr double eps = std::numeric_limits<double>::epsilon()
 
constexpr double euler = 0.57721566490153286061
 
constexpr float float_eps = std::numeric_limits<float>::epsilon()
 
constexpr float float_sqrteps = 3.4526698300e-4F
 
constexpr double ln10 = 2.30258509299404568402
 
constexpr double ln2 = 0.69314718055994530942
 
constexpr double log10e = 0.43429448190325182765
 
constexpr double log2e = 1.44269504088896340736
 
constexpr double one_over_pi = 0.31830988618379067154
 
constexpr double one_over_sqrt2pi = 0.39894228040143267794
 
constexpr double pi = 3.14159265358979323846
 
constexpr double pi_over_180 = 0.01745329251994329577
 
constexpr double pi_over_2 = 1.57079632679489661923
 
constexpr double pi_over_4 = 0.78539816339744830962
 
constexpr double sqrt1_2 = 0.70710678118654752440
 
constexpr double sqrt1_3 = 0.57735026918962576451
 
constexpr double sqrt2 = 1.41421356237309504880
 
constexpr double sqrt2pi = 2.50662827463100050242
 
constexpr double sqrteps = 0x1p-26
 
constexpr double two_over_pi = 0.63661977236758134308
 
constexpr double two_over_sqrtpi = 1.12837916709551257390
 
constexpr double twopi = 6.28318530717958647693
 

Function Documentation

◆ Absolute() [1/2]

template<typename T>
auto itk::Math::Absolute ( const std::complex< T > & x)
noexcept

Definition at line 1176 of file itkMath.h.

◆ Absolute() [2/2]

template<typename T>
auto itk::Math::Absolute ( T x)
constexprnoexcept

Returns the absolute value of a number.

This function provides a c++17 implementation of the vnl_math::abs absolute value functionality. Math::Absolute() preserves backward compatibility with vnl_math::abs that was originally used in ITK.

Key differences between Math::Absolute() and std::abs():

  • Where std::abs(x) returns the absolute value in the same type as the input, Math::Absolute(x) returns the absolute value in the unsigned equivalent of the input type, when the input is an integer.
  • std::abs(x) has undefined or compiler specific behavior when its argument is the minimum value of int, long, or long long. On the other hand, Math::Absolute does support the entire range of possible integer values. So for example Math::Absolute(INT_MIN) properly returns 2147483648 as unsigned integer (assuming that INT_MIN has the value -2147483648).
  • Unlike std::abs, Math::Absolute does support bool. For a bool argument, Math::Absolute(x) simply returns the value of the argument.
Template Parameters
TThe type of the input number.
Parameters
xThe input number.
Returns
The absolute value of the input number as an unsigned type for integer types.

Definition at line 1134 of file itkMath.h.

References ExactlyEquals().

Referenced by itk::ScanlineFilterCommon< TInputImage, TOutputImage >::CheckNeighbors(), itk::SimplexMeshAdaptTopologyFilter< TInputMesh, TOutputMesh >::SimplexCellVisitor::ComputeArea(), itk::Function::AdaptiveEqualizationHistogram< TInputPixel, TOutputPixel >::CumulativeFunction(), itk::BSplineKernelFunction< 0 >::Evaluate(), itk::BSplineKernelFunction< 0 >::Evaluate(), itk::BSplineKernelFunction< 0 >::Evaluate(), itk::BSplineKernelFunction< 0 >::Evaluate(), itk::Function::Max3(), itk::Functor::Abs< typename TInputImage::PixelType, typename TOutputImage::PixelType >::operator()(), itk::Functor::InverseDeconvolutionFunctor< TInput1, TInput2, TOutput >::operator()(), itk::Functor::SimilarPixelsFunctor< TInput >::operator()(), itk::Functor::SimilarVectorsFunctor< TInput >::operator()(), itk::Functor::WienerDeconvolutionFunctor< TPixel >::operator()(), itk::HessianToObjectnessMeasureImageFilter< TInputImage, TOutputImage >::AbsLessCompare::operator()(), itk::detail::sortEigenValuesByMagnitude(), and itk::SimplexMeshAdaptTopologyFilter< TInputMesh, TOutputMesh >::SimplexCellVisitor::Visit().

◆ AlmostEquals()

template<typename T1, typename T2>
bool itk::Math::AlmostEquals ( T1 x1,
T2 x2 )
inline

Provide consistent equality checks between values of potentially different scalar or complex types.

template< typename T1, typename T2 > AlmostEquals( T1 x1, T2 x2 )

template< typename T1, typename T2 > NotAlmostEquals( T1 x1, T2 x2 )

This function compares two scalar or complex values of potentially different types. For maximum extensibility the function is implemented through a series of templated structs which direct the AlmostEquals() call to the correct function by evaluating the parameter's types.

Overall algorithm: If both values are complex... separate values into real and imaginary components and compare them separately

If one of the values is complex.. see if the imaginary part of the complex value is approximately 0 ... compare real part of complex value with scalar value

If both values are scalars...

To compare two floating point types... use FloatAlmostEqual.

To compare a floating point and an integer type... Use static_cast<FloatingPointType>(integerValue) and call FloatAlmostEqual

To compare signed and unsigned integers... Check for negative value or overflow, then cast and use ==

To compare two signed or two unsigned integers ... Use ==

To compare anything else ... Use ==

Parameters
x1first scalar value to compare
x2second scalar value to compare

Definition at line 705 of file itkMath.h.

Referenced by itk::GTest::Predicate::CheckMetaDataPredFormat(), itk::AnchorErodeDilateLine< InputImagePixelType, TFunction1 >::Compare(), NotAlmostEquals(), and itk::DivideImageFilter< InputImageType, itk::Image< InputPixelRealValueType, ImageDimension >, OutputImageType >::VerifyPreconditions().

◆ angle_0_to_2pi()

double itk::Math::angle_0_to_2pi ( double angle)
inline

Normalize an angle (radians) into [0, 2*pi).

Definition at line 1089 of file itkMath.h.

References twopi.

◆ angle_minuspi_to_pi()

double itk::Math::angle_minuspi_to_pi ( double angle)
inline

Normalize an angle (radians) into (-pi, pi].

Definition at line 1101 of file itkMath.h.

References pi, and twopi.

◆ CastWithRangeCheck()

TInput TInput auto itk::Math::CastWithRangeCheck ( TInput x)
inline

◆ Ceil()

TInput itk::Math::Ceil ( TInput x)

References Ceil(), and itkTemplateFloatingToIntegerMacro.

Referenced by Ceil().

◆ ceil() [1/2]

int itk::Math::ceil ( double x)
inline

Definition at line 1082 of file itkMath.h.

◆ ceil() [2/2]

int itk::Math::ceil ( float x)
inline

Round toward plus infinity.

Definition at line 1077 of file itkMath.h.

◆ CholeskyLowerTriangle()

template<typename T>
vnl_matrix< T > itk::Math::CholeskyLowerTriangle ( const vnl_matrix< T > & A)

Lower-triangular Cholesky factor L of A = L L^T (A symmetric pos. def.), via Eigen LLT. Mirrors vnl_cholesky::lower_triangle().

Definition at line 70 of file itkCholeskySolve.h.

◆ cube() [1/2]

bool itk::Math::cube ( bool x)
constexpr

Cube of a value.

Definition at line 900 of file itkMath.h.

◆ cube() [2/2]

template<typename T, std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
T itk::Math::cube ( T x)
constexpr

Definition at line 906 of file itkMath.h.

◆ ExactlyEquals()

template<typename TInput1, typename TInput2>
bool itk::Math::ExactlyEquals ( const TInput1 & x1,
const TInput2 & x2 )
inlineconstexpr

Return the result of an exact comparison between two scalar values of potentially different types.

template <typename TInput1, typename TInput2> inline bool ExactlyEquals( const TInput & x1, const TInput & x2 )

template <typename TInput1, typename TInput2> inline bool NotExactlyEquals( const TInput & x1, const TInput & x2 )

These functions complement the EqualsComparison functions and determine if two scalar values are exactly equal using the compilers casting rules when comparing two different types. While this is also easily accomplished by using the equality operators, use of this function demonstrates the intent of an exact equality check and thus improves readability and clarity of code. In addition, this function suppresses float-equal warnings produced when using Clang.

Parameters
x1first floating point value to compare
x2second floating point value to compare

Definition at line 743 of file itkMath.h.

Referenced by Absolute(), itk::BSplineDerivativeKernelFunction< 3, PDFValueType >::Evaluate(), itk::BSplineKernelFunction< 0 >::Evaluate(), NotExactlyEquals(), itk::Functor::Equal< TInput1, TInput2, TOutput >::operator()(), itk::Functor::BinaryThreshold< TInput, TOutput >::operator==(), itk::Functor::ExpNegative< TInput, TOutput >::operator==(), itk::Functor::IntensityLinearTransform< TInput, TOutput >::operator==(), itk::Functor::IntensityWindowingTransform< TInput, TOutput >::operator==(), itk::Functor::LabelOverlayFunctor< typename TInputImage::PixelType, typename TLabelImage::PixelType, typename TOutputImage::PixelType >::operator==(), itk::Functor::Sigmoid< TInput, TOutput >::operator==(), itk::Functor::VectorMagnitudeLinearTransform< TInput, TOutput >::operator==(), itk::Functor::WeightedAdd2< TInput1, TInput2, TOutput >::operator==(), itk::KLMDynamicBorderArray< BorderType >::operator>(), itk::LaplacianSegmentationLevelSetFunction< OutputImageType, FeatureImageType >::SetAdvectionWeight(), itk::SigmoidImageFilter< TInputImage, TOutputImage >::SetAlpha(), itk::SigmoidImageFilter< TInputImage, TOutputImage >::SetBeta(), itk::FastMarchingImageFilter< TLevelSet, TSpeedImage >::SetBinaryMask(), itk::SigmoidImageFilter< TInputImage, TOutputImage >::SetOutputMaximum(), itk::SigmoidImageFilter< TInputImage, TOutputImage >::SetOutputMinimum(), and itk::ShapeUniqueLabelMapFilter< TImage >::TemplatedGenerateData().

◆ FloatAddULP()

template<typename T>
T itk::Math::FloatAddULP ( T x,
typename Detail::FloatIEEE< T >::IntType ulps )
inlineconstexpr

Add the given ULPs (units in the last place) to a float.

If the given ULPs can are negative, they are subtracted.

See also
FloatAlmostEqual
FloatDifferenceULP

Definition at line 292 of file itkMath.h.

References itk::Math::Detail::FloatIEEE< T >::asFloat, and itk::Math::Detail::FloatIEEE< T >::asInt.

◆ FloatAlmostEqual()

template<typename T>
bool itk::Math::FloatAlmostEqual ( T x1,
T x2,
typename Detail::FloatIEEE< T >::IntType maxUlps = 4,
typename Detail::FloatIEEE< T >::FloatType maxAbsoluteDifference = 0.1 * itk::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 value to compare
maxUlpsmaximum units in the last place to be considered equal
maxAbsoluteDifferencemaximum absolute difference to be considered equal

Definition at line 331 of file itkMath.h.

References FloatDifferenceULP().

Referenced by itk::Math::Detail::AlmostEqualsFloatVsFloat::AlmostEqualsFunction(), itk::Math::Detail::AlmostEqualsFloatVsFloat::AlmostEqualsFunction(), itk::Math::Detail::AlmostEqualsFloatVsFloat::AlmostEqualsFunction(), itk::Math::Detail::AlmostEqualsFloatVsFloat::AlmostEqualsFunction(), itk::Math::Detail::AlmostEqualsFloatVsFloat::AlmostEqualsFunction(), and itk::Math::Detail::AlmostEqualsFloatVsInteger::AlmostEqualsFunction().

◆ FloatDifferenceULP()

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

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
FloatAddULP

Definition at line 276 of file itkMath.h.

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

Referenced by FloatAlmostEqual().

◆ Floor()

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).

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).

References Floor().

Referenced by itk::LinearInterpolateImageFunction< InputImageType, CoordinateType >::EvaluateOptimized(), itk::LinearInterpolateImageFunction< InputImageType, CoordinateType >::EvaluateOptimized(), itk::LinearInterpolateImageFunction< InputImageType, CoordinateType >::EvaluateOptimized(), and Floor().

◆ floor() [1/2]

int itk::Math::floor ( double x)
inline

Definition at line 1070 of file itkMath.h.

◆ floor() [2/2]

int itk::Math::floor ( float x)
inline

Round toward minus infinity.

Definition at line 1065 of file itkMath.h.

◆ GreatestPrimeFactor()

template<typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
T itk::Math::GreatestPrimeFactor ( T n)
constexpr

Return the greatest factor of the decomposition in prime numbers.

Definition at line 800 of file itkMath.h.

References IsPrime().

◆ IncompleteGammaP()

template<typename TReal>
TReal itk::Math::IncompleteGammaP ( TReal a,
TReal x )

Regularized lower incomplete gamma P(a, x) = γ(a, x) / Γ(a).

Definition at line 33 of file itkSpecialFunctions.h.

◆ IsPrime()

template<typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
bool itk::Math::IsPrime ( T n)
constexpr

Return whether the number is a prime number or not.

Note
Negative numbers cannot be prime.

Definition at line 767 of file itkMath.h.

Referenced by GreatestPrimeFactor().

◆ MatrixExponential() [1/3]

template<typename T, unsigned int VRows, unsigned int VColumns>
Matrix< T, VRows, VColumns > itk::Math::MatrixExponential ( const Matrix< T, VRows, VColumns > & A)

◆ MatrixExponential() [2/3]

template<typename T>
vnl_matrix< T > itk::Math::MatrixExponential ( const vnl_matrix< T > & A)

Matrix exponential of a dynamically-sized vnl_matrix (must be square).

Definition at line 89 of file itkMatrixExponential.h.

References itk::Math::detail::MatrixExponentialEigen().

◆ MatrixExponential() [3/3]

template<typename T, unsigned int VRows, unsigned int VColumns>
vnl_matrix_fixed< T, VRows, VColumns > itk::Math::MatrixExponential ( const vnl_matrix_fixed< T, VRows, VColumns > & A)

Matrix exponential of a vnl_matrix_fixed (square).

Definition at line 78 of file itkMatrixExponential.h.

References itk::Math::detail::MatrixExponentialEigen().

◆ NotAlmostEquals()

◆ NotExactlyEquals()

template<typename TInput1, typename TInput2>
bool itk::Math::NotExactlyEquals ( const TInput1 & x1,
const TInput2 & x2 )
inlineconstexpr

Definition at line 754 of file itkMath.h.

References ExactlyEquals().

Referenced by itk::Functor::NotEqual< TInput1, TInput2, TOutput >::operator()(), itk::Matrix< VComponent, VRows, VCols >::operator==(), itk::VariableSizeMatrix< T >::operator==(), itk::NarrowBandLevelSetImageFilter< TInputImage, TFeatureImage, TOutputPixelType, Image< TOutputPixelType, TInputImage::ImageDimension > >::SetAdvectionScaling(), itk::SegmentationLevelSetImageFilter< TInputImage, TFeatureImage, TOutputPixelType >::SetAdvectionScaling(), itk::GaussianInterpolateImageFunction< TInputImage, TCoordinate >::SetAlpha(), itk::NotImageFilter< TInputImage, TOutputImage >::SetBackgroundValue(), itk::ConstantPadImageFilter< TInputImage, TOutputImage >::SetConstant(), itk::DivideOrZeroOutImageFilter< InternalImageType >::SetConstant(), itk::NarrowBandLevelSetImageFilter< TInputImage, TFeatureImage, TOutputPixelType, Image< TOutputPixelType, TInputImage::ImageDimension > >::SetCurvatureScaling(), itk::SegmentationLevelSetImageFilter< TInputImage, TFeatureImage, TOutputPixelType >::SetCurvatureScaling(), itk::GeodesicActiveContourLevelSetImageFilter< TInputImage, TFeatureImage, TOutputPixelType >::SetDerivativeSigma(), itk::SegmentationLevelSetImageFilter< TInputImage, TFeatureImage, TOutputPixelType >::SetFeatureScaling(), itk::NotImageFilter< TInputImage, TOutputImage >::SetForegroundValue(), itk::CannyEdgeDetectionImageFilter< TInputImage, TOutputImage >::SetMaximumError(), itk::MaskImageFilter< TInputImage, TMaskImage, TOutputImage >::SetOutsideValue(), itk::MaskNegatedImageFilter< TInputImage, TMaskImage, TOutputImage >::SetOutsideValue(), itk::NarrowBandLevelSetImageFilter< TInputImage, TFeatureImage, TOutputPixelType, Image< TOutputPixelType, TInputImage::ImageDimension > >::SetPropagationScaling(), itk::SegmentationLevelSetImageFilter< TInputImage, TFeatureImage, TOutputPixelType >::SetPropagationScaling(), itk::ShapePriorSegmentationLevelSetImageFilter< TInputImage, TFeatureImage, TOutputPixelType >::SetShapePriorScaling(), itk::DivideOrZeroOutImageFilter< InternalImageType >::SetThreshold(), itk::CannyEdgeDetectionImageFilter< TInputImage, TOutputImage >::SetVariance(), TestCellDataContainer(), and TestPointDataContainer().

◆ RegularizedIncompleteBeta()

template<typename TReal>
TReal itk::Math::RegularizedIncompleteBeta ( TReal a,
TReal b,
TReal x )

Regularized incomplete beta I_x(a, b).

Definition at line 42 of file itkSpecialFunctions.h.

◆ remainder_floored() [1/4]

double itk::Math::remainder_floored ( double x,
double y )
inline

Definition at line 1016 of file itkMath.h.

◆ remainder_floored() [2/4]

float itk::Math::remainder_floored ( float x,
float y )
inline

Definition at line 1011 of file itkMath.h.

◆ remainder_floored() [3/4]

long double itk::Math::remainder_floored ( long double x,
long double y )
inline

Definition at line 1021 of file itkMath.h.

◆ remainder_floored() [4/4]

template<typename T, std::enable_if_t< std::is_integral_v< T > &&std::is_signed_v< T >, int > = 0>
T itk::Math::remainder_floored ( T x,
T y )
constexpr

Floored remainder: quotient rounded toward minus infinity, result has the sign of y.

Definition at line 998 of file itkMath.h.

◆ remainder_truncated() [1/4]

double itk::Math::remainder_truncated ( double x,
double y )
inline

Definition at line 985 of file itkMath.h.

◆ remainder_truncated() [2/4]

float itk::Math::remainder_truncated ( float x,
float y )
inline

Definition at line 980 of file itkMath.h.

◆ remainder_truncated() [3/4]

long double itk::Math::remainder_truncated ( long double x,
long double y )
inline

Definition at line 990 of file itkMath.h.

◆ remainder_truncated() [4/4]

template<typename T, std::enable_if_t< std::is_integral_v< T >, int > = 0>
T itk::Math::remainder_truncated ( T x,
T y )
constexpr

Truncated remainder: quotient truncated toward zero, result has the sign of x.

Definition at line 975 of file itkMath.h.

◆ rnd() [1/2]

int itk::Math::rnd ( double x)
inline

Definition at line 1058 of file itkMath.h.

◆ rnd() [2/2]

int itk::Math::rnd ( float x)
inline

Round to nearest integer; halfway cases follow round-half-to-even.

Definition at line 1053 of file itkMath.h.

◆ rnd_halfinttoeven() [1/2]

int itk::Math::rnd_halfinttoeven ( double x)
inline

Definition at line 1033 of file itkMath.h.

◆ rnd_halfinttoeven() [2/2]

int itk::Math::rnd_halfinttoeven ( float x)
inline

Round to nearest integer, halfway cases to the nearest even integer.

Definition at line 1028 of file itkMath.h.

Referenced by rnd_halfintup(), and rnd_halfintup().

◆ rnd_halfintup() [1/2]

int itk::Math::rnd_halfintup ( double x)
inline

Definition at line 1046 of file itkMath.h.

References rnd_halfinttoeven().

◆ rnd_halfintup() [2/2]

int itk::Math::rnd_halfintup ( float x)
inline

Round to nearest integer, halfway cases upward (toward plus infinity). Valid only for |x| < INT_MAX / 2.

Definition at line 1041 of file itkMath.h.

References rnd_halfinttoeven().

◆ Round()

◆ RoundHalfIntegerToEven()

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.
RoundHalfIntegerToEven(TInput x) template< TReturn
Round towards nearest integer.

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).

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) == -1
TInput RoundHalfIntegerUp(TInput x) template< typename TReturn
Round towards nearest integer (This is a synonym for RoundHalfIntegerUp)

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).

References RoundHalfIntegerToEven().

Referenced by RoundHalfIntegerToEven().

◆ RoundHalfIntegerUp()

TInput itk::Math::RoundHalfIntegerUp ( TInput x)

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>()

References itkTemplateFloatingToIntegerMacro, and RoundHalfIntegerUp().

Referenced by itk::NearestNeighborExtrapolateImageFunction< TInputImage, TCoordinate >::EvaluateAtContinuousIndex(), Round(), RoundHalfIntegerUp(), and itk::DirectionType< Dimension >::TransformPhysicalPointToIndex().

◆ sgn()

template<typename T, std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
int itk::Math::sgn ( T x)
constexpr

Sign of a value: -1, 0, or +1.

Definition at line 872 of file itkMath.h.

Referenced by itk::Function::AdaptiveEqualizationHistogram< TInputPixel, TOutputPixel >::CumulativeFunction().

◆ sgn0()

template<typename T, std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
int itk::Math::sgn0 ( T x)
constexpr

Sign of a value in {-1, +1}; zero maps to +1.

Definition at line 880 of file itkMath.h.

◆ SolveSymmetricPositiveDefinite()

template<typename T>
vnl_vector< T > itk::Math::SolveSymmetricPositiveDefinite ( const vnl_matrix< T > & A,
const vnl_vector< T > & b )

Solve A x = b for a symmetric positive (semi-)definite A, via Eigen LDL^T. The pivoted LDL^T is robust to rank-deficiency and ill-conditioning.

Definition at line 53 of file itkCholeskySolve.h.

◆ sqr() [1/2]

◆ sqr() [2/2]

template<typename T, std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
T itk::Math::sqr ( T x)
constexpr

Definition at line 893 of file itkMath.h.

◆ squared_magnitude() [1/11]

unsigned int itk::Math::squared_magnitude ( char x)
constexpr

Squared magnitude; integer results are unsigned.

Definition at line 913 of file itkMath.h.

◆ squared_magnitude() [2/11]

double itk::Math::squared_magnitude ( double x)
constexpr

Definition at line 962 of file itkMath.h.

◆ squared_magnitude() [3/11]

float itk::Math::squared_magnitude ( float x)
constexpr

Definition at line 957 of file itkMath.h.

◆ squared_magnitude() [4/11]

unsigned int itk::Math::squared_magnitude ( int x)
constexpr

Definition at line 923 of file itkMath.h.

◆ squared_magnitude() [5/11]

long double itk::Math::squared_magnitude ( long double x)
constexpr

Definition at line 967 of file itkMath.h.

◆ squared_magnitude() [6/11]

unsigned long long itk::Math::squared_magnitude ( long long x)
constexpr

Definition at line 946 of file itkMath.h.

◆ squared_magnitude() [7/11]

unsigned long itk::Math::squared_magnitude ( long x)
constexpr

Definition at line 935 of file itkMath.h.

◆ squared_magnitude() [8/11]

unsigned int itk::Math::squared_magnitude ( unsigned char x)
constexpr

Definition at line 918 of file itkMath.h.

◆ squared_magnitude() [9/11]

unsigned int itk::Math::squared_magnitude ( unsigned int x)
constexpr

Definition at line 930 of file itkMath.h.

◆ squared_magnitude() [10/11]

unsigned long long itk::Math::squared_magnitude ( unsigned long long x)
constexpr

Definition at line 952 of file itkMath.h.

◆ squared_magnitude() [11/11]

unsigned long itk::Math::squared_magnitude ( unsigned long x)
constexpr

Definition at line 941 of file itkMath.h.

◆ SVD() [1/2]

template<typename TReal, unsigned int VDim>
FixedSquareSVDResult< TReal, VDim > itk::Math::SVD ( const Matrix< TReal, VDim, VDim > & A,
bool canonicalizeSigns = true )

SVD of a fixed-size square itk::Matrix.

Definition at line 364 of file itkMathSVD.h.

References itk::Matrix< T, VRows, VColumns >::GetVnlMatrix(), and SVD().

◆ SVD() [2/2]

template<typename TReal>
SVDResult< TReal > itk::Math::SVD ( const vnl_matrix< TReal > & A,
bool canonicalizeSigns = true )

SVD of a runtime-sized vnl_matrix (square or rectangular). Square inputs take the fast square path (JacobiSVD+NoQRPreconditioner / BDCSVD); rectangular inputs use BDCSVD with thin U/V. The dispatch is a single dimension comparison.

Definition at line 374 of file itkMathSVD.h.

References itk::detail::CanonicalizeColumnSignsPaired(), itk::Math::detail::DynamicSquareSVDEigen(), itk::Math::detail::RectangularSVDEigen(), itk::Math::SVDResult< TReal >::U, itk::Math::SVDResult< TReal >::V, and itk::Math::SVDResult< TReal >::W.

◆ UnsignedPower()

template<typename TReturnType = uintmax_t>
auto itk::Math::UnsignedPower ( const uintmax_t base,
const uintmax_t exponent ) -> TReturnType
constexprnoexcept

Calculates base ^ exponent. Numeric overflow triggers a compilation error in "constexpr context" and a debug assert failure at run-time. Otherwise equivalent to C++11 static_cast<uintmax_t>(std::pow(base, exponent))

Note
UnsignedPower(0, 0) is not supported, as zero to the power of zero has no agreed-upon value: https://en.wikipedia.org/wiki/Zero_to_the_power_of_zero

Definition at line 845 of file itkMath.h.

References UnsignedPower(), and UnsignedProduct().

Referenced by itk::ConnectedImageNeighborhoodShape< VImageDimension >::CalculateNumberOfConnectedNeighbors(), and UnsignedPower().

◆ UnsignedProduct()

template<typename TReturnType = uintmax_t>
auto itk::Math::UnsignedProduct ( const uintmax_t a,
const uintmax_t b )
constexprnoexcept

Returns a * b. Numeric overflow triggers a compilation error in "constexpr context" and a debug assert failure at run-time.

Definition at line 823 of file itkMath.h.

Referenced by itk::ConnectedImageNeighborhoodShape< VImageDimension >::CalculateBinomialCoefficient(), itk::ConnectedImageNeighborhoodShape< VImageDimension >::CalculateNumberOfHypercubesOnBoundaryOfCube(), and UnsignedPower().

Variable Documentation

◆ deg_per_rad

double itk::Math::deg_per_rad = 57.2957795130823208768
inlineconstexpr

\[ \frac{180}{\pi} \]

Definition at line 79 of file itkMath.h.

◆ e

double itk::Math::e = 2.71828182845904523536
inlineconstexpr

\[e\]

The base of the natural logarithm or Euler's number

Definition at line 55 of file itkMath.h.

◆ eps

double itk::Math::eps = std::numeric_limits<double>::epsilon()
inlineconstexpr

Definition at line 119 of file itkMath.h.

◆ euler

double itk::Math::euler = 0.57721566490153286061
inlineconstexpr

euler constant

Definition at line 93 of file itkMath.h.

◆ float_eps

float itk::Math::float_eps = std::numeric_limits<float>::epsilon()
inlineconstexpr

Definition at line 124 of file itkMath.h.

◆ float_sqrteps

float itk::Math::float_sqrteps = 3.4526698300e-4F
inlineconstexpr

Definition at line 125 of file itkMath.h.

◆ ln10

double itk::Math::ln10 = 2.30258509299404568402
inlineconstexpr

\[ \log_e 10 \]

Definition at line 63 of file itkMath.h.

◆ ln2

double itk::Math::ln2 = 0.69314718055994530942
inlineconstexpr

\[ \log_e 2 \]

Definition at line 61 of file itkMath.h.

◆ log10e

double itk::Math::log10e = 0.43429448190325182765
inlineconstexpr

\[ \log_{10} e \]

Definition at line 59 of file itkMath.h.

◆ log2e

double itk::Math::log2e = 1.44269504088896340736
inlineconstexpr

\[ \log_2 e \]

Definition at line 57 of file itkMath.h.

◆ one_over_pi

double itk::Math::one_over_pi = 0.31830988618379067154
inlineconstexpr

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

Definition at line 75 of file itkMath.h.

◆ one_over_sqrt2pi

double itk::Math::one_over_sqrt2pi = 0.39894228040143267794
inlineconstexpr

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

Definition at line 85 of file itkMath.h.

Referenced by itk::GaussianKernelFunction< TRealValueType >::Evaluate().

◆ pi

◆ pi_over_180

double itk::Math::pi_over_180 = 0.01745329251994329577
inlineconstexpr

\[ \frac{\pi}{180} \]

Definition at line 73 of file itkMath.h.

◆ pi_over_2

double itk::Math::pi_over_2 = 1.57079632679489661923
inlineconstexpr

◆ pi_over_4

double itk::Math::pi_over_4 = 0.78539816339744830962
inlineconstexpr

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

Definition at line 71 of file itkMath.h.

◆ sqrt1_2

double itk::Math::sqrt1_2 = 0.70710678118654752440
inlineconstexpr

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

Definition at line 89 of file itkMath.h.

◆ sqrt1_3

double itk::Math::sqrt1_3 = 0.57735026918962576451
inlineconstexpr

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

Definition at line 91 of file itkMath.h.

◆ sqrt2

double itk::Math::sqrt2 = 1.41421356237309504880
inlineconstexpr

\[ \sqrt{2} \]

Definition at line 87 of file itkMath.h.

◆ sqrt2pi

double itk::Math::sqrt2pi = 2.50662827463100050242
inlineconstexpr

\[ \sqrt{2\pi} \]

Definition at line 81 of file itkMath.h.

◆ sqrteps

double itk::Math::sqrteps = 0x1p-26
inlineconstexpr

Definition at line 122 of file itkMath.h.

◆ two_over_pi

double itk::Math::two_over_pi = 0.63661977236758134308
inlineconstexpr

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

Definition at line 77 of file itkMath.h.

◆ two_over_sqrtpi

double itk::Math::two_over_sqrtpi = 1.12837916709551257390
inlineconstexpr

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

Definition at line 83 of file itkMath.h.

◆ twopi

double itk::Math::twopi = 6.28318530717958647693
inlineconstexpr

\[ 2\pi \]

Definition at line 67 of file itkMath.h.

Referenced by angle_0_to_2pi(), and angle_minuspi_to_pi().