15 #ifndef vtkMatrixUtilities_h
16 #define vtkMatrixUtilities_h
18 #include "vtkABINamespace.h"
20 #include <type_traits>
24 VTK_ABI_NAMESPACE_BEGIN
51 template <
int ContainerTypeT,
class ContainerT>
56 "value_type is not a numeric type");
60 template <
class ContainerT>
63 typedef typename std::remove_pointer<
67 "value_type is not a numeric type");
80 template <
class ContainerT>
92 "value_type is not a numeric type");
100 template <
class MatrixT>
113 template <
class MatrixT>
127 template <
class MatrixT>
148 template <
int RowsT,
int ColsT,
class LayoutT>
152 template <
int RowsT,
int ColsT>
155 template <
int RowT,
int ColT>
158 static_assert(RowT >= 0 && RowT < RowsT,
"RowT out of bounds");
159 static_assert(ColT >= 0 && ColT < ColsT,
"ColT out of bounds");
160 return ColsT * RowT + ColT;
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 RowsT * ColT + RowT;
189 template <
int RowsT,
int ColsT,
class LayoutT = Layout::Identity>
192 template <
int RowT,
int ColT>
202 template <
int RowsT,
int ColsT,
class MatrixT,
class LayoutT,
bool MatrixLayoutIs2DT>
207 template <
int RowsT,
int ColsT,
class MatrixT,
class LayoutT>
208 class Wrapper<RowsT, ColsT, MatrixT, LayoutT, false>
214 template <
int RowT,
int ColT>
215 static const Scalar&
Get(
const MatrixT& M)
220 template <
int RowT,
int ColT>
221 static Scalar&
Get(MatrixT& M)
228 template <
int RowsT,
int ColsT,
class MatrixT>
235 template <
int RowT,
int ColT>
236 static const Scalar&
Get(
const MatrixT& M)
238 return M[RowT][ColT];
241 template <
int RowT,
int ColT>
242 static Scalar&
Get(MatrixT& M)
244 return M[RowT][ColT];
249 template <
int RowsT,
int ColsT,
class MatrixT>
256 template <
int RowT,
int ColT>
257 static const Scalar&
Get(
const MatrixT& M)
259 return M[ColT][RowT];
262 template <
int RowT,
int ColT>
263 static Scalar&
Get(MatrixT& M)
265 return M[ColT][RowT];
271 template <
int RowsT,
int ColsT,
class MatrixT>
277 template <
int RowT,
int ColT>
280 static constexpr Scalar ZERO = Scalar(0);
282 static Scalar& Get(
const MatrixT&) {
return ZERO; }
286 struct Helper<RowT, RowT>
288 static Scalar& Get(MatrixT& M) {
return M[RowT]; }
290 static const Scalar& Get(
const MatrixT& M) {
return M[RowT]; }
294 template <
int RowT,
int ColT>
295 const Scalar&
Get(
const MatrixT& M)
297 return Helper<RowT, ColT>::Get(M);
300 template <
int RowT,
int ColT>
303 return Helper<RowT, ColT>::Get(M);
323 template <
int RowsT,
int ColsT,
class MatrixT,
class LayoutT = Layout::Identity>
330 "A diagonal matrix cannot be a 2D array");
333 template <
int RowT,
int ColT>
334 static const Scalar&
Get(
const MatrixT& M)
337 MatrixLayoutIs2D<MatrixT>()>::
template Get<RowT, ColT>(M);
340 template <
int RowT,
int ColT>
341 static Scalar&
Get(MatrixT& M)
344 MatrixLayoutIs2D<MatrixT>()>::
template Get<RowT, ColT>(M);
347 VTK_ABI_NAMESPACE_END
static constexpr int GetIndex()
static constexpr bool MatrixIs2DArray()
At compile time, returns true if the templated parameter is a 2D array (double[3][3] for instance)...
static const Scalar & Get(const MatrixT &M)
static const Scalar & Get(const MatrixT &M)
const Scalar & Get(const MatrixT &M)
static Scalar & Get(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...
This struct determines a prior transform to input matrices, changing the way they are indexed...
static Scalar & Get(MatrixT &M)
static constexpr bool MatrixLayoutIs2D()
At compile time, returns true if the templated parameter layout is 2D, i.e.
static constexpr int GetIndex()
static const Scalar & Get(const MatrixT &M)
This class is a helper class to compute at compile time the index of a matrix stored as a 1D array fr...
static const Scalar & Get(const MatrixT &M)
static Scalar & Get(MatrixT &M)
static constexpr int GetIndex()