ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkMath.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 /*=========================================================================
19  *
20  * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21  *
22  * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23  *
24  * For complete copyright, license and disclaimer of warranty information
25  * please refer to the NOTICE file at the top of the ITK source tree.
26  *
27  *=========================================================================*/
28 #ifndef itkMath_h
29 #define itkMath_h
30 
31 #include "itkMathDetail.h"
32 #include "itkConceptChecking.h"
33 #include <vnl/vnl_math.h>
34 
35 /* Only maintain backwards compatibility with old versions
36  * of VXL back to the point where vnl_math:: was introduced
37  * versions of VXL where only vnl_math_ was available are not
38  * supported.
39  */
40 #include <vxl_version.h>
41 
42 namespace itk
43 {
44 namespace Math
45 {
46 // These constants originate from VXL's vnl_math.h. They have been
47 // moved here to improve visibility, and to ensure that the constants
48 // are available during compile time ( as opposed to static ITK_CONSTEXPR
49 // member vaiables ).
50 
51 
53 static constexpr double e = vnl_math::e;
55 static constexpr double log2e = vnl_math::log2e;
57 static constexpr double log10e = vnl_math::log10e;
59 static constexpr double ln2 = vnl_math::ln2;
61 static constexpr double ln10 = vnl_math::ln10;
63 static constexpr double pi = vnl_math::pi;
65 static constexpr double twopi = vnl_math::twopi;
67 static constexpr double pi_over_2 = vnl_math::pi_over_2;
69 static constexpr double pi_over_4 = vnl_math::pi_over_4;
71 static constexpr double pi_over_180 = vnl_math::pi_over_180;
73 static constexpr double one_over_pi = vnl_math::one_over_pi;
75 static constexpr double two_over_pi = vnl_math::two_over_pi;
77 static constexpr double deg_per_rad = vnl_math::deg_per_rad;
79 static constexpr double sqrt2pi = vnl_math::sqrt2pi;
81 static constexpr double two_over_sqrtpi = vnl_math::two_over_sqrtpi;
83 static constexpr double one_over_sqrt2pi = vnl_math::one_over_sqrt2pi;
85 static constexpr double sqrt2 = vnl_math::sqrt2;
87 static constexpr double sqrt1_2 = vnl_math::sqrt1_2;
89 static constexpr double sqrt1_3 = vnl_math::sqrt1_3;
91 static constexpr double euler = vnl_math::euler;
92 
93 //: IEEE double machine precision
94 static constexpr double eps = vnl_math::eps;
95 static constexpr double sqrteps = vnl_math::sqrteps;
96 //: IEEE single machine precision
97 static constexpr float float_eps = vnl_math::float_eps;
98 static constexpr float float_sqrteps = vnl_math::float_sqrteps;
99 
103 #define itkTemplateFloatingToIntegerMacro(name) \
104  template< typename TReturn, typename TInput > \
105  inline TReturn name(TInput x) \
106  { \
107  \
108  if ( sizeof( TReturn ) <= 4 ) \
109  { \
110  return static_cast< TReturn >( Detail::name##_32(x) ); \
111  } \
112  else if ( sizeof( TReturn ) <= 8 ) \
113  { \
114  return static_cast< TReturn >( Detail::name##_64(x) ); \
115  } \
116  else \
117  { \
118  return static_cast< TReturn >( Detail::name##_base< TReturn, TInput >(x) ); \
119  } \
120  }
121 
122 
143 
167 
175 template< typename TReturn, typename TInput >
176 inline TReturn Round(TInput x) { return RoundHalfIntegerUp< TReturn, TInput >(x); }
177 
191 
203 
204 #undef itkTemplateFloatingToIntegerMacro
205 
206 template< typename TReturn, typename TInput >
207 inline TReturn CastWithRangeCheck(TInput x)
208 {
209 #ifdef ITK_USE_CONCEPT_CHECKING
210  itkConceptMacro( OnlyDefinedForIntegerTypes1, ( itk::Concept::IsInteger< TReturn > ) );
211  itkConceptMacro( OnlyDefinedForIntegerTypes2, ( itk::Concept::IsInteger< TInput > ) );
212 #endif // ITK_USE_CONCEPT_CHECKING
213 
214  auto ret = static_cast< TReturn >( x );
215  if ( sizeof( TReturn ) > sizeof( TInput )
216  && !( !itk::NumericTraits< TReturn >::is_signed && itk::NumericTraits< TInput >::is_signed ) )
217  {
218  // if the output type is bigger and we are not converting a signed
219  // integer to an unsigned integer then we have no problems
220  return ret;
221  }
222  else if ( sizeof( TReturn ) >= sizeof( TInput ) )
223  {
224  if ( itk::NumericTraits< TInput >::IsPositive(x) != itk::NumericTraits< TReturn >::IsPositive(ret) )
225  {
226  itk::RangeError _e(__FILE__, __LINE__);
227  throw _e;
228  }
229  }
230  else if ( static_cast< TInput >( ret ) != x
231  || ( itk::NumericTraits< TInput >::IsPositive(x) != itk::NumericTraits< TReturn >::IsPositive(ret) ) )
232  {
233  itk::RangeError _e(__FILE__, __LINE__);
234  throw _e;
235  }
236  return ret;
237 }
238 
246 template <typename T>
247 inline typename Detail::FloatIEEE<T>::IntType
248 FloatDifferenceULP( T x1, T x2 )
249 {
250  Detail::FloatIEEE<T> x1f(x1);
251  Detail::FloatIEEE<T> x2f(x2);
252  return x1f.AsULP() - x2f.AsULP();
253 }
254 
262 template <typename T>
263 inline T
265 {
266  Detail::FloatIEEE<T> representInput( x );
267  Detail::FloatIEEE<T> representOutput( representInput.asInt + ulps );
268  return representOutput.asFloat;
269 }
270 
301 template <typename T>
302 inline bool
303 FloatAlmostEqual( T x1, T x2,
304  typename Detail::FloatIEEE<T>::IntType maxUlps = 4,
305  typename Detail::FloatIEEE<T>::FloatType maxAbsoluteDifference = 0.1*itk::NumericTraits<T>::epsilon() )
306 {
307  // Check if the numbers are really close -- needed
308  // when comparing numbers near zero.
309  const T absDifference = std::abs(x1 - x2);
310  if ( absDifference <= maxAbsoluteDifference )
311  {
312  return true;
313  }
314 
315 #if defined(__APPLE__) && (__clang_major__ == 3) && (__clang_minor__ == 0) && defined(NDEBUG) && defined(__x86_64__)
316  Detail::FloatIEEE<T> x1f(x1);
317  Detail::FloatIEEE<T> x2f(x2);
318  double x1fAsULP = static_cast<double>(x1f.AsULP());
319  double x2fAsULP = static_cast<double>(x2f.AsULP());
320  double ulps = x1fAsULP - x2fAsULP;
321  if(ulps < 0)
322  {
323  ulps = -ulps;
324  }
325  return ulps <= static_cast<double>(maxUlps);
326 #else
328  ulps = FloatDifferenceULP(x1, x2);
329  if(ulps < 0)
330  {
331  ulps = -ulps;
332  }
333  return ulps <= maxUlps;
334 #endif
335 }
336 
337 // The following code cannot be moved to the itkMathDetail.h file without introducing circular dependencies
338 namespace Detail // The Detail namespace holds the templates used by AlmostEquals
339 {
340 // The following structs and templates are used to choose
341 // which version of the AlmostEquals function
342 // should be implemented base on input parameter types
343 
344 // Structs for choosing AlmostEquals function
345 
347 {
348  template <typename TFloatType1, typename TFloatType2>
349  static bool AlmostEqualsFunction(TFloatType1 x1, TFloatType2 x2)
350  {
351  return FloatAlmostEqual<double>(x1, x2);
352  }
353 
354  template <typename TFloatType1, typename TFloatType2>
355  static bool
356  AlmostEqualsFunction(double x1, double x2)
357  {
358  return FloatAlmostEqual<double>(x1, x2);
359  }
360 
361  template <typename TFloatType1, typename TFloatType2>
362  static bool
363  AlmostEqualsFunction(double x1, float x2)
364  {
365  return FloatAlmostEqual<float>(x1, x2);
366  }
367 
368  template <typename TFloatType1, typename TFloatType2>
369  static bool
370  AlmostEqualsFunction(float x1, double x2)
371  {
372  return FloatAlmostEqual<float>(x1, x2);
373  }
374 
375  template <typename TFloatType1, typename TFloatType2>
376  static bool
377  AlmostEqualsFunction(float x1, float x2)
378  {
379  return FloatAlmostEqual<float>(x1, x2);
380  }
381 };
382 
384 {
385  template <typename TFloatType, typename TIntType>
386  static bool AlmostEqualsFunction(TFloatType floatingVariable, TIntType integerVariable)
387  {
388  return FloatAlmostEqual<TFloatType> (floatingVariable, integerVariable);
389  }
390 };
391 
393 {
394  template <typename TIntType, typename TFloatType>
395  static bool AlmostEqualsFunction(TIntType integerVariable, TFloatType floatingVariable)
396  {
397  return AlmostEqualsFloatVsInteger::AlmostEqualsFunction(floatingVariable, integerVariable);
398  }
399 };
400 
402 {
403  template <typename TSignedInt, typename TUnsignedInt>
404  static bool AlmostEqualsFunction(TSignedInt signedVariable, TUnsignedInt unsignedVariable)
405  {
406  if(signedVariable < 0) return false;
407  if( unsignedVariable > static_cast< size_t >(itk::NumericTraits<TSignedInt>::max()) ) return false;
408  return signedVariable == static_cast< TSignedInt >(unsignedVariable);
409  }
410 };
411 
413 {
414  template <typename TUnsignedInt, typename TSignedInt>
415  static bool AlmostEqualsFunction(TUnsignedInt unsignedVariable, TSignedInt signedVariable)
416  {
417  return AlmostEqualsSignedVsUnsigned::AlmostEqualsFunction(signedVariable, unsignedVariable);
418  }
419 };
420 
422 {
423  template <typename TIntegerType1, typename TIntegerType2>
424  static bool AlmostEqualsFunction(TIntegerType1 x1, TIntegerType2 x2)
425  {
426  return x1 == x2;
427  }
428 };
429 // end of structs that choose the specific AlmostEquals function
430 
431 // Selector structs, these select the correct case based on its types
432 // input1 is int? input 1 is signed? input2 is int? input 2 is signed?
433 template<bool TInput1IsIntger, bool TInput1IsSigned, bool TInput2IsInteger, bool TInput2IsSigned>
435 { // default case
437 };
438 
440 template<>
441 struct AlmostEqualsFunctionSelector < false, true, false, true>
442 // floating type v floating type
443 {
445 };
446 
447 template<>
448 struct AlmostEqualsFunctionSelector <false, true, true, true>
449 // float vs signed int
450 {
451  using SelectedVersion = AlmostEqualsFloatVsInteger;
452 };
453 
454 template<>
455 struct AlmostEqualsFunctionSelector <false, true, true,false>
456 // float vs unsigned int
457 {
458  using SelectedVersion = AlmostEqualsFloatVsInteger;
459 };
460 
461 template<>
462 struct AlmostEqualsFunctionSelector <true, false, false, true>
463 // unsigned int vs float
464 {
465  using SelectedVersion = AlmostEqualsIntegerVsFloat;
466 };
467 
468 template<>
469 struct AlmostEqualsFunctionSelector <true, true, false, true>
470 // signed int vs float
471 {
472  using SelectedVersion = AlmostEqualsIntegerVsFloat;
473 };
474 
475 template<>
476 struct AlmostEqualsFunctionSelector<true, true, true, false>
477 // signed vs unsigned
478 {
479  using SelectedVersion = AlmostEqualsSignedVsUnsigned;
480 };
481 
482 template<>
483 struct AlmostEqualsFunctionSelector<true, false, true, true>
484 // unsigned vs signed
485 {
486  using SelectedVersion = AlmostEqualsUnsignedVsSigned;
487 };
488 
489 template<>
490 struct AlmostEqualsFunctionSelector<true, true, true, true>
491 // signed vs signed
492 {
493  using SelectedVersion = AlmostEqualsPlainOldEquals;
494 };
495 
496 template<>
497 struct AlmostEqualsFunctionSelector<true, false, true, false>
498 // unsigned vs unsigned
499 {
500  using SelectedVersion = AlmostEqualsPlainOldEquals;
501 };
502 // end of AlmostEqualsFunctionSelector structs
503 
504  // The implementor tells the selector what to do
505 template<typename TInputType1, typename TInputType2>
506 struct AlmostEqualsScalarImplementer
507 {
508  static constexpr bool TInputType1IsInteger = itk::NumericTraits<TInputType1>::IsInteger;
509  static constexpr bool TInputType1IsSigned = itk::NumericTraits<TInputType1>::IsSigned;
510  static constexpr bool TInputType2IsInteger = itk::NumericTraits<TInputType2>::IsInteger;
511  static constexpr bool TInputType2IsSigned = itk::NumericTraits<TInputType2>::IsSigned;
512 
513  using SelectedVersion = typename AlmostEqualsFunctionSelector< TInputType1IsInteger, TInputType1IsSigned,
514  TInputType2IsInteger, TInputType2IsSigned >::SelectedVersion;
515 };
516 
517 // The AlmostEqualsScalarComparer returns the result of an
518 // approximate comparison between two scalar values of
519 // potentially different data types.
520 template <typename TScalarType1, typename TScalarType2>
521 inline bool
522 AlmostEqualsScalarComparer( TScalarType1 x1, TScalarType2 x2 )
523 {
524  return AlmostEqualsScalarImplementer<TScalarType1, TScalarType2>::SelectedVersion:: template AlmostEqualsFunction<TScalarType1, TScalarType2>(x1, x2);
525 }
526 
527 // The following structs are used to evaluate approximate comparisons between
528 // complex and scalar values of potentially different types.
529 
530 // Comparisons between scalar types use the AlmostEqualsScalarComparer function.
531 struct AlmostEqualsScalarVsScalar
532 {
533  template <typename TScalarType1, typename TScalarType2>
534  static bool
535  AlmostEqualsFunction(TScalarType1 x1, TScalarType2 x2)
536  {
537  return AlmostEqualsScalarComparer(x1, x2);
538  }
539 };
540 
541 // Comparisons between two complex values compare the real and imaginary components
542 // separately with the AlmostEqualsScalarComparer function.
543 struct AlmostEqualsComplexVsComplex
544 {
545  template <typename TComplexType1, typename TComplexType2>
546  static bool
547  AlmostEqualsFunction(TComplexType1 x1, TComplexType2 x2)
548  {
549  return AlmostEqualsScalarComparer(x1.real(), x2.real()) && AlmostEqualsScalarComparer( x1.imag(), x2.imag() );
550  }
551 };
552 
553 // Comparisons between complex and scalar values first check to see if the imaginary component
554 // of the complex value is approximately 0. Then a ScalarComparison is done between the real
555 // part of the complex number and the scalar value.
556 struct AlmostEqualsScalarVsComplex
557 {
558  template <typename TScalarType, typename TComplexType>
559  static bool
560  AlmostEqualsFunction(TScalarType scalarVariable, TComplexType complexVariable)
561  {
562  if( !AlmostEqualsScalarComparer( complexVariable.imag(), itk::NumericTraits< typename itk::NumericTraits< TComplexType >::ValueType >::ZeroValue() ) )
563  {
564  return false;
565  }
566  return AlmostEqualsScalarComparer(scalarVariable, complexVariable.real());
567  }
568 };
569 
570 struct AlmostEqualsComplexVsScalar
571 {
572  template <typename TComplexType, typename TScalarType>
573  static bool
574  AlmostEqualsFunction(TComplexType complexVariable, TScalarType scalarVariable)
575  {
576  return AlmostEqualsScalarVsComplex::AlmostEqualsFunction(scalarVariable, complexVariable);
577  }
578 };
579 
580 // The AlmostEqualsComplexChooser structs choose the correct case
581 // from the input parameter types' IsComplex property
582 // The default case is scalar vs scalar
583 template < bool T1IsComplex, bool T2IsComplex > //Default is false, false
584 struct AlmostEqualsComplexChooser
585 {
586  using ChosenVersion = AlmostEqualsScalarVsScalar;
587 };
588 
589 template <>
590 struct AlmostEqualsComplexChooser< true, true >
591 {
592  using ChosenVersion = AlmostEqualsComplexVsComplex;
593 };
594 
595 template <>
596 struct AlmostEqualsComplexChooser< false, true >
597 {
598  using ChosenVersion = AlmostEqualsScalarVsComplex;
599 };
600 
601 template <>
602 struct AlmostEqualsComplexChooser< true, false>
603 {
604  using ChosenVersion = AlmostEqualsComplexVsScalar;
605 };
606 // End of AlmostEqualsComplexChooser structs.
607 
608 // The AlmostEqualsComplexImplementer determines which of the input
609 // parameters are complex and which are real, and sends that information
610 // to the AlmostEqualsComplexChooser structs to determine the proper
611 // type of evaluation.
612 template <typename T1, typename T2>
613 struct AlmostEqualsComplexImplementer
614 {
615  static constexpr bool T1IsComplex = NumericTraits< T1 >::IsComplex;
616  static constexpr bool T2IsComplex = NumericTraits< T2 >::IsComplex;
617 
618  using ChosenVersion = typename AlmostEqualsComplexChooser< T1IsComplex, T2IsComplex >::ChosenVersion;
619 };
621 
622 } // end namespace Detail
623 
666 // The AlmostEquals function
667 template <typename T1, typename T2>
668 inline bool
669 AlmostEquals( T1 x1, T2 x2 )
670 {
671  return Detail::AlmostEqualsComplexImplementer<T1,T2>::ChosenVersion::AlmostEqualsFunction(x1, x2);
672 }
673 
674 // The NotAlmostEquals function
675 template <typename T1, typename T2>
676 inline bool
677 NotAlmostEquals( T1 x1, T2 x2 )
678 {
679  return ! AlmostEquals( x1, x2 );
680 }
681 
682 
704 // The ExactlyEquals function
705 template <typename TInput1, typename TInput2>
706 inline bool
707 ExactlyEquals( const TInput1 & x1, const TInput2 & x2 )
708 {
709 CLANG_PRAGMA_PUSH
710 CLANG_SUPPRESS_Wfloat_equal
711  return x1 == x2;
712 CLANG_PRAGMA_POP
713 }
714 
715 //The NotExactlyEquals function
716 template <typename TInput1, typename TInput2>
717 inline bool
718 NotExactlyEquals( const TInput1 & x1, const TInput2 & x2 )
719 {
720  return !ExactlyEquals(x1, x2);
721 }
722 
723 
728 ITKCommon_EXPORT bool IsPrime( unsigned short n );
729 ITKCommon_EXPORT bool IsPrime( unsigned int n );
730 ITKCommon_EXPORT bool IsPrime( unsigned long n );
731 ITKCommon_EXPORT bool IsPrime( unsigned long long n );
733 
734 
736 ITKCommon_EXPORT unsigned short GreatestPrimeFactor( unsigned short n );
737 ITKCommon_EXPORT unsigned int GreatestPrimeFactor( unsigned int n );
738 ITKCommon_EXPORT unsigned long GreatestPrimeFactor( unsigned long n );
739 ITKCommon_EXPORT unsigned long long GreatestPrimeFactor( unsigned long long n );
741 
742 
743 /*==========================================
744  * Alias the vnl_math functions in the itk::Math
745  * namespace. If possible, use the std:: equivalents
746  */
747 using std::isnan;
748 using std::isinf;
749 using std::isfinite;
750 using std::isnormal;
751 using std::cbrt;
752 using std::hypot;
753 using vnl_math::angle_0_to_2pi;
754 using vnl_math::angle_minuspi_to_pi;
755 using vnl_math::rnd_halfinttoeven;
756 using vnl_math::rnd_halfintup;
757 using vnl_math::rnd;
758 using vnl_math::floor;
759 using vnl_math::ceil;
760 using vnl_math::sgn;
761 using vnl_math::sgn0;
762 using vnl_math::remainder_truncated;
763 using vnl_math::remainder_floored;
764 using vnl_math::abs;
765 using vnl_math::sqr;
766 using vnl_math::cube;
767 using vnl_math::squared_magnitude;
768 
769 } // end namespace Math
770 } // end namespace itk
771 
772 #endif // end of itkMath.h
static bool AlmostEqualsFunction(double x1, float x2)
Definition: itkMath.h:363
static bool AlmostEqualsFunction(TSignedInt signedVariable, TUnsignedInt unsignedVariable)
Definition: itkMath.h:404
static bool AlmostEqualsFunction(float x1, double x2)
Definition: itkMath.h:370
static constexpr double pi_over_2
Definition: itkMath.h:67
TReturn Round(TInput x)
Round towards nearest integer (This is a synonym for RoundHalfIntegerUp)
Definition: itkMath.h:176
RoundHalfIntegerUp(TInput x)
Round towards nearest integer.
static constexpr double ln10
Definition: itkMath.h:61
Define numeric traits for std::vector.
static constexpr double two_over_sqrtpi
Definition: itkMath.h:81
static constexpr double euler
euler constant
Definition: itkMath.h:91
static constexpr double pi_over_4
Definition: itkMath.h:69
typename FloatIEEETraits< T >::IntType IntType
static constexpr double sqrt1_2
Definition: itkMath.h:87
static constexpr double log2e
Definition: itkMath.h:55
static constexpr double one_over_sqrt2pi
Definition: itkMath.h:83
static bool AlmostEqualsFunction(TIntType integerVariable, TFloatType floatingVariable)
Definition: itkMath.h:395
static constexpr double log10e
Definition: itkMath.h:57
static constexpr double pi
Definition: itkMath.h:63
static constexpr float float_sqrteps
Definition: itkMath.h:98
Floor(TInput x)
Round towards minus infinity.
bool ExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Return the result of an exact comparison between two scalar values of potetially different types...
Definition: itkMath.h:707
TReturn CastWithRangeCheck(TInput x)
Definition: itkMath.h:207
ITKCommon_EXPORT unsigned short GreatestPrimeFactor(unsigned short n)
static bool AlmostEqualsFunction(TUnsignedInt unsignedVariable, TSignedInt signedVariable)
Definition: itkMath.h:415
static constexpr double one_over_pi
Definition: itkMath.h:73
static bool AlmostEqualsFunction(TFloatType floatingVariable, TIntType integerVariable)
Definition: itkMath.h:386
Detail::FloatIEEE< T >::IntType FloatDifferenceULP(T x1, T x2)
Return the signed distance in ULPs (units in the last place) between two floats.
Definition: itkMath.h:248
static constexpr double two_over_pi
Definition: itkMath.h:75
#define itkTemplateFloatingToIntegerMacro(name)
Definition: itkMath.h:103
T FloatAddULP(T x, typename Detail::FloatIEEE< T >::IntType ulps)
Add the given ULPs (units in the last place) to a float.
Definition: itkMath.h:264
static bool AlmostEqualsFunction(TIntegerType1 x1, TIntegerType2 x2)
Definition: itkMath.h:424
static constexpr float float_eps
Definition: itkMath.h:97
static constexpr double eps
Definition: itkMath.h:94
static constexpr double ln2
Definition: itkMath.h:59
static constexpr double sqrt2pi
Definition: itkMath.h:79
static constexpr double deg_per_rad
Definition: itkMath.h:77
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:718
static constexpr double twopi
Definition: itkMath.h:65
Ceil(TInput x)
Round towards plus infinity.
AlmostEqualsPlainOldEquals SelectedVersion
Definition: itkMath.h:436
static bool AlmostEqualsFunction(float x1, float x2)
Definition: itkMath.h:377
bool AlmostEquals(T1 x1, T2 x2)
Provide consistent equality checks between values of potentially different scalar or complex types...
Definition: itkMath.h:669
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())
Compare two floats and return if they are effectively equal.
Definition: itkMath.h:303
static constexpr double e
The base of the natural logarithm or Euler&#39;s number
Definition: itkMath.h:53
static constexpr double sqrt1_3
Definition: itkMath.h:89
static bool AlmostEqualsFunction(TFloatType1 x1, TFloatType2 x2)
Definition: itkMath.h:349
static constexpr double sqrteps
Definition: itkMath.h:95
static constexpr double pi_over_180
Definition: itkMath.h:71
bool NotAlmostEquals(T1 x1, T2 x2)
Definition: itkMath.h:677
static bool AlmostEqualsFunction(double x1, double x2)
Definition: itkMath.h:356
RoundHalfIntegerToEven(TInput x)
Round towards nearest integer.
#define itkConceptMacro(name, concept)
static constexpr double sqrt2
Definition: itkMath.h:85
ITKCommon_EXPORT bool IsPrime(unsigned short n)