Core 1.0
|
This class implements 22 matrix. More...
#include <matrix.h>
Public Member Functions | |
Matrix2 () | |
Empty. | |
Matrix2 (const double &) | |
Creates a matrix with the same diagonal value. More... | |
Matrix2 (const Vector2 &) | |
Create a diagonal matrix with diagonal terms set to the vector entries. More... | |
Matrix2 (const Vector2 &, const Vector2 &) | |
Creates a column vector matrix. More... | |
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. More... | |
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. More... | |
constexpr double | operator() (int, int) const |
Overloaded. | |
Vector2 | C (int) const |
Get the i-th column vector of the matrix. More... | |
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*= (double) |
Destructive multiplication operator. | |
Matrix2 & | operator/= (double) |
Destructive division operator. | |
Vector2 | operator* (const Vector2 &) const |
Right multiply by a vector. | |
Matrix2 | T () const |
Transpose the matrix. More... | |
double | Determinant () const |
Computes the determinant of the matrix. | |
Matrix2 | Inverse () const |
Computes the inverse of a matrix A-1. More... | |
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 |
Find the eigen values of the matrix. More... | |
Vector2 | Eigen () const |
Compute the eigen values. | |
Static Public Member Functions | |
static Matrix2 | Rotation (const double &) |
Create a rotation matrix. More... | |
static Matrix2 | Rotation (RandomFast &=random239) |
Create a random rotation matrix. More... | |
static Matrix2 | Tensor2 (const double &) |
Create an anisotropic tensor matrix. More... | |
static Matrix2 | Tensor2 (const double &, const double &) |
Create a tensor matrix. More... | |
Static Public Attributes | |
static const Matrix2 | Null |
This static member defines the null matrix. | |
static const Matrix2 | Identity |
This static member defines the identity matrix. | |
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 &, const Matrix2 &) |
Overloaded. | |
Matrix2 | operator- (const Matrix2 &, const Matrix2 &) |
Overloaded. | |
Matrix2 | operator* (const Matrix2 &, const Matrix2 &) |
Multiplication. More... | |
Matrix2 | operator* (const Matrix2 &, const double &) |
Right multiply by a double. | |
Matrix2 | operator* (const double &, const Matrix2 &) |
Left multiply by a double. | |
Matrix2 | operator/ (const Matrix2 &, const double &) |
Right divide by a double. | |
Matrix2 | operator/ (const double &, const Matrix2 &) |
Computes the inverse matrix and scales it by a double. More... | |
std::ostream & | operator<< (std::ostream &, const Matrix2 &) |
Overloaded. More... | |
This class implements 22 matrix.
Operators have been overloaded to behave as expected. Thus it is possible to write:
|
inlineexplicit |
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. |
|
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 |
Find 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. |
|
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. |
|
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 the angle of the tensor. |
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. |