ITK  5.3.0 Insight Toolkit
itk::NumericTraits< T > Class Template Reference

#include <itkNumericTraits.h>

Inheritance diagram for itk::NumericTraits< T >:
Collaboration diagram for itk::NumericTraits< T >:

## Public Types

using AbsType = T

using AccumulateType = double

using FloatType = float

using MeasurementVectorType = FixedArray< ValueType, 1 >

using PrintType = T

using RealType = double

using ScalarRealType = RealType

using TraitsType = std::numeric_limits< T >

using ValueType = T

## Static Public Member Functions

template<typename TArray >
static void AssignToArray (const T &v, TArray &mv)

static unsigned int GetLength ()

static unsigned int GetLength (const T &)

static bool IsNegative (T val)

static bool IsNonnegative (T val)

static bool IsNonpositive (T val)

static bool IsPositive (T val)

static constexpr T max (const T &)

static constexpr T min (const T &)

static constexpr T NonpositiveMin ()

static T NonpositiveMin (const T &)

static T OneValue ()

static T OneValue (const T &)

static void SetLength (T &m, const unsigned int s)

static T ZeroValue ()

static T ZeroValue (const T &)

## Static Public Attributes

static constexpr bool IsComplex = false

static constexpr bool IsInteger = false

static constexpr bool IsSigned = false

static const T ITKCommon_EXPORT One

static const T ITKCommon_EXPORT Zero

## Detailed Description

### template<typename T> class itk::NumericTraits< T >

Define additional traits for native types such as int or float.

Define numeric traits for std::vector.

NumericTraits is used to extend the traits associated with native types such as float, char, int, and so on. These traits are extensions of the standard numeric_limits defined by the C++ compilers. Some of the added traits include minimum and maximum value; accumulation type; etc.

ITK Sphinx Examples:
Template Parameters
 T Component type of std::vector

We provide here a generic implementation based on creating types of std::vector whose components are the types of the NumericTraits from the original std::vector components. This implementation require support for partial specializations, since it is based on the concept that: NumericTraits<std::vector< T > > is defined piecewise by std::vector< NumericTraits< T > >

Note
The Zero(), One(), min() and max() methods here take references to a pixel as input. This is due to the fact that the length of the std::vector is not known until run-time. Since the most common use of Zero and One is for comparison purposes or initialization of sums etc, this might just as easily be re-written with a pixel passed in as a reference and the length is inferred from this pixel.
NumericTraits
Examples

Definition at line 58 of file itkNumericTraits.h.

## ◆ AbsType

template<typename T>
 using itk::NumericTraits< T >::AbsType = T

Return value of itk::Math::abs().

Definition at line 71 of file itkNumericTraits.h.

## ◆ AccumulateType

template<typename T>
 using itk::NumericTraits< T >::AccumulateType = double

Definition at line 74 of file itkNumericTraits.h.

## ◆ FloatType

template<typename T>
 using itk::NumericTraits< T >::FloatType = float

Typedef for operations that use floating point instead of real precision to save memory

Definition at line 81 of file itkNumericTraits.h.

## ◆ MeasurementVectorType

template<typename T>
 using itk::NumericTraits< T >::MeasurementVectorType = FixedArray

Measurement vector type

Definition at line 77 of file itkNumericTraits.h.

## ◆ PrintType

template<typename T>
 using itk::NumericTraits< T >::PrintType = T

## ◆ RealType

template<typename T>
 using itk::NumericTraits< T >::RealType = double

Type for real-valued scalar operations.

Definition at line 84 of file itkNumericTraits.h.

## ◆ ScalarRealType

template<typename T>
 using itk::NumericTraits< T >::ScalarRealType = RealType

Type for real-valued scalar operations.

Definition at line 87 of file itkNumericTraits.h.

## ◆ TraitsType

template<typename T>
 using itk::NumericTraits< T >::TraitsType = std::numeric_limits

The type of this limits trait object.

Definition at line 62 of file itkNumericTraits.h.

## ◆ ValueType

template<typename T>
 using itk::NumericTraits< T >::ValueType = T

Return the type of this native type.

Definition at line 65 of file itkNumericTraits.h.

## ◆ AssignToArray()

template<typename T>
template<typename TArray >
 static void itk::NumericTraits< T >::AssignToArray ( const T & v, TArray & mv )
