27#ifndef vtkMatrixUtilities_h
28#define vtkMatrixUtilities_h
60template <
int ContainerTypeT,
class ContainerT>
65 "value_type is not a numeric type");
69template <
class ContainerT>
72 typedef typename std::remove_pointer<
76 "value_type is not a numeric type");
89template <
class ContainerT>
101 "value_type is not a numeric type");
109template <
class MatrixT>
122template <
class MatrixT>
136template <
class MatrixT>
157template <
int RowsT,
int ColsT,
class LayoutT>
161template <
int RowsT,
int ColsT>
164 template <
int RowT,
int ColT>
167 static_assert(RowT >= 0 && RowT < RowsT,
"RowT out of bounds");
168 static_assert(ColT >= 0 && ColT < ColsT,
"ColT out of bounds");
169 return ColsT * RowT + ColT;
173template <
int RowsT,
int ColsT>
176 template <
int RowT,
int ColT>
179 static_assert(RowT >= 0 && RowT < RowsT,
"RowT out of bounds");
180 static_assert(ColT >= 0 && ColT < ColsT,
"ColT out of bounds");
181 return RowsT * ColT + RowT;
198template <
int RowsT,
int ColsT,
class LayoutT = Layout::Identity>
201 template <
int RowT,
int ColT>
211template <
int RowsT,
int ColsT,
class MatrixT,
class LayoutT,
bool MatrixLayoutIs2DT>
216template <
int RowsT,
int ColsT,
class MatrixT,
class LayoutT>
217class Wrapper<RowsT, ColsT, MatrixT, LayoutT, false>
223 template <
int RowT,
int ColT>
224 static const Scalar&
Get(
const MatrixT& M)
229 template <
int RowT,
int ColT>
230 static Scalar&
Get(MatrixT& M)
237template <
int RowsT,
int ColsT,
class MatrixT>
244 template <
int RowT,
int ColT>
245 static const Scalar&
Get(
const MatrixT& M)
247 return M[RowT][ColT];
250 template <
int RowT,
int ColT>
251 static Scalar&
Get(MatrixT& M)
253 return M[RowT][ColT];
258template <
int RowsT,
int ColsT,
class MatrixT>
265 template <
int RowT,
int ColT>
266 static const Scalar&
Get(
const MatrixT& M)
268 return M[ColT][RowT];
271 template <
int RowT,
int ColT>
272 static Scalar&
Get(MatrixT& M)
274 return M[ColT][RowT];
280template <
int RowsT,
int ColsT,
class MatrixT>
286 template <
int RowT,
int ColT>
289 static constexpr Scalar ZERO = Scalar(0);
291 static Scalar& Get(
const MatrixT&) {
return ZERO; }
295 struct Helper<RowT, RowT>
297 static Scalar& Get(MatrixT& M) {
return M[RowT]; }
299 static const Scalar& Get(
const MatrixT& M) {
return M[RowT]; }
303 template <
int RowT,
int ColT>
304 const Scalar&
Get(
const MatrixT& M)
306 return Helper<RowT, ColT>::Get(M);
309 template <
int RowT,
int ColT>
312 return Helper<RowT, ColT>::Get(M);
332template <
int RowsT,
int ColsT,
class MatrixT,
class LayoutT = Layout::Identity>
339 "A diagonal matrix cannot be a 2D array");
342 template <
int RowT,
int ColT>
343 static const Scalar&
Get(
const MatrixT& M)
346 MatrixLayoutIs2D<MatrixT>()>::template Get<RowT, ColT>(M);
349 template <
int RowT,
int ColT>
350 static Scalar&
Get(MatrixT& M)
353 MatrixLayoutIs2D<MatrixT>()>::template Get<RowT, ColT>(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)
const Scalar & Get(const MatrixT &M)
static Scalar & Get(MatrixT &M)
static const Scalar & Get(const MatrixT &M)
static Scalar & Get(MatrixT &M)
static const Scalar & Get(const 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, chaging 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()