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 "itkIndent.h"
27#include "itkFixedArray.h"
28#include "itkMatrix.h"
30
31namespace itk
32{
73
74template <typename TComponent, unsigned int VDimension = 3>
75class ITK_TEMPLATE_EXPORT SymmetricSecondRankTensor : public FixedArray<TComponent, VDimension *(VDimension + 1) / 2>
76{
77public:
80 using Superclass = FixedArray<TComponent, VDimension *(VDimension + 1) / 2>;
81
83 static constexpr unsigned int Dimension = VDimension;
84 static constexpr unsigned int InternalDimension = VDimension * (VDimension + 1) / 2;
95
97 using ComponentType = TComponent;
98 using typename Superclass::ValueType;
101
104
107#ifdef ITK_FUTURE_LEGACY_REMOVE
109#else
110 SymmetricSecondRankTensor() { this->Fill(0); }
111#endif
112
114
116 template <typename TCoordinateB>
120
122
127
129 template <typename TCoordinateB>
130 Self &
136
138 Self &
140
141 Self &
143
146 Self
147 operator+(const Self & r) const;
148
149 Self
150 operator-(const Self & r) const;
151
152 const Self &
153 operator+=(const Self & r);
154
155 const Self &
156 operator-=(const Self & r);
157
159 Self
160 operator*(const RealValueType & r) const;
161
162 Self
163 operator/(const RealValueType & r) const;
164
165 const Self &
167
168 const Self &
170
172 static unsigned int
177
179 ComponentType
180 GetNthComponent(int c) const
181 {
182 return this->operator[](c);
183 }
184
186 void
188 {
189 this->operator[](c) = v;
190 }
191
193 ValueType &
194 operator()(unsigned int row, unsigned int col);
195
196 const ValueType &
197 operator()(unsigned int row, unsigned int col) const;
198
201 void
203
206 GetTrace() const;
207
209 void
211
214 void
216
221 template <typename TMatrixValueType>
222 Self
224 template <typename TMatrixValueType>
225 Self
226 Rotate(const vnl_matrix_fixed<TMatrixValueType, VDimension, VDimension> & m) const
227 {
228 return this->Rotate(static_cast<Matrix<TMatrixValueType, VDimension, VDimension>>(m));
229 }
230 template <typename TMatrixValueType>
231 Self
232 Rotate(const vnl_matrix<TMatrixValueType> & m) const
233 {
234 return this->Rotate(static_cast<Matrix<TMatrixValueType>>(m));
235 }
236
237
239 MatrixType
240 PreMultiply(const MatrixType & m) const;
241
244 PostMultiply(const MatrixType & m) const;
245
246private:
247};
248
251using OutputStreamType = std::ostream;
252using InputStreamType = std::istream;
253
254template <typename TComponent, unsigned int VDimension>
257
258template <typename TComponent, unsigned int VDimension>
261
262template <typename T>
263inline void
265{
266 a.swap(b);
267}
268} // end namespace itk
269
271
272#ifndef ITK_MANUAL_INSTANTIATION
273# include "itkSymmetricSecondRankTensor.hxx"
274#endif
275
276#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)
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)
std::istream InputStreamType
std::ostream OutputStreamType