ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkMath.h File Reference
#include <cassert>
#include <complex>
#include <cmath>
#include <limits>
#include <type_traits>
#include "itkMathDetail.h"
#include "itkConceptChecking.h"
+ Include dependency graph for itkMath.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  itk::Math::Detail::AlmostEqualsFloatVsFloat
 
struct  itk::Math::Detail::AlmostEqualsFloatVsInteger
 
struct  itk::Math::Detail::AlmostEqualsFunctionSelector< TInput1IsIntger, TInput1IsSigned, TInput2IsInteger, TInput2IsSigned >
 
struct  itk::Math::Detail::AlmostEqualsIntegerVsFloat
 
struct  itk::Math::Detail::AlmostEqualsPlainOldEquals
 
struct  itk::Math::Detail::AlmostEqualsSignedVsUnsigned
 
struct  itk::Math::Detail::AlmostEqualsUnsignedVsSigned
 

Namespaces

namespace  itk
 
namespace  itk::Math
 
namespace  itk::Math::Detail
 

Macros

#define itkTemplateFloatingToIntegerMacro(name)
 

Functions

template<typename T>
auto itk::Math::Absolute (const std::complex< T > &x) noexcept
 
template<typename T>
constexpr auto itk::Math::Absolute (T x) noexcept
 
template<typename T1, typename T2>
bool itk::Math::AlmostEquals (T1 x1, T2 x2)
 
double itk::Math::angle_0_to_2pi (double angle)
 
double itk::Math::angle_minuspi_to_pi (double angle)
 
TInput TInput auto itk::Math::CastWithRangeCheck (TInput x)
 
TInput itk::Math::Ceil (TInput x) template< typename TReturn
 
int itk::Math::ceil (double x)
 
int itk::Math::ceil (float x)
 
constexpr bool itk::Math::cube (bool x)
 
template<typename T, std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
constexpr T itk::Math::cube (T x)
 
template<typename TInput1, typename TInput2>
constexpr bool itk::Math::ExactlyEquals (const TInput1 &x1, const TInput2 &x2)
 
template<typename T>
constexpr T itk::Math::FloatAddULP (T x, typename Detail::FloatIEEE< T >::IntType ulps)
 
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())
 
template<typename T>
constexpr Detail::FloatIEEE< T >::IntType itk::Math::FloatDifferenceULP (T x1, T x2)
 
template<TReturn, typename TInput>
 itk::Math::Floor (TInput x) template< TReturn
 
int itk::Math::floor (double x)
 
int itk::Math::floor (float x)
 
template<typename T1, typename T2>
bool itk::Math::NotAlmostEquals (T1 x1, T2 x2)
 
template<typename TInput1, typename TInput2>
constexpr bool itk::Math::NotExactlyEquals (const TInput1 &x1, const TInput2 &x2)
 
double itk::Math::remainder_floored (double x, double y)
 
float itk::Math::remainder_floored (float x, float y)
 
long double itk::Math::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 itk::Math::remainder_floored (T x, T y)
 
double itk::Math::remainder_truncated (double x, double y)
 
float itk::Math::remainder_truncated (float x, float y)
 
long double itk::Math::remainder_truncated (long double x, long double y)
 
template<typename T, std::enable_if_t< std::is_integral_v< T >, int > = 0>
constexpr T itk::Math::remainder_truncated (T x, T y)
 
int itk::Math::rnd (double x)
 
int itk::Math::rnd (float x)
 
int itk::Math::rnd_halfinttoeven (double x)
 
int itk::Math::rnd_halfinttoeven (float x)
 
int itk::Math::rnd_halfintup (double x)
 
int itk::Math::rnd_halfintup (float x)
 
TInput TInput constexpr auto itk::Math::Round (TInput x)
 
template<TReturn, typename TInput>
 itk::Math::RoundHalfIntegerToEven (TInput x) template< TReturn
 
TInput itk::Math::RoundHalfIntegerUp (TInput x) template< typename TReturn
 
template<typename T, std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
constexpr int itk::Math::sgn (T x)
 
template<typename T, std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
constexpr int itk::Math::sgn0 (T x)
 
constexpr bool itk::Math::sqr (bool x)
 
template<typename T, std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
constexpr T itk::Math::sqr (T x)
 
constexpr unsigned int itk::Math::squared_magnitude (char x)
 
constexpr double itk::Math::squared_magnitude (double x)
 
constexpr float itk::Math::squared_magnitude (float x)
 
constexpr unsigned int itk::Math::squared_magnitude (int x)
 
constexpr long double itk::Math::squared_magnitude (long double x)
 
constexpr unsigned long long itk::Math::squared_magnitude (long long x)
 
constexpr unsigned long itk::Math::squared_magnitude (long x)
 
constexpr unsigned int itk::Math::squared_magnitude (unsigned char x)
 
constexpr unsigned int itk::Math::squared_magnitude (unsigned int x)
 
constexpr unsigned long long itk::Math::squared_magnitude (unsigned long long x)
 
constexpr unsigned long itk::Math::squared_magnitude (unsigned long x)
 
template<typename TReturnType = uintmax_t>
constexpr auto itk::Math::UnsignedPower (const uintmax_t base, const uintmax_t exponent) noexcept -> TReturnType
 
template<typename TReturnType = uintmax_t>
constexpr auto itk::Math::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 itk::Math::IsPrime (T n)
 
template<typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
constexpr T itk::Math::GreatestPrimeFactor (T n)
 

Variables

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

Macro Definition Documentation

◆ itkTemplateFloatingToIntegerMacro

#define itkTemplateFloatingToIntegerMacro ( name)
Value:
template <typename TReturn, typename TInput> \
inline constexpr auto name(TInput x) \
{ \
if constexpr (sizeof(TReturn) <= 4) \
{ \
return static_cast<TReturn>(Detail::name##_32(x)); \
} \
else if constexpr (sizeof(TReturn) <= 8) \
{ \
return static_cast<TReturn>(Detail::name##_64(x)); \
} \
else \
{ \
return static_cast<TReturn>(Detail::name##_base<TReturn, TInput>(x)); \
} \
}

A useful macro to generate a template floating point to integer conversion templated on the return type and using either the 32 bit, the 64 bit or the vanilla version

Definition at line 130 of file itkMath.h.

Referenced by itk::Math::Ceil(), and itk::Math::RoundHalfIntegerUp().