|
Core 1.0
|
This class implements \( 2^2 \) matrix. More...
#include <matrix.h>
Public Member Functions | |
| Matrix2 () | |
| Empty. | |
| constexpr | Matrix2 (const double &) |
| Creates a matrix with the same diagonal value. | |
| Matrix2 (const Vector2 &) | |
| Create a diagonal matrix with diagonal terms set to the vector entries. | |
| Matrix2 (const Vector2 &, const Vector2 &) | |
| Creates a column vector matrix. | |
| constexpr | Matrix2 (const double &, const double &, const double &, const double &) |
| Creates a matrix with a set of double values. | |
| Matrix2 (const double &, const double &, const double &) | |
| Create a symmetric matrix. | |
| constexpr double & | operator[] (int) |
| Direct access to the array of the matrix. | |
| constexpr double | operator[] (int) const |
| Overloaded. | |
| constexpr double & | operator() (int, int) |
| Get element (i,j) of the matrix. | |
| constexpr double | operator() (int, int) const |
| Overloaded. | |
| Vector2 | C (int) const |
| Get the i-th column vector of the matrix. | |
| Matrix2 | operator- () const |
| Returns the opposite of a matrix -A. | |
| Matrix2 & | operator+= (const Matrix2 &) |
| Destructive addition operator. | |
| Matrix2 & | operator-= (const Matrix2 &) |
| Destructive subtraction operator. | |
| Matrix2 & | operator*= (const Matrix2 &) |
| Destructive multiplication. | |
| Matrix2 & | operator*= (const double &) |
| Destructive multiplication operator. | |
| Matrix2 & | operator/= (double) |
| Destructive division operator. | |
| Matrix2 | Scaled (const Matrix2 &) const |
| Hadamart product, which is the element-wise product. | |
| Vector2 | operator* (const Vector2 &) const |
| Right multiply by a vector. | |
| QString | ToGLSL () const |
| Return a string expression. | |
| Matrix2 | T () const |
| Transpose the matrix. | |
| double | Determinant () const |
| Computes the determinant of the matrix. | |
| Matrix2 | Inverse () const |
| Computes the inverse of a matrix \( A^{-1} \). | |
| double | Trace () const |
| Compute the trace (sum of diagonal terms) of a matrix. | |
| double | FrobeniusNorm () const |
| Compute the Frobenius norm of the matrix. | |
| Quadric | Characteristic () const |
| Compute the characteristic polynomial. | |
| double | SpectralNorm () const |
| Compute the spectral norm of the matrix. | |
| double | InfinityNorm () const |
| Compute the infinity norm of the matrix. | |
| void | EigenSolveSymmetric (double[2], Vector2[2]) const |
| Compute the eigen values of the matrix. | |
| Vector2 | Eigen () const |
| Compute the eigen values. | |
Static Public Member Functions | |
| static Matrix2 | Rotation (const double &) |
| Create a rotation matrix. | |
| static Matrix2 | Rotation (Xoshiro256 &=Xoshiro256::X512) |
| Create a random rotation matrix. | |
| static Matrix2 | Tensor2 (const double &) |
| Create an anisotropic tensor matrix. | |
| static Matrix2 | Tensor2 (const double &, const double &) |
| Create a tensor matrix. | |
Static Public Attributes | |
| static const Matrix2 | Null |
| Null matrix. | |
| static const Matrix2 | Identity |
| Identity matrix. | |
| static const Matrix2 | RotationHalfPi |
| Half-pi rotation. | |
| static const Matrix2 | RotationOneThirdPi |
| One third pi rotation (60°). | |
Protected Attributes | |
| double | r [4] = { 1.0,0.0,0.0,1.0 } |
| The array storing the coefficients of the matrix. | |
Friends | |
| Matrix2 | operator+ (const Matrix2 &u, const Matrix2 &v) |
| Overloaded. | |
| Matrix2 | operator- (const Matrix2 &u, const Matrix2 &v) |
| Overloaded. | |
| Matrix2 | operator* (const Matrix2 &u, const Matrix2 &v) |
| Multiplication. | |
| Matrix2 | operator* (const Matrix2 &u, const double &a) |
| Right multiply by a double. | |
| Matrix2 | operator* (const double &a, const Matrix2 &u) |
| Left multiply by a double. | |
| Matrix2 | operator/ (const Matrix2 &u, const double &a) |
| Right divide by a double. | |
| Matrix2 | operator/ (const double &x, const Matrix2 &a) |
| Computes the inverse matrix and scales it by a double. | |
| std::ostream & | operator<< (std::ostream &s, const Matrix2 &matrix) |
| Overloaded. | |
This class implements \( 2^2 \) matrix.
Operators have been overloaded to behave as expected. Thus it is possible to write:
|
inlineexplicitconstexpr |
Creates a matrix with the same diagonal value.
| a | The diagonal value. |
|
inlineexplicit |
Create a diagonal matrix with diagonal terms set to the vector entries.
Note that this is a scaling matrix.
| a | Vector of diagonal values |
Creates a column vector matrix.
| a,b | Column vectors. |
|
inlineexplicitconstexpr |
Creates a matrix with a set of double values.
The coefficients are given column by column: the parameter cJrI is the coefficient of the column J and of the row I, i.e., the element (I,J) of the matrix, which is stored at the index I+2J. The matrix whose rows are (a,b) and (c,d) is therefore Matrix2(a, c, b, d).
| c0r0,c0r1 | Coefficients of the first column. |
| c1r0,c1r1 | Coefficients of the second column. |
|
inlineexplicit |
Create a symmetric matrix.
| a,b | Diagonal terms. |
| c | Last term. |
|
inline |
Get the i-th column vector of the matrix.
| i | Index. |
| void Matrix2::EigenSolveSymmetric | ( | double | a[2], |
| Vector2 | e[2] ) const |
Compute the eigen values of the matrix.
Return eigen vectors as well.
| a | An array of two eigen values. |
| e | The array containing the two eigen vectors. |
| Matrix2 Matrix2::Inverse | ( | ) | const |
Computes the inverse of a matrix \( A^{-1} \).
This function returns the null matrix if A cannot be inversed.
The threshold value involved in the singular matrix detection is set to \( 10^{-18} \).
|
inlineconstexpr |
Get element (i,j) of the matrix.
| i | Row. |
| j | Column. |
Destructive addition operator.
| u | Matrix. |
Destructive subtraction operator.
| u | Matrix. |
|
static |
Create a rotation matrix.
| a | Angle in radian. |
|
static |
Create a random rotation matrix.
This is a simple function which is equivalent to the following inlined code:
| ra | Random number generator. |
Hadamart product, which is the element-wise product.
| u | Matrix. |
|
inline |
Transpose the matrix.
Note that if the matrix is a rotation matrix, then the transpose is equal to its inverse.
|
static |
Create an anisotropic tensor matrix.
| angle | The angle of the tensor. |
|
static |
Create a tensor matrix.
| c,s | Cosine and sine of twice the tensor angle, i.e. \( c=\cos(2\theta) \), \( s=\sin(2\theta) \). Use Tensor2(double) to pass the angle \( \theta \) directly. |
| QString Matrix2::ToGLSL | ( | ) | const |
Return a string expression.
Yields a QString of the form 'mat2(m(0, 0), ..., m(1, 1))' that write the matrix in GLSL.
Multiplication.
| u,v | Input matrices. |
Computes the inverse matrix and scales it by a double.
| x | Real. |
| a | Matrix. |
|
friend |
Overloaded.
| s | Stream. |
| matrix | The matrix. |