11 #ifndef CUBBYFLOW_MATRIX_EXPRESSION_IMPL_HPP 12 #define CUBBYFLOW_MATRIX_EXPRESSION_IMPL_HPP 20 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
23 return static_cast<const D&
>(*this).GetRows();
26 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
29 return static_cast<const D&
>(*this).GetCols();
32 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
35 return GetDerived()(i, j);
38 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
44 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
45 template <
size_t R,
size_t C,
typename E>
49 if (expression.
GetRows() != GetRows() || expression.
GetCols() != GetCols())
56 for (
size_t i = 0; i < GetRows(); ++i)
58 for (
size_t j = 0; j < GetCols(); ++j)
60 if (!op(Eval(i, j), expression.
Eval(i, j)))
70 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
73 return GetRows() == GetCols();
76 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
81 for (
size_t i = 0; i < GetRows(); ++i)
83 for (
size_t j = 0; j < GetCols(); ++j)
92 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
95 return Sum() / (GetRows() * GetCols());
98 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
103 for (
size_t j = 1; j < GetCols(); ++j)
105 s = std::min(s, Eval(0, j));
108 for (
size_t i = 1; i < GetRows(); ++i)
110 for (
size_t j = 0; j < GetCols(); ++j)
112 s = std::min(s, Eval(i, j));
119 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
124 for (
size_t j = 1; j < GetCols(); ++j)
126 s = std::max(s, Eval(0, j));
129 for (
size_t i = 1; i < GetRows(); ++i)
131 for (
size_t j = 0; j < GetCols(); ++j)
133 s = std::max(s, Eval(i, j));
140 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
145 for (
size_t j = 1; j < GetCols(); ++j)
150 for (
size_t i = 1; i < GetRows(); ++i)
152 for (
size_t j = 0; j < GetCols(); ++j)
161 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
166 for (
size_t j = 1; j < GetCols(); ++j)
171 for (
size_t i = 1; i < GetRows(); ++i)
173 for (
size_t j = 0; j < GetCols(); ++j)
182 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
185 assert(GetRows() == GetCols());
187 T result = Eval(0, 0);
189 for (
size_t i = 1; i < GetRows(); ++i)
191 result += Eval(i, i);
197 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
200 assert(GetRows() == GetCols());
202 return Determinant(*
this);
205 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
208 assert(GetCols() == 1);
213 for (
size_t i = 1; i < GetRows(); ++i)
217 if (std::fabs(curr) > std::fabs(best))
227 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
230 assert(GetCols() == 1);
235 for (
size_t i = 1; i < GetRows(); ++i)
239 if (std::fabs(curr) < std::fabs(best))
249 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
252 return std::sqrt(NormSquared());
255 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
260 for (
size_t i = 0; i < GetRows(); ++i)
262 for (
size_t j = 0; j < GetCols(); ++j)
264 result += Eval(i, j) * Eval(i, j);
271 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
277 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
280 assert(GetCols() == 1);
285 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
288 assert(GetCols() == 1);
290 return NormSquared();
293 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
294 template <
size_t R,
size_t C,
typename E>
298 assert(GetCols() == 1);
300 return std::sqrt(DistanceSquaredTo(other));
303 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
304 template <
size_t R,
size_t C,
typename E>
308 assert(GetCols() == 1);
310 return D(GetDerived() - other.
GetDerived()).NormSquared();
313 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
321 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
328 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
335 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
342 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
349 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
356 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
363 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
370 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
374 Inverse(*
this, result);
378 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
379 template <
typename U>
386 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
387 template <
size_t R,
size_t C,
typename E,
typename U>
388 std::enable_if_t<(IsMatrixSizeDynamic<Rows, Cols>() || Cols == 1) &&
389 (IsMatrixSizeDynamic<R, C>() || C == 1),
394 assert(expression.
GetRows() == GetRows() && expression.
GetCols() == 1);
396 T sum = Eval(0, 0) * expression.
Eval(0, 0);
398 for (
size_t i = 1; i < GetRows(); ++i)
400 sum += Eval(i, 0) * expression.
Eval(i, 0);
406 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
407 template <
size_t R,
size_t C,
typename E,
typename U>
408 std::enable_if_t<(IsMatrixSizeDynamic<Rows, Cols>() ||
409 (Rows == 2 && Cols == 1)) &&
410 (IsMatrixSizeDynamic<R, C>() || (R == 2 && C == 1)),
415 assert(GetRows() == 2 && GetCols() == 1 && expression.
GetRows() == 2 &&
418 return Eval(0, 0) * expression.
Eval(1, 0) -
419 expression.
Eval(0, 0) * Eval(1, 0);
422 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
423 template <
size_t R,
size_t C,
typename E,
typename U>
424 std::enable_if_t<(IsMatrixSizeDynamic<Rows, Cols>() ||
425 (Rows == 3 && Cols == 1)) &&
426 (IsMatrixSizeDynamic<R, C>() || (R == 3 && C == 1)),
431 assert(GetRows() == 3 && GetCols() == 1 && exp.
GetRows() == 3 &&
435 Eval(1, 0) * exp.
Eval(2, 0) - exp.
Eval(1, 0) * Eval(2, 0),
436 Eval(2, 0) * exp.
Eval(0, 0) - exp.
Eval(2, 0) * Eval(0, 0),
437 Eval(0, 0) * exp.
Eval(1, 0) - exp.
Eval(0, 0) * Eval(1, 0)
441 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
442 template <
size_t R,
size_t C,
typename E,
typename U>
443 std::enable_if_t<(IsMatrixSizeDynamic<Rows, Cols>() ||
444 ((Rows == 2 || Rows == 3) && Cols == 1)) &&
445 (IsMatrixSizeDynamic<R, C>() ||
446 ((R == 2 || R == 3) && C == 1)),
451 assert((GetRows() == 2 || GetRows() == 3) && GetCols() == 1 &&
455 return (*
this) - 2 * Dot(normal) * normal;
458 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
459 template <
size_t R,
size_t C,
typename E,
typename U>
460 std::enable_if_t<(IsMatrixSizeDynamic<Rows, Cols>() ||
461 ((Rows == 2 || Rows == 3) && Cols == 1)) &&
462 (IsMatrixSizeDynamic<R, C>() ||
463 ((R == 2 || R == 3) && C == 1)),
468 assert((GetRows() == 2 || GetRows() == 3) && GetCols() == 1 &&
472 return (*
this) - this->Dot(normal) * normal;
475 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
476 template <
typename U>
477 std::enable_if_t<(IsMatrixSizeDynamic<Rows, Cols>() ||
478 (Rows == 2 && Cols == 1)),
482 assert(GetRows() == 2 && GetCols() == 1);
487 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
488 template <
typename U>
489 std::enable_if_t<(IsMatrixSizeDynamic<Rows, Cols>() ||
490 (Rows == 3 && Cols == 1)),
494 assert(GetRows() == 3 && GetCols() == 1);
499 ((std::fabs(Eval(1, 0)) > 0 || std::fabs(Eval(2, 0)) > 0) ? V(1, 0, 0)
503 V b = this->Cross(a);
505 return std::make_tuple(a, b);
508 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
511 return static_cast<D&
>(*this);
514 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
517 return static_cast<const D&
>(*this);
520 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
527 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
534 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
546 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
576 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
577 template <
typename U>
578 std::enable_if_t<(Rows > 4 && Cols > 4) || IsMatrixSizeDynamic<Rows, Cols>(), U>
587 for (
size_t i = 0; i < m.
GetRows(); ++i)
590 T maxEl = std::fabs(a(i, i));
593 for (
size_t k = i + 1; k < m.
GetRows(); ++k)
595 if (std::fabs(a(k, i)) > maxEl)
597 maxEl = std::fabs(a(k, i));
605 for (
size_t k = i; k < m.
GetRows(); ++k)
607 std::swap(a(maxRow, k), a(i, k));
613 for (
size_t k = i + 1; k < m.
GetRows(); ++k)
615 T c = -a(k, i) / a(i, i);
617 for (
size_t j = i; j < m.
GetRows(); ++j)
625 a(k, j) += c * a(i, j);
631 for (
size_t i = 0; i < m.
GetRows(); ++i)
639 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
643 result(0, 0) = 1 / m(0, 0);
646 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
650 T d = Determinant(m);
652 result(0, 0) = m.
Eval(1, 1) / d;
653 result(0, 1) = -m.
Eval(0, 1) / d;
654 result(1, 0) = -m.
Eval(1, 0) / d;
655 result(1, 1) = m.
Eval(0, 0) / d;
658 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
662 T d = Determinant(m);
684 template <
typename T,
size_t Rows,
size_t Cols,
typename D>
688 T d = Determinant(m);
690 result(0, 0) = (m.
Eval(1, 1) * m.
Eval(2, 2) * m.
Eval(3, 3) +
697 result(0, 1) = (m.
Eval(0, 1) * m.
Eval(2, 3) * m.
Eval(3, 2) +
704 result(0, 2) = (m.
Eval(0, 1) * m.
Eval(1, 2) * m.
Eval(3, 3) +
711 result(0, 3) = (m.
Eval(0, 1) * m.
Eval(1, 3) * m.
Eval(2, 2) +
718 result(1, 0) = (m.
Eval(1, 0) * m.
Eval(2, 3) * m.
Eval(3, 2) +
725 result(1, 1) = (m.
Eval(0, 0) * m.
Eval(2, 2) * m.
Eval(3, 3) +
732 result(1, 2) = (m.
Eval(0, 0) * m.
Eval(1, 3) * m.
Eval(3, 2) +
739 result(1, 3) = (m.
Eval(0, 0) * m.
Eval(1, 2) * m.
Eval(2, 3) +
746 result(2, 0) = (m.
Eval(1, 0) * m.
Eval(2, 1) * m.
Eval(3, 3) +
753 result(2, 1) = (m.
Eval(0, 0) * m.
Eval(2, 3) * m.
Eval(3, 1) +
760 result(2, 2) = (m.
Eval(0, 0) * m.
Eval(1, 1) * m.
Eval(3, 3) +
767 result(2, 3) = (m.
Eval(0, 0) * m.
Eval(1, 3) * m.
Eval(2, 1) +
774 result(3, 0) = (m.
Eval(1, 0) * m.
Eval(2, 2) * m.
Eval(3, 1) +
781 result(3, 1) = (m.
Eval(0, 0) * m.
Eval(2, 1) * m.
Eval(3, 2) +
788 result(3, 2) = (m.
Eval(0, 0) * m.
Eval(1, 2) * m.
Eval(3, 1) +
795 result(3, 3) = (m.
Eval(0, 0) * m.
Eval(1, 1) * m.
Eval(2, 2) +
804 template <
typename T,
size_t Rows,
size_t Cols,
typename Derived>
805 template <
typename M>
809 (Rows > 4 && Cols > 4) || IsMatrixSizeDynamic<Rows, Cols>(), M>& result)
818 a.
GetRows(), a.GetCols(), 1 } };
821 for (
size_t i = 0; i < n; ++i)
824 T maxEl = std::fabs(a(i, i));
827 for (
size_t k = i + 1; k < n; ++k)
829 if (std::fabs(a(k, i)) > maxEl)
831 maxEl = std::fabs(a(k, i));
839 for (
size_t k = i; k < n; ++k)
841 std::swap(a(maxRow, k), a(i, k));
844 for (
size_t k = 0; k < n; ++k)
846 std::swap(result(maxRow, k), result(i, k));
851 for (
size_t k = 0; k < n; ++k)
858 T c = -a(k, i) / a(i, i);
860 for (
size_t j = 0; j < n; ++j)
862 result(k, j) += c * result(i, j);
870 a(k, j) += c * a(i, j);
876 for (
size_t k = 0; k < n; ++k)
880 for (
size_t j = 0; j < n; ++j)
889 template <
typename T,
size_t Rows,
size_t Cols>
895 template <
typename T,
size_t Rows,
size_t Cols>
901 template <
typename T,
size_t Rows,
size_t Cols>
907 template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
910 return m_mat1.GetRows();
913 template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
916 return m_mat1.GetCols();
919 template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
930 template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
933 return m_mat1.GetRows();
936 template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
939 return m_mat1.GetCols();
942 template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
953 template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
956 return m_mat1.GetRows();
959 template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
962 return m_mat1.GetCols();
965 template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
972 return (j > i) ? m_mat1(i, j) : 0;
975 return (j >= i) ? m_mat1(i, j) : 0;
980 return (j < i) ? m_mat1(i, j) : 0;
983 return (j <= i) ? m_mat1(i, j) : 0;
986 template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
989 return m_mat1.GetCols();
992 template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
995 return m_mat1.GetRows();
998 template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
1002 return m_mat1(j, i);
1005 template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename UOp>
1008 return m_mat1.GetRows();
1011 template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename UOp>
1014 return m_mat1.GetCols();
1017 template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename UOp>
1021 return m_op(m_mat1(i, j));
1024 template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
1030 template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
1036 template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
1042 template <
typename T,
size_t Rows,
size_t Cols,
typename E1,
typename E2,
1047 return m_mat1.GetRows();
1050 template <
typename T,
size_t Rows,
size_t Cols,
typename E1,
typename E2,
1055 return m_mat1.GetCols();
1058 template <
typename T,
size_t Rows,
size_t Cols,
typename E1,
typename E2,
1061 size_t i,
size_t j)
const 1063 return m_op(m_mat1(i, j), m_mat2(i, j));
1066 template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename M2>
1075 template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename M2>
1084 template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename M2>
1093 template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename M2>
1102 template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename M2>
1111 template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename M2>
1120 template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename BOp>
1124 return m_mat1.GetRows();
1127 template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename BOp>
1131 return m_mat1.GetCols();
1134 template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename BOp>
1136 size_t i,
size_t j)
const 1138 return m_op(m_mat1(i, j), m_scalar2);
1141 template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
1149 template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
1157 template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
1165 template <
typename T,
size_t Rows,
size_t Cols,
typename M1>
1173 template <
typename T,
size_t Rows,
size_t Cols,
typename M2,
typename BOp>
1177 return m_mat2.GetRows();
1180 template <
typename T,
size_t Rows,
size_t Cols,
typename M2,
typename BOp>
1184 return m_mat2.GetCols();
1187 template <
typename T,
size_t Rows,
size_t Cols,
typename M2,
typename BOp>
1189 size_t i,
size_t j)
const 1191 return m_op(m_scalar1, m_mat2(i, j));
1194 template <
typename T,
size_t Rows,
size_t Cols,
typename M2>
1202 template <
typename T,
size_t Rows,
size_t Cols,
typename M2>
1210 template <
typename T,
size_t Rows,
size_t Cols,
typename M2>
1218 template <
typename T,
size_t Rows,
size_t Cols,
typename M2>
1226 template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename M2,
1227 typename M3,
typename TOp>
1231 return m_mat1.GetRows();
1234 template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename M2,
1235 typename M3,
typename TOp>
1239 return m_mat1.GetCols();
1242 template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename M2,
1243 typename M3,
typename TOp>
1245 size_t i,
size_t j)
const 1247 return m_op(m_mat1(i, j), m_mat2(i, j), m_mat3(i, j));
1250 template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename M2,
1264 template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename M2>
1267 return m_mat1.GetRows();
1270 template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename M2>
1273 return m_mat2.GetCols();
1276 template <
typename T,
size_t Rows,
size_t Cols,
typename M1,
typename M2>
1279 T sum = m_mat1(i, 0) * m_mat2(0, j);
1281 for (
size_t k = 1; k < m_mat1.GetCols(); ++k)
1283 sum += m_mat1(i, k) * m_mat2(k, j);
1289 template <
typename T,
size_t R1,
size_t C1,
size_t R2,
size_t C2,
typename M1,
ValueType DistanceSquaredTo(const MatrixExpression< T, R, C, E > &other) const
Returns the squared distance to the other vector.
Matrix expression for element-wise binary operation.
Definition: MatrixExpression.hpp:452
ValueType AbsMin() const
Definition: MatrixExpression-Impl.hpp:141
ValueType LengthSquared() const
Definition: MatrixExpression-Impl.hpp:286
constexpr bool IsSquare() const
Returns true if this matrix is a square matrix.
Definition: MatrixExpression-Impl.hpp:71
constexpr size_t GetCols() const
Definition: MatrixExpression-Impl.hpp:914
MatrixCSR< T > operator-(const MatrixCSR< T > &a)
Definition: MatrixCSR-Impl.hpp:1029
constexpr size_t GetCols() const
Returns the number of columns.
Definition: MatrixExpression-Impl.hpp:27
ValueType Sum() const
Definition: MatrixExpression-Impl.hpp:77
ValueType DistanceTo(const MatrixExpression< T, R, C, E > &other) const
Returns the distance to the other vector.
ValueType NormSquared() const
Definition: MatrixExpression-Impl.hpp:256
constexpr auto Ceil(const MatrixExpression< T, Rows, Cols, M1 > &a)
Definition: MatrixExpression-Impl.hpp:1025
std::enable_if_t< std::is_arithmetic< T >::value, T > Clamp(T val, T low, T high)
Returns the clamped value.
Definition: MathUtils-Impl.hpp:166
MatrixTri< T, Rows, Cols, const Derived & > StrictUpperTri() const
Returns strictly upper triangle part of this matrix.
Definition: MatrixExpression-Impl.hpp:344
constexpr size_t GetRows() const
Definition: MatrixExpression-Impl.hpp:1006
constexpr auto ElemDiv(const MatrixExpression< T, Rows, Cols, M1 > &a, const MatrixExpression< T, Rows, Cols, M2 > &b)
Definition: MatrixExpression-Impl.hpp:1094
Definition: MatrixExpression.hpp:648
constexpr size_t GetRows() const
Returns the number of rows.
Definition: MatrixExpression-Impl.hpp:21
constexpr size_t GetCols() const
Definition: MatrixExpression-Impl.hpp:1181
constexpr size_t GetRows() const
Definition: MatrixExpression-Impl.hpp:1044
constexpr size_t GetRows() const
Definition: MatrixExpression-Impl.hpp:931
constexpr size_t GetCols() const
Definition: MatrixExpression-Impl.hpp:1052
T operator()(size_t i, size_t j) const
Definition: MatrixExpression-Impl.hpp:1277
ValueType FrobeniusNorm() const
Definition: MatrixExpression-Impl.hpp:272
constexpr size_t GetCols() const
Definition: MatrixExpression-Impl.hpp:1128
constexpr size_t GetRows() const
Definition: MatrixExpression-Impl.hpp:1265
Definition: MatrixExpression.hpp:75
size_t SubdominantAxis() const
Definition: MatrixExpression-Impl.hpp:228
T Eval(size_t i, size_t j) const
Returns the evaluated value for (i, j).
Definition: MatrixExpression-Impl.hpp:33
constexpr auto Floor(const MatrixExpression< T, Rows, Cols, M1 > &a)
Definition: MatrixExpression-Impl.hpp:1031
ValueType Length() const
Definition: MatrixExpression-Impl.hpp:278
constexpr auto Max(const MatrixExpression< T, Rows, Cols, M1 > &a, const MatrixExpression< T, Rows, Cols, M2 > &b)
Definition: MatrixExpression-Impl.hpp:1112
MatrixCSR< T > operator/(const MatrixCSR< T > &a, T b)
Definition: MatrixCSR-Impl.hpp:1090
constexpr T operator()(size_t, size_t) const
Definition: MatrixExpression-Impl.hpp:902
ValueType Norm() const
Definition: MatrixExpression-Impl.hpp:250
constexpr T operator()(size_t i, size_t j) const
Definition: MatrixExpression-Impl.hpp:1018
ValueType Min() const
Definition: MatrixExpression-Impl.hpp:99
constexpr size_t GetCols() const
Definition: MatrixExpression-Impl.hpp:896
T operator()(size_t i, size_t j) const
Definition: MatrixExpression-Impl.hpp:966
Definition: Matrix.hpp:27
std::enable_if_t<(IsMatrixSizeDynamic< Rows, Cols >)||Cols==1) &&(IsMatrixSizeDynamic< R, C >)||C==1), U > Dot(const MatrixExpression< T, R, C, E > &expression) const
Definition: MatrixExpression-Impl.hpp:391
MatrixTranspose< T, Rows, Cols, const Derived & > Transposed() const
Definition: MatrixExpression-Impl.hpp:365
bool IsSimilar(const MatrixExpression< T, R, C, E > &m, double tol=std::numeric_limits< double >::epsilon()) const
Definition: MatrixExpression-Impl.hpp:46
constexpr size_t GetCols() const
Definition: MatrixExpression-Impl.hpp:937
Definition: pybind11Utils.hpp:20
size_t DominantAxis() const
Definition: MatrixExpression-Impl.hpp:206
constexpr size_t GetRows() const
Definition: MatrixExpression-Impl.hpp:1174
MatrixDiagonal< T, Rows, Cols, const Derived & > Diagonal() const
Returns diagonal part of this matrix.
Definition: MatrixExpression-Impl.hpp:323
constexpr size_t GetCols() const
Definition: MatrixExpression-Impl.hpp:1271
constexpr auto ElemMul(const MatrixExpression< T, Rows, Cols, M1 > &a, const MatrixExpression< T, Rows, Cols, M2 > &b)
Definition: MatrixExpression-Impl.hpp:1085
constexpr T operator()(size_t i, size_t j) const
Definition: MatrixExpression-Impl.hpp:1244
ValueType Trace() const
Definition: MatrixExpression-Impl.hpp:183
constexpr size_t GetCols() const
Definition: MatrixExpression-Impl.hpp:993
ValueType AbsMax() const
Definition: MatrixExpression-Impl.hpp:162
MatrixOffDiagonal< T, Rows, Cols, const Derived & > OffDiagonal() const
Returns off-diagonal part of this matrix.
Definition: MatrixExpression-Impl.hpp:330
std::enable_if_t<(IsMatrixSizeDynamic< Rows, Cols >)||((Rows==2||Rows==3) &&Cols==1)) &&(IsMatrixSizeDynamic< R, C >)||((R==2||R==3) &&C==1)), Matrix< U, Rows, 1 > > Reflected(const MatrixExpression< T, R, C, E > &normal) const
Returns the reflection vector to the surface with given surface normal.
Definition: MatrixExpression-Impl.hpp:448
MatrixTri< T, Rows, Cols, const Derived & > LowerTri() const
Returns lower triangle part of this matrix (including the diagonal).
Definition: MatrixExpression-Impl.hpp:351
std::enable_if_t<(IsMatrixSizeDynamic< Rows, Cols >)||(Rows==2 &&Cols==1)) &&(IsMatrixSizeDynamic< R, C >)||(R==2 &&C==1)), U > Cross(const MatrixExpression< T, R, C, E > &expression) const
Definition: MatrixExpression-Impl.hpp:412
Definition: Matrix.hpp:312
constexpr size_t GetRows() const
Definition: MatrixExpression-Impl.hpp:908
Matrix< T, Rows, Cols > Eval() const
Definition: MatrixExpression-Impl.hpp:39
Definition: MatrixExpression.hpp:71
constexpr auto Min(const MatrixExpression< T, Rows, Cols, M1 > &a, const MatrixExpression< T, Rows, Cols, M2 > &b)
Definition: MatrixExpression-Impl.hpp:1103
Definition: MatrixExpression.hpp:590
constexpr size_t GetRows() const
Definition: MatrixExpression-Impl.hpp:1228
MatrixCSR< T > operator+(const MatrixCSR< T > &a, const MatrixCSR< T > &b)
Definition: MatrixCSR-Impl.hpp:1035
ValueType Avg() const
Definition: MatrixExpression-Impl.hpp:93
Derived & GetDerived()
Returns actual implementation (the subclass).
Definition: MatrixExpression-Impl.hpp:509
MatrixTri< T, Rows, Cols, const Derived & > UpperTri() const
Returns upper triangle part of this matrix (including the diagonal).
Definition: MatrixExpression-Impl.hpp:358
MatrixTri< T, Rows, Cols, const Derived & > StrictLowerTri() const
Returns strictly lower triangle part of this matrix.
Definition: MatrixExpression-Impl.hpp:337
constexpr T operator()(size_t i, size_t j) const
Definition: MatrixExpression-Impl.hpp:1135
constexpr size_t GetRows() const
Definition: MatrixExpression-Impl.hpp:890
Definition: MatrixExpression.hpp:68
Definition: MatrixExpression.hpp:65
Base class for matrix expression.
Definition: MatrixExpression.hpp:93
std::enable_if_t< std::is_arithmetic< T >::value, T > AbsMax(T x, T y)
Returns the absolute maximum value among the two inputs.
Definition: MathUtils-Impl.hpp:84
std::enable_if_t< std::is_arithmetic< T >::value, T > AbsMin(T x, T y)
Returns the absolute minimum value among the two inputs.
Definition: MathUtils-Impl.hpp:78
Definition: MatrixExpression.hpp:62
std::enable_if_t<(IsMatrixSizeDynamic< Rows, Cols >)||((Rows==2||Rows==3) &&Cols==1)) &&(IsMatrixSizeDynamic< R, C >)||((R==2||R==3) &&C==1)), Matrix< U, Rows, 1 > > Projected(const MatrixExpression< T, R, C, E > &normal) const
Returns the projected vector to the surface with given surface normal.
Definition: MatrixExpression-Impl.hpp:465
Definition: MatrixExpression.hpp:289
True if similar.
Definition: Functors.hpp:90
constexpr T operator()(size_t i, size_t j) const
Definition: MatrixExpression-Impl.hpp:999
MatrixUnaryOp< U, Rows, Cols, const Derived &, TypeCast< T, U > > CastTo() const
Matrix< T, Rows, Cols > Inverse() const
Returns inverse matrix.
Definition: MatrixExpression-Impl.hpp:371
constexpr size_t GetCols() const
Definition: MatrixExpression-Impl.hpp:960
constexpr T operator()(size_t i, size_t j) const
Definition: MatrixExpression-Impl.hpp:1188
Vector< T, 3 > operator*(const Quaternion< T > &q, const Vector< T, 3 > &v)
Returns quaternion q * vector v.
Definition: Quaternion-Impl.hpp:543
constexpr T operator()(size_t i, size_t j) const
Definition: MatrixExpression-Impl.hpp:1060
ValueType Max() const
Definition: MatrixExpression-Impl.hpp:120
constexpr size_t GetCols() const
Definition: MatrixExpression-Impl.hpp:1012
constexpr size_t GetCols() const
Definition: MatrixExpression-Impl.hpp:1236
MatrixScalarElemWiseBinaryOp< T, Rows, Cols, const Derived &, std::divides< T > > Normalized() const
Definition: MatrixExpression-Impl.hpp:315
constexpr size_t GetRows() const
Definition: MatrixExpression-Impl.hpp:1121
Definition: MatrixExpression.hpp:79
constexpr size_t GetRows() const
Definition: MatrixExpression-Impl.hpp:954
ValueType Determinant() const
Definition: MatrixExpression-Impl.hpp:198
T operator()(size_t i, size_t j) const
Definition: MatrixExpression-Impl.hpp:920
constexpr size_t GetRows() const
Definition: MatrixExpression-Impl.hpp:987
T operator()(size_t i, size_t j) const
Definition: MatrixExpression-Impl.hpp:943
Definition: MatrixExpression.hpp:684