ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkMath.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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 <cassert>
32#include <cmath>
33#include "itkMathDetail.h"
34#include "itkConceptChecking.h"
35#include <vnl/vnl_math.h>
36
37/* Only maintain backwards compatibility with old versions
38 * of VXL back to the point where vnl_math:: was introduced
39 * versions of VXL where only vnl_math_ was available are not
40 * supported.
41 */
42#include <vxl_version.h>
43
44namespace itk::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 variables ).
50
51
53static constexpr double e = vnl_math::e;
55static constexpr double log2e = vnl_math::log2e;
57static constexpr double log10e = vnl_math::log10e;
59static constexpr double ln2 = vnl_math::ln2;
61static constexpr double ln10 = vnl_math::ln10;
63static constexpr double pi = vnl_math::pi;
65static constexpr double twopi = vnl_math::twopi;
67static constexpr double pi_over_2 = vnl_math::pi_over_2;
69static constexpr double pi_over_4 = vnl_math::pi_over_4;
71static constexpr double pi_over_180 = vnl_math::pi_over_180;
73static constexpr double one_over_pi = vnl_math::one_over_pi;
75static constexpr double two_over_pi = vnl_math::two_over_pi;
77static constexpr double deg_per_rad = vnl_math::deg_per_rad;
79static constexpr double sqrt2pi = vnl_math::sqrt2pi;
81static constexpr double two_over_sqrtpi = vnl_math::two_over_sqrtpi;
83static constexpr double one_over_sqrt2pi = vnl_math::one_over_sqrt2pi;
85static constexpr double sqrt2 = vnl_math::sqrt2;
87static constexpr double sqrt1_2 = vnl_math::sqrt1_2;
89static constexpr double sqrt1_3 = vnl_math::sqrt1_3;
91static constexpr double euler = vnl_math::euler;
92
93//: IEEE double machine precision
94static constexpr double eps = vnl_math::eps;
95static constexpr double sqrteps = vnl_math::sqrteps;
96//: IEEE single machine precision
97static constexpr float float_eps = vnl_math::float_eps;
98static 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 if constexpr (sizeof(TReturn) <= 4) \
108 { \
109 return static_cast<TReturn>(Detail::name##_32(x)); \
110 } \
111 else if constexpr (sizeof(TReturn) <= 8) \
112 { \
113 return static_cast<TReturn>(Detail::name##_64(x)); \
114 } \
115 else \
116 { \
117 return static_cast<TReturn>(Detail::name##_base<TReturn, TInput>(x)); \
118 } \
119 }
120
141
142
165
173template <typename TReturn, typename TInput>
174inline TReturn
175Round(TInput x)
176{
178}
179
193
194
205
206#undef itkTemplateFloatingToIntegerMacro
207
208template <typename TReturn, typename TInput>
209inline TReturn
211{
212 itkConceptMacro(OnlyDefinedForIntegerTypes1, (itk::Concept::IsInteger<TReturn>));
213 itkConceptMacro(OnlyDefinedForIntegerTypes2, (itk::Concept::IsInteger<TInput>));
214
215 auto ret = static_cast<TReturn>(x);
216 if constexpr (sizeof(TReturn) > sizeof(TInput) &&
218 {
219 // if the output type is bigger and we are not converting a signed
220 // integer to an unsigned integer then we have no problems
221 return ret;
222 }
223 else if constexpr (sizeof(TReturn) >= sizeof(TInput))
224 {
226 {
227 itk::RangeError _e(__FILE__, __LINE__);
228 throw _e;
229 }
230 }
231 else if (static_cast<TInput>(ret) != x ||
233 {
234 itk::RangeError _e(__FILE__, __LINE__);
235 throw _e;
236 }
237 return ret;
238}
239
247template <typename T>
248inline typename Detail::FloatIEEE<T>::IntType
250{
251 const Detail::FloatIEEE<T> x1f(x1);
252 const Detail::FloatIEEE<T> x2f(x2);
253 return x1f.AsULP() - x2f.AsULP();
254}
255
263template <typename T>
264inline T
266{
267 const Detail::FloatIEEE<T> representInput(x);
268 const Detail::FloatIEEE<T> representOutput(representInput.asInt + ulps);
269 return representOutput.asFloat;
270}
271
302template <typename T>
303inline bool
305 T x2,
306 typename Detail::FloatIEEE<T>::IntType maxUlps = 4,
307 typename Detail::FloatIEEE<T>::FloatType maxAbsoluteDifference = 0.1 *
309{
310 // Check if the numbers are really close -- needed
311 // when comparing numbers near zero.
312 const T absDifference = std::abs(x1 - x2);
313 if (absDifference <= maxAbsoluteDifference)
314 {
315 return true;
316 }
317
318 // This check for different signs is necessary for several reasons, see the blog link above.
319 // Subtracting the signed-magnitude representation of floats using twos-complement
320 // math isn't particularly meaningful, and the subtraction would produce a 33-bit
321 // result and overflow an int.
322 if (std::signbit(x1) != std::signbit(x2))
323 {
324 return false;
325 }
326
327 const typename Detail::FloatIEEE<T>::IntType ulps = std::abs(FloatDifferenceULP(x1, x2));
328 return ulps <= maxUlps;
329}
330
331// The following code cannot be moved to the itkMathDetail.h file without introducing circular dependencies
332namespace Detail // The Detail namespace holds the templates used by AlmostEquals
333{
334// The following structs and templates are used to choose
335// which version of the AlmostEquals function
336// should be implemented base on input parameter types
337
338// Structs for choosing AlmostEquals function
339
341{
342 template <typename TFloatType1, typename TFloatType2>
343 static bool
344 AlmostEqualsFunction(TFloatType1 x1, TFloatType2 x2)
345 {
346 return FloatAlmostEqual<double>(x1, x2);
347 }
348
349 template <typename TFloatType1, typename TFloatType2>
350 static bool
351 AlmostEqualsFunction(double x1, double x2)
352 {
353 return FloatAlmostEqual<double>(x1, x2);
354 }
355
356 template <typename TFloatType1, typename TFloatType2>
357 static bool
358 AlmostEqualsFunction(double x1, float x2)
359 {
360 return FloatAlmostEqual<float>(x1, x2);
361 }
362
363 template <typename TFloatType1, typename TFloatType2>
364 static bool
365 AlmostEqualsFunction(float x1, double x2)
366 {
367 return FloatAlmostEqual<float>(x1, x2);
368 }
369
370 template <typename TFloatType1, typename TFloatType2>
371 static bool
372 AlmostEqualsFunction(float x1, float x2)
373 {
374 return FloatAlmostEqual<float>(x1, x2);
375 }
376};
377
379{
380 template <typename TFloatType, typename TIntType>
381 static bool
382 AlmostEqualsFunction(TFloatType floatingVariable, TIntType integerVariable)
383 {
384 return FloatAlmostEqual<TFloatType>(floatingVariable, integerVariable);
385 }
386};
387
389{
390 template <typename TIntType, typename TFloatType>
391 static bool
392 AlmostEqualsFunction(TIntType integerVariable, TFloatType floatingVariable)
393 {
394 return AlmostEqualsFloatVsInteger::AlmostEqualsFunction(floatingVariable, integerVariable);
395 }
396};
397
399{
400 template <typename TSignedInt, typename TUnsignedInt>
401 static bool
402 AlmostEqualsFunction(TSignedInt signedVariable, TUnsignedInt unsignedVariable)
403 {
404 if (signedVariable < 0)
405 {
406 return false;
407 }
408 if (unsignedVariable > static_cast<size_t>(itk::NumericTraits<TSignedInt>::max()))
409 {
410 return false;
411 }
412 return signedVariable == static_cast<TSignedInt>(unsignedVariable);
413 }
414};
415
417{
418 template <typename TUnsignedInt, typename TSignedInt>
419 static bool
420 AlmostEqualsFunction(TUnsignedInt unsignedVariable, TSignedInt signedVariable)
421 {
422 return AlmostEqualsSignedVsUnsigned::AlmostEqualsFunction(signedVariable, unsignedVariable);
423 }
424};
425
427{
428 template <typename TIntegerType1, typename TIntegerType2>
429 static bool
430 AlmostEqualsFunction(TIntegerType1 x1, TIntegerType2 x2)
431 {
432 return x1 == x2;
433 }
434};
435// end of structs that choose the specific AlmostEquals function
436
437// Selector structs, these select the correct case based on its types
438// input1 is int? input 1 is signed? input2 is int? input 2 is signed?
439template <bool TInput1IsIntger, bool TInput1IsSigned, bool TInput2IsInteger, bool TInput2IsSigned>
444
446template <>
447struct AlmostEqualsFunctionSelector<false, true, false, true>
448// floating type v floating type
449{
451};
452
453template <>
454struct AlmostEqualsFunctionSelector<false, true, true, true>
455// float vs int
456{
457 using SelectedVersion = AlmostEqualsFloatVsInteger;
458};
459
460template <>
461struct AlmostEqualsFunctionSelector<false, true, true, false>
462// float vs unsigned int
463{
464 using SelectedVersion = AlmostEqualsFloatVsInteger;
465};
466
467template <>
468struct AlmostEqualsFunctionSelector<true, false, false, true>
469// unsigned int vs float
470{
471 using SelectedVersion = AlmostEqualsIntegerVsFloat;
472};
473
474template <>
475struct AlmostEqualsFunctionSelector<true, true, false, true>
476// int vs float
477{
478 using SelectedVersion = AlmostEqualsIntegerVsFloat;
479};
480
481template <>
482struct AlmostEqualsFunctionSelector<true, true, true, false>
483// signed vs unsigned
484{
485 using SelectedVersion = AlmostEqualsSignedVsUnsigned;
486};
487
488template <>
489struct AlmostEqualsFunctionSelector<true, false, true, true>
490// unsigned vs signed
491{
492 using SelectedVersion = AlmostEqualsUnsignedVsSigned;
493};
494
495template <>
496struct AlmostEqualsFunctionSelector<true, true, true, true>
497// signed vs signed
498{
499 using SelectedVersion = AlmostEqualsPlainOldEquals;
500};
501
502template <>
503struct AlmostEqualsFunctionSelector<true, false, true, false>
504// unsigned vs unsigned
505{
506 using SelectedVersion = AlmostEqualsPlainOldEquals;
507};
508// end of AlmostEqualsFunctionSelector structs
509
510// The implementor tells the selector what to do
511template <typename TInputType1, typename TInputType2>
512struct AlmostEqualsScalarImplementer
513{
514 static constexpr bool TInputType1IsInteger = std::is_integral_v<TInputType1>;
515 static constexpr bool TInputType1IsSigned = std::is_signed_v<TInputType1>;
516 static constexpr bool TInputType2IsInteger = std::is_integral_v<TInputType2>;
517 static constexpr bool TInputType2IsSigned = std::is_signed_v<TInputType2>;
518
519 using SelectedVersion = typename AlmostEqualsFunctionSelector<TInputType1IsInteger,
520 TInputType1IsSigned,
521 TInputType2IsInteger,
522 TInputType2IsSigned>::SelectedVersion;
523};
524
525// The AlmostEqualsScalarComparer returns the result of an
526// approximate comparison between two scalar values of
527// potentially different data types.
528template <typename TScalarType1, typename TScalarType2>
529inline bool
530AlmostEqualsScalarComparer(TScalarType1 x1, TScalarType2 x2)
531{
532 return AlmostEqualsScalarImplementer<TScalarType1, TScalarType2>::SelectedVersion::
533 template AlmostEqualsFunction<TScalarType1, TScalarType2>(x1, x2);
534}
535
536// The following structs are used to evaluate approximate comparisons between
537// complex and scalar values of potentially different types.
538
539// Comparisons between scalar types use the AlmostEqualsScalarComparer function.
540struct AlmostEqualsScalarVsScalar
541{
542 template <typename TScalarType1, typename TScalarType2>
543 static bool
544 AlmostEqualsFunction(TScalarType1 x1, TScalarType2 x2)
545 {
546 return AlmostEqualsScalarComparer(x1, x2);
547 }
548};
549
550// Comparisons between two complex values compare the real and imaginary components
551// separately with the AlmostEqualsScalarComparer function.
552struct AlmostEqualsComplexVsComplex
553{
554 template <typename TComplexType1, typename TComplexType2>
555 static bool
556 AlmostEqualsFunction(TComplexType1 x1, TComplexType2 x2)
557 {
558 return AlmostEqualsScalarComparer(x1.real(), x2.real()) && AlmostEqualsScalarComparer(x1.imag(), x2.imag());
559 }
560};
561
562// Comparisons between complex and scalar values first check to see if the imaginary component
563// of the complex value is approximately 0. Then a ScalarComparison is done between the real
564// part of the complex number and the scalar value.
565struct AlmostEqualsScalarVsComplex
566{
567 template <typename TScalarType, typename TComplexType>
568 static bool
569 AlmostEqualsFunction(TScalarType scalarVariable, TComplexType complexVariable)
570 {
571 if (!AlmostEqualsScalarComparer(complexVariable.imag(), typename itk::NumericTraits<TComplexType>::ValueType{}))
572 {
573 return false;
574 }
575 return AlmostEqualsScalarComparer(scalarVariable, complexVariable.real());
576 }
577};
578
579struct AlmostEqualsComplexVsScalar
580{
581 template <typename TComplexType, typename TScalarType>
582 static bool
583 AlmostEqualsFunction(TComplexType complexVariable, TScalarType scalarVariable)
584 {
585 return AlmostEqualsScalarVsComplex::AlmostEqualsFunction(scalarVariable, complexVariable);
586 }
587};
588
589// The AlmostEqualsComplexChooser structs choose the correct case
590// from the input parameter types' IsComplex property
591// The default case is scalar vs scalar
592template <bool T1IsComplex, bool T2IsComplex> // Default is false, false
593struct AlmostEqualsComplexChooser
594{
595 using ChosenVersion = AlmostEqualsScalarVsScalar;
596};
597
598template <>
599struct AlmostEqualsComplexChooser<true, true>
600{
601 using ChosenVersion = AlmostEqualsComplexVsComplex;
602};
603
604template <>
605struct AlmostEqualsComplexChooser<false, true>
606{
607 using ChosenVersion = AlmostEqualsScalarVsComplex;
608};
609
610template <>
611struct AlmostEqualsComplexChooser<true, false>
612{
613 using ChosenVersion = AlmostEqualsComplexVsScalar;
614};
615// End of AlmostEqualsComplexChooser structs.
616
617// The AlmostEqualsComplexImplementer determines which of the input
618// parameters are complex and which are real, and sends that information
619// to the AlmostEqualsComplexChooser structs to determine the proper
620// type of evaluation.
621template <typename T1, typename T2>
622struct AlmostEqualsComplexImplementer
623{
624 static constexpr bool T1IsComplex = NumericTraits<T1>::IsComplex;
625 static constexpr bool T2IsComplex = NumericTraits<T2>::IsComplex;
626
627 using ChosenVersion = typename AlmostEqualsComplexChooser<T1IsComplex, T2IsComplex>::ChosenVersion;
628};
630
631} // end namespace Detail
632
674
675// The AlmostEquals function
676template <typename T1, typename T2>
677inline bool
678AlmostEquals(T1 x1, T2 x2)
679{
680 return Detail::AlmostEqualsComplexImplementer<T1, T2>::ChosenVersion::AlmostEqualsFunction(x1, x2);
681}
682
683// The NotAlmostEquals function
684template <typename T1, typename T2>
685inline bool
686NotAlmostEquals(T1 x1, T2 x2)
687{
688 return !AlmostEquals(x1, x2);
689}
690
691
712
713// The ExactlyEquals function
714template <typename TInput1, typename TInput2>
715inline bool
716ExactlyEquals(const TInput1 & x1, const TInput2 & x2)
717{
718 ITK_GCC_PRAGMA_PUSH
719 ITK_GCC_SUPPRESS_Wfloat_equal
720 return x1 == x2;
721 ITK_GCC_PRAGMA_POP
722}
723
724// The NotExactlyEquals function
725template <typename TInput1, typename TInput2>
726inline bool
727NotExactlyEquals(const TInput1 & x1, const TInput2 & x2)
728{
729 return !ExactlyEquals(x1, x2);
730}
731
732
738ITKCommon_EXPORT bool
739IsPrime(unsigned short n);
740ITKCommon_EXPORT bool
741IsPrime(unsigned int n);
742ITKCommon_EXPORT bool
743IsPrime(unsigned long n);
744ITKCommon_EXPORT bool
745IsPrime(unsigned long long n);
747
750ITKCommon_EXPORT unsigned short
751GreatestPrimeFactor(unsigned short n);
752ITKCommon_EXPORT unsigned int
753GreatestPrimeFactor(unsigned int n);
754ITKCommon_EXPORT unsigned long
755GreatestPrimeFactor(unsigned long n);
756ITKCommon_EXPORT unsigned long long
757GreatestPrimeFactor(unsigned long long n);
759
763template <typename TReturnType = uintmax_t>
764constexpr TReturnType
765UnsignedProduct(const uintmax_t a, const uintmax_t b) noexcept
766{
767 static_assert(std::is_unsigned_v<TReturnType>, "UnsignedProduct only supports unsigned return types");
768
769 // Note that numeric overflow is not "undefined behavior", for unsigned numbers.
770 // This function checks if the result of a*b is mathematically correct.
771 return (a == 0) || (b == 0) ||
772 (((static_cast<TReturnType>(a * b) / a) == b) && ((static_cast<TReturnType>(a * b) / b) == a))
773 ? static_cast<TReturnType>(a * b)
774 : (assert(!"UnsignedProduct overflow!"), 0);
775}
776
777
785template <typename TReturnType = uintmax_t>
786constexpr TReturnType
787UnsignedPower(const uintmax_t base, const uintmax_t exponent) noexcept
788{
789 static_assert(std::is_unsigned_v<TReturnType>, "UnsignedPower only supports unsigned return types");
790
791 // Uses recursive function calls because C++11 does not support other ways of
792 // iterations for a constexpr function.
793 return (exponent == 0) ? (assert(base > 0), 1)
794 : (exponent == 1) ? base
796 UnsignedPower<TReturnType>(base, (exponent + 1) / 2));
797}
798
799
800/*==========================================
801 * Alias the vnl_math functions in the itk::Math
802 * namespace. If possible, use the std:: equivalents
803 */
804using std::isnan;
805using std::isinf;
806using std::isfinite;
807using std::isnormal;
808using std::cbrt;
809using std::hypot;
810using vnl_math::angle_0_to_2pi;
811using vnl_math::angle_minuspi_to_pi;
812using vnl_math::rnd_halfinttoeven;
813using vnl_math::rnd_halfintup;
814using vnl_math::rnd;
815using vnl_math::floor;
816using vnl_math::ceil;
817using vnl_math::sgn;
818using vnl_math::sgn0;
819using vnl_math::remainder_truncated;
820using vnl_math::remainder_floored;
821using vnl_math::sqr;
822using vnl_math::cube;
823using vnl_math::squared_magnitude;
824
825
826/*============================================
827Decouple dependence and exposure of vnl_math::abs operations
828in ITK. Placing this small amount of duplicate vnl_math
829code directly in ITK removes backward compatibility
830issues with system installed VXL versions.
831*/
832inline bool
833abs(bool x)
834{
835 return x;
836}
837inline unsigned char
838abs(unsigned char x)
839{
840 return x;
841}
842inline unsigned char
843abs(signed char x)
844{
845 return x < 0 ? static_cast<unsigned char>(-x) : x;
846}
847inline unsigned char
848abs(char x)
849{
850 return static_cast<unsigned char>(x);
851}
852inline unsigned short
853abs(short x)
854{
855 return x < 0 ? static_cast<unsigned short>(-x) : x;
856}
857inline unsigned short
858abs(unsigned short x)
859{
860 return x;
861}
862inline unsigned int
863abs(unsigned int x)
864{
865 return x;
866}
867inline unsigned long
868abs(unsigned long x)
869{
870 return x;
871}
872// long long - target type will have width of at least 64 bits. (since C++11)
873inline unsigned long long
874abs(unsigned long long x)
875{
876 return x;
877}
878
879using std::abs;
880
881} // namespace itk::Math
882
883#endif // end of itkMath.h
Define additional traits for native types such as int or float.
static constexpr T max(const T &)
static bool IsPositive(T val)
#define itkConceptMacro(name, concept)
#define itkTemplateFloatingToIntegerMacro(name)
Definition itkMath.h:103
RoundHalfIntegerToEven(TInput x) template< TReturn
Round towards nearest integer.
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:249
bool AlmostEquals(T1 x1, T2 x2)
Provide consistent equality checks between values of potentially different scalar or complex types.
Definition itkMath.h:678
static constexpr double sqrt2pi
Definition itkMath.h:79
static constexpr double sqrt1_2
Definition itkMath.h:87
bool ExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Return the result of an exact comparison between two scalar values of potentially different types.
Definition itkMath.h:716
ITKCommon_EXPORT unsigned short GreatestPrimeFactor(unsigned short n)
static constexpr double eps
Definition itkMath.h:94
bool NotAlmostEquals(T1 x1, T2 x2)
Definition itkMath.h:686
TInput Ceil(TInput x) template< typename TReturn
static constexpr double pi_over_2
Definition itkMath.h:67
constexpr TReturnType UnsignedPower(const uintmax_t base, const uintmax_t exponent) noexcept
Definition itkMath.h:787
TInput TInput TReturn CastWithRangeCheck(TInput x)
Definition itkMath.h:210
static constexpr double one_over_sqrt2pi
Definition itkMath.h:83
static constexpr double pi_over_4
Definition itkMath.h:69
TInput RoundHalfIntegerUp(TInput x) template< typename TReturn
Round towards nearest integer (This is a synonym for RoundHalfIntegerUp)
bool abs(bool x)
Definition itkMath.h:833
static constexpr double sqrteps
Definition itkMath.h:95
static constexpr double two_over_sqrtpi
Definition itkMath.h:81
static constexpr double one_over_pi
Definition itkMath.h:73
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:265
constexpr TReturnType UnsignedProduct(const uintmax_t a, const uintmax_t b) noexcept
Definition itkMath.h:765
static constexpr double ln2
Definition itkMath.h:59
Floor(TInput x) template< TReturn
Round towards minus infinity.
static constexpr double euler
euler constant
Definition itkMath.h:91
static constexpr float float_sqrteps
Definition itkMath.h:98
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition itkMath.h:727
static constexpr float float_eps
Definition itkMath.h:97
static constexpr double ln10
Definition itkMath.h:61
static constexpr double twopi
Definition itkMath.h:65
ITKCommon_EXPORT bool IsPrime(unsigned short n)
static constexpr double sqrt2
Definition itkMath.h:85
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:304
static constexpr double pi
Definition itkMath.h:63
static constexpr double deg_per_rad
Definition itkMath.h:77
static constexpr double two_over_pi
Definition itkMath.h:75
static constexpr double e
Definition itkMath.h:53
static constexpr double sqrt1_3
Definition itkMath.h:89
static constexpr double pi_over_180
Definition itkMath.h:71
static constexpr double log10e
Definition itkMath.h:57
static constexpr double log2e
Definition itkMath.h:55
TInput TInput TReturn Round(TInput x)
Definition itkMath.h:175
static bool AlmostEqualsFunction(double x1, double x2)
Definition itkMath.h:351
static bool AlmostEqualsFunction(float x1, double x2)
Definition itkMath.h:365
static bool AlmostEqualsFunction(TFloatType1 x1, TFloatType2 x2)
Definition itkMath.h:344
static bool AlmostEqualsFunction(double x1, float x2)
Definition itkMath.h:358
static bool AlmostEqualsFunction(float x1, float x2)
Definition itkMath.h:372
static bool AlmostEqualsFunction(TFloatType floatingVariable, TIntType integerVariable)
Definition itkMath.h:382
AlmostEqualsPlainOldEquals SelectedVersion
Definition itkMath.h:442
static bool AlmostEqualsFunction(TIntType integerVariable, TFloatType floatingVariable)
Definition itkMath.h:392
static bool AlmostEqualsFunction(TIntegerType1 x1, TIntegerType2 x2)
Definition itkMath.h:430
static bool AlmostEqualsFunction(TSignedInt signedVariable, TUnsignedInt unsignedVariable)
Definition itkMath.h:402
static bool AlmostEqualsFunction(TUnsignedInt unsignedVariable, TSignedInt signedVariable)
Definition itkMath.h:420
typename FloatIEEETraits< T >::IntType IntType