Jet
v1.3.3
|
3-D matrix class. More...
#include <jet/matrix3x3.h>
Public Member Functions | |
Matrix () | |
Constructs identity matrix. More... | |
Matrix (T s) | |
Constructs constant value matrix. More... | |
Matrix (T m00, T m01, T m02, T m10, T m11, T m12, T m20, T m21, T m22) | |
template<typename U > | |
Matrix (const std::initializer_list< std::initializer_list< U >> &lst) | |
Constructs a matrix with given initializer list lst . More... | |
Matrix (const Matrix &m) | |
Constructs a matrix with input matrix. More... | |
Matrix (const T *arr) | |
void | set (T s) |
Sets whole matrix with input scalar. More... | |
void | set (T m00, T m01, T m02, T m10, T m11, T m12, T m20, T m21, T m22) |
template<typename U > | |
void | set (const std::initializer_list< std::initializer_list< U >> &lst) |
Sets a matrix with given initializer list lst . More... | |
void | set (const Matrix &m) |
Copies from input matrix. More... | |
void | set (const T *arr) |
void | setDiagonal (T s) |
Sets diagonal elements with input scalar. More... | |
void | setOffDiagonal (T s) |
Sets off-diagonal elements with input scalar. More... | |
void | setRow (size_t i, const Vector3< T > &row) |
Sets i-th row with input vector. More... | |
void | setColumn (size_t i, const Vector3< T > &col) |
Sets i-th column with input vector. More... | |
bool | isSimilar (const Matrix &m, double tol=std::numeric_limits< double >::epsilon()) const |
bool | isSquare () const |
Returns true if this matrix is a square matrix. More... | |
size_t | rows () const |
Returns number of rows of this matrix. More... | |
size_t | cols () const |
Returns number of columns of this matrix. More... | |
T * | data () |
Returns data pointer of this matrix. More... | |
const T * | data () const |
Returns constant pointer of this matrix. More... | |
Matrix | add (T s) const |
Returns this matrix + input scalar. More... | |
Matrix | add (const Matrix &m) const |
Returns this matrix + input matrix (element-wise). More... | |
Matrix | sub (T s) const |
Returns this matrix - input scalar. More... | |
Matrix | sub (const Matrix &m) const |
Returns this matrix - input matrix (element-wise). More... | |
Matrix | mul (T s) const |
Returns this matrix * input scalar. More... | |
Vector3< T > | mul (const Vector3< T > &v) const |
Returns this matrix * input vector. More... | |
Matrix | mul (const Matrix &m) const |
Returns this matrix * input matrix. More... | |
Matrix | div (T s) const |
Returns this matrix / input scalar. More... | |
Matrix | radd (T s) const |
Returns input scalar + this matrix. More... | |
Matrix | radd (const Matrix &m) const |
Returns input matrix + this matrix (element-wise). More... | |
Matrix | rsub (T s) const |
Returns input scalar - this matrix. More... | |
Matrix | rsub (const Matrix &m) const |
Returns input matrix - this matrix (element-wise). More... | |
Matrix | rmul (T s) const |
Returns input scalar * this matrix. More... | |
Matrix | rmul (const Matrix &m) const |
Returns input matrix * this matrix. More... | |
Matrix | rdiv (T s) const |
Returns input scalar / this matrix. More... | |
void | iadd (T s) |
Adds input scalar to this matrix. More... | |
void | iadd (const Matrix &m) |
Adds input matrix to this matrix (element-wise). More... | |
void | isub (T s) |
Subtracts input scalar from this matrix. More... | |
void | isub (const Matrix &m) |
Subtracts input matrix from this matrix (element-wise). More... | |
void | imul (T s) |
Multiplies input scalar to this matrix. More... | |
void | imul (const Matrix &m) |
Multiplies input matrix to this matrix. More... | |
void | idiv (T s) |
Divides this matrix with input scalar. More... | |
void | transpose () |
Transposes this matrix. More... | |
void | invert () |
Inverts this matrix. More... | |
T | sum () const |
Returns sum of all elements. More... | |
T | avg () const |
Returns average of all elements. More... | |
T | min () const |
Returns minimum among all elements. More... | |
T | max () const |
Returns maximum among all elements. More... | |
T | absmin () const |
Returns absolute minimum among all elements. More... | |
T | absmax () const |
Returns absolute maximum among all elements. More... | |
T | trace () const |
Returns sum of all diagonal elements. More... | |
T | determinant () const |
Returns determinant of this matrix. More... | |
Matrix | diagonal () const |
Returns diagonal part of this matrix. More... | |
Matrix | offDiagonal () const |
Returns off-diagonal part of this matrix. More... | |
Matrix | strictLowerTri () const |
Returns strictly lower triangle part of this matrix. More... | |
Matrix | strictUpperTri () const |
Returns strictly upper triangle part of this matrix. More... | |
Matrix | lowerTri () const |
Returns lower triangle part of this matrix (including the diagonal). More... | |
Matrix | upperTri () const |
Returns upper triangle part of this matrix (including the diagonal). More... | |
Matrix | transposed () const |
Returns transposed matrix. More... | |
Matrix | inverse () const |
Returns inverse matrix. More... | |
T | frobeniusNorm () const |
Returns Frobenius norm. More... | |
template<typename U > | |
Matrix< U, 3, 3 > | castTo () const |
Matrix & | operator= (const Matrix &m) |
Assigns input matrix. More... | |
Matrix & | operator+= (T s) |
Addition assignment with input scalar. More... | |
Matrix & | operator+= (const Matrix &m) |
Addition assignment with input matrix (element-wise). More... | |
Matrix & | operator-= (T s) |
Subtraction assignment with input scalar. More... | |
Matrix & | operator-= (const Matrix &m) |
Subtraction assignment with input matrix (element-wise). More... | |
Matrix & | operator*= (T s) |
Multiplication assignment with input scalar. More... | |
Matrix & | operator*= (const Matrix &m) |
Multiplication assignment with input matrix. More... | |
Matrix & | operator/= (T s) |
Division assignment with input scalar. More... | |
T & | operator[] (size_t i) |
Returns reference of i-th element. More... | |
const T & | operator[] (size_t i) const |
Returns constant reference of i-th element. More... | |
T & | operator() (size_t i, size_t j) |
Returns reference of (i,j) element. More... | |
const T & | operator() (size_t i, size_t j) const |
Returns constant reference of (i,j) element. More... | |
bool | operator== (const Matrix &m) const |
Returns true if is equal to m. More... | |
bool | operator!= (const Matrix &m) const |
Returns true if is not equal to m. More... | |
Static Public Member Functions | |
static Matrix | makeZero () |
Sets all matrix entries to zero. More... | |
static Matrix | makeIdentity () |
Makes all diagonal elements to 1, and other elements to 0. More... | |
static Matrix | makeScaleMatrix (T sx, T sy, T sz) |
Makes scale matrix. More... | |
static Matrix | makeScaleMatrix (const Vector3< T > &s) |
Makes scale matrix. More... | |
static Matrix | makeRotationMatrix (const Vector3< T > &axis, T rad) |
3-D matrix class.
This class is a row-major 3-D matrix class, which means each element of the matrix is stored in order of (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), and (2, 2).
T | - Type of the element. |
jet::Matrix< T, 3, 3 >::Matrix | ( | ) |
Constructs identity matrix.
|
explicit |
Constructs constant value matrix.
jet::Matrix< T, 3, 3 >::Matrix | ( | T | m00, |
T | m01, | ||
T | m02, | ||
T | m10, | ||
T | m11, | ||
T | m12, | ||
T | m20, | ||
T | m21, | ||
T | m22 | ||
) |
Constructs a matrix with input elements.
jet::Matrix< T, 3, 3 >::Matrix | ( | const std::initializer_list< std::initializer_list< U >> & | lst | ) |
Constructs a matrix with given initializer list lst
.
This constructor will build a matrix with given initializer list lst
such as
Note the initializer also has 3x3 structure.
lst | Initializer list that should be copy to the new matrix. |
jet::Matrix< T, 3, 3 >::Matrix | ( | const Matrix< T, 3, 3 > & | m | ) |
Constructs a matrix with input matrix.
|
explicit |
Constructs a matrix with input array.
T jet::Matrix< T, 3, 3 >::absmax | ( | ) | const |
Returns absolute maximum among all elements.
T jet::Matrix< T, 3, 3 >::absmin | ( | ) | const |
Returns absolute minimum among all elements.
Matrix jet::Matrix< T, 3, 3 >::add | ( | const Matrix< T, 3, 3 > & | m | ) | const |
Returns this matrix + input matrix (element-wise).
Matrix jet::Matrix< T, 3, 3 >::add | ( | T | s | ) | const |
Returns this matrix + input scalar.
T jet::Matrix< T, 3, 3 >::avg | ( | ) | const |
Returns average of all elements.
Matrix<U, 3, 3> jet::Matrix< T, 3, 3 >::castTo | ( | ) | const |
size_t jet::Matrix< T, 3, 3 >::cols | ( | ) | const |
Returns number of columns of this matrix.
T* jet::Matrix< T, 3, 3 >::data | ( | ) |
Returns data pointer of this matrix.
const T* jet::Matrix< T, 3, 3 >::data | ( | ) | const |
Returns constant pointer of this matrix.
T jet::Matrix< T, 3, 3 >::determinant | ( | ) | const |
Returns determinant of this matrix.
Matrix jet::Matrix< T, 3, 3 >::diagonal | ( | ) | const |
Returns diagonal part of this matrix.
Matrix jet::Matrix< T, 3, 3 >::div | ( | T | s | ) | const |
Returns this matrix / input scalar.
T jet::Matrix< T, 3, 3 >::frobeniusNorm | ( | ) | const |
Returns Frobenius norm.
void jet::Matrix< T, 3, 3 >::iadd | ( | const Matrix< T, 3, 3 > & | m | ) |
Adds input matrix to this matrix (element-wise).
void jet::Matrix< T, 3, 3 >::iadd | ( | T | s | ) |
Adds input scalar to this matrix.
void jet::Matrix< T, 3, 3 >::idiv | ( | T | s | ) |
Divides this matrix with input scalar.
void jet::Matrix< T, 3, 3 >::imul | ( | const Matrix< T, 3, 3 > & | m | ) |
Multiplies input matrix to this matrix.
void jet::Matrix< T, 3, 3 >::imul | ( | T | s | ) |
Multiplies input scalar to this matrix.
Matrix jet::Matrix< T, 3, 3 >::inverse | ( | ) | const |
Returns inverse matrix.
void jet::Matrix< T, 3, 3 >::invert | ( | ) |
Inverts this matrix.
bool jet::Matrix< T, 3, 3 >::isSimilar | ( | const Matrix< T, 3, 3 > & | m, |
double | tol = std::numeric_limits< double >::epsilon() |
||
) | const |
Returns true if this matrix is similar to the input matrix within the given tolerance.
bool jet::Matrix< T, 3, 3 >::isSquare | ( | ) | const |
Returns true if this matrix is a square matrix.
void jet::Matrix< T, 3, 3 >::isub | ( | const Matrix< T, 3, 3 > & | m | ) |
Subtracts input matrix from this matrix (element-wise).
void jet::Matrix< T, 3, 3 >::isub | ( | T | s | ) |
Subtracts input scalar from this matrix.
Matrix jet::Matrix< T, 3, 3 >::lowerTri | ( | ) | const |
Returns lower triangle part of this matrix (including the diagonal).
|
static |
Makes all diagonal elements to 1, and other elements to 0.
|
static |
Makes rotation matrix.
|
static |
Makes scale matrix.
|
static |
Makes scale matrix.
|
static |
Sets all matrix entries to zero.
T jet::Matrix< T, 3, 3 >::max | ( | ) | const |
Returns maximum among all elements.
T jet::Matrix< T, 3, 3 >::min | ( | ) | const |
Returns minimum among all elements.
Matrix jet::Matrix< T, 3, 3 >::mul | ( | const Matrix< T, 3, 3 > & | m | ) | const |
Returns this matrix * input matrix.
Vector3<T> jet::Matrix< T, 3, 3 >::mul | ( | const Vector3< T > & | v | ) | const |
Returns this matrix * input vector.
Matrix jet::Matrix< T, 3, 3 >::mul | ( | T | s | ) | const |
Returns this matrix * input scalar.
Matrix jet::Matrix< T, 3, 3 >::offDiagonal | ( | ) | const |
Returns off-diagonal part of this matrix.
bool jet::Matrix< T, 3, 3 >::operator!= | ( | const Matrix< T, 3, 3 > & | m | ) | const |
Returns true if is not equal to m.
T& jet::Matrix< T, 3, 3 >::operator() | ( | size_t | i, |
size_t | j | ||
) |
Returns reference of (i,j) element.
const T& jet::Matrix< T, 3, 3 >::operator() | ( | size_t | i, |
size_t | j | ||
) | const |
Returns constant reference of (i,j) element.
Matrix& jet::Matrix< T, 3, 3 >::operator*= | ( | const Matrix< T, 3, 3 > & | m | ) |
Multiplication assignment with input matrix.
Matrix& jet::Matrix< T, 3, 3 >::operator*= | ( | T | s | ) |
Multiplication assignment with input scalar.
Matrix& jet::Matrix< T, 3, 3 >::operator+= | ( | const Matrix< T, 3, 3 > & | m | ) |
Addition assignment with input matrix (element-wise).
Matrix& jet::Matrix< T, 3, 3 >::operator+= | ( | T | s | ) |
Addition assignment with input scalar.
Matrix& jet::Matrix< T, 3, 3 >::operator-= | ( | const Matrix< T, 3, 3 > & | m | ) |
Subtraction assignment with input matrix (element-wise).
Matrix& jet::Matrix< T, 3, 3 >::operator-= | ( | T | s | ) |
Subtraction assignment with input scalar.
Matrix& jet::Matrix< T, 3, 3 >::operator/= | ( | T | s | ) |
Division assignment with input scalar.
Matrix& jet::Matrix< T, 3, 3 >::operator= | ( | const Matrix< T, 3, 3 > & | m | ) |
Assigns input matrix.
bool jet::Matrix< T, 3, 3 >::operator== | ( | const Matrix< T, 3, 3 > & | m | ) | const |
Returns true if is equal to m.
T& jet::Matrix< T, 3, 3 >::operator[] | ( | size_t | i | ) |
Returns reference of i-th element.
const T& jet::Matrix< T, 3, 3 >::operator[] | ( | size_t | i | ) | const |
Returns constant reference of i-th element.
Matrix jet::Matrix< T, 3, 3 >::radd | ( | const Matrix< T, 3, 3 > & | m | ) | const |
Returns input matrix + this matrix (element-wise).
Matrix jet::Matrix< T, 3, 3 >::radd | ( | T | s | ) | const |
Returns input scalar + this matrix.
Matrix jet::Matrix< T, 3, 3 >::rdiv | ( | T | s | ) | const |
Returns input scalar / this matrix.
Matrix jet::Matrix< T, 3, 3 >::rmul | ( | const Matrix< T, 3, 3 > & | m | ) | const |
Returns input matrix * this matrix.
Matrix jet::Matrix< T, 3, 3 >::rmul | ( | T | s | ) | const |
Returns input scalar * this matrix.
size_t jet::Matrix< T, 3, 3 >::rows | ( | ) | const |
Returns number of rows of this matrix.
Matrix jet::Matrix< T, 3, 3 >::rsub | ( | const Matrix< T, 3, 3 > & | m | ) | const |
Returns input matrix - this matrix (element-wise).
Matrix jet::Matrix< T, 3, 3 >::rsub | ( | T | s | ) | const |
Returns input scalar - this matrix.
void jet::Matrix< T, 3, 3 >::set | ( | const Matrix< T, 3, 3 > & | m | ) |
Copies from input matrix.
void jet::Matrix< T, 3, 3 >::set | ( | const std::initializer_list< std::initializer_list< U >> & | lst | ) |
Sets a matrix with given initializer list lst
.
This function will fill the matrix with given initializer list lst
such as
Note the initializer also has 3x3 structure.
lst | Initializer list that should be copy to the new matrix. |
void jet::Matrix< T, 3, 3 >::set | ( | const T * | arr | ) |
Copies from input array.
void jet::Matrix< T, 3, 3 >::set | ( | T | m00, |
T | m01, | ||
T | m02, | ||
T | m10, | ||
T | m11, | ||
T | m12, | ||
T | m20, | ||
T | m21, | ||
T | m22 | ||
) |
Sets this matrix with input elements.
void jet::Matrix< T, 3, 3 >::set | ( | T | s | ) |
Sets whole matrix with input scalar.
void jet::Matrix< T, 3, 3 >::setColumn | ( | size_t | i, |
const Vector3< T > & | col | ||
) |
Sets i-th column with input vector.
void jet::Matrix< T, 3, 3 >::setDiagonal | ( | T | s | ) |
Sets diagonal elements with input scalar.
void jet::Matrix< T, 3, 3 >::setOffDiagonal | ( | T | s | ) |
Sets off-diagonal elements with input scalar.
void jet::Matrix< T, 3, 3 >::setRow | ( | size_t | i, |
const Vector3< T > & | row | ||
) |
Sets i-th row with input vector.
Matrix jet::Matrix< T, 3, 3 >::strictLowerTri | ( | ) | const |
Returns strictly lower triangle part of this matrix.
Matrix jet::Matrix< T, 3, 3 >::strictUpperTri | ( | ) | const |
Returns strictly upper triangle part of this matrix.
Matrix jet::Matrix< T, 3, 3 >::sub | ( | const Matrix< T, 3, 3 > & | m | ) | const |
Returns this matrix - input matrix (element-wise).
Matrix jet::Matrix< T, 3, 3 >::sub | ( | T | s | ) | const |
Returns this matrix - input scalar.
T jet::Matrix< T, 3, 3 >::sum | ( | ) | const |
Returns sum of all elements.
T jet::Matrix< T, 3, 3 >::trace | ( | ) | const |
Returns sum of all diagonal elements.
void jet::Matrix< T, 3, 3 >::transpose | ( | ) |
Transposes this matrix.
Matrix jet::Matrix< T, 3, 3 >::transposed | ( | ) | const |
Returns transposed matrix.
Matrix jet::Matrix< T, 3, 3 >::upperTri | ( | ) | const |
Returns upper triangle part of this matrix (including the diagonal).