Loading...
Searching...
No Matches
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
15
16#include <functional>
17
18namespace CubbyFlow
19{
20static constexpr size_t MATRIX_SIZE_DYNAMIC = 0;
21
22template <size_t Rows, size_t Cols>
23constexpr bool IsMatrixSizeDynamic()
24{
25 return (Rows == MATRIX_SIZE_DYNAMIC) || (Cols == MATRIX_SIZE_DYNAMIC);
26}
27
28template <size_t Rows, size_t Cols>
29constexpr bool IsMatrixSizeStatic()
30{
32}
33
34template <size_t Rows, size_t Cols>
35constexpr bool IsMatrixStaticSquare()
36{
38}
39
40template <size_t Rows, size_t Cols>
45
46template <size_t Rows, size_t Cols>
51
52template <size_t Rows, size_t Cols>
57
58template <typename T, size_t Rows, size_t Cols>
59class Matrix;
60
61template <typename T, size_t Rows, size_t Cols, typename M1>
62class MatrixDiagonal;
63
64template <typename T, size_t Rows, size_t Cols, typename M1>
66
67template <typename T, size_t Rows, size_t Cols, typename M1>
68class MatrixTri;
69
70template <typename T, size_t Rows, size_t Cols, typename M1>
71class MatrixTranspose;
72
73template <typename T, size_t Rows, size_t Cols, typename M1,
74 typename UnaryOperation>
75class MatrixUnaryOp;
76
77template <typename T, size_t Rows, size_t Cols, typename M1,
78 typename BinaryOperation>
80
92template <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
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
144
145 [[nodiscard]] ValueType Length() const;
146
148
150 template <size_t R, size_t C, typename E>
153
155 template <size_t R, size_t C, typename E>
158
159 [[nodiscard]] MatrixScalarElemWiseBinaryOp<T, Rows, Cols, const Derived&,
160 std::divides<T>>
161 Normalized() const;
162
165 const;
166
169 const;
170
173 const;
174
177 const;
178
181
184
186 const;
187
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>
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>
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)),
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)) &&
219 ((R == 2 || R == 3) && C == 1)),
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)) &&
228 ((R == 2 || R == 3) && C == 1)),
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
257
259
261
263
264 template <typename U = ValueType>
265 static std::enable_if_t<
266 (Rows > 4 && Cols > 4) || IsMatrixSizeDynamic<Rows, Cols>(), U>
268
271
274
277
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) ||
285 M>& result);
286};
287
288template <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
311template <typename T, size_t Rows, size_t Cols, typename M1>
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
331template <typename T, size_t Rows, size_t Cols, typename M1>
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
352template <typename T, size_t Rows, size_t Cols, typename M1>
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
375template <typename T, size_t Rows, size_t Cols, typename M1>
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
395template <typename T, size_t Rows, size_t Cols, typename M1,
396 typename UnaryOperation>
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
418template <typename T, size_t Rows, size_t Cols, typename M1>
420
421template <typename T, size_t Rows, size_t Cols, typename M1>
423
424template <typename T, size_t Rows, size_t Cols, typename M1>
426
427template <typename T, size_t Rows, size_t Cols, typename U, typename M1>
429
430template <typename T, size_t Rows, size_t Cols, typename M1>
431constexpr auto Ceil(const MatrixExpression<T, Rows, Cols, M1>& a);
432
433template <typename T, size_t Rows, size_t Cols, typename M1>
434constexpr auto Floor(const MatrixExpression<T, Rows, Cols, M1>& a);
435
436template <typename T, size_t Rows, size_t Cols, typename M1>
437constexpr auto operator-(const MatrixExpression<T, Rows, Cols, M1>& m);
438
450template <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
477template <typename T, size_t Rows, size_t Cols, typename E1, typename E2>
480
482template <typename T, size_t Rows, size_t Cols, typename E1, typename E2>
485
487template <typename T, size_t Rows, size_t Cols, typename E1, typename E2>
490
492template <typename T, size_t Rows, size_t Cols, typename E1, typename E2>
495
497template <typename T, size_t Rows, size_t Cols, typename E1, typename E2>
500
502template <typename T, size_t Rows, size_t Cols, typename E1, typename E2>
505
506template <typename T, size_t Rows, size_t Cols, typename M1, typename M2>
509
510template <typename T, size_t Rows, size_t Cols, typename M1, typename M2>
513
514template <typename T, size_t Rows, size_t Cols, typename M1, typename M2>
515constexpr auto ElemMul(const MatrixExpression<T, Rows, Cols, M1>& a,
517
518template <typename T, size_t Rows, size_t Cols, typename M1, typename M2>
519constexpr auto ElemDiv(const MatrixExpression<T, Rows, Cols, M1>& a,
521
522template <typename T, size_t Rows, size_t Cols, typename M1, typename M2>
523constexpr auto Min(const MatrixExpression<T, Rows, Cols, M1>& a,
525
526template <typename T, size_t Rows, size_t Cols, typename M1, typename M2>
527constexpr auto Max(const MatrixExpression<T, Rows, Cols, M1>& a,
529
530template <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
556template <typename T, size_t Rows, size_t Cols, typename M1>
559
560template <typename T, size_t Rows, size_t Cols, typename M1>
563
564template <typename T, size_t Rows, size_t Cols, typename M1>
567
568template <typename T, size_t Rows, size_t Cols, typename M1>
571
572template <typename T, size_t Rows, size_t Cols, typename M1>
574 const T& b);
575
576template <typename T, size_t Rows, size_t Cols, typename M1>
578 const T& b);
579
580template <typename T, size_t Rows, size_t Cols, typename M1>
582 const T& b);
583
584template <typename T, size_t Rows, size_t Cols, typename M1>
586 const T& b);
587
588template <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
614template <typename T, size_t Rows, size_t Cols, typename M2>
617
618template <typename T, size_t Rows, size_t Cols, typename M2>
621
622template <typename T, size_t Rows, size_t Cols, typename M2>
625
626template <typename T, size_t Rows, size_t Cols, typename M2>
629
630template <typename T, size_t Rows, size_t Cols, typename M2>
631constexpr auto operator+(const T& a,
633
634template <typename T, size_t Rows, size_t Cols, typename M2>
635constexpr auto operator-(const T& a,
637
638template <typename T, size_t Rows, size_t Cols, typename M2>
639constexpr auto operator*(const T& a,
641
642template <typename T, size_t Rows, size_t Cols, typename M2>
643constexpr auto operator/(const T& a,
645
646template <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
673template <typename T, size_t Rows, size_t Cols, typename M1, typename M2,
674 typename M3>
676
677template <typename T, size_t Rows, size_t Cols, typename M1, typename M2,
678 typename M3>
682
683template <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
705template <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
Definition MatrixExpression.hpp:291
constexpr size_t GetRows() const
Definition MatrixExpression-Impl.hpp:890
constexpr size_t GetCols() const
Definition MatrixExpression-Impl.hpp:896
constexpr T operator()(size_t, size_t) const
Definition MatrixExpression-Impl.hpp:902
constexpr MatrixConstant(size_t r, size_t c, const T &val)
Definition MatrixExpression.hpp:293
Definition MatrixExpression.hpp:314
constexpr MatrixDiagonal(const M1 &mat1)
Definition MatrixExpression.hpp:316
constexpr size_t GetRows() const
Definition MatrixExpression-Impl.hpp:908
T operator()(size_t i, size_t j) const
Definition MatrixExpression-Impl.hpp:920
constexpr size_t GetCols() const
Definition MatrixExpression-Impl.hpp:914
Matrix expression for element-wise binary operation.
Definition MatrixExpression.hpp:456
constexpr size_t GetCols() const
Definition MatrixExpression-Impl.hpp:1052
constexpr size_t GetRows() const
Definition MatrixExpression-Impl.hpp:1044
constexpr T operator()(size_t i, size_t j) const
Definition MatrixExpression-Impl.hpp:1060
constexpr MatrixElemWiseBinaryOp(const E1 &mat1, const E2 &mat2)
Definition MatrixExpression.hpp:458
Base class for matrix expression.
Definition MatrixExpression.hpp:94
ValueType Determinant() const
Definition MatrixExpression-Impl.hpp:198
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.
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
static constexpr T Determinant(const MatrixExpression< T, 2, 2, Derived > &m)
bool IsSimilar(const MatrixExpression< T, R, C, E > &m, double tol=std::numeric_limits< double >::epsilon()) const
Definition MatrixExpression-Impl.hpp:46
Matrix< T, Rows, Cols > Inverse() const
Returns inverse matrix.
Definition MatrixExpression-Impl.hpp:371
std::enable_if_t<(IsMatrixSizeDynamic< Rows, Cols >()||(Rows==3 &&Cols==1)), std::tuple< Matrix< U, 3, 1 >, Matrix< U, 3, 1 > > Tangentials() const
Returns the tangential vectors for this vector.
constexpr size_t GetRows() const
Returns the number of rows.
Definition MatrixExpression-Impl.hpp:21
ValueType AbsMin() const
Definition MatrixExpression-Impl.hpp:141
ValueType Avg() const
Definition MatrixExpression-Impl.hpp:93
ValueType Sum() const
Definition MatrixExpression-Impl.hpp:77
size_t SubdominantAxis() const
Definition MatrixExpression-Impl.hpp:228
MatrixTri< T, Rows, Cols, const Derived & > StrictLowerTri() const
Returns strictly lower triangle part of this matrix.
Definition MatrixExpression-Impl.hpp:337
ValueType Length() const
Definition MatrixExpression-Impl.hpp:278
ValueType NormSquared() const
Definition MatrixExpression-Impl.hpp:256
static void Inverse(const MatrixExpression< T, 2, 2, Derived > &m, Matrix< T, Rows, Cols > &result)
ValueType FrobeniusNorm() const
Definition MatrixExpression-Impl.hpp:272
constexpr size_t GetCols() const
Returns the number of columns.
Definition MatrixExpression-Impl.hpp:27
std::enable_if_t<(IsMatrixSizeDynamic< Rows, Cols >()||(Rows==2 &&Cols==1)), Matrix< U, 2, 1 > Tangential() const
Returns the tangential vector for this vector.
ValueType DistanceTo(const MatrixExpression< T, R, C, E > &other) const
Returns the distance to the other vector.
MatrixTri< T, Rows, Cols, const Derived & > UpperTri() const
Returns upper triangle part of this matrix (including the diagonal).
Definition MatrixExpression-Impl.hpp:358
MatrixDiagonal< T, Rows, Cols, const Derived & > Diagonal() const
Returns diagonal part of this matrix.
Definition MatrixExpression-Impl.hpp:323
static void Inverse(const MatrixExpression< T, 4, 4, Derived > &m, Matrix< T, Rows, Cols > &result)
MatrixUnaryOp< U, Rows, Cols, const Derived &, TypeCast< T, U > > CastTo() const
static void Inverse(const MatrixExpression< T, 1, 1, Derived > &m, Matrix< T, Rows, Cols > &result)
ValueType Min() const
Definition MatrixExpression-Impl.hpp:99
MatrixTranspose< T, Rows, Cols, const Derived & > Transposed() const
Definition MatrixExpression-Impl.hpp:365
ValueType LengthSquared() const
Definition MatrixExpression-Impl.hpp:286
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
constexpr bool IsSquare() const
Returns true if this matrix is a square matrix.
Definition MatrixExpression-Impl.hpp:71
ValueType AbsMax() const
Definition MatrixExpression-Impl.hpp:162
MatrixTri< T, Rows, Cols, const Derived & > LowerTri() const
Returns lower triangle part of this matrix (including the diagonal).
Definition MatrixExpression-Impl.hpp:351
ValueType Norm() const
Definition MatrixExpression-Impl.hpp:250
ValueType DistanceSquaredTo(const MatrixExpression< T, R, C, E > &other) const
Returns the squared distance to the other vector.
size_t DominantAxis() const
Definition MatrixExpression-Impl.hpp:206
ValueType Max() const
Definition MatrixExpression-Impl.hpp:120
static constexpr T Determinant(const MatrixExpression< T, 3, 3, Derived > &m)
Matrix< T, Rows, Cols > Eval() const
Definition MatrixExpression-Impl.hpp:39
static constexpr T Determinant(const MatrixExpression< T, 4, 4, Derived > &m)
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.
static constexpr T Determinant(const MatrixExpression< T, 1, 1, Derived > &m)
std::enable_if_t<(IsMatrixSizeDynamic< Rows, Cols >()||(Rows==3 &&Cols==1)) &&(IsMatrixSizeDynamic< R, C >()||(R==3 &&C==1)), Matrix< U, 3, 1 > Cross(const MatrixExpression< T, R, C, E > &expression) const
Derived & GetDerived()
Returns actual implementation (the subclass).
Definition MatrixExpression-Impl.hpp:509
MatrixScalarElemWiseBinaryOp< T, Rows, Cols, const Derived &, std::divides< T > > Normalized() const
Definition MatrixExpression-Impl.hpp:315
static void Inverse(const MatrixExpression< T, 3, 3, Derived > &m, Matrix< T, Rows, Cols > &result)
MatrixOffDiagonal< T, Rows, Cols, const Derived & > OffDiagonal() const
Returns off-diagonal part of this matrix.
Definition MatrixExpression-Impl.hpp:330
MatrixTri< T, Rows, Cols, const Derived & > StrictUpperTri() const
Returns strictly upper triangle part of this matrix.
Definition MatrixExpression-Impl.hpp:344
ValueType Trace() const
Definition MatrixExpression-Impl.hpp:183
Definition Matrix.hpp:30
Definition MatrixExpression.hpp:686
constexpr MatrixMul(const M1 &mat1, const M2 &mat2)
Definition MatrixExpression.hpp:688
constexpr size_t GetRows() const
Definition MatrixExpression-Impl.hpp:1265
constexpr size_t GetCols() const
Definition MatrixExpression-Impl.hpp:1271
T operator()(size_t i, size_t j) const
Definition MatrixExpression-Impl.hpp:1277
Definition MatrixExpression.hpp:335
constexpr MatrixOffDiagonal(const M1 &mat1)
Definition MatrixExpression.hpp:337
constexpr size_t GetCols() const
Definition MatrixExpression-Impl.hpp:937
constexpr size_t GetRows() const
Definition MatrixExpression-Impl.hpp:931
T operator()(size_t i, size_t j) const
Definition MatrixExpression-Impl.hpp:943
Definition MatrixExpression.hpp:536
constexpr size_t GetCols() const
Definition MatrixExpression-Impl.hpp:1128
constexpr T operator()(size_t i, size_t j) const
Definition MatrixExpression-Impl.hpp:1135
constexpr size_t GetRows() const
Definition MatrixExpression-Impl.hpp:1121
constexpr MatrixScalarElemWiseBinaryOp(const M1 &mat1, const T &scalar2)
Definition MatrixExpression.hpp:538
Definition MatrixExpression.hpp:652
constexpr MatrixTernaryOp(const M1 &mat1, const M2 &mat2, const M3 &mat3)
Definition MatrixExpression.hpp:654
constexpr size_t GetRows() const
Definition MatrixExpression-Impl.hpp:1228
constexpr T operator()(size_t i, size_t j) const
Definition MatrixExpression-Impl.hpp:1244
constexpr size_t GetCols() const
Definition MatrixExpression-Impl.hpp:1236
Definition MatrixExpression.hpp:378
constexpr T operator()(size_t i, size_t j) const
Definition MatrixExpression-Impl.hpp:999
constexpr size_t GetCols() const
Definition MatrixExpression-Impl.hpp:993
constexpr size_t GetRows() const
Definition MatrixExpression-Impl.hpp:987
constexpr MatrixTranspose(const M1 &m_mat1)
Definition MatrixExpression.hpp:380
Definition MatrixExpression.hpp:355
constexpr size_t GetCols() const
Definition MatrixExpression-Impl.hpp:960
T operator()(size_t i, size_t j) const
Definition MatrixExpression-Impl.hpp:966
constexpr size_t GetRows() const
Definition MatrixExpression-Impl.hpp:954
constexpr MatrixTri(const M1 &mat1, bool isUpper, bool isStrict)
Definition MatrixExpression.hpp:357
Definition MatrixExpression.hpp:400
constexpr size_t GetCols() const
Definition MatrixExpression-Impl.hpp:1012
constexpr size_t GetRows() const
Definition MatrixExpression-Impl.hpp:1006
constexpr T operator()(size_t i, size_t j) const
Definition MatrixExpression-Impl.hpp:1018
constexpr MatrixUnaryOp(const M1 &mat1)
Definition MatrixExpression.hpp:402
Definition MatrixExpression.hpp:594
constexpr ScalarMatrixElemWiseBinaryOp(const T &s1, const M2 &m2)
Definition MatrixExpression.hpp:596
constexpr T operator()(size_t i, size_t j) const
Definition MatrixExpression-Impl.hpp:1188
constexpr size_t GetRows() const
Definition MatrixExpression-Impl.hpp:1174
constexpr size_t GetCols() const
Definition MatrixExpression-Impl.hpp:1181
Definition pybind11Utils.hpp:21
constexpr bool IsMatrixStaticSquare()
Definition MatrixExpression.hpp:35
MatrixCSR< T > operator-(const MatrixCSR< T > &a)
Definition MatrixCSR-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
constexpr auto Ceil(const MatrixExpression< T, Rows, Cols, M1 > &a)
Definition MatrixExpression-Impl.hpp:1025
constexpr bool IsMatrixSizeDynamic()
Definition MatrixExpression.hpp:23
constexpr auto Min(const MatrixExpression< T, Rows, Cols, M1 > &a, const MatrixExpression< T, Rows, Cols, M2 > &b)
Definition MatrixExpression-Impl.hpp:1103
constexpr auto ElemMul(const MatrixExpression< T, Rows, Cols, M1 > &a, const MatrixExpression< T, Rows, Cols, M2 > &b)
Definition MatrixExpression-Impl.hpp:1085
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 Floor(const MatrixExpression< T, Rows, Cols, M1 > &a)
Definition MatrixExpression-Impl.hpp:1031
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738
MatrixCSR< T > operator+(const MatrixCSR< T > &a, const MatrixCSR< T > &b)
Definition MatrixCSR-Impl.hpp:1037
constexpr auto ElemDiv(const MatrixExpression< T, Rows, Cols, M1 > &a, const MatrixExpression< T, Rows, Cols, M2 > &b)
Definition MatrixExpression-Impl.hpp:1094
MatrixCSR< T > operator/(const MatrixCSR< T > &a, T b)
Definition MatrixCSR-Impl.hpp:1092
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 IsMatrixSizeStatic()
Definition MatrixExpression.hpp:29
Definition MatrixExpression.hpp:42
static const bool value
Definition MatrixExpression.hpp:43
Definition MatrixExpression.hpp:54
static const bool value
Definition MatrixExpression.hpp:55
Definition MatrixExpression.hpp:48
static const bool value
Definition MatrixExpression.hpp:49