18 #ifndef itkNumericTraits_h
19 #define itkNumericTraits_h
26 #define itkNUMERIC_TRAITS_MIN_MAX_MACRO() \
27 static ITK_CONSTEXPR_FUNC ValueType min() \
29 return std::numeric_limits< ValueType >::min(); \
31 static ITK_CONSTEXPR_FUNC ValueType max() \
33 return std::numeric_limits< ValueType >::max(); \
35 static ITK_CONSTEXPR_FUNC ValueType min(ValueType) \
37 return std::numeric_limits< ValueType >::min(); \
39 static ITK_CONSTEXPR_FUNC ValueType max(ValueType) \
41 return std::numeric_limits< ValueType >::max(); \
44 #if ITK_COMPILER_CXX_CONSTEXPR
45 #define itkNUMERIC_TRAITS_C11_ASSINMENT(x) = x
47 #define itkNUMERIC_TRAITS_C11_ASSINMENT(x)
50 #if !defined( ITK_LEGACY_FUTURE_REMOVE )
51 # include "vcl_limits.h"
60 template<
typename TValue,
unsigned int VLength>
class FixedArray;
77 template<
typename T >
158 static ITK_CONSTEXPR_FUNC T
max(
const T &) {
return TraitsType::max(); }
159 static ITK_CONSTEXPR_FUNC T
min(
const T &) {
return TraitsType::min(); }
172 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
219 template<
typename TArray>
237 class NumericTraits< bool > :
public std::numeric_limits< bool >
249 static ITK_CONSTEXPR_VAR
bool Zero =
false;
250 static ITK_CONSTEXPR_VAR
bool One =
true;
252 static ITK_CONSTEXPR_FUNC
bool min() {
return false; }
253 static ITK_CONSTEXPR_FUNC
bool max() {
return true; }
254 static ITK_CONSTEXPR_FUNC
bool min(
bool) {
return min(); }
255 static ITK_CONSTEXPR_FUNC
bool max(
bool) {
return max(); }
257 static ITK_CONSTEXPR_FUNC
bool IsPositive(
bool val) {
return val; }
258 static ITK_CONSTEXPR_FUNC
bool IsNonpositive(
bool val) {
return !val; }
259 static ITK_CONSTEXPR_FUNC
bool IsNegative(
bool val) {
return val ?
false :
false; }
260 static ITK_CONSTEXPR_FUNC
bool IsNonnegative(
bool val) {
return val ?
true :
true; }
261 static ITK_CONSTEXPR_VAR
bool IsSigned =
false;
262 static ITK_CONSTEXPR_VAR
bool IsInteger =
true;
263 static ITK_CONSTEXPR_VAR
bool IsComplex =
false;
265 static ITK_CONSTEXPR_FUNC
bool OneValue() {
return One; }
267 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
272 template<
typename TArray>
281 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
294 class NumericTraits< char > :
public std::numeric_limits< char >
306 static ITK_CONSTEXPR_VAR
char ITKCommon_EXPORT
Zero = 0;
307 static ITK_CONSTEXPR_VAR
char ITKCommon_EXPORT
One = 1;
309 static ITK_CONSTEXPR_FUNC
char min() {
return char(255) < char(0) ? char(-128) : char(0); }
310 static ITK_CONSTEXPR_FUNC
char max() {
return char(255) < char(0) ? char(127) : char(255); }
312 static ITK_CONSTEXPR_FUNC
char min(
char) {
return min(); }
313 static ITK_CONSTEXPR_FUNC
char max(
char) {
return max(); }
315 static ITK_CONSTEXPR_FUNC
bool IsPositive(
char val) {
return val >
Zero; }
318 #if VCL_CHAR_IS_SIGNED
319 static ITK_CONSTEXPR_FUNC
bool IsNegative(
char val) {
return val <
Zero; }
321 static ITK_CONSTEXPR_VAR
bool IsSigned =
true;
323 static ITK_CONSTEXPR_FUNC
bool IsNegative(
char) {
return false; }
324 static ITK_CONSTEXPR_FUNC
bool IsNonnegative(
char) {
return true; }
325 static ITK_CONSTEXPR_VAR
bool IsSigned =
false;
327 static ITK_CONSTEXPR_VAR
bool IsInteger =
true;
328 static ITK_CONSTEXPR_VAR
bool IsComplex =
false;
330 static ITK_CONSTEXPR_FUNC
char OneValue() {
return One; }
332 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
337 template<
typename TArray>
346 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
358 class NumericTraits< signed char > :
public std::numeric_limits< signed char >
370 static ITK_CONSTEXPR_VAR
signed char ITKCommon_EXPORT
Zero = 0;
371 static ITK_CONSTEXPR_VAR
signed char ITKCommon_EXPORT
One = 1;
373 static ITK_CONSTEXPR_FUNC
signed char min() {
return -128; }
374 static ITK_CONSTEXPR_FUNC
signed char max() {
return 127; }
375 static ITK_CONSTEXPR_FUNC
signed char min(
signed char) {
return min(); }
376 static ITK_CONSTEXPR_FUNC
signed char max(
signed char) {
return max(); }
378 static ITK_CONSTEXPR_FUNC
bool IsPositive(
signed char val) {
return val >
Zero; }
379 static ITK_CONSTEXPR_FUNC
bool IsNonpositive(
signed char val) {
return val <=
Zero; }
380 static ITK_CONSTEXPR_FUNC
bool IsNegative(
signed char val) {
return val <
Zero; }
381 static ITK_CONSTEXPR_FUNC
bool IsNonnegative(
signed char val) {
return val >=
Zero; }
382 static ITK_CONSTEXPR_VAR
bool IsSigned =
true;
383 static ITK_CONSTEXPR_VAR
bool IsInteger =
true;
384 static ITK_CONSTEXPR_VAR
bool IsComplex =
false;
385 static ITK_CONSTEXPR_FUNC
signed char ZeroValue() {
return Zero; }
386 static ITK_CONSTEXPR_FUNC
signed char OneValue() {
return One; }
388 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
393 template<
typename TArray>
402 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
414 class NumericTraits< unsigned char > :
public std::numeric_limits< unsigned char >
426 static ITK_CONSTEXPR_VAR
unsigned char ITKCommon_EXPORT
Zero = 0;
427 static ITK_CONSTEXPR_VAR
unsigned char ITKCommon_EXPORT
One = 1;
431 static ITK_CONSTEXPR_FUNC
unsigned char NonpositiveMin() {
return std::numeric_limits< ValueType >::min(); }
432 static ITK_CONSTEXPR_FUNC
bool IsPositive(
unsigned char val) {
return val !=
Zero; }
433 static ITK_CONSTEXPR_FUNC
bool IsNonpositive(
unsigned char val) {
return val ==
Zero; }
434 static ITK_CONSTEXPR_FUNC
bool IsNegative(
unsigned char val) {
return val ?
false :
false; }
435 static ITK_CONSTEXPR_FUNC
bool IsNonnegative(
unsigned char val) {
return val ?
true :
true; }
436 static ITK_CONSTEXPR_VAR
bool IsSigned =
false;
437 static ITK_CONSTEXPR_VAR
bool IsInteger =
true;
438 static ITK_CONSTEXPR_VAR
bool IsComplex =
false;
439 static ITK_CONSTEXPR_FUNC
unsigned char ZeroValue() {
return Zero; }
440 static ITK_CONSTEXPR_FUNC
unsigned char OneValue() {
return One; }
442 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
447 template<
typename TArray>
456 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
467 class NumericTraits< short > :
public std::numeric_limits< short >
472 typedef unsigned short AbsType;
479 static ITK_CONSTEXPR_VAR
short ITKCommon_EXPORT
Zero = 0;
480 static ITK_CONSTEXPR_VAR
short ITKCommon_EXPORT
One = 1;
483 static ITK_CONSTEXPR_FUNC
short NonpositiveMin() {
return std::numeric_limits< ValueType >::min(); }
484 static ITK_CONSTEXPR_FUNC
bool IsPositive(
short val) {
return val >
Zero; }
486 static ITK_CONSTEXPR_FUNC
bool IsNegative(
short val) {
return val <
Zero; }
488 static ITK_CONSTEXPR_VAR
bool IsSigned =
true;
489 static ITK_CONSTEXPR_VAR
bool IsInteger =
true;
490 static ITK_CONSTEXPR_VAR
bool IsComplex =
false;
492 static ITK_CONSTEXPR_FUNC
short OneValue() {
return One; }
494 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
499 template<
typename TArray>
508 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
520 class NumericTraits< unsigned short > :
public std::numeric_limits< unsigned short >
525 typedef unsigned short AbsType;
532 static ITK_CONSTEXPR_VAR
unsigned short ITKCommon_EXPORT
Zero = 0;
533 static ITK_CONSTEXPR_VAR
unsigned short ITKCommon_EXPORT
One = 1;
536 static ITK_CONSTEXPR_FUNC
unsigned short NonpositiveMin() {
return std::numeric_limits< ValueType >::min(); }
537 static ITK_CONSTEXPR_FUNC
bool IsPositive(
unsigned short val) {
return val !=
Zero; }
538 static ITK_CONSTEXPR_FUNC
bool IsNonpositive(
unsigned short val) {
return val ==
Zero; }
539 static ITK_CONSTEXPR_FUNC
bool IsNegative(
unsigned short val) {
return val ?
false :
false; }
540 static ITK_CONSTEXPR_FUNC
bool IsNonnegative(
unsigned short val) {
return val ?
true :
true; }
541 static ITK_CONSTEXPR_VAR
bool IsSigned =
false;
542 static ITK_CONSTEXPR_VAR
bool IsInteger =
true;
543 static ITK_CONSTEXPR_VAR
bool IsComplex =
false;
544 static ITK_CONSTEXPR_FUNC
unsigned short ZeroValue() {
return Zero; }
545 static ITK_CONSTEXPR_FUNC
unsigned short OneValue() {
return One; }
547 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
552 template<
typename TArray>
561 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
572 class NumericTraits< int > :
public std::numeric_limits< int >
584 static ITK_CONSTEXPR_VAR
int ITKCommon_EXPORT
Zero = 0;
585 static ITK_CONSTEXPR_VAR
int ITKCommon_EXPORT
One = 1;
588 static ITK_CONSTEXPR_FUNC
int NonpositiveMin() {
return std::numeric_limits< ValueType >::min(); }
589 static ITK_CONSTEXPR_FUNC
bool IsPositive(
int val) {
return val >
Zero; }
591 static ITK_CONSTEXPR_FUNC
bool IsNegative(
int val) {
return val <
Zero; }
593 static ITK_CONSTEXPR_VAR
bool IsSigned =
true;
594 static ITK_CONSTEXPR_VAR
bool IsInteger =
true;
595 static ITK_CONSTEXPR_VAR
bool IsComplex =
false;
597 static ITK_CONSTEXPR_FUNC
int OneValue() {
return One; }
599 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
604 template<
typename TArray>
613 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
625 class NumericTraits< unsigned int > :
public std::numeric_limits< unsigned int >
637 static ITK_CONSTEXPR_VAR
unsigned int ITKCommon_EXPORT
Zero = 0;
638 static ITK_CONSTEXPR_VAR
unsigned int ITKCommon_EXPORT
One = 1;
640 static ITK_CONSTEXPR_FUNC
unsigned int min(
void) {
return 0; }
641 static ITK_CONSTEXPR_FUNC
unsigned int max(
void) {
return static_cast< unsigned int >( -1 ); }
642 static ITK_CONSTEXPR_FUNC
unsigned int min(
unsigned int) {
return std::numeric_limits< ValueType >::min(); }
643 static ITK_CONSTEXPR_FUNC
unsigned int max(
unsigned int) {
return std::numeric_limits< ValueType >::max(); }
644 static ITK_CONSTEXPR_FUNC
unsigned int NonpositiveMin() {
return 0; }
645 static ITK_CONSTEXPR_FUNC
bool IsPositive(
unsigned int val) {
return val !=
Zero; }
646 static ITK_CONSTEXPR_FUNC
bool IsNonpositive(
unsigned int val) {
return val ==
Zero; }
647 static ITK_CONSTEXPR_FUNC
bool IsNegative(
unsigned int val) {
return val ?
false :
false; }
648 static ITK_CONSTEXPR_FUNC
bool IsNonnegative(
unsigned int val) {
return val ?
true :
true; }
649 static ITK_CONSTEXPR_VAR
bool IsSigned =
false;
650 static ITK_CONSTEXPR_VAR
bool IsInteger =
true;
651 static ITK_CONSTEXPR_VAR
bool IsComplex =
false;
652 static ITK_CONSTEXPR_FUNC
unsigned int ZeroValue() {
return Zero; }
653 static ITK_CONSTEXPR_FUNC
unsigned int OneValue() {
return One; }
655 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
660 template<
typename TArray>
669 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
681 class NumericTraits< long > :
public std::numeric_limits< long >
693 static ITK_CONSTEXPR_VAR
long ITKCommon_EXPORT
Zero = 0L;
694 static ITK_CONSTEXPR_VAR
long ITKCommon_EXPORT
One = 1L;
697 static ITK_CONSTEXPR_FUNC
long NonpositiveMin() {
return std::numeric_limits< ValueType >::min(); }
698 static ITK_CONSTEXPR_FUNC
bool IsPositive(
long val) {
return val >
Zero; }
700 static ITK_CONSTEXPR_FUNC
bool IsNegative(
long val) {
return val <
Zero; }
702 static ITK_CONSTEXPR_VAR
bool IsSigned =
true;
703 static ITK_CONSTEXPR_VAR
bool IsInteger =
true;
704 static ITK_CONSTEXPR_VAR
bool IsComplex =
false;
706 static ITK_CONSTEXPR_FUNC
long OneValue() {
return One; }
708 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
713 template<
typename TArray>
722 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
734 class NumericTraits< unsigned long > :
public std::numeric_limits< unsigned long >
746 static ITK_CONSTEXPR_VAR
unsigned long ITKCommon_EXPORT
Zero = 0UL;
747 static ITK_CONSTEXPR_VAR
unsigned long ITKCommon_EXPORT
One = 1UL;
750 static ITK_CONSTEXPR_FUNC
unsigned long NonpositiveMin() {
return std::numeric_limits< ValueType >::min(); }
751 static ITK_CONSTEXPR_FUNC
bool IsPositive(
unsigned long val) {
return val !=
Zero; }
752 static ITK_CONSTEXPR_FUNC
bool IsNonpositive(
unsigned long val) {
return val ==
Zero; }
753 static ITK_CONSTEXPR_FUNC
bool IsNegative(
unsigned long) {
return false; }
754 static ITK_CONSTEXPR_FUNC
bool IsNonnegative(
unsigned long) {
return true; }
755 static ITK_CONSTEXPR_VAR
bool IsSigned =
false;
756 static ITK_CONSTEXPR_VAR
bool IsInteger =
true;
757 static ITK_CONSTEXPR_VAR
bool IsComplex =
false;
758 static ITK_CONSTEXPR_FUNC
unsigned long ZeroValue() {
return Zero; }
759 static ITK_CONSTEXPR_FUNC
unsigned long OneValue() {
return One; }
761 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
766 template<
typename TArray>
775 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
787 class NumericTraits< float > :
public std::numeric_limits< float >
804 static ITK_CONSTEXPR_FUNC
float NonpositiveMin() {
return -std::numeric_limits< ValueType >::max(); }
805 static ITK_CONSTEXPR_FUNC
bool IsPositive(
float val) {
return val >
Zero; }
807 static ITK_CONSTEXPR_FUNC
bool IsNegative(
float val) {
return val <
Zero; }
809 static ITK_CONSTEXPR_VAR
bool IsSigned =
true;
810 static ITK_CONSTEXPR_VAR
bool IsInteger =
false;
811 static ITK_CONSTEXPR_VAR
bool IsComplex =
false;
813 static ITK_CONSTEXPR_FUNC
float OneValue() {
return One; }
815 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
820 template<
typename TArray>
829 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
841 class NumericTraits< double > :
public std::numeric_limits< double >
857 static ITK_CONSTEXPR_FUNC
double NonpositiveMin() {
return -std::numeric_limits< ValueType >::max(); }
858 static ITK_CONSTEXPR_FUNC
bool IsPositive(
double val) {
return val >
Zero; }
860 static ITK_CONSTEXPR_FUNC
bool IsNegative(
double val) {
return val <
Zero; }
862 static ITK_CONSTEXPR_VAR
bool IsSigned =
true;
863 static ITK_CONSTEXPR_VAR
bool IsInteger =
false;
864 static ITK_CONSTEXPR_VAR
bool IsComplex =
false;
865 static ITK_CONSTEXPR_FUNC
double ZeroValue() {
return Zero; }
866 static ITK_CONSTEXPR_FUNC
double OneValue() {
return One; }
868 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
873 template<
typename TArray>
882 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
894 class NumericTraits< long double > :
public std::numeric_limits< long double >
898 #if defined( __SUNPRO_CC ) && defined( _ILP32 )
918 static ITK_CONSTEXPR_FUNC
long double NonpositiveMin() {
return -std::numeric_limits< ValueType >::max(); }
919 static ITK_CONSTEXPR_FUNC
bool IsPositive(
long double val) {
return val >
Zero; }
920 static ITK_CONSTEXPR_FUNC
bool IsNonpositive(
long double val) {
return val <=
Zero; }
921 static ITK_CONSTEXPR_FUNC
bool IsNegative(
long double val) {
return val <
Zero; }
922 static ITK_CONSTEXPR_FUNC
bool IsNonnegative(
long double val) {
return val >=
Zero; }
923 static ITK_CONSTEXPR_VAR
bool IsSigned =
true;
924 static ITK_CONSTEXPR_VAR
bool IsInteger =
false;
925 static ITK_CONSTEXPR_VAR
bool IsComplex =
false;
926 static ITK_CONSTEXPR_FUNC
long double ZeroValue() {
return Zero; }
927 static ITK_CONSTEXPR_FUNC
long double OneValue() {
return One; }
929 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
934 template<
typename TArray>
943 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
956 class NumericTraits< long long > :
957 public std::numeric_limits< long long >
969 static ITK_CONSTEXPR_VAR
ValueType ITKCommon_EXPORT
Zero = 0LL;
970 static ITK_CONSTEXPR_VAR
ValueType ITKCommon_EXPORT
One = 1LL;
978 static ITK_CONSTEXPR_VAR
bool IsSigned =
true;
979 static ITK_CONSTEXPR_VAR
bool IsInteger =
true;
980 static ITK_CONSTEXPR_VAR
bool IsComplex =
false;
984 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
989 template<
typename TArray>
998 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
1010 class NumericTraits< unsigned long long > :
1011 public std::numeric_limits< unsigned long long >
1016 typedef unsigned long long AbsType;
1023 static ITK_CONSTEXPR_VAR
ValueType ITKCommon_EXPORT
Zero = 0ULL;
1024 static ITK_CONSTEXPR_VAR
ValueType ITKCommon_EXPORT
One = 1ULL;
1032 static ITK_CONSTEXPR_VAR
bool IsSigned =
false;
1033 static ITK_CONSTEXPR_VAR
bool IsInteger =
true;
1034 static ITK_CONSTEXPR_VAR
bool IsComplex =
false;
1038 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
1043 template<
typename TArray>
1052 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
1065 class NumericTraits< std::complex< char > >
1068 typedef std::complex< char > Self;
1070 typedef Self TheType;
1075 typedef std::complex< double >
RealType;
1077 typedef std::complex< float >
FloatType;
1080 static const Self ITKCommon_EXPORT
Zero;
1081 static const Self ITKCommon_EXPORT
One;
1083 static Self
min() {
return std::numeric_limits< Self >::min(); }
1084 static Self
max() {
return std::numeric_limits< Self >::max(); }
1085 static Self
min(Self) {
return min(); }
1086 static Self
max(Self) {
return max(); }
1089 return Self(NumericTraits< ValueType >::NonpositiveMin(), 0);
1092 static bool IsPositive(Self val) {
return val.real() > 0; }
1093 static bool IsNonpositive(Self val) {
return val.real() <= 0; }
1095 #if VCL_CHAR_IS_SIGNED
1096 static bool IsNegative(Self val) {
return val.real() < 0; }
1097 static bool IsNonnegative(Self val) {
return val.real() >= 0; }
1099 static bool IsNegative(Self) {
return false; }
1102 static ITK_CONSTEXPR_VAR
bool IsSigned = NumericTraits< ValueType >::IsSigned;
1103 static ITK_CONSTEXPR_VAR
bool IsInteger =
false;
1104 static ITK_CONSTEXPR_VAR
bool IsComplex =
true;
1107 static unsigned int GetLength(
const Self &) {
return 2; }
1108 static unsigned int GetLength() {
return 2; }
1112 template<
typename TArray>
1118 static void SetLength(Self & m,
const unsigned int s)
1122 itkGenericExceptionMacro(<<
"Cannot set the size of a complex to " << s);
1134 class NumericTraits< std::complex< unsigned char > >
1137 typedef std::complex< unsigned char > Self;
1139 typedef Self TheType;
1141 typedef std::complex< unsigned int >
PrintType;
1144 typedef std::complex< double >
RealType;
1146 typedef std::complex< float >
FloatType;
1149 static const Self ITKCommon_EXPORT
Zero;
1150 static const Self ITKCommon_EXPORT
One;
1152 static Self
min() {
return std::numeric_limits< Self >::min(); }
1153 static Self
max() {
return std::numeric_limits< Self >::max(); }
1154 static Self
min(Self) {
return min(); }
1155 static Self
max(Self) {
return max(); }
1158 return Self(NumericTraits< ValueType >::NonpositiveMin(), 0);
1161 static bool IsPositive(Self val) {
return val.real() > 0; }
1162 static bool IsNonpositive(Self val) {
return val.real() == 0; }
1163 static bool IsNegative(Self) {
return false; }
1165 static ITK_CONSTEXPR_VAR
bool IsSigned = NumericTraits< ValueType >::IsSigned;
1166 static ITK_CONSTEXPR_VAR
bool IsInteger =
false;
1167 static ITK_CONSTEXPR_VAR
bool IsComplex =
true;
1170 static unsigned int GetLength(
const Self &) {
return 2; }
1171 static unsigned int GetLength() {
return 2; }
1175 template<
typename TArray>
1181 static void SetLength(Self & m,
const unsigned int s)
1185 itkGenericExceptionMacro(<<
"Cannot set the size of a complex to " << s);
1197 class NumericTraits< std::complex< short > >
1200 typedef std::complex< short > Self;
1202 typedef Self TheType;
1207 typedef std::complex< double >
RealType;
1209 typedef std::complex< float >
FloatType;
1212 static const Self ITKCommon_EXPORT
Zero;
1213 static const Self ITKCommon_EXPORT
One;
1215 static Self
min() {
return std::numeric_limits< Self >::min(); }
1216 static Self
max() {
return std::numeric_limits< Self >::max(); }
1217 static Self
min(Self) {
return min(); }
1218 static Self
max(Self) {
return max(); }
1221 return Self(NumericTraits< ValueType >::NonpositiveMin(), 0);
1224 static bool IsPositive(Self val) {
return val.real() > 0; }
1225 static bool IsNonpositive(Self val) {
return val.real() <= 0; }
1226 static bool IsNegative(Self val) {
return val.real() < 0; }
1227 static bool IsNonnegative(Self val) {
return val.real() >= 0; }
1228 static ITK_CONSTEXPR_VAR
bool IsSigned = NumericTraits< ValueType >::IsSigned;
1229 static ITK_CONSTEXPR_VAR
bool IsInteger =
false;
1230 static ITK_CONSTEXPR_VAR
bool IsComplex =
true;
1233 static unsigned int GetLength(
const Self &) {
return 2; }
1234 static unsigned int GetLength() {
return 2; }
1238 template<
typename TArray>
1244 static void SetLength(Self & m,
const unsigned int s)
1248 itkGenericExceptionMacro(<<
"Cannot set the size of a complex to " << s);
1260 class NumericTraits< std::complex< unsigned short > >
1263 typedef std::complex< unsigned short > Self;
1265 typedef Self TheType;
1270 typedef std::complex< double >
RealType;
1272 typedef std::complex< float >
FloatType;
1275 static const Self ITKCommon_EXPORT
Zero;
1276 static const Self ITKCommon_EXPORT
One;
1278 static Self
min() {
return std::numeric_limits< Self >::min(); }
1279 static Self
max() {
return std::numeric_limits< Self >::max(); }
1280 static Self
min(Self) {
return min(); }
1281 static Self
max(Self) {
return max(); }
1284 return Self(NumericTraits< ValueType >::NonpositiveMin(), 0);
1287 static bool IsPositive(Self val) {
return val.real() > 0; }
1288 static bool IsNonpositive(Self val) {
return val.real() == 0; }
1289 static bool IsNegative(Self) {
return false; }
1291 static ITK_CONSTEXPR_VAR
bool IsSigned = NumericTraits< ValueType >::IsSigned;
1292 static ITK_CONSTEXPR_VAR
bool IsInteger =
false;
1293 static ITK_CONSTEXPR_VAR
bool IsComplex =
true;
1296 static unsigned int GetLength(
const Self &) {
return 2; }
1297 static unsigned int GetLength() {
return 2; }
1301 template<
typename TArray>
1307 static void SetLength(Self & m,
const unsigned int s)
1311 itkGenericExceptionMacro(<<
"Cannot set the size of a complex to " << s);
1323 class NumericTraits< std::complex< int > >
1326 typedef std::complex< int > Self;
1328 typedef Self TheType;
1333 typedef std::complex< double >
RealType;
1335 typedef std::complex< float >
FloatType;
1338 static const Self ITKCommon_EXPORT
Zero;
1339 static const Self ITKCommon_EXPORT
One;
1341 static Self
min() {
return std::numeric_limits< Self >::min(); }
1342 static Self
max() {
return std::numeric_limits< Self >::max(); }
1343 static Self
min(Self) {
return min(); }
1344 static Self
max(Self) {
return max(); }
1347 return Self(NumericTraits< ValueType >::NonpositiveMin(), 0);
1350 static bool IsPositive(Self val) {
return val.real() > 0; }
1351 static bool IsNonpositive(Self val) {
return val.real() <= 0; }
1352 static bool IsNegative(Self val) {
return val.real() < 0; }
1353 static bool IsNonnegative(Self val) {
return val.real() >= 0; }
1354 static ITK_CONSTEXPR_VAR
bool IsSigned = NumericTraits< ValueType >::IsSigned;
1355 static ITK_CONSTEXPR_VAR
bool IsInteger =
false;
1356 static ITK_CONSTEXPR_VAR
bool IsComplex =
true;
1359 static unsigned int GetLength(
const Self &) {
return 2; }
1360 static unsigned int GetLength() {
return 2; }
1364 template<
typename TArray>
1370 static void SetLength(Self & m,
const unsigned int s)
1374 itkGenericExceptionMacro(<<
"Cannot set the size of a complex to " << s);
1386 class NumericTraits< std::complex< unsigned int > >
1389 typedef std::complex< unsigned int > Self;
1391 typedef Self TheType;
1396 typedef std::complex< double >
RealType;
1398 typedef std::complex< float >
FloatType;
1401 static const Self ITKCommon_EXPORT
Zero;
1402 static const Self ITKCommon_EXPORT
One;
1404 static Self
min() {
return std::numeric_limits< Self >::min(); }
1405 static Self
max() {
return std::numeric_limits< Self >::max(); }
1406 static Self
min(Self) {
return min(); }
1407 static Self
max(Self) {
return max(); }
1410 return Self(NumericTraits< ValueType >::NonpositiveMin(), 0);
1413 static bool IsPositive(Self val) {
return val.real() > 0; }
1414 static bool IsNonpositive(Self val) {
return val.real() == 0; }
1415 static bool IsNegative(Self) {
return false; }
1417 static ITK_CONSTEXPR_VAR
bool IsSigned = NumericTraits< ValueType >::IsSigned;
1418 static ITK_CONSTEXPR_VAR
bool IsInteger =
false;
1419 static ITK_CONSTEXPR_VAR
bool IsComplex =
true;
1422 static unsigned int GetLength(
const Self &) {
return 2; }
1423 static unsigned int GetLength() {
return 2; }
1427 template<
typename TArray>
1433 static void SetLength(Self & m,
const unsigned int s)
1437 itkGenericExceptionMacro(<<
"Cannot set the size of a complex to " << s);
1449 class NumericTraits< std::complex< long > >
1452 typedef std::complex< long > Self;
1454 typedef Self TheType;
1459 typedef std::complex< double >
RealType;
1461 typedef std::complex< float >
FloatType;
1464 static const Self ITKCommon_EXPORT
Zero;
1465 static const Self ITKCommon_EXPORT
One;
1467 static Self
min() {
return std::numeric_limits< Self >::min(); }
1468 static Self
max() {
return std::numeric_limits< Self >::max(); }
1469 static Self
min(Self) {
return min(); }
1470 static Self
max(Self) {
return max(); }
1473 return Self(NumericTraits< ValueType >::NonpositiveMin(), 0);
1476 static bool IsPositive(Self val) {
return val.real() > 0; }
1477 static bool IsNonpositive(Self val) {
return val.real() <= 0; }
1478 static bool IsNegative(Self val) {
return val.real() < 0; }
1479 static bool IsNonnegative(Self val) {
return val.real() >= 0; }
1480 static ITK_CONSTEXPR_VAR
bool IsSigned = NumericTraits< ValueType >::IsSigned;
1481 static ITK_CONSTEXPR_VAR
bool IsInteger =
false;
1482 static ITK_CONSTEXPR_VAR
bool IsComplex =
true;
1485 static unsigned int GetLength(
const Self &) {
return 2; }
1486 static unsigned int GetLength() {
return 2; }
1490 template<
typename TArray>
1496 static void SetLength(Self & m,
const unsigned int s)
1500 itkGenericExceptionMacro(<<
"Cannot set the size of a complex to " << s);
1512 class NumericTraits< std::complex< unsigned long > >
1515 typedef std::complex< unsigned long > Self;
1517 typedef Self TheType;
1522 typedef std::complex< double >
RealType;
1524 typedef std::complex< float >
FloatType;
1527 static const Self ITKCommon_EXPORT
Zero;
1528 static const Self ITKCommon_EXPORT
One;
1530 static Self
min() {
return std::numeric_limits< Self >::min(); }
1531 static Self
max() {
return std::numeric_limits< Self >::max(); }
1532 static Self
min(Self) {
return min(); }
1533 static Self
max(Self) {
return max(); }
1536 return Self(NumericTraits< ValueType >::NonpositiveMin(), 0);
1539 static bool IsPositive(Self val) {
return val.real() > 0; }
1540 static bool IsNonpositive(Self val) {
return val.real() == 0; }
1541 static bool IsNegative(Self) {
return false; }
1543 static ITK_CONSTEXPR_VAR
bool IsSigned = NumericTraits< ValueType >::IsSigned;
1544 static ITK_CONSTEXPR_VAR
bool IsInteger =
false;
1545 static ITK_CONSTEXPR_VAR
bool IsComplex =
true;
1548 static unsigned int GetLength(
const Self &) {
return 2; }
1549 static unsigned int GetLength() {
return 2; }
1553 template<
typename TArray>
1559 static void SetLength(Self & m,
const unsigned int s)
1563 itkGenericExceptionMacro(<<
"Cannot set the size of a complex to " << s);
1575 class NumericTraits< std::complex< float > >
1578 typedef std::complex< float > Self;
1580 typedef Self TheType;
1585 typedef std::complex< double >
RealType;
1587 typedef std::complex< float >
FloatType;
1590 static const Self ITKCommon_EXPORT
Zero;
1591 static const Self ITKCommon_EXPORT
One;
1593 static Self
min() {
return std::numeric_limits< Self >::min(); }
1594 static Self
max() {
return std::numeric_limits< Self >::max(); }
1595 static Self
min(Self) {
return min(); }
1596 static Self
max(Self) {
return max(); }
1599 return Self(NumericTraits< float >::NonpositiveMin(), 0.0f);
1602 static bool IsPositive(Self val) {
return val.real() > 0.0; }
1603 static bool IsNonpositive(Self val) {
return val.real() <= 0.0; }
1604 static bool IsNegative(Self val) {
return val.real() < 0.0; }
1605 static bool IsNonnegative(Self val) {
return val.real() >= 0.0; }
1606 static ITK_CONSTEXPR_VAR
bool IsSigned = NumericTraits< ValueType >::IsSigned;
1607 static ITK_CONSTEXPR_VAR
bool IsInteger =
false;
1608 static ITK_CONSTEXPR_VAR
bool IsComplex =
true;
1611 static unsigned int GetLength(
const Self &) {
return 2; }
1612 static unsigned int GetLength() {
return 2; }
1616 template<
typename TArray>
1622 static void SetLength(Self & m,
const unsigned int s)
1626 itkGenericExceptionMacro(<<
"Cannot set the size of a complex to " << s);
1638 class NumericTraits< std::complex< double > >
1641 typedef std::complex< double > Self;
1643 typedef Self TheType;
1648 typedef std::complex< double >
RealType;
1650 typedef std::complex< float >
FloatType;
1653 static const Self ITKCommon_EXPORT
Zero;
1654 static const Self ITKCommon_EXPORT
One;
1656 static Self
min() {
return std::numeric_limits< ValueType >::min(); }
1657 static Self
max() {
return std::numeric_limits< ValueType >::max(); }
1658 static Self
min(Self) {
return min(); }
1659 static Self
max(Self) {
return max(); }
1662 return Self(NumericTraits< double >::NonpositiveMin(), 0.0);
1665 static bool IsPositive(Self val) {
return val.real() > 0.0; }
1666 static bool IsNonpositive(Self val) {
return val.real() <= 0.0; }
1667 static bool IsNegative(Self val) {
return val.real() < 0.0; }
1668 static bool IsNonnegative(Self val) {
return val.real() >= 0.0; }
1669 static ITK_CONSTEXPR_VAR
bool IsSigned = NumericTraits< ValueType >::IsSigned;
1670 static ITK_CONSTEXPR_VAR
bool IsInteger =
false;
1671 static ITK_CONSTEXPR_VAR
bool IsComplex =
true;
1674 static unsigned int GetLength(
const Self &) {
return 2; }
1675 static unsigned int GetLength() {
return 2; }
1679 template<
typename TArray>
1685 static void SetLength(Self & m,
const unsigned int s)
1689 itkGenericExceptionMacro(<<
"Cannot set the size of a complex to " << s);
1701 class NumericTraits< std::complex< long double > >
1704 typedef std::complex< long double > Self;
1706 typedef Self TheType;
1711 typedef std::complex< long double >
RealType;
1713 typedef std::complex< float >
FloatType;
1716 static const Self ITKCommon_EXPORT
Zero;
1717 static const Self ITKCommon_EXPORT
One;
1719 static Self
min() {
return std::numeric_limits< ValueType >::min(); }
1720 static Self
max() {
return std::numeric_limits< ValueType >::max(); }
1721 static Self
min(Self) {
return min(); }
1722 static Self
max(Self) {
return max(); }
1725 return Self(NumericTraits< ValueType >::NonpositiveMin(), 0.0);
1728 static bool IsPositive(Self val) {
return val.real() > 0.0; }
1729 static bool IsNonpositive(Self val) {
return val.real() <= 0.0; }
1730 static bool IsNegative(Self val) {
return val.real() < 0.0; }
1731 static bool IsNonnegative(Self val) {
return val.real() >= 0.0; }
1732 static ITK_CONSTEXPR_VAR
bool IsSigned = NumericTraits< ValueType >::IsSigned;
1733 static ITK_CONSTEXPR_VAR
bool IsInteger =
false;
1734 static ITK_CONSTEXPR_VAR
bool IsComplex =
true;
1737 static unsigned int GetLength(
const Self &) {
return 2; }
1738 static unsigned int GetLength() {
return 2; }
1742 template<
typename TArray>
1748 static void SetLength(Self & m,
const unsigned int s)
1752 itkGenericExceptionMacro(<<
"Cannot set the size of a complex to " << s);
1762 #undef itkNUMERIC_TRAITS_C11_ASSINMENT
1765 #endif // itkNumericTraits_h
#define itkNUMERIC_TRAITS_MIN_MAX_MACRO()
static T OneValue(const T &)
static ITK_CONSTEXPR_VAR bool IsComplex
static void AssignToArray(const T &v, TArray &mv)
static bool IsPositive(T val)
static ITK_CONSTEXPR_VAR bool IsInteger
Simulate a standard C array with copy semnatics.
static ITK_CONSTEXPR_FUNC T max(const T &)
static bool IsNonnegative(T val)
static T NonpositiveMin(const T &)
std::numeric_limits< T > TraitsType
static unsigned int GetLength()
static void SetLength(T &m, const unsigned int s)
static bool IsNegative(T val)
static T ZeroValue(const T &)
#define itkNUMERIC_TRAITS_C11_ASSINMENT(x)
static ITK_CONSTEXPR_FUNC T NonpositiveMin()
static ITK_CONSTEXPR_FUNC T min(const T &)
static ITK_CONSTEXPR_VAR bool IsSigned
static bool IsNonpositive(T val)
FixedArray< ValueType, 1 > MeasurementVectorType
Define additional traits for native types such as int or float.
static unsigned int GetLength(const T &)