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 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);
372 x = std::move(
other.x);
373 y = std::move(
other.y);
374 z = std::move(
other.z);
380 void Fill(
const std::function<
T(
size_t i)>&
func);
382 void Fill(
const std::function<
T(
size_t i,
size_t j)>&
func);
386 [[
nodiscard]]
constexpr size_t GetRows()
const;
388 [[
nodiscard]]
constexpr size_t GetCols()
const;
392 [[
nodiscard]]
constexpr ConstIterator begin()
const;
396 [[
nodiscard]]
constexpr ConstIterator end()
const;
400 [[
nodiscard]]
constexpr ConstPointer data()
const;
402 Reference operator[](
size_t i);
404 ConstReference operator[](
size_t i)
const;
406 constexpr static Matrix MakeUnitX();
408 constexpr static Matrix MakeUnitY();
410 constexpr static Matrix MakeUnitZ();
412 constexpr static Matrix MakeUnit(
size_t i);
425 using Base::operator();
446 template <
size_t R,
size_t C,
typename E>
449 Matrix(
const std::initializer_list<T>&
lst);
460 : x(std::move(
other.x)),
461 y(std::move(
other.y)),
462 z(std::move(
other.z)),
463 w(std::move(
other.w))
479 x = std::move(
other.x);
480 y = std::move(
other.y);
481 z = std::move(
other.z);
482 w = std::move(
other.w);
488 void Fill(
const std::function<
T(
size_t i)>&
func);
490 void Fill(
const std::function<
T(
size_t i,
size_t j)>&
func);
494 [[
nodiscard]]
constexpr size_t GetRows()
const;
496 [[
nodiscard]]
constexpr size_t GetCols()
const;
500 [[
nodiscard]]
constexpr ConstIterator begin()
const;
504 [[
nodiscard]]
constexpr ConstIterator end()
const;
508 [[
nodiscard]]
constexpr ConstPointer data()
const;
510 Reference operator[](
size_t i);
512 ConstReference operator[](
size_t i)
const;
514 constexpr static Matrix MakeUnitX();
516 constexpr static Matrix MakeUnitY();
518 constexpr static Matrix MakeUnitZ();
520 constexpr static Matrix MakeUnitW();
522 constexpr static Matrix MakeUnit(
size_t i);
533 T, MATRIX_SIZE_DYNAMIC, MATRIX_SIZE_DYNAMIC,
534 Matrix<T, MATRIX_SIZE_DYNAMIC, MATRIX_SIZE_DYNAMIC>>,
536 T, MATRIX_SIZE_DYNAMIC, MATRIX_SIZE_DYNAMIC,
537 Matrix<T, MATRIX_SIZE_DYNAMIC, MATRIX_SIZE_DYNAMIC>>
548 T, MATRIX_SIZE_DYNAMIC, MATRIX_SIZE_DYNAMIC,
555 template <
size_t R,
size_t C,
typename E>
574 void Fill(
const std::function<
T(
size_t i)>&
func);
576 void Fill(
const std::function<
T(
size_t i,
size_t j)>&
func);
590 [[
nodiscard]] ConstIterator begin()
const;
600 Reference operator[](
size_t i);
602 ConstReference operator[](
size_t i)
const;
605 std::vector<T> m_elements;
613 Matrix<T, MATRIX_SIZE_DYNAMIC, 1>>,
615 Matrix<T, MATRIX_SIZE_DYNAMIC, 1>>
632 template <
size_t R,
size_t C,
typename E>
635 Matrix(
const std::initializer_list<T>&
lst);
651 void Fill(
const std::function<
T(
size_t i)>&
func);
653 void Fill(
const std::function<
T(
size_t i,
size_t j)>&
func);
659 void AddElement(ConstReference
newElem);
667 [[
nodiscard]]
constexpr size_t GetCols()
const;
671 [[
nodiscard]] ConstIterator begin()
const;
681 Reference operator[](
size_t i);
683 ConstReference operator[](
size_t i)
const;
686 std::vector<T> m_elements;
737template <
typename T,
size_t Rows>
836template <
typename T,
size_t Rows,
size_t Cols>
842template <
typename T,
size_t R1,
size_t C1,
size_t R2,
size_t C2,
typename M2>
845template <
typename T,
size_t Rows,
size_t Cols>
848template <
typename T,
size_t R1,
size_t C1,
size_t R2,
size_t C2,
typename M2>
851template <
typename T,
size_t Rows,
size_t Cols>
854template <
typename T,
size_t R1,
size_t C1,
size_t R2,
size_t C2,
typename M2>
857template <
typename T,
size_t R1,
size_t C1,
size_t R2,
size_t C2,
typename M2>
860template <
typename T,
size_t Rows,
size_t Cols>
863template <
typename T,
size_t R1,
size_t C1,
size_t R2,
size_t C2,
typename M2>
866template <
typename T,
size_t Rows,
size_t Cols>
869template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename M2>
870constexpr std::enable_if_t<IsMatrixSizeStatic<Rows, Cols>(),
bool>
operator==(
874template <
typename T,
size_t R1,
size_t C1,
size_t R2,
size_t C2,
typename M1,
879template <
typename T,
size_t R1,
size_t C1,
size_t R2,
size_t C2,
typename M1,
884template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
886constexpr std::enable_if_t<TraitIsMatrixSizeStatic<Rows, Cols>::value,
T>
890template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
891constexpr std::enable_if_t<TraitIsMatrixSizeStatic<Rows, Cols>::value,
T>
894template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
895constexpr std::enable_if_t<TraitIsMatrixSizeStatic<Rows, Cols>::value,
T>
898template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
900constexpr std::enable_if_t<TraitIsMatrixSizeDynamic<Rows, Cols>::value,
T>
904template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
905constexpr std::enable_if_t<TraitIsMatrixSizeDynamic<Rows, Cols>::value,
T>
908template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
909constexpr std::enable_if_t<TraitIsMatrixSizeDynamic<Rows, Cols>::value,
T>
912template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
916template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename M2,
917 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
Matrix & operator=(Matrix &&other) noexcept
Definition Matrix.hpp:370
ValueType z
Definition Matrix.hpp:416
constexpr Matrix()
Definition Matrix.hpp:327
constexpr Matrix(const Matrix &other)
Definition Matrix.hpp:351
constexpr Matrix(const T &_x, const T &_y, const T &_z)
Definition Matrix.hpp:338
ValueType y
Definition Matrix.hpp:415
constexpr Matrix(const Matrix< T, 2, 1 > &_xy, const T &_z)
Definition Matrix.hpp:332
ValueType x
Definition Matrix.hpp:414
constexpr Matrix(Matrix &&other) noexcept
Definition Matrix.hpp:356
Matrix & operator=(const Matrix &other)
Definition Matrix.hpp:362
Matrix & operator=(const Matrix &other)
Definition Matrix.hpp:468
ValueType z
Definition Matrix.hpp:526
constexpr Matrix(const T &_x, const T &_y, const T &_z, const T &_w)
Definition Matrix.hpp:440
constexpr Matrix(const Matrix &other)
Definition Matrix.hpp:453
constexpr Matrix(Matrix &&other) noexcept
Definition Matrix.hpp:459
constexpr Matrix()
Definition Matrix.hpp:435
Matrix & operator=(Matrix &&other) noexcept
Definition Matrix.hpp:477
ValueType x
Definition Matrix.hpp:524
ValueType w
Definition Matrix.hpp:527
ValueType y
Definition Matrix.hpp:525
Definition Matrix.hpp:616
const T & ConstReference
Definition Matrix.hpp:620
const T * ConstPointer
Definition Matrix.hpp:622
Definition Matrix.hpp:538
const T & ConstReference
Definition Matrix.hpp:542
const T * ConstPointer
Definition Matrix.hpp:544
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:21
void ElemIDiv(Matrix< T, R1, C1 > &a, const MatrixExpression< T, R2, C2, M2 > &b)
Definition Matrix-Impl.hpp:1393
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:19
void ElemIMul(Matrix< T, R1, C1 > &a, const MatrixExpression< T, R2, C2, M2 > &b)
Definition Matrix-Impl.hpp:1375
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:1408
constexpr T Product(const MatrixExpression< T, Rows, Cols, M1 > &a, const T &init)
Definition Matrix-Impl.hpp:1503
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:738
bool operator!=(const MatrixExpression< T, R1, C1, M1 > &a, const MatrixExpression< T, R2, C2, M2 > &b)
Definition Matrix-Impl.hpp:1443
void operator+=(Matrix< T, R1, C1 > &a, const MatrixExpression< T, R2, C2, M2 > &b)
Definition Matrix-Impl.hpp:1342
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:1452
void operator*=(Matrix< T, R1, C1 > &a, const MatrixExpression< T, R2, C2, M2 > &b)
Definition Matrix-Impl.hpp:1366
void operator/=(Matrix< T, Rows, Cols > &a, const T &b)
Definition Matrix-Impl.hpp:1400
void operator-=(Matrix< T, R1, C1 > &a, const MatrixExpression< T, R2, C2, M2 > &b)
Definition Matrix-Impl.hpp:1354
Returns the type of the value itself.
Definition TypeHelpers.hpp:19