ITK  6.0.0
Insight Toolkit
itkNumericTraitsTensorPixel.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * https://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkNumericTraitsTensorPixel_h
19 #define itkNumericTraitsTensorPixel_h
20 
21 #include "itkNumericTraits.h"
23 
24 namespace itk
25 {
43 template <typename T, unsigned int D>
45 {
46 private:
52 
53 public:
55  using ValueType = T;
56 
58 
61 
64 
68 
71 
74 
77 
80 
86  static const Self
87  max(const Self &)
88  {
89  return MakeFilled<Self>(NumericTraits<T>::max());
90  }
91 
92  static const Self
93  min(const Self &)
94  {
95  return MakeFilled<Self>(NumericTraits<T>::min());
96  }
97 
98  static const Self
99  max()
100  {
101  return MakeFilled<Self>(NumericTraits<T>::max());
102  }
103 
104  static const Self
105  min()
106  {
107  return MakeFilled<Self>(NumericTraits<T>::min());
108  }
109 
110  static const Self
112  {
113  return MakeFilled<Self>(NumericTraits<T>::NonpositiveMin());
114  }
115 
116  static const Self
118  {
119  return Self{};
120  }
121 
122  static const Self
124  {
125  return MakeFilled<Self>(NumericTraits<T>::OneValue());
126  }
127 
128  static const Self
130  {
131  return NonpositiveMin();
132  }
133 
134  static const Self
135  ZeroValue(const Self &)
136  {
137  return ZeroValue();
138  }
139 
140  static const Self
141  OneValue(const Self &)
142  {
143  return OneValue();
144  }
145 
146  static constexpr bool IsSigned = std::is_signed_v<ValueType>;
147  static constexpr bool IsInteger = std::is_integral_v<ValueType>;
149 
154  static void
155  SetLength(SymmetricSecondRankTensor<T, D> & m, const unsigned int s)
156  {
157  if (s != D * (D + 1) / 2)
158  {
159  itkGenericExceptionMacro("Cannot set the size of a SymmetricSecondRankTensor "
160  "of dimension "
161  << D << " ( = size of " << D * (D + 1) / 2 << ") to " << s);
162  }
163  m.Fill(T{});
164  }
168  static unsigned int
170  {
171  return GetLength();
172  }
173 
175  static unsigned int
177  {
178  return D * (D + 1) / 2;
179  }
180 
181  static void
183  {
184  mv = v;
185  }
186 
187  template <typename TArray>
188  static void
189  AssignToArray(const Self & v, TArray & mv)
190  {
191  for (unsigned int i = 0; i < GetLength(); ++i)
192  {
193  mv[i] = v[i];
194  }
195  }
196 
200  static const Self ITKCommon_EXPORT Zero;
201  static const Self ITKCommon_EXPORT One;
202 };
203 } // end namespace itk
204 
205 #endif // itkNumericTraitsTensorPixel_h
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::One
static const Self ITKCommon_EXPORT One
Definition: itkNumericTraitsTensorPixel.h:201
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::ElementPrintType
typename NumericTraits< T >::PrintType ElementPrintType
Definition: itkNumericTraitsTensorPixel.h:50
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::NonpositiveMin
static const Self NonpositiveMin()
Definition: itkNumericTraitsTensorPixel.h:111
Self
AddImageFilter Self
Definition: itkAddImageFilter.h:89
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::min
static const Self min()
Definition: itkNumericTraitsTensorPixel.h:105
itk::NumericTraits::NonpositiveMin
static constexpr T NonpositiveMin()
Definition: itkNumericTraits.h:99
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::OneValue
static const Self OneValue()
Definition: itkNumericTraitsTensorPixel.h:123
itk::NumericTraits::AccumulateType
double AccumulateType
Definition: itkNumericTraits.h:76
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::AssignToArray
static void AssignToArray(const Self &v, TArray &mv)
Definition: itkNumericTraitsTensorPixel.h:189
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::ElementAbsType
typename NumericTraits< T >::AbsType ElementAbsType
Definition: itkNumericTraitsTensorPixel.h:47
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::ZeroValue
static const Self ZeroValue()
Definition: itkNumericTraitsTensorPixel.h:117
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::GetLength
static unsigned int GetLength()
Definition: itkNumericTraitsTensorPixel.h:176
itk::SymmetricSecondRankTensor
Represent a symmetric tensor of second rank.
Definition: itkSymmetricSecondRankTensor.h:75
itk::NumericTraits::IsSigned
static constexpr bool IsSigned
Definition: itkNumericTraits.h:135
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::ValueType
T ValueType
Definition: itkNumericTraitsTensorPixel.h:55
itk::NumericTraits::IsInteger
static constexpr bool IsInteger
Definition: itkNumericTraits.h:140
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::GetLength
static unsigned int GetLength(const SymmetricSecondRankTensor< T, D > &)
Definition: itkNumericTraitsTensorPixel.h:169
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::max
static const Self max()
Definition: itkNumericTraitsTensorPixel.h:99
itkSymmetricSecondRankTensor.h
itk::NumericTraits::OneValue
static T OneValue()
Definition: itkNumericTraits.h:158
itk::NumericTraits::PrintType
T PrintType
Definition: itkNumericTraits.h:70
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::AssignToArray
static void AssignToArray(const Self &v, MeasurementVectorType &mv)
Definition: itkNumericTraitsTensorPixel.h:182
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::ElementRealType
typename NumericTraits< T >::RealType ElementRealType
Definition: itkNumericTraitsTensorPixel.h:51
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::ZeroValue
static const Self ZeroValue(const Self &)
Definition: itkNumericTraitsTensorPixel.h:135
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:60
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::Zero
static const Self ITKCommon_EXPORT Zero
Definition: itkNumericTraitsTensorPixel.h:200
itk::NumericTraits::ZeroValue
static T ZeroValue()
Definition: itkNumericTraits.h:150
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::ScalarRealType
ElementRealType ScalarRealType
Definition: itkNumericTraitsTensorPixel.h:76
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::min
static const Self min(const Self &)
Definition: itkNumericTraitsTensorPixel.h:93
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::SetLength
static void SetLength(SymmetricSecondRankTensor< T, D > &m, const unsigned int s)
Definition: itkNumericTraitsTensorPixel.h:155
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::NumericTraits::GetLength
static unsigned int GetLength()
Definition: itkNumericTraits.h:210
itk::NumericTraits::IsComplex
static constexpr bool IsComplex
Definition: itkNumericTraits.h:145
itkNumericTraits.h
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::ElementFloatType
typename NumericTraits< T >::FloatType ElementFloatType
Definition: itkNumericTraitsTensorPixel.h:49
itk::NumericTraits::RealType
double RealType
Definition: itkNumericTraits.h:86
AddImageFilter
Definition: itkAddImageFilter.h:81
itk::NumericTraits::FloatType
float FloatType
Definition: itkNumericTraits.h:83
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::NonpositiveMin
static const Self NonpositiveMin(const Self &)
Definition: itkNumericTraitsTensorPixel.h:129
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::ElementAccumulateType
typename NumericTraits< T >::AccumulateType ElementAccumulateType
Definition: itkNumericTraitsTensorPixel.h:48
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::OneValue
static const Self OneValue(const Self &)
Definition: itkNumericTraitsTensorPixel.h:141
itk::NumericTraits::AbsType
T AbsType
Definition: itkNumericTraits.h:73
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::max
static const Self max(const Self &)
Definition: itkNumericTraitsTensorPixel.h:87
itk::FixedArray< TComponent, VDimension *(VDimension+1)/2 >::Fill
void Fill(const ValueType &)