inlinestatic

assign the value to an array

Definition at line 243 of file itkNumericTraits.h.

## ◆ GetLength() [2/2]

template<typename T>
 static unsigned int itk::NumericTraits< T >::GetLength ( const T & )
inlinestatic

Return the length of the scalar. This API is needed for VariableLengthVector because its length is only known at run-time. Specializations of the VariableLengthVector will provide a different implementation where a vector of the correct size is built.

Definition at line 201 of file itkNumericTraits.h.

## ◆ IsNegative()

template<typename T>
 static bool itk::NumericTraits< T >::IsNegative ( T val )
inlinestatic

Is a given value negative?

Examples
SphinxExamples/src/Core/Common/GetTypeBasicInformation/Code.cxx.

Definition at line 118 of file itkNumericTraits.h.

## ◆ IsNonnegative()

template<typename T>
 static bool itk::NumericTraits< T >::IsNonnegative ( T val )
inlinestatic

Is a given value nonnegative?

Definition at line 125 of file itkNumericTraits.h.

## ◆ IsNonpositive()

template<typename T>
 static bool itk::NumericTraits< T >::IsNonpositive ( T val )
inlinestatic

Is a given value nonpositive?

Definition at line 111 of file itkNumericTraits.h.

## ◆ IsPositive()

template<typename T>
 static bool itk::NumericTraits< T >::IsPositive ( T val )
inlinestatic

Is a given value positive?

Definition at line 104 of file itkNumericTraits.h.

## ◆ min()

template<typename T>
 static constexpr T itk::NumericTraits< T >::min ( const T & )
inlinestaticconstexpr

## ◆ NonpositiveMin() [2/2]

template<typename T>
 static T itk::NumericTraits< T >::NonpositiveMin ( const T & )
inlinestatic

Smallest (most nonpositive) value. This API is needed for VariableLengthVector because its length is only known at run-time.

Definition at line 217 of file itkNumericTraits.h.

## ◆ OneValue() [2/2]

template<typename T>
 static T itk::NumericTraits< T >::OneValue ( const T & )
inlinestatic

One value. This API is needed for VariableLengthVector because its length is only known at run-time.

Definition at line 235 of file itkNumericTraits.h.

## ◆ SetLength()

template<typename T>
 static void itk::NumericTraits< T >::SetLength ( T & m, const unsigned int s )
inlinestatic

Scalars cannot be resized, so an exception will be thrown if the input size is not 1. If the size is valid the will be zeros. This API is needed for VariableLengthVector because its length is only known at run-time. Specializations of the VariableLengthVector will provide a different implementation where a vector of the correct size is built.

Definition at line 185 of file itkNumericTraits.h.

## ◆ ZeroValue() [2/2]

template<typename T>
 static T itk::NumericTraits< T >::ZeroValue ( const T & )
inlinestatic

Zero value. This API is needed for VariableLengthVector because its length is only known at run-time.

Definition at line 226 of file itkNumericTraits.h.

## ◆ IsComplex

template<typename T>
 constexpr bool itk::NumericTraits< T >::IsComplex = false
staticconstexpr

Is a given type complex? – default is no. For uniform array data types in ITK, the value of IsComplex is determined by the component elements of the array.

Definition at line 143 of file itkNumericTraits.h.

## ◆ IsInteger

template<typename T>
 constexpr bool itk::NumericTraits< T >::IsInteger = false
staticconstexpr

Is a given type an integer? – default is no. For uniform array data types in ITK, the value of IsInteger is determined by the component elements of the array.

Definition at line 138 of file itkNumericTraits.h.

## ◆ IsSigned

template<typename T>
 constexpr bool itk::NumericTraits< T >::IsSigned = false
staticconstexpr

Is a given type signed? – default is no. For uniform array data types in ITK, the value of IsSigned is determined by the component elements of the array.

Definition at line 133 of file itkNumericTraits.h.

## ◆ One

template<typename T>
 const T ITKCommon_EXPORT itk::NumericTraits< T >::One
static

Multiplicative identity.

Definition at line 93 of file itkNumericTraits.h.

Referenced by itk::NumericTraits< InputImagePixelType >::OneValue().

## ◆ Zero

template<typename T>
 const T ITKCommon_EXPORT itk::NumericTraits< T >::Zero
static

The documentation for this class was generated from the following file: