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_COMPILED_CXX_VERSION >= 201103L) 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
bool Zero =
false;
250 static ITK_CONSTEXPR
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
bool IsSigned =
false;
262 static ITK_CONSTEXPR
bool IsInteger =
true;
263 static ITK_CONSTEXPR
bool IsComplex =
false;
265 static ITK_CONSTEXPR_FUNC
bool OneValue() {
return One; }
266 static ITK_CONSTEXPR_FUNC
unsigned int GetLength(
const ValueType &) {
return 1; }
267 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
269 static ITK_CONSTEXPR_FUNC ValueType
ZeroValue(
const ValueType &) {
return ZeroValue(); }
270 static ITK_CONSTEXPR_FUNC ValueType
OneValue(
const ValueType &) {
return OneValue(); }
272 template<
typename TArray>
273 static void AssignToArray(
const ValueType & v, TArray & mv )
277 static void SetLength(ValueType & m,
const unsigned int s)
281 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
294 class NumericTraits< char > :
public std::numeric_limits< char >
306 static ITK_CONSTEXPR
char ITKCommon_EXPORT
Zero = 0;
307 static ITK_CONSTEXPR
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
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
bool IsSigned =
false;
327 static ITK_CONSTEXPR
bool IsInteger =
true;
328 static ITK_CONSTEXPR
bool IsComplex =
false;
330 static ITK_CONSTEXPR_FUNC
char OneValue() {
return One; }
331 static ITK_CONSTEXPR_FUNC
unsigned int GetLength(
const ValueType &) {
return 1; }
332 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
334 static ITK_CONSTEXPR_FUNC ValueType
ZeroValue(
const ValueType &) {
return ZeroValue(); }
335 static ITK_CONSTEXPR_FUNC ValueType
OneValue(
const ValueType &) {
return OneValue(); }
337 template<
typename TArray>
338 static void AssignToArray(
const ValueType & v, TArray & mv )
342 static void SetLength(ValueType & m,
const unsigned int s)
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
signed char ITKCommon_EXPORT
Zero = 0;
371 static ITK_CONSTEXPR
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
bool IsSigned =
true;
383 static ITK_CONSTEXPR
bool IsInteger =
true;
384 static ITK_CONSTEXPR
bool IsComplex =
false;
385 static ITK_CONSTEXPR_FUNC
signed char ZeroValue() {
return Zero; }
386 static ITK_CONSTEXPR_FUNC
signed char OneValue() {
return One; }
387 static ITK_CONSTEXPR_FUNC
unsigned int GetLength(
const ValueType &) {
return 1; }
388 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
390 static ITK_CONSTEXPR_FUNC ValueType
ZeroValue(
const ValueType &) {
return ZeroValue(); }
391 static ITK_CONSTEXPR_FUNC ValueType
OneValue(
const ValueType &) {
return OneValue(); }
393 template<
typename TArray>
394 static void AssignToArray(
const ValueType & v, TArray & mv )
398 static void SetLength(ValueType & m,
const unsigned int s)
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
unsigned char ITKCommon_EXPORT
Zero = 0;
427 static ITK_CONSTEXPR
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
bool IsSigned =
false;
437 static ITK_CONSTEXPR
bool IsInteger =
true;
438 static ITK_CONSTEXPR
bool IsComplex =
false;
439 static ITK_CONSTEXPR_FUNC
unsigned char ZeroValue() {
return Zero; }
440 static ITK_CONSTEXPR_FUNC
unsigned char OneValue() {
return One; }
441 static ITK_CONSTEXPR_FUNC
unsigned int GetLength(
const ValueType &) {
return 1; }
442 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
444 static ITK_CONSTEXPR_FUNC ValueType
ZeroValue(
const ValueType &) {
return ZeroValue(); }
445 static ITK_CONSTEXPR_FUNC ValueType
OneValue(
const ValueType &) {
return OneValue(); }
447 template<
typename TArray>
448 static void AssignToArray(
const ValueType & v, TArray & mv )
452 static void SetLength(ValueType & m,
const unsigned int s)
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
short ITKCommon_EXPORT
Zero = 0;
480 static ITK_CONSTEXPR
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
bool IsSigned =
true;
489 static ITK_CONSTEXPR
bool IsInteger =
true;
490 static ITK_CONSTEXPR
bool IsComplex =
false;
492 static ITK_CONSTEXPR_FUNC
short OneValue() {
return One; }
493 static ITK_CONSTEXPR_FUNC
unsigned int GetLength(
const ValueType &) {
return 1; }
494 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
496 static ITK_CONSTEXPR_FUNC ValueType
ZeroValue(
const ValueType &) {
return ZeroValue(); }
497 static ITK_CONSTEXPR_FUNC ValueType
OneValue(
const ValueType &) {
return OneValue(); }
499 template<
typename TArray>
500 static void AssignToArray(
const ValueType & v, TArray & mv )
504 static void SetLength(ValueType & m,
const unsigned int s)
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
unsigned short ITKCommon_EXPORT
Zero = 0;
533 static ITK_CONSTEXPR
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
bool IsSigned =
false;
542 static ITK_CONSTEXPR
bool IsInteger =
true;
543 static ITK_CONSTEXPR
bool IsComplex =
false;
544 static ITK_CONSTEXPR_FUNC
unsigned short ZeroValue() {
return Zero; }
545 static ITK_CONSTEXPR_FUNC
unsigned short OneValue() {
return One; }
546 static ITK_CONSTEXPR_FUNC
unsigned int GetLength(
const ValueType &) {
return 1; }
547 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
549 static ITK_CONSTEXPR_FUNC ValueType
ZeroValue(
const ValueType &) {
return ZeroValue(); }
550 static ITK_CONSTEXPR_FUNC ValueType
OneValue(
const ValueType &) {
return OneValue(); }
552 template<
typename TArray>
553 static void AssignToArray(
const ValueType & v, TArray & mv )
557 static void SetLength(ValueType & m,
const unsigned int s)
561 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
572 class NumericTraits< int > :
public std::numeric_limits< int >
584 static ITK_CONSTEXPR
int ITKCommon_EXPORT
Zero = 0;
585 static ITK_CONSTEXPR
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
bool IsSigned =
true;
594 static ITK_CONSTEXPR
bool IsInteger =
true;
595 static ITK_CONSTEXPR
bool IsComplex =
false;
597 static ITK_CONSTEXPR_FUNC
int OneValue() {
return One; }
598 static ITK_CONSTEXPR_FUNC
unsigned int GetLength(
const ValueType &) {
return 1; }
599 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
601 static ITK_CONSTEXPR_FUNC ValueType
ZeroValue(
const ValueType &) {
return ZeroValue(); }
602 static ITK_CONSTEXPR_FUNC ValueType
OneValue(
const ValueType &) {
return OneValue(); }
604 template<
typename TArray>
605 static void AssignToArray(
const ValueType & v, TArray & mv )
609 static void SetLength(ValueType & m,
const unsigned int s)
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
unsigned int ITKCommon_EXPORT
Zero = 0;
638 static ITK_CONSTEXPR
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
bool IsSigned =
false;
650 static ITK_CONSTEXPR
bool IsInteger =
true;
651 static ITK_CONSTEXPR
bool IsComplex =
false;
652 static ITK_CONSTEXPR_FUNC
unsigned int ZeroValue() {
return Zero; }
653 static ITK_CONSTEXPR_FUNC
unsigned int OneValue() {
return One; }
654 static ITK_CONSTEXPR_FUNC
unsigned int GetLength(
const ValueType &) {
return 1; }
655 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
657 static ITK_CONSTEXPR_FUNC ValueType
ZeroValue(
const ValueType &) {
return ZeroValue(); }
658 static ITK_CONSTEXPR_FUNC ValueType
OneValue(
const ValueType &) {
return OneValue(); }
660 template<
typename TArray>
661 static void AssignToArray(
const ValueType & v, TArray & mv )
665 static void SetLength(ValueType & m,
const unsigned int s)
669 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
681 class NumericTraits< long > :
public std::numeric_limits< long >
693 static ITK_CONSTEXPR
long ITKCommon_EXPORT
Zero = 0L;
694 static ITK_CONSTEXPR
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
bool IsSigned =
true;
703 static ITK_CONSTEXPR
bool IsInteger =
true;
704 static ITK_CONSTEXPR
bool IsComplex =
false;
706 static ITK_CONSTEXPR_FUNC
long OneValue() {
return One; }
707 static ITK_CONSTEXPR_FUNC
unsigned int GetLength(
const ValueType &) {
return 1; }
708 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
710 static ITK_CONSTEXPR_FUNC ValueType
ZeroValue(
const ValueType &) {
return ZeroValue(); }
711 static ITK_CONSTEXPR_FUNC ValueType
OneValue(
const ValueType &) {
return OneValue(); }
713 template<
typename TArray>
714 static void AssignToArray(
const ValueType & v, TArray & mv )
718 static void SetLength(ValueType & m,
const unsigned int s)
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
unsigned long ITKCommon_EXPORT
Zero = 0UL;
747 static ITK_CONSTEXPR
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
bool IsSigned =
false;
756 static ITK_CONSTEXPR
bool IsInteger =
true;
757 static ITK_CONSTEXPR
bool IsComplex =
false;
758 static ITK_CONSTEXPR_FUNC
unsigned long ZeroValue() {
return Zero; }
759 static ITK_CONSTEXPR_FUNC
unsigned long OneValue() {
return One; }
760 static ITK_CONSTEXPR_FUNC
unsigned int GetLength(
const ValueType &) {
return 1; }
761 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
763 static ITK_CONSTEXPR_FUNC ValueType
ZeroValue(
const ValueType &) {
return ZeroValue(); }
764 static ITK_CONSTEXPR_FUNC ValueType
OneValue(
const ValueType &) {
return OneValue(); }
766 template<
typename TArray>
767 static void AssignToArray(
const ValueType & v, TArray & mv )
771 static void SetLength(ValueType & m,
const unsigned int s)
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
bool IsSigned =
true;
810 static ITK_CONSTEXPR
bool IsInteger =
false;
811 static ITK_CONSTEXPR
bool IsComplex =
false;
813 static ITK_CONSTEXPR_FUNC
float OneValue() {
return One; }
814 static ITK_CONSTEXPR_FUNC
unsigned int GetLength(
const ValueType &) {
return 1; }
815 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
817 static ITK_CONSTEXPR_FUNC ValueType
ZeroValue(
const ValueType &) {
return ZeroValue(); }
818 static ITK_CONSTEXPR_FUNC ValueType
OneValue(
const ValueType &) {
return OneValue(); }
820 template<
typename TArray>
821 static void AssignToArray(
const ValueType & v, TArray & mv )
825 static void SetLength(ValueType & m,
const unsigned int s)
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
bool IsSigned =
true;
863 static ITK_CONSTEXPR
bool IsInteger =
false;
864 static ITK_CONSTEXPR
bool IsComplex =
false;
865 static ITK_CONSTEXPR_FUNC
double ZeroValue() {
return Zero; }
866 static ITK_CONSTEXPR_FUNC
double OneValue() {
return One; }
867 static ITK_CONSTEXPR_FUNC
unsigned int GetLength(
const ValueType &) {
return 1; }
868 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
870 static ITK_CONSTEXPR_FUNC ValueType
ZeroValue(
const ValueType &) {
return ZeroValue(); }
871 static ITK_CONSTEXPR_FUNC ValueType
OneValue(
const ValueType &) {
return OneValue(); }
873 template<
typename TArray>
874 static void AssignToArray(
const ValueType & v, TArray & mv )
878 static void SetLength(ValueType & m,
const unsigned int s)
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
bool IsSigned =
true;
924 static ITK_CONSTEXPR
bool IsInteger =
false;
925 static ITK_CONSTEXPR
bool IsComplex =
false;
926 static ITK_CONSTEXPR_FUNC
long double ZeroValue() {
return Zero; }
927 static ITK_CONSTEXPR_FUNC
long double OneValue() {
return One; }
928 static ITK_CONSTEXPR_FUNC
unsigned int GetLength(
const ValueType &) {
return 1; }
929 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
931 static ITK_CONSTEXPR_FUNC ValueType
ZeroValue(
const ValueType &) {
return ZeroValue(); }
932 static ITK_CONSTEXPR_FUNC ValueType
OneValue(
const ValueType &) {
return OneValue(); }
934 template<
typename TArray>
935 static void AssignToArray(
const ValueType & v, TArray & mv )
939 static void SetLength(ValueType & m,
const unsigned int s)
943 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
957 public std::numeric_limits< long long >
969 static ITK_CONSTEXPR ValueType ITKCommon_EXPORT
Zero = 0LL;
970 static ITK_CONSTEXPR ValueType ITKCommon_EXPORT
One = 1LL;
973 static ITK_CONSTEXPR_FUNC ValueType
NonpositiveMin() {
return std::numeric_limits< ValueType >::min(); }
974 static ITK_CONSTEXPR_FUNC
bool IsPositive(ValueType val) {
return val >
Zero; }
975 static ITK_CONSTEXPR_FUNC
bool IsNonpositive(ValueType val) {
return val <=
Zero; }
976 static ITK_CONSTEXPR_FUNC
bool IsNegative(ValueType val) {
return val <
Zero; }
977 static ITK_CONSTEXPR_FUNC
bool IsNonnegative(ValueType val) {
return val >=
Zero; }
978 static ITK_CONSTEXPR
bool IsSigned =
true;
979 static ITK_CONSTEXPR
bool IsInteger =
true;
980 static ITK_CONSTEXPR
bool IsComplex =
false;
981 static ITK_CONSTEXPR_FUNC ValueType
ZeroValue() {
return Zero; }
982 static ITK_CONSTEXPR_FUNC ValueType
OneValue() {
return One; }
983 static ITK_CONSTEXPR_FUNC
unsigned int GetLength(
const ValueType &) {
return 1; }
984 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
986 static ITK_CONSTEXPR_FUNC ValueType
ZeroValue(
const ValueType &) {
return ZeroValue(); }
987 static ITK_CONSTEXPR_FUNC ValueType
OneValue(
const ValueType &) {
return OneValue(); }
989 template<
typename TArray>
990 static void AssignToArray(
const ValueType & v, TArray & mv )
994 static void SetLength(ValueType & m,
const unsigned int s)
998 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
1011 public std::numeric_limits< unsigned long long >
1016 typedef unsigned long long AbsType;
1023 static ITK_CONSTEXPR ValueType ITKCommon_EXPORT
Zero = 0ULL;
1024 static ITK_CONSTEXPR ValueType ITKCommon_EXPORT
One = 1ULL;
1027 static ITK_CONSTEXPR_FUNC ValueType
NonpositiveMin() {
return std::numeric_limits< ValueType >::min(); }
1028 static ITK_CONSTEXPR_FUNC
bool IsPositive(ValueType val) {
return val !=
Zero; }
1029 static ITK_CONSTEXPR_FUNC
bool IsNonpositive(ValueType val) {
return val ==
Zero; }
1030 static ITK_CONSTEXPR_FUNC
bool IsNegative(ValueType) {
return false; }
1031 static ITK_CONSTEXPR_FUNC
bool IsNonnegative(ValueType) {
return true; }
1032 static ITK_CONSTEXPR
bool IsSigned =
false;
1033 static ITK_CONSTEXPR
bool IsInteger =
true;
1034 static ITK_CONSTEXPR
bool IsComplex =
false;
1035 static ITK_CONSTEXPR_FUNC ValueType
ZeroValue() {
return Zero; }
1036 static ITK_CONSTEXPR_FUNC ValueType
OneValue() {
return One; }
1037 static ITK_CONSTEXPR_FUNC
unsigned int GetLength(
const ValueType &) {
return 1; }
1038 static ITK_CONSTEXPR_FUNC
unsigned int GetLength() {
return 1; }
1040 static ITK_CONSTEXPR_FUNC ValueType
ZeroValue(
const ValueType &) {
return ZeroValue(); }
1041 static ITK_CONSTEXPR_FUNC ValueType
OneValue(
const ValueType &) {
return OneValue(); }
1043 template<
typename TArray>
1044 static void AssignToArray(
const ValueType & v, TArray & mv )
1048 static void SetLength(ValueType & m,
const unsigned int s)
1052 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
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(); }
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; }
1103 static ITK_CONSTEXPR
bool IsInteger =
false;
1104 static ITK_CONSTEXPR
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);
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(); }
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; }
1166 static ITK_CONSTEXPR
bool IsInteger =
false;
1167 static ITK_CONSTEXPR
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);
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(); }
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; }
1229 static ITK_CONSTEXPR
bool IsInteger =
false;
1230 static ITK_CONSTEXPR
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);
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(); }
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; }
1292 static ITK_CONSTEXPR
bool IsInteger =
false;
1293 static ITK_CONSTEXPR
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);
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(); }
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; }
1355 static ITK_CONSTEXPR
bool IsInteger =
false;
1356 static ITK_CONSTEXPR
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);
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(); }
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; }
1418 static ITK_CONSTEXPR
bool IsInteger =
false;
1419 static ITK_CONSTEXPR
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);
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(); }
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; }
1481 static ITK_CONSTEXPR
bool IsInteger =
false;
1482 static ITK_CONSTEXPR
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);
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(); }
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; }
1544 static ITK_CONSTEXPR
bool IsInteger =
false;
1545 static ITK_CONSTEXPR
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);
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(); }
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; }
1607 static ITK_CONSTEXPR
bool IsInteger =
false;
1608 static ITK_CONSTEXPR
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);
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(); }
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; }
1670 static ITK_CONSTEXPR
bool IsInteger =
false;
1671 static ITK_CONSTEXPR
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);
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(); }
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; }
1733 static ITK_CONSTEXPR
bool IsInteger =
false;
1734 static ITK_CONSTEXPR
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 static T OneValue(const T &)
static ITK_CONSTEXPR bool IsComplex
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes...
static void AssignToArray(const T &v, TArray &mv)
static bool IsPositive(T val)
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 bool IsNonpositive(T val)
static ITK_CONSTEXPR bool IsSigned
FixedArray< ValueType, 1 > MeasurementVectorType
Define additional traits for native types such as int or float.
static unsigned int GetLength(const T &)
static ITK_CONSTEXPR bool IsInteger
#define itkNUMERIC_TRAITS_MIN_MAX_MACRO()