ITK  6.0.0
Insight Toolkit
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{
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;
85
88
91
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
114 SymmetricSecondRankTensor(const ComponentType & r) { this->Fill(r); }
115
117 template <typename TCoordinateB>
119 : BaseArray(pa)
120 {}
121
122 using ComponentArrayType = ComponentType[Self::InternalDimension];
123
126 : BaseArray(r)
127 {}
128
130 template <typename TCoordinateB>
131 Self &
133 {
134 BaseArray::operator=(pa);
135 return *this;
136 }
140 Self &
142
143 Self &
145
148 Self
149 operator+(const Self & r) const;
150
151 Self
152 operator-(const Self & r) const;
153
154 const Self &
155 operator+=(const Self & r);
156
157 const Self &
158 operator-=(const Self & r);
159
161 Self
162 operator*(const RealValueType & r) const;
163
164 Self
165 operator/(const RealValueType & r) const;
166
167 const Self &
169
170 const Self &
172
174 static unsigned int
176 {
177 return Self::InternalDimension;
178 }
179
181 ComponentType
182 GetNthComponent(int c) const
183 {
184 return this->operator[](c);
185 }
186
188 void
190 {
191 this->operator[](c) = v;
192 }
193
195 ValueType &
196 operator()(unsigned int row, unsigned int col);
197
198 const ValueType &
199 operator()(unsigned int row, unsigned int col) const;
200
203 void
205
208 GetTrace() const;
209
211 void
213
216 void
218
222 template <typename TMatrixValueType>
223 Self
225 template <typename TMatrixValueType>
226 Self
227 Rotate(const vnl_matrix_fixed<TMatrixValueType, VDimension, VDimension> & m) const
228 {
229 return this->Rotate(static_cast<Matrix<TMatrixValueType, VDimension, VDimension>>(m));
230 }
231 template <typename TMatrixValueType>
232 Self
233 Rotate(const vnl_matrix<TMatrixValueType> & m) const
234 {
235 return this->Rotate(static_cast<Matrix<TMatrixValueType>>(m));
236 }
240 MatrixType
241 PreMultiply(const MatrixType & m) const;
242
245 PostMultiply(const MatrixType & m) const;
246
247private:
248};
249
252using OutputStreamType = std::ostream;
253using InputStreamType = std::istream;
254
255template <typename TComponent, unsigned int VDimension>
258
259template <typename TComponent, unsigned int VDimension>
262
263template <typename T>
264inline void
266{
267 a.swap(b);
268}
269} // end namespace itk
270
272
273#ifndef ITK_MANUAL_INSTANTIATION
274# include "itkSymmetricSecondRankTensor.hxx"
275#endif
276
277#endif
Pixel-wise addition of two images.
Simulate a standard C array with copy semantics.
Definition: itkFixedArray.h:54
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
SymmetricSecondRankTensor(const ComponentType &r)
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
AccumulateValueType GetTrace() const
Self Rotate(const Matrix< TMatrixValueType, VDimension, VDimension > &m) const
Self & operator=(const ComponentType &r)
MatrixType PreMultiply(const MatrixType &m) const
ComponentType GetNthComponent(int c) 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)
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:242
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