MatrixExpression.hpp
Go to the documentation of this file.
1 // This code is based on Jet framework.
2 // Copyright (c) 2018 Doyub Kim
3 // CubbyFlow is voxel-based fluid simulation engine for computer games.
4 // Copyright (c) 2020 CubbyFlow Team
5 // Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6 // AI Part: Dongheon Cho, Minseo Kim
7 // We are making my contributions/submissions to this project solely in our
8 // personal capacity and are not conveying any rights to any intellectual
9 // property of any third parties.
10 
11 #ifndef CUBBYFLOW_MATRIX_EXPRESSION_HPP
12 #define CUBBYFLOW_MATRIX_EXPRESSION_HPP
13 
14 #include <Core/Utils/Functors.hpp>
15 
16 #include <functional>
17 
18 namespace CubbyFlow
19 {
20 static constexpr size_t MATRIX_SIZE_DYNAMIC = 0;
21 
22 template <size_t Rows, size_t Cols>
23 constexpr bool IsMatrixSizeDynamic()
24 {
25  return (Rows == MATRIX_SIZE_DYNAMIC) || (Cols == MATRIX_SIZE_DYNAMIC);
26 }
27 
28 template <size_t Rows, size_t Cols>
29 constexpr bool IsMatrixSizeStatic()
30 {
31  return !IsMatrixSizeDynamic<Rows, Cols>();
32 }
33 
34 template <size_t Rows, size_t Cols>
35 constexpr bool IsMatrixStaticSquare()
36 {
37  return IsMatrixSizeStatic<Rows, Cols>() && (Rows == Cols);
38 }
39 
40 template <size_t Rows, size_t Cols>
42 {
43  static const bool value = IsMatrixSizeDynamic<Rows, Cols>();
44 };
45 
46 template <size_t Rows, size_t Cols>
48 {
49  static const bool value = IsMatrixSizeStatic<Rows, Cols>();
50 };
51 
52 template <size_t Rows, size_t Cols>
54 {
55  static const bool value = IsMatrixStaticSquare<Rows, Cols>();
56 };
57 
58 template <typename T, size_t Rows, size_t Cols>
59 class Matrix;
60 
61 template <typename T, size_t Rows, size_t Cols, typename M1>
63 
64 template <typename T, size_t Rows, size_t Cols, typename M1>
66 
67 template <typename T, size_t Rows, size_t Cols, typename M1>
68 class MatrixTri;
69 
70 template <typename T, size_t Rows, size_t Cols, typename M1>
72 
73 template <typename T, size_t Rows, size_t Cols, typename M1,
74  typename UnaryOperation>
76 
77 template <typename T, size_t Rows, size_t Cols, typename M1,
78  typename BinaryOperation>
80 
92 template <typename T, size_t Rows, size_t Cols, typename Derived>
94 {
95  public:
96  using ValueType = T;
97 
99  [[nodiscard]] constexpr size_t GetRows() const;
100 
102  [[nodiscard]] constexpr size_t GetCols() const;
103 
105  [[nodiscard]] T Eval(size_t i, size_t j) const;
106 
107  [[nodiscard]] Matrix<T, Rows, Cols> Eval() const;
108 
111  template <size_t R, size_t C, typename E>
112  [[nodiscard]] bool IsSimilar(
114  double tol = std::numeric_limits<double>::epsilon()) const;
115 
117  [[nodiscard]] constexpr bool IsSquare() const;
118 
119  [[nodiscard]] ValueType Sum() const;
120 
121  [[nodiscard]] ValueType Avg() const;
122 
123  [[nodiscard]] ValueType Min() const;
124 
125  [[nodiscard]] ValueType Max() const;
126 
127  [[nodiscard]] ValueType AbsMin() const;
128 
129  [[nodiscard]] ValueType AbsMax() const;
130 
131  [[nodiscard]] ValueType Trace() const;
132 
133  [[nodiscard]] ValueType Determinant() const;
134 
135  [[nodiscard]] size_t DominantAxis() const;
136 
137  [[nodiscard]] size_t SubdominantAxis() const;
138 
139  [[nodiscard]] ValueType Norm() const;
140 
141  [[nodiscard]] ValueType NormSquared() const;
142 
143  [[nodiscard]] ValueType FrobeniusNorm() const;
144 
145  [[nodiscard]] ValueType Length() const;
146 
147  [[nodiscard]] ValueType LengthSquared() const;
148 
150  template <size_t R, size_t C, typename E>
151  [[nodiscard]] ValueType DistanceTo(
152  const MatrixExpression<T, R, C, E>& other) const;
153 
155  template <size_t R, size_t C, typename E>
156  [[nodiscard]] ValueType DistanceSquaredTo(
157  const MatrixExpression<T, R, C, E>& other) const;
158 
159  [[nodiscard]] MatrixScalarElemWiseBinaryOp<T, Rows, Cols, const Derived&,
160  std::divides<T>>
161  Normalized() const;
162 
164  [[nodiscard]] MatrixDiagonal<T, Rows, Cols, const Derived&> Diagonal()
165  const;
166 
168  [[nodiscard]] MatrixOffDiagonal<T, Rows, Cols, const Derived&> OffDiagonal()
169  const;
170 
172  [[nodiscard]] MatrixTri<T, Rows, Cols, const Derived&> StrictLowerTri()
173  const;
174 
176  [[nodiscard]] MatrixTri<T, Rows, Cols, const Derived&> StrictUpperTri()
177  const;
178 
180  [[nodiscard]] MatrixTri<T, Rows, Cols, const Derived&> LowerTri() const;
181 
183  [[nodiscard]] MatrixTri<T, Rows, Cols, const Derived&> UpperTri() const;
184 
185  [[nodiscard]] MatrixTranspose<T, Rows, Cols, const Derived&> Transposed()
186  const;
187 
189  [[nodiscard]] Matrix<T, Rows, Cols> Inverse() const;
190 
191  template <typename U>
193 
194  template <size_t R, size_t C, typename E, typename U = ValueType>
195  std::enable_if_t<(IsMatrixSizeDynamic<Rows, Cols>() || Cols == 1) &&
196  (IsMatrixSizeDynamic<R, C>() || C == 1),
197  U>
198  Dot(const MatrixExpression<T, R, C, E>& expression) const;
199 
200  template <size_t R, size_t C, typename E, typename U = ValueType>
201  std::enable_if_t<(IsMatrixSizeDynamic<Rows, Cols>() ||
202  (Rows == 2 && Cols == 1)) &&
203  (IsMatrixSizeDynamic<R, C>() || (R == 2 && C == 1)),
204  U>
205  Cross(const MatrixExpression<T, R, C, E>& expression) const;
206 
207  template <size_t R, size_t C, typename E, typename U = ValueType>
208  std::enable_if_t<(IsMatrixSizeDynamic<Rows, Cols>() ||
209  (Rows == 3 && Cols == 1)) &&
210  (IsMatrixSizeDynamic<R, C>() || (R == 3 && C == 1)),
212  Cross(const MatrixExpression<T, R, C, E>& expression) const;
213 
215  template <size_t R, size_t C, typename E, typename U = ValueType>
216  std::enable_if_t<(IsMatrixSizeDynamic<Rows, Cols>() ||
217  ((Rows == 2 || Rows == 3) && Cols == 1)) &&
218  (IsMatrixSizeDynamic<R, C>() ||
219  ((R == 2 || R == 3) && C == 1)),
221  Reflected(const MatrixExpression<T, R, C, E>& normal) const;
222 
224  template <size_t R, size_t C, typename E, typename U = ValueType>
225  std::enable_if_t<(IsMatrixSizeDynamic<Rows, Cols>() ||
226  ((Rows == 2 || Rows == 3) && Cols == 1)) &&
227  (IsMatrixSizeDynamic<R, C>() ||
228  ((R == 2 || R == 3) && C == 1)),
230  Projected(const MatrixExpression<T, R, C, E>& normal) const;
231 
233  template <typename U = ValueType>
234  std::enable_if_t<(IsMatrixSizeDynamic<Rows, Cols>() ||
235  (Rows == 2 && Cols == 1)),
237  Tangential() const;
238 
240  template <typename U = ValueType>
241  std::enable_if_t<(IsMatrixSizeDynamic<Rows, Cols>() ||
242  (Rows == 3 && Cols == 1)),
243  std::tuple<Matrix<U, 3, 1>, Matrix<U, 3, 1>>>
244  Tangentials() const;
245 
247  [[nodiscard]] Derived& GetDerived();
248 
250  [[nodiscard]] const Derived& GetDerived() const;
251 
252  protected:
253  // Prohibits constructing this class instance.
254  MatrixExpression() = default;
255 
256  constexpr static T Determinant(const MatrixExpression<T, 1, 1, Derived>& m);
257 
258  constexpr static T Determinant(const MatrixExpression<T, 2, 2, Derived>& m);
259 
260  constexpr static T Determinant(const MatrixExpression<T, 3, 3, Derived>& m);
261 
262  constexpr static T Determinant(const MatrixExpression<T, 4, 4, Derived>& m);
263 
264  template <typename U = ValueType>
265  static std::enable_if_t<
266  (Rows > 4 && Cols > 4) || IsMatrixSizeDynamic<Rows, Cols>(), U>
267  Determinant(const MatrixExpression<T, Rows, Cols, Derived>& m);
268 
269  static void Inverse(const MatrixExpression<T, 1, 1, Derived>& m,
270  Matrix<T, Rows, Cols>& result);
271 
272  static void Inverse(const MatrixExpression<T, 2, 2, Derived>& m,
273  Matrix<T, Rows, Cols>& result);
274 
275  static void Inverse(const MatrixExpression<T, 3, 3, Derived>& m,
276  Matrix<T, Rows, Cols>& result);
277 
278  static void Inverse(const MatrixExpression<T, 4, 4, Derived>& m,
279  Matrix<T, Rows, Cols>& result);
280 
281  template <typename M = Matrix<T, Rows, Cols>>
282  static void Inverse(const MatrixExpression& m,
283  std::enable_if_t<(Rows > 4 && Cols > 4) ||
284  IsMatrixSizeDynamic<Rows, Cols>(),
285  M>& result);
286 };
287 
288 template <typename T, size_t Rows, size_t Cols>
290  : public MatrixExpression<T, Rows, Cols, MatrixConstant<T, Rows, Cols>>
291 {
292  public:
293  constexpr MatrixConstant(size_t r, size_t c, const T& val)
294  : m_rows(r), m_cols(c), m_val(val)
295  {
296  // Do nothing
297  }
298 
299  [[nodiscard]] constexpr size_t GetRows() const;
300 
301  [[nodiscard]] constexpr size_t GetCols() const;
302 
303  constexpr T operator()(size_t, size_t) const;
304 
305  private:
306  size_t m_rows;
307  size_t m_cols;
308  T m_val;
309 };
310 
311 template <typename T, size_t Rows, size_t Cols, typename M1>
312 class MatrixDiagonal
313  : public MatrixExpression<T, Rows, Cols, MatrixDiagonal<T, Rows, Cols, M1>>
314 {
315  public:
316  constexpr MatrixDiagonal(const M1& mat1) : m_mat1(mat1)
317  {
318  // Do nothing
319  }
320 
321  [[nodiscard]] constexpr size_t GetRows() const;
322 
323  [[nodiscard]] constexpr size_t GetCols() const;
324 
325  T operator()(size_t i, size_t j) const;
326 
327  private:
328  M1 m_mat1;
329 };
330 
331 template <typename T, size_t Rows, size_t Cols, typename M1>
332 class MatrixOffDiagonal
333  : public MatrixExpression<T, Rows, Cols,
334  MatrixOffDiagonal<T, Rows, Cols, M1>>
335 {
336  public:
337  constexpr MatrixOffDiagonal(const M1& mat1) : m_mat1(mat1)
338  {
339  // Do nothing
340  }
341 
342  [[nodiscard]] constexpr size_t GetRows() const;
343 
344  [[nodiscard]] constexpr size_t GetCols() const;
345 
346  T operator()(size_t i, size_t j) const;
347 
348  private:
349  M1 m_mat1;
350 };
351 
352 template <typename T, size_t Rows, size_t Cols, typename M1>
353 class MatrixTri
354  : public MatrixExpression<T, Rows, Cols, MatrixTri<T, Rows, Cols, M1>>
355 {
356  public:
357  constexpr MatrixTri(const M1& mat1, bool isUpper, bool isStrict)
358  : m_mat1(mat1), m_isUpper(isUpper), m_isStrict(isStrict)
359  {
360  // Do nothing
361  }
362 
363  [[nodiscard]] constexpr size_t GetRows() const;
364 
365  [[nodiscard]] constexpr size_t GetCols() const;
366 
367  T operator()(size_t i, size_t j) const;
368 
369  private:
370  M1 m_mat1;
371  bool m_isUpper;
372  bool m_isStrict;
373 };
374 
375 template <typename T, size_t Rows, size_t Cols, typename M1>
376 class MatrixTranspose
377  : public MatrixExpression<T, Rows, Cols, MatrixTranspose<T, Rows, Cols, M1>>
378 {
379  public:
380  constexpr MatrixTranspose(const M1& m_mat1) : m_mat1(m_mat1)
381  {
382  // Do nothing
383  }
384 
385  [[nodiscard]] constexpr size_t GetRows() const;
386 
387  [[nodiscard]] constexpr size_t GetCols() const;
388 
389  constexpr T operator()(size_t i, size_t j) const;
390 
391  private:
392  M1 m_mat1;
393 };
394 
395 template <typename T, size_t Rows, size_t Cols, typename M1,
396  typename UnaryOperation>
397 class MatrixUnaryOp
398  : public MatrixExpression<T, Rows, Cols,
399  MatrixUnaryOp<T, Rows, Cols, M1, UnaryOperation>>
400 {
401  public:
402  constexpr MatrixUnaryOp(const M1& mat1) : m_mat1(mat1)
403  {
404  // Do nothing
405  }
406 
407  [[nodiscard]] constexpr size_t GetRows() const;
408 
409  [[nodiscard]] constexpr size_t GetCols() const;
410 
411  constexpr T operator()(size_t i, size_t j) const;
412 
413  private:
414  M1 m_mat1;
415  UnaryOperation m_op;
416 };
417 
418 template <typename T, size_t Rows, size_t Cols, typename M1>
420 
421 template <typename T, size_t Rows, size_t Cols, typename M1>
423 
424 template <typename T, size_t Rows, size_t Cols, typename M1>
426 
427 template <typename T, size_t Rows, size_t Cols, typename U, typename M1>
429 
430 template <typename T, size_t Rows, size_t Cols, typename M1>
431 constexpr auto Ceil(const MatrixExpression<T, Rows, Cols, M1>& a);
432 
433 template <typename T, size_t Rows, size_t Cols, typename M1>
434 constexpr auto Floor(const MatrixExpression<T, Rows, Cols, M1>& a);
435 
436 template <typename T, size_t Rows, size_t Cols, typename M1>
437 constexpr auto operator-(const MatrixExpression<T, Rows, Cols, M1>& m);
438 
450 template <typename T, size_t Rows, size_t Cols, typename E1, typename E2,
451  typename BinaryOperation>
453  : public MatrixExpression<
454  T, Rows, Cols,
455  MatrixElemWiseBinaryOp<T, Rows, Cols, E1, E2, BinaryOperation>>
456 {
457  public:
458  constexpr MatrixElemWiseBinaryOp(const E1& mat1, const E2& mat2)
459  : m_mat1(mat1), m_mat2(mat2)
460  {
461  // Do nothing
462  }
463 
464  [[nodiscard]] constexpr size_t GetRows() const;
465 
466  [[nodiscard]] constexpr size_t GetCols() const;
467 
468  constexpr T operator()(size_t i, size_t j) const;
469 
470  private:
471  E1 m_mat1;
472  E2 m_mat2;
473  BinaryOperation m_op;
474 };
475 
477 template <typename T, size_t Rows, size_t Cols, typename E1, typename E2>
478 using MatrixElemWiseAdd =
480 
482 template <typename T, size_t Rows, size_t Cols, typename E1, typename E2>
483 using MatrixElemWiseSub =
485 
487 template <typename T, size_t Rows, size_t Cols, typename E1, typename E2>
488 using MatrixElemWiseMul =
490 
492 template <typename T, size_t Rows, size_t Cols, typename E1, typename E2>
493 using MatrixElemWiseDiv =
495 
497 template <typename T, size_t Rows, size_t Cols, typename E1, typename E2>
498 using MatrixElemWiseMin =
500 
502 template <typename T, size_t Rows, size_t Cols, typename E1, typename E2>
503 using MatrixElemWiseMax =
505 
506 template <typename T, size_t Rows, size_t Cols, typename M1, typename M2>
507 constexpr auto operator+(const MatrixExpression<T, Rows, Cols, M1>& a,
509 
510 template <typename T, size_t Rows, size_t Cols, typename M1, typename M2>
511 constexpr auto operator-(const MatrixExpression<T, Rows, Cols, M1>& a,
513 
514 template <typename T, size_t Rows, size_t Cols, typename M1, typename M2>
515 constexpr auto ElemMul(const MatrixExpression<T, Rows, Cols, M1>& a,
517 
518 template <typename T, size_t Rows, size_t Cols, typename M1, typename M2>
519 constexpr auto ElemDiv(const MatrixExpression<T, Rows, Cols, M1>& a,
521 
522 template <typename T, size_t Rows, size_t Cols, typename M1, typename M2>
523 constexpr auto Min(const MatrixExpression<T, Rows, Cols, M1>& a,
525 
526 template <typename T, size_t Rows, size_t Cols, typename M1, typename M2>
527 constexpr auto Max(const MatrixExpression<T, Rows, Cols, M1>& a,
529 
530 template <typename T, size_t Rows, size_t Cols, typename M1,
531  typename BinaryOperation>
533  : public MatrixExpression<
534  T, Rows, Cols,
535  MatrixScalarElemWiseBinaryOp<T, Rows, Cols, M1, BinaryOperation>>
536 {
537  public:
538  constexpr MatrixScalarElemWiseBinaryOp(const M1& mat1, const T& scalar2)
539  : m_mat1(mat1), m_scalar2(scalar2)
540  {
541  // Do nothing
542  }
543 
544  [[nodiscard]] constexpr size_t GetRows() const;
545 
546  [[nodiscard]] constexpr size_t GetCols() const;
547 
548  constexpr T operator()(size_t i, size_t j) const;
549 
550  private:
551  M1 m_mat1;
552  T m_scalar2;
553  BinaryOperation m_op;
554 };
555 
556 template <typename T, size_t Rows, size_t Cols, typename M1>
559 
560 template <typename T, size_t Rows, size_t Cols, typename M1>
563 
564 template <typename T, size_t Rows, size_t Cols, typename M1>
567 
568 template <typename T, size_t Rows, size_t Cols, typename M1>
571 
572 template <typename T, size_t Rows, size_t Cols, typename M1>
573 constexpr auto operator+(const MatrixExpression<T, Rows, Cols, M1>& a,
574  const T& b);
575 
576 template <typename T, size_t Rows, size_t Cols, typename M1>
577 constexpr auto operator-(const MatrixExpression<T, Rows, Cols, M1>& a,
578  const T& b);
579 
580 template <typename T, size_t Rows, size_t Cols, typename M1>
581 constexpr auto operator*(const MatrixExpression<T, Rows, Cols, M1>& a,
582  const T& b);
583 
584 template <typename T, size_t Rows, size_t Cols, typename M1>
585 constexpr auto operator/(const MatrixExpression<T, Rows, Cols, M1>& a,
586  const T& b);
587 
588 template <typename T, size_t Rows, size_t Cols, typename M2,
589  typename BinaryOperation>
591  : public MatrixExpression<
592  T, Rows, Cols,
593  ScalarMatrixElemWiseBinaryOp<T, Rows, Cols, M2, BinaryOperation>>
594 {
595  public:
596  constexpr ScalarMatrixElemWiseBinaryOp(const T& s1, const M2& m2)
597  : m_scalar1(s1), m_mat2(m2)
598  {
599  // Do nothing
600  }
601 
602  [[nodiscard]] constexpr size_t GetRows() const;
603 
604  [[nodiscard]] constexpr size_t GetCols() const;
605 
606  constexpr T operator()(size_t i, size_t j) const;
607 
608  private:
609  T m_scalar1;
610  M2 m_mat2;
611  BinaryOperation m_op;
612 };
613 
614 template <typename T, size_t Rows, size_t Cols, typename M2>
617 
618 template <typename T, size_t Rows, size_t Cols, typename M2>
621 
622 template <typename T, size_t Rows, size_t Cols, typename M2>
625 
626 template <typename T, size_t Rows, size_t Cols, typename M2>
629 
630 template <typename T, size_t Rows, size_t Cols, typename M2>
631 constexpr auto operator+(const T& a,
633 
634 template <typename T, size_t Rows, size_t Cols, typename M2>
635 constexpr auto operator-(const T& a,
637 
638 template <typename T, size_t Rows, size_t Cols, typename M2>
639 constexpr auto operator*(const T& a,
641 
642 template <typename T, size_t Rows, size_t Cols, typename M2>
643 constexpr auto operator/(const T& a,
645 
646 template <typename T, size_t Rows, size_t Cols, typename M1, typename M2,
647  typename M3, typename TernaryOperation>
649  : public MatrixExpression<
650  T, Rows, Cols,
651  MatrixTernaryOp<T, Rows, Cols, M1, M2, M3, TernaryOperation>>
652 {
653  public:
654  constexpr MatrixTernaryOp(const M1& mat1, const M2& mat2, const M3& mat3)
655  : m_mat1(mat1), m_mat2(mat2), m_mat3(mat3)
656  {
657  // Do nothing
658  }
659 
660  [[nodiscard]] constexpr size_t GetRows() const;
661 
662  [[nodiscard]] constexpr size_t GetCols() const;
663 
664  constexpr T operator()(size_t i, size_t j) const;
665 
666  private:
667  M1 m_mat1;
668  M2 m_mat2;
669  M3 m_mat3;
670  TernaryOperation m_op;
671 };
672 
673 template <typename T, size_t Rows, size_t Cols, typename M1, typename M2,
674  typename M3>
676 
677 template <typename T, size_t Rows, size_t Cols, typename M1, typename M2,
678  typename M3>
682 
683 template <typename T, size_t Rows, size_t Cols, typename M1, typename M2>
685  : public MatrixExpression<T, Rows, Cols, MatrixMul<T, Rows, Cols, M1, M2>>
686 {
687  public:
688  constexpr MatrixMul(const M1& mat1, const M2& mat2)
689  : m_mat1(mat1), m_mat2(mat2)
690  {
691  // Do nothing
692  }
693 
694  [[nodiscard]] constexpr size_t GetRows() const;
695 
696  [[nodiscard]] constexpr size_t GetCols() const;
697 
698  T operator()(size_t i, size_t j) const;
699 
700  private:
701  M1 m_mat1;
702  M2 m_mat2;
703 };
704 
705 template <typename T, size_t R1, size_t C1, size_t R2, size_t C2, typename M1,
706  typename M2>
709 } // namespace CubbyFlow
710 
712 
713 #endif
Matrix expression for element-wise binary operation.
Definition: MatrixExpression.hpp:452
MatrixCSR< T > operator-(const MatrixCSR< T > &a)
Definition: MatrixCSR-Impl.hpp:1029
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
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 MatrixElemWiseBinaryOp(const E1 &mat1, const E2 &mat2)
Definition: MatrixExpression.hpp:458
Definition: MatrixExpression.hpp:75
constexpr auto Floor(const MatrixExpression< T, Rows, Cols, M1 > &a)
Definition: MatrixExpression-Impl.hpp:1031
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
Definition: Matrix.hpp:27
constexpr bool IsMatrixStaticSquare()
Definition: MatrixExpression.hpp:35
static const bool value
Definition: MatrixExpression.hpp:43
Definition: pybind11Utils.hpp:20
constexpr bool IsMatrixSizeStatic()
Definition: MatrixExpression.hpp:29
constexpr MatrixMul(const M1 &mat1, const M2 &mat2)
Definition: MatrixExpression.hpp:688
constexpr auto ElemMul(const MatrixExpression< T, Rows, Cols, M1 > &a, const MatrixExpression< T, Rows, Cols, M2 > &b)
Definition: MatrixExpression-Impl.hpp:1085
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 MatrixOffDiagonal(const M1 &mat1)
Definition: MatrixExpression.hpp:337
MatrixCSR< T > operator+(const MatrixCSR< T > &a, const MatrixCSR< T > &b)
Definition: MatrixCSR-Impl.hpp:1035
constexpr MatrixConstant(size_t r, size_t c, const T &val)
Definition: MatrixExpression.hpp:293
Definition: MatrixExpression.hpp:47
constexpr MatrixTri(const M1 &mat1, bool isUpper, bool isStrict)
Definition: MatrixExpression.hpp:357
Definition: MatrixExpression.hpp:53
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
constexpr MatrixDiagonal(const M1 &mat1)
Definition: MatrixExpression.hpp:316
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
constexpr ScalarMatrixElemWiseBinaryOp(const T &s1, const M2 &m2)
Definition: MatrixExpression.hpp:596
Definition: MatrixExpression.hpp:289
Vector< T, 3 > operator*(const Quaternion< T > &q, const Vector< T, 3 > &v)
Returns quaternion q * vector v.
Definition: Quaternion-Impl.hpp:543
constexpr bool IsMatrixSizeDynamic()
Definition: MatrixExpression.hpp:23
constexpr MatrixUnaryOp(const M1 &mat1)
Definition: MatrixExpression.hpp:402
Definition: MatrixExpression.hpp:79
Definition: MatrixExpression.hpp:41
constexpr MatrixTernaryOp(const M1 &mat1, const M2 &mat2, const M3 &mat3)
Definition: MatrixExpression.hpp:654
constexpr MatrixScalarElemWiseBinaryOp(const M1 &mat1, const T &scalar2)
Definition: MatrixExpression.hpp:538
constexpr MatrixTranspose(const M1 &m_mat1)
Definition: MatrixExpression.hpp:380
Definition: MatrixExpression.hpp:684