ITK  5.4.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
24namespace itk
25{
43template <typename T, unsigned int D>
45{
46private:
52
53public:
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
100 {
101 return MakeFilled<Self>(NumericTraits<T>::max());
102 }
103
104 static const Self
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
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
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
Pixel-wise addition of two images.
void Fill(const ValueType &)
static void SetLength(SymmetricSecondRankTensor< T, D > &m, const unsigned int s)
typename NumericTraits< T >::AccumulateType ElementAccumulateType
static unsigned int GetLength(const SymmetricSecondRankTensor< T, D > &)
static void AssignToArray(const Self &v, MeasurementVectorType &mv)
Define additional traits for native types such as int or float.
static constexpr bool IsInteger
static constexpr bool IsSigned
static constexpr T NonpositiveMin()
static unsigned int GetLength()
static constexpr bool IsComplex
Represent a symmetric tensor of second rank.
AddImageFilter Self
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....