ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkSymmetricSecondRankTensor.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 itkSymmetricSecondRankTensor_h
19#define itkSymmetricSecondRankTensor_h
20
21// Undefine an eventual SymmetricSecondRankTensor macro
22#ifdef SymmetricSecondRankTensor
23# undef SymmetricSecondRankTensor
24#endif
25
26#include "itkFixedArray.h"
27#include "itkMatrix.h"
29
30namespace itk
31{
72
73template <typename TComponent, unsigned int VDimension = 3>
74class ITK_TEMPLATE_EXPORT SymmetricSecondRankTensor : public FixedArray<TComponent, VDimension *(VDimension + 1) / 2>
75{
76public:
79 using Superclass = FixedArray<TComponent, VDimension *(VDimension + 1) / 2>;
80
82 static constexpr unsigned int Dimension = VDimension;
83 static constexpr unsigned int InternalDimension = VDimension * (VDimension + 1) / 2;
84
87
90
94
96 using ComponentType = TComponent;
97 using typename Superclass::ValueType;
100
103
106#ifdef ITK_FUTURE_LEGACY_REMOVE
108#else
109 SymmetricSecondRankTensor() { this->Fill(0); }
110#endif
111
113
115 template <typename TCoordinateB>
119
121
126
128 template <typename TCoordinateB>
129 Self &
135
137 Self &
139
140 Self &
142
145 Self
146 operator+(const Self & r) const;
147
148 Self
149 operator-(const Self & r) const;
150
151 const Self &
152 operator+=(const Self & r);
153
154 const Self &
155 operator-=(const Self & r);
156
158 Self
159 operator*(const RealValueType & r) const;
160
161 Self
162 operator/(const RealValueType & r) const;
163
164 const Self &
166
167 const Self &
169
171 static unsigned int
176
178 [[nodiscard]] ComponentType
179 GetNthComponent(int c) const
180 {
181 return this->operator[](c);
182 }
183
185 void
187 {
188 this->operator[](c) = v;
189 }
190
192 ValueType &
193 operator()(unsigned int row, unsigned int col);
194
195 const ValueType &
196 operator()(unsigned int row, unsigned int col) const;
197
200 void
202
204 [[nodiscard]] AccumulateValueType
205 GetTrace() const;
206
208 void
210
213 void
215
220 template <typename TMatrixValueType>
221 Self
223 template <typename TMatrixValueType>
224 Self
225 Rotate(const vnl_matrix_fixed<TMatrixValueType, VDimension, VDimension> & m) const
226 {
227 return this->Rotate(static_cast<Matrix<TMatrixValueType, VDimension, VDimension>>(m));
228 }
229 template <typename TMatrixValueType>
230 Self
231 Rotate(const vnl_matrix<TMatrixValueType> & m) const
232 {
233 return this->Rotate(static_cast<Matrix<TMatrixValueType>>(m));
234 }
235
236
238 [[nodiscard]] MatrixType
239 PreMultiply(const MatrixType & m) const;
240
242 [[nodiscard]] MatrixType
243 PostMultiply(const MatrixType & m) const;
244};
245
248using OutputStreamType = std::ostream;
249using InputStreamType = std::istream;
250
251template <typename TComponent, unsigned int VDimension>
254
255template <typename TComponent, unsigned int VDimension>
258
259template <typename T>
260inline void
262{
263 a.swap(b);
264}
265} // end namespace itk
266
268
269#ifndef ITK_MANUAL_INSTANTIATION
270# include "itkSymmetricSecondRankTensor.hxx"
271#endif
272
273#endif
FixedArray & operator=(const FixedArray< TFixedArrayValueType, VLength > &r)
ITK_GCC_PRAGMA_PUSH ITK_GCC_SUPPRESS_Warray_bounds constexpr reference operator[](unsigned int index)
A templated class holding a M x N size Matrix.
Definition itkMatrix.h:53
Represent a symmetric tensor of second rank.
void ComputeEigenAnalysis(EigenValuesArrayType &eigenValues, EigenVectorsMatrixType &eigenVectors) const
const Self & operator*=(const RealValueType &r)
Self operator/(const RealValueType &r) const
MatrixType PostMultiply(const MatrixType &m) const
Self operator*(const RealValueType &r) const
typename NumericTraits< ValueType >::RealType RealValueType
Self & operator=(const SymmetricSecondRankTensor< TCoordinateB, VDimension > &pa)
Self Rotate(const vnl_matrix< TMatrixValueType > &m) const
Self & operator=(const ComponentArrayType r)
Self operator+(const Self &r) const
SymmetricSecondRankTensor(const ComponentArrayType r)
SymmetricSecondRankTensor(const SymmetricSecondRankTensor< TCoordinateB, VDimension > &pa)
Self operator-(const Self &r) const
ComponentType[Self::InternalDimension] ComponentArrayType
FixedArray< TComponent, VDimension > EigenValuesArrayType
Matrix< TComponent, VDimension, VDimension > EigenVectorsMatrixType
AccumulateValueType GetTrace() const
FixedArray< TComponent, Self::InternalDimension > BaseArray
Self Rotate(const Matrix< TMatrixValueType, VDimension, VDimension > &m) const
Self & operator=(const ComponentType &r)
FixedArray< TComponent, VDimension *(VDimension+1)/2 > Superclass
SymmetricEigenAnalysisFixedDimension< Dimension, MatrixType, EigenValuesArrayType, EigenVectorsMatrixType > SymmetricEigenAnalysisType
MatrixType PreMultiply(const MatrixType &m) const
const Self & operator+=(const Self &r)
void ComputeEigenValues(EigenValuesArrayType &eigenValues) const
const Self & operator-=(const Self &r)
Self Rotate(const vnl_matrix_fixed< TMatrixValueType, VDimension, VDimension > &m) const
const ValueType & operator()(unsigned int row, unsigned int col) const
typename NumericTraits< ValueType >::RealType AccumulateValueType
const Self & operator/=(const RealValueType &r)
Matrix< TComponent, VDimension, VDimension > MatrixType
void SetNthComponent(int c, const ComponentType &v)
ValueType & operator()(unsigned int row, unsigned int col)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
void swap(Array< T > &a, Array< T > &b) noexcept
Definition itkArray.h:247
std::istream & operator>>(std::istream &is, Point< T, VPointDimension > &vct)
std::istream InputStreamType
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, AnatomicalOrientation::CoordinateEnum value)
std::ostream OutputStreamType