|
Ginger 1.1.9
|
#include <matrix2.hpp>
Public Member Functions | |
| constexpr | Matrix2 (T1 x, T2 y) noexcept |
| Construct a new Matrix2 object. | |
| constexpr auto | x () const -> const T1 & |
| Get the first column vector. | |
| constexpr auto | y () const -> const T2 & |
| Get the second column vector. | |
Arithmetic operators | |
definie +, -, *, /, +=, -=, *=, /=, etc. | |
| constexpr auto | operator- () const -> Matrix2< T1, T2 > |
| Negate the matrix. | |
| template<typename U1 , typename U2 > | |
| CONSTEXPR14 auto | operator+= (const Matrix2< U1, U2 > &other) -> Matrix2< T1, T2 > & |
| Add another matrix to this one. | |
| template<typename U1 , typename U2 > | |
| CONSTEXPR14 auto | operator-= (const Matrix2< U1, U2 > &other) -> Matrix2< T1, T2 > & |
| Subtract another matrix from this one. | |
| template<typename R > | |
| CONSTEXPR14 auto | operator*= (const R &alpha) -> Matrix2< T1, T2 > & |
| Multiply. | |
| template<typename R > | |
| CONSTEXPR14 auto | operator/= (const R &alpha) -> Matrix2< T1, T2 > & |
| Divide matrix by a scalar. | |
| template<typename U1 , typename U2 > | |
| constexpr auto | mdot (const Vector2< U1, U2 > &other) const -> T1 |
| Multiply matrix with vector. | |
| constexpr auto | det () const -> double |
| Calculate the determinant. | |
| template<typename U1 , typename U2 > | |
| constexpr auto | operator+ (Matrix2< T1, T2 > x, const Matrix2< U1, U2 > &y) -> Matrix2< T1, T2 > |
| Add two matrices. | |
| template<typename U1 , typename U2 > | |
| constexpr auto | operator- (Matrix2< T1, T2 > x, const Matrix2< U1, U2 > &y) -> Matrix2< T1, T2 > |
| Subtract two matrices. | |
| template<typename R > | |
| constexpr auto | operator* (Matrix2< T1, T2 > x, const R &alpha) -> Matrix2< T1, T2 > |
| Multiply matrix by a scalar. | |
| template<typename R > | |
| constexpr auto | operator* (const R &alpha, Matrix2< T1, T2 > x) -> Matrix2< T1, T2 > |
| Multiply a scalar by a matrix. | |
| template<typename R > | |
| constexpr auto | operator/ (Matrix2< T1, T2 > x, const R &alpha) -> Matrix2< T1, T2 > |
| Divide matrix by a scalar. | |
A template class representing a 2x2 matrix with column vectors. The matrix is stored as two column vectors (x and y).
| T1 | The type of the first column vector |
| T2 | The type of the second column vector (defaults to T1) |
Construct a new Matrix2 object.
| [in] | x | The first column vector |
| [in] | y | The second column vector |
Calculate the determinant.
Computes the determinant of the 2x2 matrix:
\[ \det\begin{bmatrix} a & b \\ c & d \end{bmatrix} = ad - bc \]
|
inlineconstexpr |
Multiply matrix with vector.
Performs matrix-vector multiplication:
\[ \begin{bmatrix} a & b \\ c & d \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} ax + by \\ cx + dy \end{bmatrix} \]
| U1 | Type of the first component of the vector |
| U2 | Type of the second component of the vector |
| [in] | other | The vector to multiply |
|
inline |
Multiply.
| R |
| [in] | alpha |
|
inline |
Add another matrix to this one.
| U1 | Type of the first column of the other matrix |
| U2 | Type of the second column of the other matrix |
| [in] | other | The matrix to add |
|
inlineconstexpr |
Negate the matrix.
|
inline |
Subtract another matrix from this one.
| U1 | Type of the first column of the other matrix |
| U2 | Type of the second column of the other matrix |
| [in] | other | The matrix to subtract |
|
inline |
Divide matrix by a scalar.
| R | The scalar type |
| [in] | alpha | The scalar value |
Get the first column vector.
Get the second column vector.
Multiply a scalar by a matrix.
| R | The scalar type |
| [in] | alpha | The scalar value |
| [in] | x | The matrix |
Multiply matrix by a scalar.
| R | The scalar type |
| [in] | x | The matrix |
| [in] | alpha | The scalar value |
|
friend |
Add two matrices.
| U1 | Type of the first column of the first matrix |
| U2 | Type of the second column of the first matrix |
| [in] | x | The first matrix |
| [in] | y | The second matrix |
|
friend |
Subtract two matrices.
| U1 | Type of the first column of the first matrix |
| U2 | Type of the second column of the first matrix |
| [in] | x | The first matrix |
| [in] | y | The second matrix |
Divide matrix by a scalar.
| R | The scalar type |
| [in] | x | The matrix |
| [in] | alpha | The scalar value |