#include <ginger/matrix2.hpp>
template<typename T1, typename T2 = T1>
Matrix2 class
| Template parameters | |
|---|---|
| T1 | The type of the first column vector |
| T2 | The type of the second column vector (defaults to T1) |
A template class representing a 2x2 matrix with column vectors. The matrix is stored as two column vectors (x and y).
Constructors, destructors, conversion operators
Public functions
Arithmetic operators
definie +, -, *, /, +=, -=, *=, /=, etc.
- auto operator-() const -> Matrix2< T1, T2 > -> auto constexpr
- Negate the matrix.
-
template<typename U1, typename U2>auto operator+=(const Matrix2<U1, U2>& other) -> Matrix2< T1, T2 > & -> CONSTEXPR14 auto
- Add another matrix to this one.
-
template<typename U1, typename U2>auto operator-=(const Matrix2<U1, U2>& other) -> Matrix2< T1, T2 > & -> CONSTEXPR14 auto
- Subtract another matrix from this one.
-
template<typename R>auto operator*=(const R& alpha) -> Matrix2< T1, T2 > & -> CONSTEXPR14 auto
- Multiply.
-
template<typename R>auto operator/=(const R& alpha) -> Matrix2< T1, T2 > & -> CONSTEXPR14 auto
- Divide matrix by a scalar.
-
template<typename U1, typename U2>auto mdot(const Vector2<U1, U2>& other) const -> T1 -> auto constexpr
- Multiply matrix with vector.
- auto det() const -> double -> auto constexpr
- Calculate the determinant.
-
template<typename U1, typename U2>auto operator+(Matrix2<T1, T2> x, const Matrix2<U1, U2>& y) -> Matrix2< T1, T2 > -> auto constexpr
- Add two matrices.
-
template<typename U1, typename U2>auto operator-(Matrix2<T1, T2> x, const Matrix2<U1, U2>& y) -> Matrix2< T1, T2 > -> auto constexpr
- Subtract two matrices.
-
template<typename R>auto operator*(Matrix2<T1, T2> x, const R& alpha) -> Matrix2< T1, T2 > -> auto constexpr
- Multiply matrix by a scalar.
-
template<typename R>auto operator*(const R& alpha, Matrix2<T1, T2> x) -> Matrix2< T1, T2 > -> auto constexpr
- Multiply a scalar by a matrix.
-
template<typename R>auto operator/(Matrix2<T1, T2> x, const R& alpha) -> Matrix2< T1, T2 > -> auto constexpr
- Divide matrix by a scalar.
Function documentation
template<typename T1, typename T2>
auto ginger:: Matrix2<T1, T2>:: x() const -> const T1 & constexpr
Get the first column vector.
| Returns | constexpr const T1& Reference to the first column vector |
|---|
template<typename T1, typename T2>
auto ginger:: Matrix2<T1, T2>:: y() const -> const T2 & constexpr
Get the second column vector.
| Returns | constexpr const T2& Reference to the second column vector |
|---|
template<typename T1, typename T2>
auto ginger:: Matrix2<T1, T2>:: operator-() const -> Matrix2< T1, T2 > constexpr
Negate the matrix.
| Returns | Matrix2<T1, T2> A new matrix with negated column vectors |
|---|
template<typename T1, typename T2>
template<typename U1, typename U2>
CONSTEXPR14 auto ginger:: Matrix2<T1, T2>:: operator+=(const Matrix2<U1, U2>& other) -> Matrix2< T1, T2 > &
Add another matrix to this one.
| Template parameters | |
|---|---|
| U1 | Type of the first column of the other matrix |
| U2 | Type of the second column of the other matrix |
| Parameters | |
| other in | The matrix to add |
| Returns | Matrix2<T1, T2>& Reference to this matrix |
template<typename T1, typename T2>
template<typename U1, typename U2>
CONSTEXPR14 auto ginger:: Matrix2<T1, T2>:: operator-=(const Matrix2<U1, U2>& other) -> Matrix2< T1, T2 > &
Subtract another matrix from this one.
| Template parameters | |
|---|---|
| U1 | Type of the first column of the other matrix |
| U2 | Type of the second column of the other matrix |
| Parameters | |
| other in | The matrix to subtract |
| Returns | Matrix2<T1, T2>& Reference to this matrix |
template<typename T1, typename T2>
template<typename R>
CONSTEXPR14 auto ginger:: Matrix2<T1, T2>:: operator*=(const R& alpha) -> Matrix2< T1, T2 > &
Multiply.
| Template parameters | |
|---|---|
| R | |
| Parameters | |
| alpha in | |
| Returns | Matrix2<T1, T2>& |
template<typename T1, typename T2>
template<typename R>
CONSTEXPR14 auto ginger:: Matrix2<T1, T2>:: operator/=(const R& alpha) -> Matrix2< T1, T2 > &
Divide matrix by a scalar.
| Template parameters | |
|---|---|
| R | The scalar type |
| Parameters | |
| alpha in | The scalar value |
| Returns | Matrix2<T1, T2>& Reference to this matrix |
template<typename T1, typename T2>
template<typename U1, typename U2>
auto ginger:: Matrix2<T1, T2>:: mdot(const Vector2<U1, U2>& other) const -> T1 constexpr
Multiply matrix with vector.
| Template parameters | |
|---|---|
| U1 | Type of the first component of the vector |
| U2 | Type of the second component of the vector |
| Parameters | |
| other in | The vector to multiply |
| Returns | T1 The resulting vector (as column vector type) |
Performs matrix-vector multiplication: this * other.
template<typename T1, typename T2>
auto ginger:: Matrix2<T1, T2>:: det() const -> double constexpr
Calculate the determinant.
| Returns | double The determinant value |
|---|
Computes the determinant of the 2x2 matrix.
template<typename T1, typename T2>
template<typename U1, typename U2>
auto ginger:: Matrix2<T1, T2>:: operator+(Matrix2<T1, T2> x,
const Matrix2<U1, U2>& y) -> Matrix2< T1, T2 > constexpr
Add two matrices.
| Template parameters | |
|---|---|
| U1 | Type of the first column of the first matrix |
| U2 | Type of the second column of the first matrix |
| Parameters | |
| x in | The first matrix |
| y in | The second matrix |
| Returns | Matrix2<T1, T2> The result matrix |
template<typename T1, typename T2>
template<typename U1, typename U2>
auto ginger:: Matrix2<T1, T2>:: operator-(Matrix2<T1, T2> x,
const Matrix2<U1, U2>& y) -> Matrix2< T1, T2 > constexpr
Subtract two matrices.
| Template parameters | |
|---|---|
| U1 | Type of the first column of the first matrix |
| U2 | Type of the second column of the first matrix |
| Parameters | |
| x in | The first matrix |
| y in | The second matrix |
| Returns | Matrix2<T1, T2> The result matrix |
template<typename T1, typename T2>
template<typename R>
auto ginger:: Matrix2<T1, T2>:: operator*(Matrix2<T1, T2> x,
const R& alpha) -> Matrix2< T1, T2 > constexpr
Multiply matrix by a scalar.
| Template parameters | |
|---|---|
| R | The scalar type |
| Parameters | |
| x in | The matrix |
| alpha in | The scalar value |
| Returns | Matrix2<T1, T2> The result matrix |
template<typename T1, typename T2>
template<typename R>
auto ginger:: Matrix2<T1, T2>:: operator*(const R& alpha,
Matrix2<T1, T2> x) -> Matrix2< T1, T2 > constexpr
Multiply a scalar by a matrix.
| Template parameters | |
|---|---|
| R | The scalar type |
| Parameters | |
| alpha in | The scalar value |
| x in | The matrix |
| Returns | Matrix2<T1, T2> The result matrix |
template<typename T1, typename T2>
template<typename R>
auto ginger:: Matrix2<T1, T2>:: operator/(Matrix2<T1, T2> x,
const R& alpha) -> Matrix2< T1, T2 > constexpr
Divide matrix by a scalar.
| Template parameters | |
|---|---|
| R | The scalar type |
| Parameters | |
| x in | The matrix |
| alpha in | The scalar value |
| Returns | Matrix2<T1, T2> The result matrix |