18 #ifndef itkNumericTraits_h
19 #define itkNumericTraits_h
26 #define itkNUMERIC_TRAITS_MIN_MAX_MACRO() \
27 static constexpr ValueType min(ValueType) \
29 return std::numeric_limits< ValueType >::min(); \
31 static constexpr ValueType max(ValueType) \
33 return std::numeric_limits< ValueType >::max(); \
35 static constexpr ValueType min() \
37 return std::numeric_limits< ValueType >::min(); \
39 static constexpr ValueType max() \
41 return std::numeric_limits< ValueType >::max(); \
51 template<
typename TValue,
unsigned int VLength>
class FixedArray;
68 template<
typename T >
73 using TraitsType = std::numeric_limits< T >;
85 using AccumulateType = double;
88 using MeasurementVectorType = FixedArray<ValueType, 1>;
92 using FloatType = float;
95 using RealType = double;
98 using ScalarRealType = RealType;
101 static const T ITKCommon_EXPORT Zero;
104 static const T ITKCommon_EXPORT One;
107 static constexpr T NonpositiveMin() {
return TraitsType::lowest(); }
110 static bool IsPositive(T val) {
return val > Zero; }
113 static bool IsNonpositive(T val) {
return val <= Zero; }
116 static bool IsNegative(T val) {
return val < Zero; }
119 static bool IsNonnegative(T val) {
return val >= Zero; }
124 static constexpr
bool IsSigned =
false;
129 static constexpr
bool IsInteger =
false;
134 static constexpr
bool IsComplex =
false;
138 static T ZeroValue() {
return Zero; }
142 static T OneValue() {
return One; }
149 static constexpr T max(
const T &) {
return TraitsType::max(); }
150 static constexpr T min(
const T &) {
return TraitsType::min(); }
159 static void SetLength(T & m,
const unsigned int s)
163 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
174 static unsigned int GetLength(
const T &)
180 static unsigned int GetLength()
188 static T NonpositiveMin(
const T &)
190 return NonpositiveMin();
196 static T ZeroValue(
const T &)
204 static T OneValue(
const T &)
210 template<
typename TArray>
211 static void AssignToArray(
const T & v, TArray & mv )
228 class NumericTraits< bool > :
public std::numeric_limits< bool >
231 using ValueType = bool;
232 using PrintType = bool;
233 using AbsType =
unsigned char;
234 using AccumulateType =
unsigned char;
235 using RealType = double;
236 using ScalarRealType = RealType;
237 using FloatType = float;
238 using MeasurementVectorType = FixedArray<ValueType, 1>;
240 static constexpr
bool ITKCommon_EXPORT Zero =
false;
241 static constexpr
bool ITKCommon_EXPORT One =
true;
243 static constexpr
bool min() {
return false; }
244 static constexpr
bool max() {
return true; }
245 static constexpr
bool min(
bool) {
return min(); }
246 static constexpr
bool max(
bool) {
return max(); }
247 static constexpr
bool NonpositiveMin() {
return false; }
248 static constexpr
bool IsPositive(
bool val) {
return val; }
249 static constexpr
bool IsNonpositive(
bool val) {
return !val; }
250 static constexpr
bool IsNegative(
bool val) {
return val ?
false :
false; }
251 static constexpr
bool IsNonnegative(
bool val) {
return val ?
true :
true; }
252 static constexpr
bool IsSigned =
false;
253 static constexpr
bool IsInteger =
true;
254 static constexpr
bool IsComplex =
false;
255 static constexpr
bool ZeroValue() {
return Zero; }
256 static constexpr
bool OneValue() {
return One; }
257 static constexpr
unsigned int GetLength(
const ValueType &) {
return 1; }
258 static constexpr
unsigned int GetLength() {
return 1; }
259 static constexpr ValueType NonpositiveMin(
const ValueType &) {
return NonpositiveMin(); }
260 static constexpr ValueType ZeroValue(
const ValueType &) {
return ZeroValue(); }
261 static constexpr ValueType OneValue(
const ValueType &) {
return OneValue(); }
263 template<
typename TArray>
264 static void AssignToArray(
const ValueType & v, TArray & mv )
268 static void SetLength(ValueType & m,
const unsigned int s)
272 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
285 class NumericTraits< char > :
public std::numeric_limits< char >
288 using ValueType = char;
289 using PrintType = int;
290 using AbsType =
unsigned char;
291 using AccumulateType = short;
292 using RealType = double;
293 using ScalarRealType = RealType;
294 using FloatType = float;
295 using MeasurementVectorType = FixedArray<ValueType, 1>;
297 static constexpr
char ITKCommon_EXPORT Zero = 0;
298 static constexpr
char ITKCommon_EXPORT One = 1;
302 static constexpr
char NonpositiveMin() {
return lowest(); }
303 static constexpr
bool IsPositive(
char val) {
return val > Zero; }
304 static constexpr
bool IsNonpositive(
char val) {
return val <= Zero; }
306 static constexpr
bool IsNegative(
char) {
return false; }
307 static constexpr
bool IsNonnegative(
char) {
return true; }
308 static constexpr
bool IsSigned = std::numeric_limits<char>::is_signed;
310 static constexpr
bool IsInteger = std::numeric_limits<char>::is_integer;
311 static constexpr
bool IsComplex =
false;
312 static constexpr
char ZeroValue() {
return Zero; }
313 static constexpr
char OneValue() {
return One; }
314 static constexpr
unsigned int GetLength(
const ValueType &) {
return 1; }
315 static constexpr
unsigned int GetLength() {
return 1; }
316 static constexpr ValueType NonpositiveMin(
const ValueType &) {
return NonpositiveMin(); }
317 static constexpr ValueType ZeroValue(
const ValueType &) {
return ZeroValue(); }
318 static constexpr ValueType OneValue(
const ValueType &) {
return OneValue(); }
320 template<
typename TArray>
321 static void AssignToArray(
const ValueType & v, TArray & mv )
325 static void SetLength(ValueType & m,
const unsigned int s)
329 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
341 class NumericTraits< signed char > :
public std::numeric_limits< signed char >
344 using ValueType =
signed char;
345 using PrintType = int;
346 using AbsType =
unsigned char;
347 using AccumulateType = short;
348 using RealType = double;
349 using ScalarRealType = RealType;
350 using FloatType = float;
351 using MeasurementVectorType = FixedArray<ValueType, 1>;
353 static constexpr
signed char ITKCommon_EXPORT Zero = 0;
354 static constexpr
signed char ITKCommon_EXPORT One = 1;
356 static constexpr
signed char min() {
return -128; }
357 static constexpr
signed char max() {
return 127; }
358 static constexpr
signed char min(
signed char) {
return min(); }
359 static constexpr
signed char max(
signed char) {
return max(); }
360 static constexpr
signed char NonpositiveMin() {
return lowest(); }
361 static constexpr
bool IsPositive(
signed char val) {
return val > Zero; }
362 static constexpr
bool IsNonpositive(
signed char val) {
return val <= Zero; }
363 static constexpr
bool IsNegative(
signed char val) {
return val < Zero; }
364 static constexpr
bool IsNonnegative(
signed char val) {
return val >= Zero; }
365 static constexpr
bool IsSigned =
true;
366 static constexpr
bool IsInteger =
true;
367 static constexpr
bool IsComplex =
false;
368 static constexpr
signed char ZeroValue() {
return Zero; }
369 static constexpr
signed char OneValue() {
return One; }
370 static constexpr
unsigned int GetLength(
const ValueType &) {
return 1; }
371 static constexpr
unsigned int GetLength() {
return 1; }
372 static constexpr ValueType NonpositiveMin(
const ValueType &) {
return NonpositiveMin(); }
373 static constexpr ValueType ZeroValue(
const ValueType &) {
return ZeroValue(); }
374 static constexpr ValueType OneValue(
const ValueType &) {
return OneValue(); }
376 template<
typename TArray>
377 static void AssignToArray(
const ValueType & v, TArray & mv )
381 static void SetLength(ValueType & m,
const unsigned int s)
385 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
397 class NumericTraits< unsigned char > :
public std::numeric_limits< unsigned char >
400 using ValueType =
unsigned char;
401 using PrintType = int;
402 using AbsType =
unsigned char;
403 using AccumulateType =
unsigned short;
404 using RealType = double;
405 using ScalarRealType = RealType;
406 using FloatType = float;
407 using MeasurementVectorType = FixedArray<ValueType, 1>;
409 static constexpr
unsigned char ITKCommon_EXPORT Zero = 0;
410 static constexpr
unsigned char ITKCommon_EXPORT One = 1;
414 static constexpr
unsigned char NonpositiveMin() {
return std::numeric_limits< ValueType >::lowest(); }
415 static constexpr
bool IsPositive(
unsigned char val) {
return val != Zero; }
416 static constexpr
bool IsNonpositive(
unsigned char val) {
return val == Zero; }
417 static constexpr
bool IsNegative(
unsigned char val) {
return val ?
false :
false; }
418 static constexpr
bool IsNonnegative(
unsigned char val) {
return val ?
true :
true; }
419 static constexpr
bool IsSigned =
false;
420 static constexpr
bool IsInteger =
true;
421 static constexpr
bool IsComplex =
false;
422 static constexpr
unsigned char ZeroValue() {
return Zero; }
423 static constexpr
unsigned char OneValue() {
return One; }
424 static constexpr
unsigned int GetLength(
const ValueType &) {
return 1; }
425 static constexpr
unsigned int GetLength() {
return 1; }
426 static constexpr ValueType NonpositiveMin(
const ValueType &) {
return NonpositiveMin(); }
427 static constexpr ValueType ZeroValue(
const ValueType &) {
return ZeroValue(); }
428 static constexpr ValueType OneValue(
const ValueType &) {
return OneValue(); }
430 template<
typename TArray>
431 static void AssignToArray(
const ValueType & v, TArray & mv )
435 static void SetLength(ValueType & m,
const unsigned int s)
439 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
450 class NumericTraits< short > :
public std::numeric_limits< short >
453 using ValueType = short;
454 using PrintType = short;
455 using AbsType =
unsigned short;
456 using AccumulateType = int;
457 using RealType = double;
458 using ScalarRealType = RealType;
459 using FloatType = float;
460 using MeasurementVectorType = FixedArray<ValueType, 1>;
462 static constexpr
short ITKCommon_EXPORT Zero = 0;
463 static constexpr
short ITKCommon_EXPORT One = 1;
466 static constexpr
short NonpositiveMin() {
return std::numeric_limits< ValueType >::lowest(); }
467 static constexpr
bool IsPositive(
short val) {
return val > Zero; }
468 static constexpr
bool IsNonpositive(
short val) {
return val <= Zero; }
469 static constexpr
bool IsNegative(
short val) {
return val < Zero; }
470 static constexpr
bool IsNonnegative(
short val) {
return val >= Zero; }
471 static constexpr
bool IsSigned =
true;
472 static constexpr
bool IsInteger =
true;
473 static constexpr
bool IsComplex =
false;
474 static constexpr
short ZeroValue() {
return Zero; }
475 static constexpr
short OneValue() {
return One; }
476 static constexpr
unsigned int GetLength(
const ValueType &) {
return 1; }
477 static constexpr
unsigned int GetLength() {
return 1; }
478 static constexpr ValueType NonpositiveMin(
const ValueType &) {
return NonpositiveMin(); }
479 static constexpr ValueType ZeroValue(
const ValueType &) {
return ZeroValue(); }
480 static constexpr ValueType OneValue(
const ValueType &) {
return OneValue(); }
482 template<
typename TArray>
483 static void AssignToArray(
const ValueType & v, TArray & mv )
487 static void SetLength(ValueType & m,
const unsigned int s)
491 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
503 class NumericTraits< unsigned short > :
public std::numeric_limits< unsigned short >
506 using ValueType =
unsigned short;
507 using PrintType =
unsigned short;
508 using AbsType =
unsigned short;
509 using AccumulateType =
unsigned int;
510 using RealType = double;
511 using ScalarRealType = RealType;
512 using FloatType = float;
513 using MeasurementVectorType = FixedArray<ValueType, 1>;
515 static constexpr
unsigned short ITKCommon_EXPORT Zero = 0;
516 static constexpr
unsigned short ITKCommon_EXPORT One = 1;
519 static constexpr
unsigned short NonpositiveMin() {
return std::numeric_limits< ValueType >::lowest(); }
520 static constexpr
bool IsPositive(
unsigned short val) {
return val != Zero; }
521 static constexpr
bool IsNonpositive(
unsigned short val) {
return val == Zero; }
522 static constexpr
bool IsNegative(
unsigned short val) {
return val ?
false :
false; }
523 static constexpr
bool IsNonnegative(
unsigned short val) {
return val ?
true :
true; }
524 static constexpr
bool IsSigned =
false;
525 static constexpr
bool IsInteger =
true;
526 static constexpr
bool IsComplex =
false;
527 static constexpr
unsigned short ZeroValue() {
return Zero; }
528 static constexpr
unsigned short OneValue() {
return One; }
529 static constexpr
unsigned int GetLength(
const ValueType &) {
return 1; }
530 static constexpr
unsigned int GetLength() {
return 1; }
531 static constexpr ValueType NonpositiveMin(
const ValueType &) {
return NonpositiveMin(); }
532 static constexpr ValueType ZeroValue(
const ValueType &) {
return ZeroValue(); }
533 static constexpr ValueType OneValue(
const ValueType &) {
return OneValue(); }
535 template<
typename TArray>
536 static void AssignToArray(
const ValueType & v, TArray & mv )
540 static void SetLength(ValueType & m,
const unsigned int s)
544 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
555 class NumericTraits< int > :
public std::numeric_limits< int >
558 using ValueType = int;
559 using PrintType = int;
560 using AbsType =
unsigned int;
561 using AccumulateType = long;
562 using RealType = double;
563 using ScalarRealType = RealType;
564 using FloatType = float;
565 using MeasurementVectorType = FixedArray<ValueType, 1>;
567 static constexpr
int ITKCommon_EXPORT Zero = 0;
568 static constexpr
int ITKCommon_EXPORT One = 1;
571 static constexpr
int NonpositiveMin() {
return std::numeric_limits< ValueType >::lowest(); }
572 static constexpr
bool IsPositive(
int val) {
return val > Zero; }
573 static constexpr
bool IsNonpositive(
int val) {
return val <= Zero; }
574 static constexpr
bool IsNegative(
int val) {
return val < Zero; }
575 static constexpr
bool IsNonnegative(
int val) {
return val >= Zero; }
576 static constexpr
bool IsSigned =
true;
577 static constexpr
bool IsInteger =
true;
578 static constexpr
bool IsComplex =
false;
579 static constexpr
int ZeroValue() {
return Zero; }
580 static constexpr
int OneValue() {
return One; }
581 static constexpr
unsigned int GetLength(
const ValueType &) {
return 1; }
582 static constexpr
unsigned int GetLength() {
return 1; }
583 static constexpr ValueType NonpositiveMin(
const ValueType &) {
return NonpositiveMin(); }
584 static constexpr ValueType ZeroValue(
const ValueType &) {
return ZeroValue(); }
585 static constexpr ValueType OneValue(
const ValueType &) {
return OneValue(); }
587 template<
typename TArray>
588 static void AssignToArray(
const ValueType & v, TArray & mv )
592 static void SetLength(ValueType & m,
const unsigned int s)
596 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
608 class NumericTraits< unsigned int > :
public std::numeric_limits< unsigned int >
611 using ValueType =
unsigned int;
612 using PrintType =
unsigned int;
613 using AbsType =
unsigned int;
614 using AccumulateType =
unsigned int;
615 using RealType = double;
616 using ScalarRealType = RealType;
617 using FloatType = float;
618 using MeasurementVectorType = FixedArray<ValueType, 1>;
620 static constexpr
unsigned int ITKCommon_EXPORT Zero = 0;
621 static constexpr
unsigned int ITKCommon_EXPORT One = 1;
623 static constexpr
unsigned int min() {
return 0; }
624 static constexpr
unsigned int max() {
return static_cast< unsigned int >( -1 ); }
625 static constexpr
unsigned int min(
unsigned int) {
return std::numeric_limits< ValueType >::min(); }
626 static constexpr
unsigned int max(
unsigned int) {
return std::numeric_limits< ValueType >::max(); }
627 static constexpr
unsigned int NonpositiveMin() {
return 0; }
628 static constexpr
bool IsPositive(
unsigned int val) {
return val != Zero; }
629 static constexpr
bool IsNonpositive(
unsigned int val) {
return val == Zero; }
630 static constexpr
bool IsNegative(
unsigned int val) {
return val ?
false :
false; }
631 static constexpr
bool IsNonnegative(
unsigned int val) {
return val ?
true :
true; }
632 static constexpr
bool IsSigned =
false;
633 static constexpr
bool IsInteger =
true;
634 static constexpr
bool IsComplex =
false;
635 static constexpr
unsigned int ZeroValue() {
return Zero; }
636 static constexpr
unsigned int OneValue() {
return One; }
637 static constexpr
unsigned int GetLength(
const ValueType &) {
return 1; }
638 static constexpr
unsigned int GetLength() {
return 1; }
639 static constexpr ValueType NonpositiveMin(
const ValueType &) {
return NonpositiveMin(); }
640 static constexpr ValueType ZeroValue(
const ValueType &) {
return ZeroValue(); }
641 static constexpr ValueType OneValue(
const ValueType &) {
return OneValue(); }
643 template<
typename TArray>
644 static void AssignToArray(
const ValueType & v, TArray & mv )
648 static void SetLength(ValueType & m,
const unsigned int s)
652 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
664 class NumericTraits< long > :
public std::numeric_limits< long >
667 using ValueType = long;
668 using PrintType = long;
669 using AbsType =
unsigned long;
670 using AccumulateType = long;
671 using RealType = double;
672 using ScalarRealType = RealType;
673 using FloatType = float;
674 using MeasurementVectorType = FixedArray<ValueType, 1>;
676 static constexpr
long ITKCommon_EXPORT Zero = 0L;
677 static constexpr
long ITKCommon_EXPORT One = 1L;
680 static constexpr
long NonpositiveMin() {
return std::numeric_limits< ValueType >::lowest(); }
681 static constexpr
bool IsPositive(
long val) {
return val > Zero; }
682 static constexpr
bool IsNonpositive(
long val) {
return val <= Zero; }
683 static constexpr
bool IsNegative(
long val) {
return val < Zero; }
684 static constexpr
bool IsNonnegative(
long val) {
return val >= Zero; }
685 static constexpr
bool IsSigned =
true;
686 static constexpr
bool IsInteger =
true;
687 static constexpr
bool IsComplex =
false;
688 static constexpr
long ZeroValue() {
return Zero; }
689 static constexpr
long OneValue() {
return One; }
690 static constexpr
unsigned int GetLength(
const ValueType &) {
return 1; }
691 static constexpr
unsigned int GetLength() {
return 1; }
692 static constexpr ValueType NonpositiveMin(
const ValueType &) {
return NonpositiveMin(); }
693 static constexpr ValueType ZeroValue(
const ValueType &) {
return ZeroValue(); }
694 static constexpr ValueType OneValue(
const ValueType &) {
return OneValue(); }
696 template<
typename TArray>
697 static void AssignToArray(
const ValueType & v, TArray & mv )
701 static void SetLength(ValueType & m,
const unsigned int s)
705 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
717 class NumericTraits< unsigned long > :
public std::numeric_limits< unsigned long >
720 using ValueType =
unsigned long;
721 using PrintType =
unsigned long;
722 using AbsType =
unsigned long;
723 using AccumulateType =
unsigned long;
724 using RealType = double;
725 using ScalarRealType = RealType;
726 using FloatType = float;
727 using MeasurementVectorType = FixedArray<ValueType, 1>;
729 static constexpr
unsigned long ITKCommon_EXPORT Zero = 0UL;
730 static constexpr
unsigned long ITKCommon_EXPORT One = 1UL;
733 static constexpr
unsigned long NonpositiveMin() {
return std::numeric_limits< ValueType >::lowest(); }
734 static constexpr
bool IsPositive(
unsigned long val) {
return val != Zero; }
735 static constexpr
bool IsNonpositive(
unsigned long val) {
return val == Zero; }
736 static constexpr
bool IsNegative(
unsigned long) {
return false; }
737 static constexpr
bool IsNonnegative(
unsigned long) {
return true; }
738 static constexpr
bool IsSigned =
false;
739 static constexpr
bool IsInteger =
true;
740 static constexpr
bool IsComplex =
false;
741 static constexpr
unsigned long ZeroValue() {
return Zero; }
742 static constexpr
unsigned long OneValue() {
return One; }
743 static constexpr
unsigned int GetLength(
const ValueType &) {
return 1; }
744 static constexpr
unsigned int GetLength() {
return 1; }
745 static constexpr ValueType NonpositiveMin(
const ValueType &) {
return NonpositiveMin(); }
746 static constexpr ValueType ZeroValue(
const ValueType &) {
return ZeroValue(); }
747 static constexpr ValueType OneValue(
const ValueType &) {
return OneValue(); }
749 template<
typename TArray>
750 static void AssignToArray(
const ValueType & v, TArray & mv )
754 static void SetLength(ValueType & m,
const unsigned int s)
758 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
770 class NumericTraits< float > :
public std::numeric_limits< float >
773 using ValueType = float;
774 using PrintType = float;
775 using AbsType = float;
776 using AccumulateType = double;
777 using RealType = double;
778 using ScalarRealType = RealType;
779 using FloatType = float;
780 using MeasurementVectorType = FixedArray<ValueType, 1>;
783 static constexpr
float ITKCommon_EXPORT Zero =0.0f;
784 static constexpr
float ITKCommon_EXPORT One =1.0f;
787 static constexpr
float NonpositiveMin() {
return std::numeric_limits< ValueType >::lowest(); }
788 static constexpr
bool IsPositive(
float val) {
return val > Zero; }
789 static constexpr
bool IsNonpositive(
float val) {
return val <= Zero; }
790 static constexpr
bool IsNegative(
float val) {
return val < Zero; }
791 static constexpr
bool IsNonnegative(
float val) {
return val >= Zero; }
792 static constexpr
bool IsSigned =
true;
793 static constexpr
bool IsInteger =
false;
794 static constexpr
bool IsComplex =
false;
795 static constexpr
float ZeroValue() {
return Zero; }
796 static constexpr
float OneValue() {
return One; }
797 static constexpr
unsigned int GetLength(
const ValueType &) {
return 1; }
798 static constexpr
unsigned int GetLength() {
return 1; }
799 static constexpr ValueType NonpositiveMin(
const ValueType &) {
return NonpositiveMin(); }
800 static constexpr ValueType ZeroValue(
const ValueType &) {
return ZeroValue(); }
801 static constexpr ValueType OneValue(
const ValueType &) {
return OneValue(); }
803 template<
typename TArray>
804 static void AssignToArray(
const ValueType & v, TArray & mv )
808 static void SetLength(ValueType & m,
const unsigned int s)
812 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
824 class NumericTraits< double > :
public std::numeric_limits< double >
827 using ValueType = double;
828 using PrintType = double;
829 using AbsType = double;
830 using AccumulateType = double;
831 using RealType = double;
832 using ScalarRealType = RealType;
833 using FloatType = float;
834 using MeasurementVectorType = FixedArray<ValueType, 1>;
836 static constexpr
double ITKCommon_EXPORT Zero = 0.0;
837 static constexpr
double ITKCommon_EXPORT One = 1.0;
840 static constexpr
double NonpositiveMin() {
return std::numeric_limits< ValueType >::lowest(); }
841 static constexpr
bool IsPositive(
double val) {
return val > Zero; }
842 static constexpr
bool IsNonpositive(
double val) {
return val <= Zero; }
843 static constexpr
bool IsNegative(
double val) {
return val < Zero; }
844 static constexpr
bool IsNonnegative(
double val) {
return val >= Zero; }
845 static constexpr
bool IsSigned =
true;
846 static constexpr
bool IsInteger =
false;
847 static constexpr
bool IsComplex =
false;
848 static constexpr
double ZeroValue() {
return Zero; }
849 static constexpr
double OneValue() {
return One; }
850 static constexpr
unsigned int GetLength(
const ValueType &) {
return 1; }
851 static constexpr
unsigned int GetLength() {
return 1; }
852 static constexpr ValueType NonpositiveMin(
const ValueType &) {
return NonpositiveMin(); }
853 static constexpr ValueType ZeroValue(
const ValueType &) {
return ZeroValue(); }
854 static constexpr ValueType OneValue(
const ValueType &) {
return OneValue(); }
856 template<
typename TArray>
857 static void AssignToArray(
const ValueType & v, TArray & mv )
861 static void SetLength(ValueType & m,
const unsigned int s)
865 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
877 class NumericTraits< long double > :
public std::numeric_limits< long double >
880 using ValueType =
long double;
881 #if defined( __SUNPRO_CC ) && defined( _ILP32 )
886 using PrintType = double;
888 using PrintType =
long double;
890 using AbsType =
long double;
891 using AccumulateType =
long double;
892 using RealType =
long double;
893 using ScalarRealType = RealType;
894 using FloatType = float;
895 using MeasurementVectorType = FixedArray<ValueType, 1>;
897 static constexpr
long double ITKCommon_EXPORT Zero = 0.0;
898 static constexpr
long double ITKCommon_EXPORT One = 1.0;
901 static constexpr
long double NonpositiveMin() {
return std::numeric_limits< ValueType >::lowest(); }
902 static constexpr
bool IsPositive(
long double val) {
return val > Zero; }
903 static constexpr
bool IsNonpositive(
long double val) {
return val <= Zero; }
904 static constexpr
bool IsNegative(
long double val) {
return val < Zero; }
905 static constexpr
bool IsNonnegative(
long double val) {
return val >= Zero; }
906 static constexpr
bool IsSigned =
true;
907 static constexpr
bool IsInteger =
false;
908 static constexpr
bool IsComplex =
false;
909 static constexpr
long double ZeroValue() {
return Zero; }
910 static constexpr
long double OneValue() {
return One; }
911 static constexpr
unsigned int GetLength(
const ValueType &) {
return 1; }
912 static constexpr
unsigned int GetLength() {
return 1; }
913 static constexpr ValueType NonpositiveMin(
const ValueType &) {
return NonpositiveMin(); }
914 static constexpr ValueType ZeroValue(
const ValueType &) {
return ZeroValue(); }
915 static constexpr ValueType OneValue(
const ValueType &) {
return OneValue(); }
917 template<
typename TArray>
918 static void AssignToArray(
const ValueType & v, TArray & mv )
922 static void SetLength(ValueType & m,
const unsigned int s)
926 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
940 public std::numeric_limits< long long >
943 using ValueType =
long long;
944 using PrintType =
long long;
945 using AbsType =
long long;
946 using AccumulateType =
long long;
947 using RealType = double;
948 using ScalarRealType = RealType;
949 using FloatType = float;
950 using MeasurementVectorType = FixedArray<ValueType, 1>;
952 static constexpr ValueType ITKCommon_EXPORT Zero = 0LL;
953 static constexpr ValueType ITKCommon_EXPORT One = 1LL;
956 static constexpr ValueType NonpositiveMin() {
return std::numeric_limits< ValueType >::lowest(); }
957 static constexpr
bool IsPositive(ValueType val) {
return val > Zero; }
958 static constexpr
bool IsNonpositive(ValueType val) {
return val <= Zero; }
959 static constexpr
bool IsNegative(ValueType val) {
return val < Zero; }
960 static constexpr
bool IsNonnegative(ValueType val) {
return val >= Zero; }
961 static constexpr
bool IsSigned =
true;
962 static constexpr
bool IsInteger =
true;
963 static constexpr
bool IsComplex =
false;
964 static constexpr ValueType ZeroValue() {
return Zero; }
965 static constexpr ValueType OneValue() {
return One; }
966 static constexpr
unsigned int GetLength(
const ValueType &) {
return 1; }
967 static constexpr
unsigned int GetLength() {
return 1; }
968 static constexpr ValueType NonpositiveMin(
const ValueType &) {
return NonpositiveMin(); }
969 static constexpr ValueType ZeroValue(
const ValueType &) {
return ZeroValue(); }
970 static constexpr ValueType OneValue(
const ValueType &) {
return OneValue(); }
972 template<
typename TArray>
973 static void AssignToArray(
const ValueType & v, TArray & mv )
977 static void SetLength(ValueType & m,
const unsigned int s)
981 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
994 public std::numeric_limits< unsigned long long >
997 using ValueType =
unsigned long long;
998 using PrintType =
unsigned long long;
999 using AbsType =
unsigned long long;
1000 using AccumulateType =
unsigned long long;
1001 using RealType = double;
1002 using ScalarRealType = RealType;
1003 using FloatType = float;
1004 using MeasurementVectorType = FixedArray<ValueType, 1>;
1006 static constexpr ValueType ITKCommon_EXPORT Zero = 0ULL;
1007 static constexpr ValueType ITKCommon_EXPORT One = 1ULL;
1010 static constexpr ValueType NonpositiveMin() {
return std::numeric_limits< ValueType >::lowest(); }
1011 static constexpr
bool IsPositive(ValueType val) {
return val != Zero; }
1012 static constexpr
bool IsNonpositive(ValueType val) {
return val == Zero; }
1013 static constexpr
bool IsNegative(ValueType) {
return false; }
1014 static constexpr
bool IsNonnegative(ValueType) {
return true; }
1015 static constexpr
bool IsSigned =
false;
1016 static constexpr
bool IsInteger =
true;
1017 static constexpr
bool IsComplex =
false;
1018 static constexpr ValueType ZeroValue() {
return Zero; }
1019 static constexpr ValueType OneValue() {
return One; }
1020 static constexpr
unsigned int GetLength(
const ValueType &) {
return 1; }
1021 static constexpr
unsigned int GetLength() {
return 1; }
1022 static constexpr ValueType NonpositiveMin(
const ValueType &) {
return NonpositiveMin(); }
1023 static constexpr ValueType ZeroValue(
const ValueType &) {
return ZeroValue(); }
1024 static constexpr ValueType OneValue(
const ValueType &) {
return OneValue(); }
1026 template<
typename TArray>
1027 static void AssignToArray(
const ValueType & v, TArray & mv )
1031 static void SetLength(ValueType & m,
const unsigned int s)
1035 itkGenericExceptionMacro(<<
"Cannot set the size of a scalar to " << s);
1047 template<
typename TComponent>
1051 using Self = std::complex< TComponent >;
1053 using TheType = Self;
1054 using ValueType = TComponent;
1055 using PrintType = Self;
1056 using AbsType = double;
1057 using AccumulateType = Self;
1058 using RealType = std::complex< double >;
1059 using ScalarRealType = double;
1060 using FloatType = std::complex< float >;
1061 using MeasurementVectorType = FixedArray<ValueType, 2>;
1063 static const Self ITKCommon_EXPORT Zero;
1064 static const Self ITKCommon_EXPORT One;
1066 static constexpr Self min() {
return std::numeric_limits< ValueType >::min(); }
1067 static constexpr Self max() {
return std::numeric_limits< ValueType >::max(); }
1068 static constexpr Self min(Self) {
return min(); }
1069 static constexpr Self max(Self) {
return max(); }
1070 static constexpr ValueType epsilon() {
return std::numeric_limits<ValueType>::epsilon(); }
1071 static constexpr Self NonpositiveMin()
1076 static constexpr
bool IsPositive(Self val) {
return val.real() > 0; }
1077 static constexpr
bool IsNonpositive(Self val) {
return val.real() <= 0; }
1078 static constexpr
bool IsNegative(Self val) {
return val.real() < 0; }
1079 static constexpr
bool IsNonnegative(Self val) {
return val.real() >= 0; }
1082 static constexpr
bool IsInteger =
false;
1083 static constexpr
bool IsComplex =
true;
1084 static Self ZeroValue() {
return Zero; }
1085 static Self OneValue() {
return One; }
1086 static constexpr
unsigned int GetLength(
const Self &) {
return 2; }
1087 static constexpr
unsigned int GetLength() {
return 2; }
1088 static constexpr Self NonpositiveMin(
const Self &) {
return NonpositiveMin(); }
1089 static Self ZeroValue(
const Self &) {
return ZeroValue(); }
1090 static Self OneValue(
const Self &) {
return OneValue(); }
1092 template<
typename TArray>
1093 static void AssignToArray(
const Self & v, TArray & mv )
1098 static void SetLength(Self & m,
const unsigned int s)
1102 itkGenericExceptionMacro(<<
"Cannot set the size of a complex to " << s);
1111 #endif // itkNumericTraits_h
#define itkNUMERIC_TRAITS_MIN_MAX_MACRO()
Define numeric traits for std::vector.