ITK  5.2.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  * http://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 Self(NumericTraits<T>::max());
90  }
91 
92  static const Self
93  min(const Self &)
94  {
95  return Self(NumericTraits<T>::min());
96  }
97 
98  static const Self
99  max()
100  {
101  return Self(NumericTraits<T>::max());
102  }
103 
104  static const Self
105  min()
106  {
107  return Self(NumericTraits<T>::min());
108  }
109 
110  static const Self
112  {
114  }
115 
116  static const Self
118  {
120  }
121 
122  static const Self
124  {
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 
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  }
164  }
166 
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
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::min
static const Self min()
Definition: itkNumericTraitsTensorPixel.h:105
itk::NumericTraits::NonpositiveMin
static constexpr T NonpositiveMin()
Definition: itkNumericTraits.h:97
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::OneValue
static const Self OneValue()
Definition: itkNumericTraitsTensorPixel.h:123
itk::NumericTraits::AccumulateType
double AccumulateType
Definition: itkNumericTraits.h:74
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:133
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::ValueType
T ValueType
Definition: itkNumericTraitsTensorPixel.h:55
itk::NumericTraits::IsInteger
static constexpr bool IsInteger
Definition: itkNumericTraits.h:138
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:156
itk::NumericTraits::PrintType
T PrintType
Definition: itkNumericTraits.h:68
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:58
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:148
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: itkAnnulusOperator.h:24
itk::NumericTraits::GetLength
static unsigned int GetLength()
Definition: itkNumericTraits.h:208
itk::NumericTraits::IsComplex
static constexpr bool IsComplex
Definition: itkNumericTraits.h:143
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:84
itk::NumericTraits::FloatType
float FloatType
Definition: itkNumericTraits.h:81
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:71
itk::NumericTraits< SymmetricSecondRankTensor< T, D > >::max
static const Self max(const Self &)
Definition: itkNumericTraitsTensorPixel.h:87
itk::FixedArray< TComponent, NDimension *(NDimension+1)/2 >::Fill
void Fill(const ValueType &)