15#ifndef vtkMatrixUtilities_h
16#define vtkMatrixUtilities_h
18#include "vtkABINamespace.h"
25VTK_ABI_NAMESPACE_BEGIN
52template <
int ContainerTypeT,
class ContainerT>
55 typedef typename std::decay<typename std::decay<ContainerT>::type::value_type>
::type value_type;
57 "value_type is not a numeric type");
61template <
class ContainerT>
68 typedef typename std::decay<
typename std::remove_pointer<
typename std::remove_all_extents<
72 "value_type is not a numeric type");
76template <
class MatrixT,
int Depth = 0>
79 static constexpr int Value = Depth;
83template <
class MatrixT,
int Depth>
90template <
class MatrixT,
int N,
int Depth>
97template <
class MatrixT,
int Depth>
104template <
class MatrixT,
int Depth>
116template <
class MatrixT>
125template <
class MatrixT,
class =
void>
129template <
class MatrixT>
132 using Type =
decltype(std::declval<MatrixT>()[0][0]);
136template <
class MatrixT>
139 using Type =
decltype(std::declval<MatrixT>()[0]);
152template <
class ContainerT>
167 "value_type is not a numeric type");
187template <
class MatrixT>
201template <
class MatrixT>
204 return MatrixIs2DArray<MatrixT>();
210template <
int RowsT,
int ColsT,
class LayoutT>
214template <
int RowsT,
int ColsT>
217 template <
int RowT,
int ColT>
220 static_assert(RowT >= 0 && RowT < RowsT,
"RowT out of bounds");
221 static_assert(ColT >= 0 && ColT < ColsT,
"ColT out of bounds");
222 return ColsT * RowT + ColT;
226template <
int RowsT,
int ColsT>
229 template <
int RowT,
int ColT>
232 static_assert(RowT >= 0 && RowT < RowsT,
"RowT out of bounds");
233 static_assert(ColT >= 0 && ColT < ColsT,
"ColT out of bounds");
234 return RowsT * ColT + RowT;
251template <
int RowsT,
int ColsT,
class LayoutT = Layout::Identity>
254 template <
int RowT,
int ColT>
264template <
int RowsT,
int ColsT,
class MatrixT,
class LayoutT,
bool MatrixLayoutIs2DT>
269template <
int RowsT,
int ColsT,
class MatrixT,
class LayoutT>
270class Wrapper<RowsT, ColsT, MatrixT, LayoutT, false>
276 template <
int RowT,
int ColT,
class MatrixTT>
277 static ComponentType
Get(MatrixTT&& M)
284template <
int RowsT,
int ColsT,
class MatrixT>
291 template <
int RowT,
int ColT,
class MatrixTT>
292 static ComponentType
Get(MatrixTT&& M)
294 return M[RowT][ColT];
299template <
int RowsT,
int ColsT,
class MatrixT>
306 template <
int RowT,
int ColT,
class MatrixTT>
307 static ComponentType
Get(MatrixTT&& M)
309 return M[ColT][RowT];
315template <
int RowsT,
int ColsT,
class MatrixT>
322 template <
int RowT,
int ColT>
325 static constexpr Scalar
ZERO = Scalar(0);
327 template <
class MatrixTT>
328 static ComponentType Get(MatrixTT&&)
335 struct Helper<RowT, RowT>
337 template <
class MatrixTT>
338 static ComponentType Get(MatrixTT&& M)
345 template <
int RowT,
int ColT,
class MatrixTT>
346 ComponentType
Get(MatrixTT& M)
348 return Helper<RowT, ColT>::Get(std::forward<MatrixTT>(M));
368template <
int RowsT,
int ColsT,
class MatrixT,
class LayoutT = Layout::Identity>
376 "A diagonal matrix cannot be a 2D array");
379 template <
int RowT,
int ColT,
class MatrixTT>
380 static ComponentType
Get(MatrixTT&& M)
383 MatrixLayoutIs2D<MatrixT>()>::template Get<RowT, ColT>(std::forward<MatrixTT>(M));
static ComponentType Get(MatrixTT &&M)
static ComponentType Get(MatrixTT &&M)
ComponentType Get(MatrixTT &M)
static ComponentType Get(MatrixTT &&M)
static ComponentType Get(MatrixTT &&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 Value
static constexpr int GetIndex()
static constexpr int GetIndex()