11#ifndef CUBBYFLOW_MATRIX_HPP
12#define CUBBYFLOW_MATRIX_HPP
26template <
typename T,
size_t Rows,
size_t Cols>
33 "This class should be a static-sized matrix.");
37 using Base::operator();
54 template <
typename...
Args>
61 template <
size_t R,
size_t C,
typename E>
66 explicit Matrix(ConstPointer
ptr);
76 : m_elements(std::move(
other.m_elements))
83 m_elements =
other.m_elements;
89 m_elements = std::move(
other.m_elements);
95 void Fill(
const std::function<
T(
size_t i)>&
func);
97 void Fill(
const std::function<
T(
size_t i,
size_t j)>&
func);
101 [[
nodiscard]]
constexpr size_t GetRows()
const;
103 [[
nodiscard]]
constexpr size_t GetCols()
const;
107 constexpr ConstIterator begin()
const;
111 constexpr ConstIterator end()
const;
115 constexpr ConstPointer data()
const;
117 Reference operator[](
size_t i);
119 ConstReference operator[](
size_t i)
const;
122 std::array<T, Rows * Cols> m_elements;
131 using Base::operator();
151 template <
size_t R,
size_t C,
typename E>
154 Matrix(
const std::initializer_list<T>&
lst);
176 x = std::move(
other.x);
182 void Fill(
const std::function<
T(
size_t i)>&
func);
184 void Fill(
const std::function<
T(
size_t i,
size_t j)>&
func);
188 [[
nodiscard]]
constexpr size_t GetRows()
const;
190 [[
nodiscard]]
constexpr size_t GetCols()
const;
194 [[
nodiscard]]
constexpr ConstIterator begin()
const;
198 [[
nodiscard]]
constexpr ConstIterator end()
const;
202 [[
nodiscard]]
constexpr ConstPointer data()
const;
204 Reference operator[](
size_t i);
206 ConstReference operator[](
size_t i)
const;
208 constexpr static Matrix MakeUnitX();
210 constexpr static Matrix MakeUnit(
size_t i);
221 using Base::operator();
241 template <
size_t R,
size_t C,
typename E>
244 Matrix(
const std::initializer_list<T>&
lst);
254 : x(std::move(
other.x)), y(std::move(
other.y))
268 x = std::move(
other.x);
269 y = std::move(
other.y);
275 void Fill(
const std::function<
T(
size_t i)>&
func);
277 void Fill(
const std::function<
T(
size_t i,
size_t j)>&
func);
281 [[
nodiscard]]
constexpr size_t GetRows()
const;
283 [[
nodiscard]]
constexpr size_t GetCols()
const;
287 [[
nodiscard]]
constexpr ConstIterator begin()
const;
291 [[
nodiscard]]
constexpr ConstIterator end()
const;
295 [[
nodiscard]]
constexpr ConstPointer data()
const;
297 Reference operator[](
size_t i);
299 ConstReference operator[](
size_t i)
const;
301 constexpr static Matrix MakeUnitX();
303 constexpr static Matrix MakeUnitY();
305 constexpr static Matrix MakeUnit(
size_t i);
317 using Base::operator();
344 template <
size_t R,
size_t C,
typename E>
347 Matrix(
const std::initializer_list<T>&
lst);
406 using Base::operator();
427 template <
size_t R,
size_t C,
typename E>
430 Matrix(
const std::initializer_list<T>&
lst);
441 : x(std::move(
other.x)),
442 y(std::move(
other.y)),
443 z(std::move(
other.z)),
444 w(std::move(
other.w))
460 x = std::move(
other.x);
461 y = std::move(
other.y);
462 z = std::move(
other.z);
463 w = std::move(
other.w);
469 void Fill(
const std::function<
T(
size_t i)>&
func);
471 void Fill(
const std::function<
T(
size_t i,
size_t j)>&
func);
475 [[
nodiscard]]
constexpr size_t GetRows()
const;
477 [[
nodiscard]]
constexpr size_t GetCols()
const;
481 [[
nodiscard]]
constexpr ConstIterator begin()
const;
485 [[
nodiscard]]
constexpr ConstIterator end()
const;
489 [[
nodiscard]]
constexpr ConstPointer data()
const;
491 Reference operator[](
size_t i);
493 ConstReference operator[](
size_t i)
const;
495 constexpr static Matrix MakeUnitX();
497 constexpr static Matrix MakeUnitY();
499 constexpr static Matrix MakeUnitZ();
501 constexpr static Matrix MakeUnitW();
503 constexpr static Matrix MakeUnit(
size_t i);
514 T, MATRIX_SIZE_DYNAMIC, MATRIX_SIZE_DYNAMIC,
515 Matrix<T, MATRIX_SIZE_DYNAMIC, MATRIX_SIZE_DYNAMIC>>,
517 T, MATRIX_SIZE_DYNAMIC, MATRIX_SIZE_DYNAMIC,
518 Matrix<T, MATRIX_SIZE_DYNAMIC, MATRIX_SIZE_DYNAMIC>>
529 T, MATRIX_SIZE_DYNAMIC, MATRIX_SIZE_DYNAMIC,
536 template <
size_t R,
size_t C,
typename E>
555 void Fill(
const std::function<
T(
size_t i)>&
func);
557 void Fill(
const std::function<
T(
size_t i,
size_t j)>&
func);
571 [[
nodiscard]] ConstIterator begin()
const;
581 Reference operator[](
size_t i);
583 ConstReference operator[](
size_t i)
const;
586 std::vector<T> m_elements;
594 Matrix<T, MATRIX_SIZE_DYNAMIC, 1>>,
596 Matrix<T, MATRIX_SIZE_DYNAMIC, 1>>
613 template <
size_t R,
size_t C,
typename E>
616 Matrix(
const std::initializer_list<T>&
lst);
632 void Fill(
const std::function<
T(
size_t i)>&
func);
634 void Fill(
const std::function<
T(
size_t i,
size_t j)>&
func);
640 void AddElement(ConstReference
newElem);
648 [[
nodiscard]]
constexpr size_t GetCols()
const;
652 [[
nodiscard]] ConstIterator begin()
const;
662 Reference operator[](
size_t i);
664 ConstReference operator[](
size_t i)
const;
667 std::vector<T> m_elements;
718template <
typename T,
size_t Rows>
817template <
typename T,
size_t Rows,
size_t Cols>
823template <
typename T,
size_t R1,
size_t C1,
size_t R2,
size_t C2,
typename M2>
826template <
typename T,
size_t Rows,
size_t Cols>
829template <
typename T,
size_t R1,
size_t C1,
size_t R2,
size_t C2,
typename M2>
832template <
typename T,
size_t Rows,
size_t Cols>
835template <
typename T,
size_t R1,
size_t C1,
size_t R2,
size_t C2,
typename M2>
838template <
typename T,
size_t R1,
size_t C1,
size_t R2,
size_t C2,
typename M2>
841template <
typename T,
size_t Rows,
size_t Cols>
844template <
typename T,
size_t R1,
size_t C1,
size_t R2,
size_t C2,
typename M2>
847template <
typename T,
size_t Rows,
size_t Cols>
850template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename M2>
851constexpr std::enable_if_t<IsMatrixSizeStatic<Rows, Cols>(),
bool>
operator==(
855template <
typename T,
size_t R1,
size_t C1,
size_t R2,
size_t C2,
typename M1,
860template <
typename T,
size_t R1,
size_t C1,
size_t R2,
size_t C2,
typename M1,
865template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
867constexpr std::enable_if_t<TraitIsMatrixSizeStatic<Rows, Cols>::value,
T>
871template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
872constexpr std::enable_if_t<TraitIsMatrixSizeStatic<Rows, Cols>::value,
T>
875template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
876constexpr std::enable_if_t<TraitIsMatrixSizeStatic<Rows, Cols>::value,
T>
879template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
881constexpr std::enable_if_t<TraitIsMatrixSizeDynamic<Rows, Cols>::value,
T>
885template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
886constexpr std::enable_if_t<TraitIsMatrixSizeDynamic<Rows, Cols>::value,
T>
889template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
890constexpr std::enable_if_t<TraitIsMatrixSizeDynamic<Rows, Cols>::value,
T>
893template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
897template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename M2,
898 typename M3,
typename M4>
constexpr Matrix(Matrix &&other) noexcept
Definition Matrix.hpp:163
Matrix & operator=(Matrix &&other) noexcept
Definition Matrix.hpp:174
constexpr Matrix(const T &_x)
Definition Matrix.hpp:146
Matrix & operator=(const Matrix &other)
Definition Matrix.hpp:168
constexpr Matrix()
Definition Matrix.hpp:141
ValueType x
Definition Matrix.hpp:212
constexpr Matrix(const Matrix &other)
Definition Matrix.hpp:158
Matrix & operator=(const Matrix &other)
Definition Matrix.hpp:259
constexpr Matrix(const Matrix &other)
Definition Matrix.hpp:248
constexpr Matrix(Matrix &&other) noexcept
Definition Matrix.hpp:253
constexpr Matrix()
Definition Matrix.hpp:231
constexpr Matrix(const T &_x, const T &_y)
Definition Matrix.hpp:236
ValueType x
Definition Matrix.hpp:307
Matrix & operator=(Matrix &&other) noexcept
Definition Matrix.hpp:266
ValueType y
Definition Matrix.hpp:308
constexpr Matrix()
Definition Matrix.hpp:327
constexpr Matrix(const T &_x, const T &_y, const T &_z)
Definition Matrix.hpp:338
constexpr Matrix(const Matrix &)=default
constexpr Matrix(const Matrix< T, 2, 1 > &_xy, const T &_z)
Definition Matrix.hpp:332
constexpr Matrix(Matrix &&) noexcept=default
Matrix & operator=(const Matrix &other)
Definition Matrix.hpp:449
ValueType z
Definition Matrix.hpp:507
constexpr Matrix(const T &_x, const T &_y, const T &_z, const T &_w)
Definition Matrix.hpp:421
constexpr Matrix(const Matrix &other)
Definition Matrix.hpp:434
constexpr Matrix(Matrix &&other) noexcept
Definition Matrix.hpp:440
constexpr Matrix()
Definition Matrix.hpp:416
Matrix & operator=(Matrix &&other) noexcept
Definition Matrix.hpp:458
ValueType x
Definition Matrix.hpp:505
ValueType w
Definition Matrix.hpp:508
ValueType y
Definition Matrix.hpp:506
Definition Matrix.hpp:597
const T & ConstReference
Definition Matrix.hpp:601
const T * ConstPointer
Definition Matrix.hpp:603
Definition Matrix.hpp:519
const T & ConstReference
Definition Matrix.hpp:523
const T * ConstPointer
Definition Matrix.hpp:525
Definition MatrixDenseBase.hpp:21
void CopyFrom(const MatrixExpression< T, R, C, E > &expression)
Copies from generic expression.
Definition MatrixDenseBase-Impl.hpp:21
Base class for matrix expression.
Definition MatrixExpression.hpp:94
Matrix & operator=(Matrix &&other) noexcept
Definition Matrix.hpp:87
Matrix & operator=(const Matrix &other)
Definition Matrix.hpp:81
const T * ConstPointer
Definition Matrix.hpp:43
T * Pointer
Definition Matrix.hpp:42
constexpr Matrix(const Matrix &other)
Definition Matrix.hpp:70
constexpr Matrix()
Definition Matrix.hpp:47
constexpr Matrix(ConstReference first, Args... rest)
Definition Matrix.hpp:55
const T & ConstReference
Definition Matrix.hpp:41
constexpr Matrix(Matrix &&other) noexcept
Definition Matrix.hpp:75
Definition pybind11Utils.hpp:22
void ElemIDiv(Matrix< T, R1, C1 > &a, const MatrixExpression< T, R2, C2, M2 > &b)
Definition Matrix-Impl.hpp:1387
void Fill(ArrayView< T, N > a, const Vector< size_t, N > &begin, const Vector< size_t, N > &end, const T &val)
Definition ArrayUtils-Impl.hpp:132
void ElemIMul(Matrix< T, R1, C1 > &a, const MatrixExpression< T, R2, C2, M2 > &b)
Definition Matrix-Impl.hpp:1369
constexpr std::enable_if_t< IsMatrixSizeStatic< Rows, Cols >(), bool > operator==(const MatrixExpression< T, Rows, Cols, M1 > &a, const MatrixExpression< T, Rows, Cols, M2 > &b)
Definition Matrix-Impl.hpp:1402
constexpr T Product(const MatrixExpression< T, Rows, Cols, M1 > &a, const T &init)
Definition Matrix-Impl.hpp:1499
std::enable_if_t< std::is_arithmetic< T >::value, T > MonotonicCatmullRom(const T &f0, const T &f1, const T &f2, const T &f3, T t)
Computes monotonic Catmull-Rom interpolation.
Definition MathUtils-Impl.hpp:336
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:719
bool operator!=(const MatrixExpression< T, R1, C1, M1 > &a, const MatrixExpression< T, R2, C2, M2 > &b)
Definition Matrix-Impl.hpp:1437
void operator+=(Matrix< T, R1, C1 > &a, const MatrixExpression< T, R2, C2, M2 > &b)
Definition Matrix-Impl.hpp:1336
constexpr std::enable_if_t< TraitIsMatrixSizeStatic< Rows, Cols >::value, T > Accumulate(const MatrixExpression< T, Rows, Cols, M1 > &a, const T &init, BinaryOperation op)
Definition Matrix-Impl.hpp:1446
void operator*=(Matrix< T, R1, C1 > &a, const MatrixExpression< T, R2, C2, M2 > &b)
Definition Matrix-Impl.hpp:1360
void operator/=(Matrix< T, Rows, Cols > &a, const T &b)
Definition Matrix-Impl.hpp:1394
void operator-=(Matrix< T, R1, C1 > &a, const MatrixExpression< T, R2, C2, M2 > &b)
Definition Matrix-Impl.hpp:1348
Returns the type of the value itself.
Definition TypeHelpers.hpp:19