45 static const double e = 2.7182818284590452354;
47 static const double log2e = 1.4426950408889634074;
49 static const double log10e = 0.43429448190325182765;
51 static const double ln2 = 0.69314718055994530942;
53 static const double ln10 = 2.30258509299404568402;
55 static const double pi = 3.14159265358979323846;
57 static const double pi_over_2 = 1.57079632679489661923;
59 static const double pi_over_4 = 0.78539816339744830962;
69 static const double sqrt2 = 1.41421356237309504880;
71 static const double sqrt1_2 = 0.70710678118654752440;
76 #define itkTemplateFloatingToIntegerMacro(name) \
77 template< typename TReturn, typename TInput > \
78 inline TReturn name(TInput x) \
81 if ( sizeof( TReturn ) <= 4 ) \
83 return static_cast< TReturn >( Detail::name##_32(x) ); \
85 else if ( sizeof( TReturn ) <= 8 ) \
87 return static_cast< TReturn >( Detail::name##_64(x) ); \
91 return static_cast< TReturn >( Detail::name##_base< TReturn, TInput >(x) ); \
148 template<
typename TReturn,
typename TInput >
149 inline TReturn
Round(TInput x) {
return RoundHalfIntegerUp< TReturn, TInput >(x); }
177 #undef itkTemplateFloatingToIntegerMacro
179 template<
typename TReturn,
typename TInput >
182 #ifdef ITK_USE_CONCEPT_CHECKING
185 #endif // ITK_USE_CONCEPT_CHECKING
187 TReturn ret =
static_cast< TReturn
>( x );
188 if (
sizeof( TReturn ) >
sizeof( TInput )
195 else if (
sizeof( TReturn ) >=
sizeof( TInput ) )
203 else if ( static_cast< TInput >( ret ) != x
218 template <
typename T>
219 inline typename Detail::FloatIEEE<T>::IntType
257 template <
typename T>
265 const T absDifference = std::abs(x1 - x2);
266 if ( absDifference <= maxAbsoluteDifference )
277 return ulps <= maxUlps;
284 ITKCommon_EXPORT
bool IsPrime(
unsigned short n );
285 ITKCommon_EXPORT
bool IsPrime(
unsigned int n );
286 ITKCommon_EXPORT
bool IsPrime(
unsigned long n );
287 ITKCommon_EXPORT
bool IsPrime(
unsigned long long n );
300 #endif // end of itkMath.h
static const double two_over_pi
TReturn Round(TInput x)
Round towards nearest integer (This is a synonym for RoundHalfIntegerUp)
RoundHalfIntegerUp(TInput x)
Round towards nearest integer.
bool FloatAlmostEqual(T x1, T x2, typename Detail::FloatIEEE< T >::IntType maxUlps=4, typename Detail::FloatIEEE< T >::FloatType maxAbsoluteDifference=0.1 *NumericTraits< T >::epsilon())
Compare two floats and return if they are effectively equal.
static const double two_over_sqrtpi
static const double one_over_sqrt2pi
Floor(TInput x)
Round towards minus infinity.
TReturn CastWithRangeCheck(TInput x)
ITKCommon_EXPORT unsigned short GreatestPrimeFactor(unsigned short n)
static const double e
The base of the natural logarithm or Euler's number
static bool IsPositive(T val)
static const double pi_over_2
Detail::FloatIEEE< T >::IntType FloatDifferenceULP(T x1, T x2)
Return the signed distance in ULPs (units in the last place) between two floats.
#define itkTemplateFloatingToIntegerMacro(name)
static const double sqrt2
static const double log10e
FloatIEEETraits< T >::IntType IntType
static const double log2e
Ceil(TInput x)
Round towards plus infinity.
static const double one_over_pi
static const double pi_over_4
Define additional traits for native types such as int or float.
static const double sqrt1_2
RoundHalfIntegerToEven(TInput x)
Round towards nearest integer.
#define itkConceptMacro(name, concept)
ITKCommon_EXPORT bool IsPrime(unsigned short n)