27 #ifndef vtkMatrixUtilities_h
28 #define vtkMatrixUtilities_h
30 #include "vtkABINamespace.h"
32 #include <type_traits>
36 VTK_ABI_NAMESPACE_BEGIN
63 template <
int ContainerTypeT,
class ContainerT>
68 "value_type is not a numeric type");
72 template <
class ContainerT>
75 typedef typename std::remove_pointer<
79 "value_type is not a numeric type");
92 template <
class ContainerT>
104 "value_type is not a numeric type");
112 template <
class MatrixT>
125 template <
class MatrixT>
139 template <
class MatrixT>
160 template <
int RowsT,
int ColsT,
class LayoutT>
164 template <
int RowsT,
int ColsT>
167 template <
int RowT,
int ColT>
170 static_assert(RowT >= 0 && RowT < RowsT,
"RowT out of bounds");
171 static_assert(ColT >= 0 && ColT < ColsT,
"ColT out of bounds");
172 return ColsT * RowT + ColT;
176 template <
int RowsT,
int ColsT>
179 template <
int RowT,
int ColT>
182 static_assert(RowT >= 0 && RowT < RowsT,
"RowT out of bounds");
183 static_assert(ColT >= 0 && ColT < ColsT,
"ColT out of bounds");
184 return RowsT * ColT + RowT;
201 template <
int RowsT,
int ColsT,
class LayoutT = Layout::Identity>
204 template <
int RowT,
int ColT>
214 template <
int RowsT,
int ColsT,
class MatrixT,
class LayoutT,
bool MatrixLayoutIs2DT>
219 template <
int RowsT,
int ColsT,
class MatrixT,
class LayoutT>
220 class Wrapper<RowsT, ColsT, MatrixT, LayoutT, false>
226 template <
int RowT,
int ColT>
227 static const Scalar&
Get(
const MatrixT& M)
232 template <
int RowT,
int ColT>
233 static Scalar&
Get(MatrixT& M)
240 template <
int RowsT,
int ColsT,
class MatrixT>
247 template <
int RowT,
int ColT>
248 static const Scalar&
Get(
const MatrixT& M)
250 return M[RowT][ColT];
253 template <
int RowT,
int ColT>
254 static Scalar&
Get(MatrixT& M)
256 return M[RowT][ColT];
261 template <
int RowsT,
int ColsT,
class MatrixT>
268 template <
int RowT,
int ColT>
269 static const Scalar&
Get(
const MatrixT& M)
271 return M[ColT][RowT];
274 template <
int RowT,
int ColT>
275 static Scalar&
Get(MatrixT& M)
277 return M[ColT][RowT];
283 template <
int RowsT,
int ColsT,
class MatrixT>
289 template <
int RowT,
int ColT>
292 static constexpr Scalar ZERO = Scalar(0);
294 static Scalar& Get(
const MatrixT&) {
return ZERO; }
298 struct Helper<RowT, RowT>
300 static Scalar& Get(MatrixT& M) {
return M[RowT]; }
302 static const Scalar& Get(
const MatrixT& M) {
return M[RowT]; }
306 template <
int RowT,
int ColT>
307 const Scalar&
Get(
const MatrixT& M)
309 return Helper<RowT, ColT>::Get(M);
312 template <
int RowT,
int ColT>
315 return Helper<RowT, ColT>::Get(M);
335 template <
int RowsT,
int ColsT,
class MatrixT,
class LayoutT = Layout::Identity>
342 "A diagonal matrix cannot be a 2D array");
345 template <
int RowT,
int ColT>
346 static const Scalar&
Get(
const MatrixT& M)
349 MatrixLayoutIs2D<MatrixT>()>::template Get<RowT, ColT>(M);
352 template <
int RowT,
int ColT>
353 static Scalar&
Get(MatrixT& M)
356 MatrixLayoutIs2D<MatrixT>()>::template Get<RowT, ColT>(M);
359 VTK_ABI_NAMESPACE_END
static const Scalar & Get(const MatrixT &M)
static Scalar & Get(MatrixT &M)
static Scalar & Get(MatrixT &M)
static const Scalar & Get(const MatrixT &M)
const Scalar & Get(const MatrixT &M)
static const Scalar & Get(const MatrixT &M)
static Scalar & Get(MatrixT &M)
static const Scalar & Get(const MatrixT &M)
static Scalar & Get(MatrixT &M)
static constexpr bool MatrixIsPointerToPointer()
At compile time, returns true if the templated parameter is a pointer to pointer (double** for instan...
static constexpr bool MatrixIs2DArray()
At compile time, returns true if the templated parameter is a 2D array (double[3][3] for instance),...
static constexpr bool MatrixLayoutIs2D()
At compile time, returns true if the templated parameter layout is 2D, i.e.
This struct determines a prior transform to input matrices, changing the way they are indexed.
This class is a helper class to compute at compile time the index of a matrix stored as a 1D array fr...
static constexpr int GetIndex()
static constexpr int GetIndex()
static constexpr int GetIndex()