|
Jet
v1.3.3
|
Static-sized M x N matrix class. More...
#include <jet/matrix.h>
Public Types | |
| typedef std::array< T, M *N > | ContainerType |
| typedef ContainerType::iterator | Iterator |
| typedef ContainerType::const_iterator | ConstIterator |
Public Member Functions | |
| Matrix () | |
| template<typename... Params> | |
| Matrix (Params... params) | |
| Constructs matrix instance with parameters. More... | |
| Matrix (const std::initializer_list< std::initializer_list< T >> &lst) | |
Constructs a matrix with given initializer list lst. More... | |
| template<typename E > | |
| Matrix (const MatrixExpression< T, E > &other) | |
| Constructs a matrix with expression template. More... | |
| Matrix (const Matrix &other) | |
| Copy constructor. More... | |
| void | resize (size_t m, size_t n, const T &s=T(0)) |
Resizes to m x n matrix with initial value s. More... | |
| void | set (const T &s) |
| Sets whole matrix with input scalar. More... | |
| void | set (const std::initializer_list< std::initializer_list< T >> &lst) |
Sets a matrix with given initializer list lst. More... | |
| template<typename E > | |
| void | set (const MatrixExpression< T, E > &other) |
| Copies from input matrix expression. More... | |
| void | setDiagonal (const T &s) |
| Sets diagonal elements with input scalar. More... | |
| void | setOffDiagonal (const T &s) |
| Sets off-diagonal elements with input scalar. More... | |
| template<typename E > | |
| void | setRow (size_t i, const VectorExpression< T, E > &row) |
| Sets i-th row with input vector. More... | |
| template<typename E > | |
| void | setColumn (size_t j, const VectorExpression< T, E > &col) |
| Sets j-th column with input vector. More... | |
| template<typename E > | |
| bool | isEqual (const MatrixExpression< T, E > &other) const |
| template<typename E > | |
| bool | isSimilar (const MatrixExpression< T, E > &other, double tol=std::numeric_limits< double >::epsilon()) const |
| constexpr bool | isSquare () const |
| Returns true if this matrix is a square matrix. More... | |
| constexpr Size2 | size () const |
| Returns the size of this matrix. More... | |
| constexpr size_t | rows () const |
| Returns number of rows of this matrix. More... | |
| constexpr size_t | cols () const |
| Returns number of columns of this matrix. More... | |
| T * | data () |
| Returns data pointer of this matrix. More... | |
| const T *const | data () const |
| Returns constant pointer of this matrix. More... | |
| Iterator | begin () |
| Returns the begin iterator of the matrix. More... | |
| ConstIterator | begin () const |
| Returns the begin const iterator of the matrix. More... | |
| Iterator | end () |
| Returns the end iterator of the matrix. More... | |
| ConstIterator | end () const |
| Returns the end const iterator of the matrix. More... | |
| MatrixScalarAdd< T, Matrix > | add (const T &s) const |
| Returns this matrix + input scalar. More... | |
| template<typename E > | |
| MatrixAdd< T, Matrix, E > | add (const E &m) const |
| Returns this matrix + input matrix (element-wise). More... | |
| MatrixScalarSub< T, Matrix > | sub (const T &s) const |
| Returns this matrix - input scalar. More... | |
| template<typename E > | |
| MatrixSub< T, Matrix, E > | sub (const E &m) const |
| Returns this matrix - input matrix (element-wise). More... | |
| MatrixScalarMul< T, Matrix > | mul (const T &s) const |
| Returns this matrix * input scalar. More... | |
| template<typename VE > | |
| MatrixVectorMul< T, Matrix, VE > | mul (const VectorExpression< T, VE > &v) const |
| Returns this matrix * input vector. More... | |
| template<size_t L> | |
| MatrixMul< T, Matrix, Matrix< T, N, L > > | mul (const Matrix< T, N, L > &m) const |
| Returns this matrix * input matrix. More... | |
| MatrixScalarDiv< T, Matrix > | div (const T &s) const |
| Returns this matrix / input scalar. More... | |
| MatrixScalarAdd< T, Matrix > | radd (const T &s) const |
| Returns input scalar + this matrix. More... | |
| template<typename E > | |
| MatrixAdd< T, Matrix, E > | radd (const E &m) const |
| Returns input matrix + this matrix (element-wise). More... | |
| MatrixScalarRSub< T, Matrix > | rsub (const T &s) const |
| Returns input scalar - this matrix. More... | |
| template<typename E > | |
| MatrixSub< T, Matrix, E > | rsub (const E &m) const |
| Returns input matrix - this matrix (element-wise). More... | |
| MatrixScalarMul< T, Matrix > | rmul (const T &s) const |
| Returns input scalar * this matrix. More... | |
| template<size_t L> | |
| MatrixMul< T, Matrix< T, N, L >, Matrix > | rmul (const Matrix< T, N, L > &m) const |
| Returns input matrix * this matrix. More... | |
| MatrixScalarRDiv< T, Matrix > | rdiv (const T &s) const |
| Returns input matrix / this scalar. More... | |
| void | iadd (const T &s) |
| Adds input scalar to this matrix. More... | |
| template<typename E > | |
| void | iadd (const E &m) |
| Adds input matrix to this matrix (element-wise). More... | |
| void | isub (const T &s) |
| Subtracts input scalar from this matrix. More... | |
| template<typename E > | |
| void | isub (const E &m) |
| Subtracts input matrix from this matrix (element-wise). More... | |
| void | imul (const T &s) |
| Multiplies input scalar to this matrix. More... | |
| template<typename E > | |
| void | imul (const E &m) |
| Multiplies input matrix to this matrix. More... | |
| void | idiv (const 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 |
| T | determinant () const |
| Returns determinant of this matrix. More... | |
| MatrixDiagonal< T, Matrix > | diagonal () const |
| Returns diagonal part of this matrix. More... | |
| MatrixDiagonal< T, Matrix > | offDiagonal () const |
| Returns off-diagonal part of this matrix. More... | |
| MatrixTriangular< T, Matrix > | strictLowerTri () const |
| Returns strictly lower triangle part of this matrix. More... | |
| MatrixTriangular< T, Matrix > | strictUpperTri () const |
| Returns strictly upper triangle part of this matrix. More... | |
| MatrixTriangular< T, Matrix > | lowerTri () const |
| Returns lower triangle part of this matrix (including the diagonal). More... | |
| MatrixTriangular< T, Matrix > | upperTri () const |
| Returns upper triangle part of this matrix (including the diagonal). More... | |
| Matrix< T, N, M > | transposed () const |
| Returns transposed matrix. More... | |
| Matrix | inverse () const |
| Returns inverse matrix. More... | |
| template<typename U > | |
| MatrixTypeCast< U, Matrix, T > | castTo () const |
| template<typename E > | |
| Matrix & | operator= (const E &m) |
| Assigns input matrix. More... | |
| Matrix & | operator= (const Matrix &other) |
| Copies to this matrix. More... | |
| Matrix & | operator+= (const T &s) |
| Addition assignment with input scalar. More... | |
| template<typename E > | |
| Matrix & | operator+= (const E &m) |
| Addition assignment with input matrix (element-wise). More... | |
| Matrix & | operator-= (const T &s) |
| Subtraction assignment with input scalar. More... | |
| template<typename E > | |
| Matrix & | operator-= (const E &m) |
| Subtraction assignment with input matrix (element-wise). More... | |
| Matrix & | operator*= (const T &s) |
| Multiplication assignment with input scalar. More... | |
| template<typename E > | |
| Matrix & | operator*= (const E &m) |
| Multiplication assignment with input matrix. More... | |
| Matrix & | operator/= (const 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... | |
| template<typename E > | |
| bool | operator== (const MatrixExpression< T, E > &m) const |
| Returns true if is equal to m. More... | |
| template<typename E > | |
| bool | operator!= (const MatrixExpression< T, E > &m) const |
| Returns true if is not equal to m. More... | |
| template<typename Callback > | |
| void | forEach (Callback func) const |
Iterates the matrix and invoke given func for each index. More... | |
| template<typename Callback > | |
| void | forEachIndex (Callback func) const |
Iterates the matrix and invoke given func for each index. More... | |
Public Member Functions inherited from jet::MatrixExpression< T, Matrix< T, M, N > > | |
| Size2 | size () const |
| Size of the matrix. More... | |
| size_t | rows () const |
| Number of rows. More... | |
| size_t | cols () const |
| Number of columns. More... | |
| const Matrix< T, M, N > & | operator() () const |
| Returns actual implementation (the subclass). More... | |
Static Public Member Functions | |
| static MatrixConstant< T > | makeZero () |
| Makes a M x N matrix with zeros. More... | |
| static MatrixIdentity< T > | makeIdentity () |
Static-sized M x N matrix class.
This class defines M x N row-major matrix data where its size is determined statically at compile time.
| T | - Real number type. |
| M | - Number of rows. |
| N | - Number of columns. |
| typedef ContainerType::const_iterator jet::Matrix< T, M, N >::ConstIterator |
| typedef std::array<T, M * N> jet::Matrix< T, M, N >::ContainerType |
| typedef ContainerType::iterator jet::Matrix< T, M, N >::Iterator |
| jet::Matrix< T, M, N >::Matrix | ( | ) |
Default constructor.
|
explicit |
Constructs matrix instance with parameters.
| jet::Matrix< T, M, N >::Matrix | ( | const std::initializer_list< std::initializer_list< T >> & | lst | ) |
Constructs a matrix with given initializer list lst.
This constructor will build a matrix with given initializer list lst such as
| lst | Initializer list that should be copy to the new matrix. |
| jet::Matrix< T, M, N >::Matrix | ( | const MatrixExpression< T, E > & | other | ) |
Constructs a matrix with expression template.
| jet::Matrix< T, M, N >::Matrix | ( | const Matrix< T, M, N > & | other | ) |
Copy constructor.
| T jet::Matrix< T, M, N >::absmax | ( | ) | const |
Returns absolute maximum among all elements.
| T jet::Matrix< T, M, N >::absmin | ( | ) | const |
Returns absolute minimum among all elements.
| MatrixAdd<T, Matrix, E> jet::Matrix< T, M, N >::add | ( | const E & | m | ) | const |
Returns this matrix + input matrix (element-wise).
| MatrixScalarAdd<T, Matrix> jet::Matrix< T, M, N >::add | ( | const T & | s | ) | const |
Returns this matrix + input scalar.
| T jet::Matrix< T, M, N >::avg | ( | ) | const |
Returns average of all elements.
| Iterator jet::Matrix< T, M, N >::begin | ( | ) |
Returns the begin iterator of the matrix.
| ConstIterator jet::Matrix< T, M, N >::begin | ( | ) | const |
Returns the begin const iterator of the matrix.
| MatrixTypeCast<U, Matrix, T> jet::Matrix< T, M, N >::castTo | ( | ) | const |
|
constexpr |
Returns number of columns of this matrix.
| T* jet::Matrix< T, M, N >::data | ( | ) |
Returns data pointer of this matrix.
| const T* const jet::Matrix< T, M, N >::data | ( | ) | const |
Returns constant pointer of this matrix.
| T jet::Matrix< T, M, N >::determinant | ( | ) | const |
Returns determinant of this matrix.
| MatrixDiagonal<T, Matrix> jet::Matrix< T, M, N >::diagonal | ( | ) | const |
Returns diagonal part of this matrix.
| MatrixScalarDiv<T, Matrix> jet::Matrix< T, M, N >::div | ( | const T & | s | ) | const |
Returns this matrix / input scalar.
| Iterator jet::Matrix< T, M, N >::end | ( | ) |
Returns the end iterator of the matrix.
| ConstIterator jet::Matrix< T, M, N >::end | ( | ) | const |
Returns the end const iterator of the matrix.
| void jet::Matrix< T, M, N >::forEach | ( | Callback | func | ) | const |
Iterates the matrix and invoke given func for each index.
This function iterates the matrix elements and invoke the callback function func. The callback function takes matrix's element as its input. The order of execution will be the same as the nested for-loop below:
Below is the sample usage:
| void jet::Matrix< T, M, N >::forEachIndex | ( | Callback | func | ) | const |
Iterates the matrix and invoke given func for each index.
This function iterates the matrix elements and invoke the callback function func. The callback function takes two parameters which are the (i, j) indices of the matrix. The order of execution will be the same as the nested for-loop below:
Below is the sample usage:
| void jet::Matrix< T, M, N >::iadd | ( | const E & | m | ) |
Adds input matrix to this matrix (element-wise).
| void jet::Matrix< T, M, N >::iadd | ( | const T & | s | ) |
Adds input scalar to this matrix.
| void jet::Matrix< T, M, N >::idiv | ( | const T & | s | ) |
Divides this matrix with input scalar.
| void jet::Matrix< T, M, N >::imul | ( | const E & | m | ) |
Multiplies input matrix to this matrix.
| void jet::Matrix< T, M, N >::imul | ( | const T & | s | ) |
Multiplies input scalar to this matrix.
| Matrix jet::Matrix< T, M, N >::inverse | ( | ) | const |
Returns inverse matrix.
| void jet::Matrix< T, M, N >::invert | ( | ) |
Inverts this matrix.
This function computes the inverse using Gaussian elimination method.
| bool jet::Matrix< T, M, N >::isEqual | ( | const MatrixExpression< T, E > & | other | ) | const |
| bool jet::Matrix< T, M, N >::isSimilar | ( | const MatrixExpression< T, E > & | other, |
| double | tol = std::numeric_limits< double >::epsilon() |
||
| ) | const |
Returns true if this matrix is similar to the input matrix within the given tolerance.
|
constexpr |
Returns true if this matrix is a square matrix.
| void jet::Matrix< T, M, N >::isub | ( | const E & | m | ) |
Subtracts input matrix from this matrix (element-wise).
| void jet::Matrix< T, M, N >::isub | ( | const T & | s | ) |
Subtracts input scalar from this matrix.
| MatrixTriangular<T, Matrix> jet::Matrix< T, M, N >::lowerTri | ( | ) | const |
Returns lower triangle part of this matrix (including the diagonal).
|
static |
Makes a M x N matrix with all diagonal elements to 1, and other elements to 0.
|
static |
Makes a M x N matrix with zeros.
| T jet::Matrix< T, M, N >::max | ( | ) | const |
Returns maximum among all elements.
| T jet::Matrix< T, M, N >::min | ( | ) | const |
Returns minimum among all elements.
| MatrixMul<T, Matrix, Matrix<T, N, L> > jet::Matrix< T, M, N >::mul | ( | const Matrix< T, N, L > & | m | ) | const |
Returns this matrix * input matrix.
| MatrixScalarMul<T, Matrix> jet::Matrix< T, M, N >::mul | ( | const T & | s | ) | const |
Returns this matrix * input scalar.
| MatrixVectorMul<T, Matrix, VE> jet::Matrix< T, M, N >::mul | ( | const VectorExpression< T, VE > & | v | ) | const |
Returns this matrix * input vector.
| MatrixDiagonal<T, Matrix> jet::Matrix< T, M, N >::offDiagonal | ( | ) | const |
Returns off-diagonal part of this matrix.
| bool jet::Matrix< T, M, N >::operator!= | ( | const MatrixExpression< T, E > & | m | ) | const |
Returns true if is not equal to m.
| T& jet::Matrix< T, M, N >::operator() | ( | size_t | i, |
| size_t | j | ||
| ) |
Returns reference of (i,j) element.
| const T& jet::Matrix< T, M, N >::operator() | ( | size_t | i, |
| size_t | j | ||
| ) | const |
Returns constant reference of (i,j) element.
| Matrix& jet::Matrix< T, M, N >::operator*= | ( | const E & | m | ) |
Multiplication assignment with input matrix.
| Matrix& jet::Matrix< T, M, N >::operator*= | ( | const T & | s | ) |
Multiplication assignment with input scalar.
| Matrix& jet::Matrix< T, M, N >::operator+= | ( | const E & | m | ) |
Addition assignment with input matrix (element-wise).
| Matrix& jet::Matrix< T, M, N >::operator+= | ( | const T & | s | ) |
Addition assignment with input scalar.
| Matrix& jet::Matrix< T, M, N >::operator-= | ( | const E & | m | ) |
Subtraction assignment with input matrix (element-wise).
| Matrix& jet::Matrix< T, M, N >::operator-= | ( | const T & | s | ) |
Subtraction assignment with input scalar.
| Matrix& jet::Matrix< T, M, N >::operator/= | ( | const T & | s | ) |
Division assignment with input scalar.
| Matrix& jet::Matrix< T, M, N >::operator= | ( | const E & | m | ) |
Assigns input matrix.
| Matrix& jet::Matrix< T, M, N >::operator= | ( | const Matrix< T, M, N > & | other | ) |
Copies to this matrix.
| bool jet::Matrix< T, M, N >::operator== | ( | const MatrixExpression< T, E > & | m | ) | const |
Returns true if is equal to m.
| T& jet::Matrix< T, M, N >::operator[] | ( | size_t | i | ) |
Returns reference of i-th element.
| const T& jet::Matrix< T, M, N >::operator[] | ( | size_t | i | ) | const |
Returns constant reference of i-th element.
| MatrixAdd<T, Matrix, E> jet::Matrix< T, M, N >::radd | ( | const E & | m | ) | const |
Returns input matrix + this matrix (element-wise).
| MatrixScalarAdd<T, Matrix> jet::Matrix< T, M, N >::radd | ( | const T & | s | ) | const |
Returns input scalar + this matrix.
| MatrixScalarRDiv<T, Matrix> jet::Matrix< T, M, N >::rdiv | ( | const T & | s | ) | const |
Returns input matrix / this scalar.
| void jet::Matrix< T, M, N >::resize | ( | size_t | m, |
| size_t | n, | ||
| const T & | s = T(0) |
||
| ) |
Resizes to m x n matrix with initial value s.
| MatrixMul<T, Matrix<T, N, L>, Matrix> jet::Matrix< T, M, N >::rmul | ( | const Matrix< T, N, L > & | m | ) | const |
Returns input matrix * this matrix.
| MatrixScalarMul<T, Matrix> jet::Matrix< T, M, N >::rmul | ( | const T & | s | ) | const |
Returns input scalar * this matrix.
|
constexpr |
Returns number of rows of this matrix.
| MatrixSub<T, Matrix, E> jet::Matrix< T, M, N >::rsub | ( | const E & | m | ) | const |
Returns input matrix - this matrix (element-wise).
| MatrixScalarRSub<T, Matrix> jet::Matrix< T, M, N >::rsub | ( | const T & | s | ) | const |
Returns input scalar - this matrix.
| void jet::Matrix< T, M, N >::set | ( | const MatrixExpression< T, E > & | other | ) |
Copies from input matrix expression.
| void jet::Matrix< T, M, N >::set | ( | const std::initializer_list< std::initializer_list< T >> & | lst | ) |
Sets a matrix with given initializer list lst.
This function will fill the matrix with given initializer list lst such as
| lst | Initializer list that should be copy to the new matrix. |
| void jet::Matrix< T, M, N >::set | ( | const T & | s | ) |
Sets whole matrix with input scalar.
| void jet::Matrix< T, M, N >::setColumn | ( | size_t | j, |
| const VectorExpression< T, E > & | col | ||
| ) |
Sets j-th column with input vector.
| void jet::Matrix< T, M, N >::setDiagonal | ( | const T & | s | ) |
Sets diagonal elements with input scalar.
| void jet::Matrix< T, M, N >::setOffDiagonal | ( | const T & | s | ) |
Sets off-diagonal elements with input scalar.
| void jet::Matrix< T, M, N >::setRow | ( | size_t | i, |
| const VectorExpression< T, E > & | row | ||
| ) |
Sets i-th row with input vector.
|
constexpr |
Returns the size of this matrix.
| MatrixTriangular<T, Matrix> jet::Matrix< T, M, N >::strictLowerTri | ( | ) | const |
Returns strictly lower triangle part of this matrix.
| MatrixTriangular<T, Matrix> jet::Matrix< T, M, N >::strictUpperTri | ( | ) | const |
Returns strictly upper triangle part of this matrix.
| MatrixSub<T, Matrix, E> jet::Matrix< T, M, N >::sub | ( | const E & | m | ) | const |
Returns this matrix - input matrix (element-wise).
| MatrixScalarSub<T, Matrix> jet::Matrix< T, M, N >::sub | ( | const T & | s | ) | const |
Returns this matrix - input scalar.
| T jet::Matrix< T, M, N >::sum | ( | ) | const |
Returns sum of all elements.
| T jet::Matrix< T, M, N >::trace | ( | ) | const |
Returns sum of all diagonal elements.
| void jet::Matrix< T, M, N >::transpose | ( | ) |
Transposes this matrix.
| Matrix<T, N, M> jet::Matrix< T, M, N >::transposed | ( | ) | const |
Returns transposed matrix.
| MatrixTriangular<T, Matrix> jet::Matrix< T, M, N >::upperTri | ( | ) | const |
Returns upper triangle part of this matrix (including the diagonal).
1.8.18