15 #ifndef vtkMatrixUtilities_h
16 #define vtkMatrixUtilities_h
18 #include "vtkABINamespace.h"
20 #include <type_traits>
25 VTK_ABI_NAMESPACE_BEGIN
52 template <
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");
61 template <
class ContainerT>
68 typedef typename std::decay<
typename std::remove_pointer<
typename std::remove_all_extents<
72 "value_type is not a numeric type");
76 template <
class MatrixT,
int Depth = 0>
79 static constexpr
int Value = Depth;
83 template <
class MatrixT,
int Depth>
90 template <
class MatrixT,
int N,
int Depth>
97 template <
class MatrixT,
int Depth>
104 template <
class MatrixT,
int Depth>
116 template <
class MatrixT>
125 template <
class MatrixT,
class =
void>
129 template <
class MatrixT>
132 using Type = decltype(std::declval<MatrixT>()[0][0]);
136 template <
class MatrixT>
139 using Type = decltype(std::declval<MatrixT>()[0]);
152 template <
class ContainerT>
167 "value_type is not a numeric type");
187 template <
class MatrixT>
201 template <
class MatrixT>
204 return MatrixIs2DArray<MatrixT>();
210 template <
int RowsT,
int ColsT,
class LayoutT>
214 template <
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;
226 template <
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;
251 template <
int RowsT,
int ColsT,
class LayoutT = Layout::Identity>
254 template <
int RowT,
int ColT>
264 template <
int RowsT,
int ColsT,
class MatrixT,
class LayoutT,
bool MatrixLayoutIs2DT>
269 template <
int RowsT,
int ColsT,
class MatrixT,
class LayoutT>
270 class Wrapper<RowsT, ColsT, MatrixT, LayoutT, false>
276 template <
int RowT,
int ColT,
class MatrixTT>
277 static ComponentType
Get(MatrixTT&& M)
284 template <
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];
299 template <
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];
315 template <
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));
368 template <
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));
386 VTK_ABI_NAMESPACE_END
static constexpr int GetIndex()
static constexpr int Value
ComponentType Get(MatrixTT &M)
static ComponentType Get(MatrixTT &&M)
static constexpr bool MatrixIs2DArray()
At compile time, returns true if the templated parameter is a 2D array (double[3][3] for instance)...
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...
This struct determines a prior transform to input matrices, changing the way they are indexed...
static constexpr bool MatrixLayoutIs2D()
At compile time, returns true if the templated parameter layout is 2D, i.e.
static constexpr int GetIndex()
This class is a helper class to compute at compile time the index of a matrix stored as a 1D array fr...
static ComponentType Get(MatrixTT &&M)
static ComponentType Get(MatrixTT &&M)
static constexpr int GetIndex()