Ocean
|
This class implements a matrix with arbitrary size. More...
Public Types | |
enum | MatrixProperty { MP_UNKNOWN , MP_SYMMETRIC } |
Definition of specific properties of matrices. More... | |
typedef T | Type |
Definition of the used data type. More... | |
Public Member Functions | |
MatrixT ()=default | |
Creates a new matrix with no size. More... | |
MatrixT (const size_t rows, const size_t columns) | |
Creates a new matrix with defined rows and columns. More... | |
MatrixT (const size_t rows, const size_t columns, bool toIdentity) | |
Creates a new matrix with defined rows and columns. More... | |
MatrixT (const size_t rows, const size_t columns, const T value) | |
Creates a new matrix with defined rows and columns. More... | |
MatrixT (const size_t rows, const size_t columns, const T *source) | |
Creates a new matrix with defined rows and columns. More... | |
MatrixT (const size_t rows, const size_t columns, const T *source, const bool valuesRowAligned) | |
Creates a new matrix with defined rows and columns. More... | |
MatrixT (const size_t rows, const size_t columns, const MatrixT< T > &diagonal) | |
Creates a new matrix with defined rows and columns and initializes the diagonal with small sub matrices. More... | |
MatrixT (const size_t rows, const size_t columns, const MatrixT< T > &subMatrix, const size_t row, const size_t column, const T value=T(0.0)) | |
Creates a new matrix with defined rows and columns and a given sub-matrix. More... | |
MatrixT (const MatrixT< T > &matrix) | |
Copies a matrix. More... | |
MatrixT (MatrixT< T > &&matrix) noexcept | |
Move constructor. More... | |
~MatrixT () | |
Destructs a matrix and releases the elements. More... | |
size_t | rows () const |
Returns the count of rows. More... | |
size_t | columns () const |
Returns the count of columns. More... | |
size_t | elements () const |
Returns the number of entire elements, which is the product of rows and columns. More... | |
MatrixT< T > | inverted () const |
Returns the inverted of this matrix. More... | |
bool | invert () |
Inverts this matrix. More... | |
MatrixT< T > | transposed () const |
Returns the transposed of this matrix. More... | |
void | transpose () |
Transposes this matrix. More... | |
MatrixT< T > | selfSquareMatrix () const |
Returns the matrix product of this matrix and the transposed matrix of this matrix. More... | |
MatrixT< T > | selfTransposedSquareMatrix () const |
Returns the matrix product of transposed matrix of this matrix and this matrix. More... | |
void | selfTransposedSquareMatrix (MatrixT< T > &result) const |
Returns the matrix product of transposed matrix of this matrix and this matrix. More... | |
void | weightedSelfTransposedSquareMatrix (const MatrixT< T > &weightDiagonal, MatrixT< T > &result) const |
Returns the matrix product of transposed matrix of this matrix and this matrix and applies a further squared diagonal weighting matrix. More... | |
bool | selfSquareDiagonalMatrixMultiply (const MatrixT< T > &right, MatrixT< T > &result) const |
Interprets this matrix as diagonal matrix and multiplies a second matrix on the right of the interpreted diagonal matrix. More... | |
bool | selfSquareDiagonalMatrixMultiply (const MatrixT< T > &weightDiagonal, const MatrixT< T > &right, MatrixT< T > &result) const |
Interprets this matrix as diagonal matrix and multiplies a second matrix on the right of the interpreted diagonal matrix. More... | |
MatrixT< T > | transposedMultiply (const MatrixT< T > &right) const |
Multiplies this transposed matrix with a second matrix. More... | |
void | transposedMultiply (const MatrixT< T > &right, MatrixT< T > &result) const |
Multiplies this transposed matrix with a second matrix. More... | |
bool | solve (const MatrixT< T > &b, MatrixT< T > &x, const MatrixProperty matrixProperty=MP_UNKNOWN) const |
Solves the given linear system. More... | |
template<MatrixProperty tMatrixProperty> | |
bool | solve (const MatrixT< T > &b, MatrixT< T > &x) const |
Solves the given linear system. More... | |
bool | solve (const T *b, T *x, const MatrixProperty matrixProperty=MP_UNKNOWN) const |
Solves the given linear system. More... | |
template<MatrixProperty tMatrixProperty> | |
bool | solve (const T *b, T *x) const |
Solves the given linear system. More... | |
bool | nonNegativeMatrixFactorization (MatrixT< T > &subcomponents, MatrixT< T > &weights, const size_t components=0u, const unsigned int iterations=100u, const T convergenceThreshold=T(0.0001)) const |
Performs a non-negative matrix factorization with multiplicative update rules V = W * H, V is a matrix containing non-negative values This matrix is V, and will be factorized into two matrices W (weights) and H (subcomponents). More... | |
bool | eigenSystem (MatrixT< T > &values, MatrixT< T > &vectors) const |
Computes the eigen system of this matrix. More... | |
bool | singularValueDecomposition (MatrixT< T > &u, MatrixT< T > &w, MatrixT< T > &v) const |
Computes the singular value decomposition for this matrix. More... | |
bool | qrDecomposition (MatrixT< T > &qMatrix, MatrixT< T > *rMatrix=nullptr) const |
Computes the QR decomposition for this matrix [m x n] while m >= n must hold. More... | |
bool | choleskyDecomposition (MatrixT< T > &lMatrix) const |
Computes the Cholesky decomposition for this square matrix [m x m]. More... | |
MatrixT< T > | pseudoInverted (const T epsilon=NumericT< T >::eps()) const |
Returns the pseudo inverse of this matrix by application of the singular value decomposition. More... | |
size_t | rank () const |
Computes the rank of this matrix. More... | |
MatrixT< T > | row (const size_t index) const |
Returns a row of the matrix. More... | |
MatrixT< T > | vector (const size_t column) const |
Returns a column vector of the matrix. More... | |
MatrixT< T > | diagonal () const |
Returns a vector containing the values of the diagonal. More... | |
T | norm () const |
Determines the L1 norm (sum of absolute elements) of this matrix. More... | |
T | sum () const |
Determines the sum of all elements of this matrix. More... | |
MatrixT< T > | subMatrix (const size_t row, const size_t column, const size_t rows, const size_t columns) |
Returns a sub matrix of this one. More... | |
void | multiplyRow (const size_t row, const T scalar) |
Multiplies a row with a scalar. More... | |
void | multiplyColumn (const size_t column, const T scalar) |
Multiplies a column with a scalar. More... | |
void | resize (const size_t rows, const size_t columns) |
Resizes this matrix. More... | |
bool | isEqual (const MatrixT< T > &matrix, const T eps=NumericT< T >::eps()) const |
Returns whether two matrices are almost identical up to a specified epsilon. More... | |
bool | isSymmetric (const T eps=NumericT< T >::eps()) const |
Returns whether this matrix is symmetric (and whether this matrix is a square matrix). More... | |
const T * | data () const |
Returns a pointer to the internal values. More... | |
T * | data () |
Returns a pointer to the internal values. More... | |
MatrixT< T > & | operator= (const MatrixT< T > &matrix) |
Assigns a matrix to this one. More... | |
MatrixT< T > & | operator= (MatrixT< T > &&matrix) noexcept |
Move assign operator. More... | |
bool | operator== (const MatrixT< T > &right) const |
Returns whether two matrices are identical up to a small epsilon. More... | |
bool | operator!= (const MatrixT< T > &right) const |
Returns whether two matrices are not identical up to a small epsilon. More... | |
MatrixT< T > | operator+ (const MatrixT< T > &right) const |
Adds two matrices. More... | |
MatrixT< T > & | operator+= (const MatrixT< T > &right) |
Adds and assigns two matrices. More... | |
MatrixT< T > | operator- (const MatrixT< T > &right) const |
Subtracts two matrices. More... | |
MatrixT< T > & | operator-= (const MatrixT< T > &right) |
Subtracts and assigns two matrices. More... | |
MatrixT< T > | operator* (const MatrixT< T > &right) const |
Multiplies two matrices. More... | |
MatrixT< T > | operator* (const T scalar) const |
Multiplies the matrix with a scalar. More... | |
MatrixT< T > & | operator*= (const MatrixT< T > &right) |
Multiplies and assigns two matrices. More... | |
MatrixT< T > & | operator*= (const T scalar) |
Multiplies this matrix by a scalar. More... | |
const T * | operator[] (const size_t row) const |
Returns the pointer to the elements of a specified row. More... | |
T * | operator[] (const size_t row) |
Element operator for the row aligned elements. More... | |
T | operator() (const size_t row, const size_t column) const |
Element operator allowing to access a specific elements of this matrix. More... | |
T & | operator() (const size_t row, const size_t column) |
Element operator allowing to access a specific elements of this matrix. More... | |
T | operator() (const size_t index) const |
Element operator for the row aligned elements. More... | |
T & | operator() (const size_t index) |
Element operator for the row aligned elements. More... | |
operator bool () const | |
Returns whether the matrix holds at least one element. More... | |
Static Public Member Functions | |
static size_t | rank (const T *data, const size_t rows, const size_t columns) |
Computes the rank of given matrix data. More... | |
Protected Member Functions | |
void | swapRows (const size_t row0, const size_t row1) |
Swaps two rows. More... | |
void | swapColumns (const size_t column0, const size_t column1) |
Swaps two columns. More... | |
void | addRows (const size_t targetRow, const size_t sourceRow, const T scalar) |
Adds a multiple of a row to another one. More... | |
void | elementwiseMultiplication (const MatrixT< T > &multiplier) |
Performs an element-wise matrix multiplication meaning that each element of this matrix will be multiplied by a corresponding element from 'multiplier'. More... | |
void | elementwiseDivision (const MatrixT< T > &denominator) |
Performs an element-wise matrix division meaning that each element of this matrix will be divided by a corresponding element from 'denominator'. More... | |
Protected Attributes | |
size_t | rows_ = 0 |
Number of rows. More... | |
size_t | columns_ = 0 |
Number of columns. More... | |
T * | values_ = nullptr |
Elements of the matrix. More... | |
This class implements a matrix with arbitrary size.
The elements of this matrix are stored in a row aligned order.
That means that elements are stored in the following pattern:
| 0 1 2 3 4 ... c-1 | | c c+1 c+2 c+3 c+4 ... | | ... |
T | Data type of matrix elements |
typedef T Ocean::MatrixT< T >::Type |
Definition of the used data type.
enum Ocean::MatrixT::MatrixProperty |
|
default |
Creates a new matrix with no size.
Ocean::MatrixT< T >::MatrixT | ( | const size_t | rows, |
const size_t | columns | ||
) |
Creates a new matrix with defined rows and columns.
rows | The rows of the new matrix |
columns | The columns of the new matrix |
Ocean::MatrixT< T >::MatrixT | ( | const size_t | rows, |
const size_t | columns, | ||
bool | toIdentity | ||
) |
Creates a new matrix with defined rows and columns.
rows | The rows of the new matrix |
columns | The columns of the new matrix |
toIdentity | Determines whether the matrix will be initialized with as entity matrix or zero matrix. |
Ocean::MatrixT< T >::MatrixT | ( | const size_t | rows, |
const size_t | columns, | ||
const T | value | ||
) |
Creates a new matrix with defined rows and columns.
rows | The rows of the new matrix |
columns | The columns of the new matrix |
value | The value that every matrix element will be set to |
Ocean::MatrixT< T >::MatrixT | ( | const size_t | rows, |
const size_t | columns, | ||
const T * | source | ||
) |
Creates a new matrix with defined rows and columns.
rows | The rows of the new matrix |
columns | The columns of the new matrix |
source | Elements to be copied into this matrix |
Ocean::MatrixT< T >::MatrixT | ( | const size_t | rows, |
const size_t | columns, | ||
const T * | source, | ||
const bool | valuesRowAligned | ||
) |
Creates a new matrix with defined rows and columns.
rows | The rows of the new matrix |
columns | The columns of the new matrix |
source | Elements to be copied into this matrix |
valuesRowAligned | True, if the given values are stored in a row aligned order (which is the default case for this matrix); False, if the values are stored in a column aligned order |
Ocean::MatrixT< T >::MatrixT | ( | const size_t | rows, |
const size_t | columns, | ||
const MatrixT< T > & | diagonal | ||
) |
Creates a new matrix with defined rows and columns and initializes the diagonal with small sub matrices.
The number of columns of the given diagonal vector matrix defines the size of the small sub matrices.
The number of rows of the diagonal vector matrix must be a multiple of the number of rows.
rows | The rows of the new matrix |
columns | The columns of the new matrix |
diagonal | The diagonal vector matrix holding the new diagonal sub matrices |
Ocean::MatrixT< T >::MatrixT | ( | const size_t | rows, |
const size_t | columns, | ||
const MatrixT< T > & | subMatrix, | ||
const size_t | row, | ||
const size_t | column, | ||
const T | value = T(0.0) |
||
) |
Creates a new matrix with defined rows and columns and a given sub-matrix.
The given sub-matrix can be larger than the new matrix as elements not fitting into the new matrix will be skipped.
All remaining elements of the matrix will be set to the specified value.
rows | The number of rows the new matrix will have, with range [1, infinity) |
columns | The number of columns the new matrix will have, with range [1, infinity) |
subMatrix | The sub-matrix from which the elements will be copied into the new matrix |
row | The row at which the sub-matrix will be placed in the new matrix, with range [0, rows - 1] |
column | The column at which the sub-matrix will be placed in the new matrix, with range [0, columns - 1] |
value | The value which will be used to fill the remaining matrix elements, with range (-infinity, infinity) |
Ocean::MatrixT< T >::MatrixT | ( | const MatrixT< T > & | matrix | ) |
Copies a matrix.
matrix | The matrix to copy |
|
noexcept |
Move constructor.
matrix | The matrix to be moved |
Ocean::MatrixT< T >::~MatrixT | ( | ) |
Destructs a matrix and releases the elements.
|
protected |
bool Ocean::MatrixT< T >::choleskyDecomposition | ( | MatrixT< T > & | lMatrix | ) | const |
Computes the Cholesky decomposition for this square matrix [m x m].
This matrix is decomposed into M = L * L^T, where L is a lower triangular matrix [m x m].
lMatrix | Resulting L matrix, the lower triangle matrix |
|
inline |
Returns the count of columns.
|
inline |
Returns a pointer to the internal values.
|
inline |
Returns a pointer to the internal values.
MatrixT<T> Ocean::MatrixT< T >::diagonal | ( | ) | const |
Returns a vector containing the values of the diagonal.
bool Ocean::MatrixT< T >::eigenSystem | ( | MatrixT< T > & | values, |
MatrixT< T > & | vectors | ||
) | const |
Computes the eigen system of this matrix.
The function determines values and vectors that: matrix * vectors = vectors * diagonal(values).
Beware: The eigen values are not ordered!
values | Vector with resulting eigen values |
vectors | Matrix with resulting eigen vectors as columns |
|
inline |
Returns the number of entire elements, which is the product of rows and columns.
|
protected |
Performs an element-wise matrix division meaning that each element of this matrix will be divided by a corresponding element from 'denominator'.
denominator | The matrix providing the denominator elements, with same size as this matrix |
|
protected |
Performs an element-wise matrix multiplication meaning that each element of this matrix will be multiplied by a corresponding element from 'multiplier'.
multiplier | The matrix providing the multiplication elements, with same size as this matrix, all elements must not be zero |
bool Ocean::MatrixT< T >::invert | ( | ) |
|
inline |
Returns the inverted of this matrix.
Beware: This function does not throw an exception if the matrix cannot be inverted.
Thus, ensure that the matrix is invertible before calling this function.
This matrix is invertible e.g., if the matrix is square and has full rank (rank() == rows() && rank() == columns()).
Even better: avoid the usage of this function and call invert() instead.
In case, this matrix is not invertible, this matrix will be returned instead.
bool Ocean::MatrixT< T >::isEqual | ( | const MatrixT< T > & | matrix, |
const T | eps = NumericT< T >::eps() |
||
) | const |
Returns whether two matrices are almost identical up to a specified epsilon.
matrix | Second matrix that will be checked |
eps | The epsilon threshold to be used, with range [0, infinity) |
bool Ocean::MatrixT< T >::isSymmetric | ( | const T | eps = NumericT< T >::eps() | ) | const |
Returns whether this matrix is symmetric (and whether this matrix is a square matrix).
Beware: An empty matrix (without any rows or columns) is symmetric.
eps | The epsilon threshold to be used, with range [0, infinity) |
void Ocean::MatrixT< T >::multiplyColumn | ( | const size_t | column, |
const T | scalar | ||
) |
Multiplies a column with a scalar.
Beware: No range check will be done!
column | The column to multiply, with range [0, columns() - 1] |
scalar | The scalar to multiply, with range (-infinity, infinity) |
void Ocean::MatrixT< T >::multiplyRow | ( | const size_t | row, |
const T | scalar | ||
) |
Multiplies a row with a scalar.
Beware: No range check will be done!
row | The row to multiply, with range [0, rows() - 1] |
scalar | The scalar to multiply, with range (-infinity, infinity) |
bool Ocean::MatrixT< T >::nonNegativeMatrixFactorization | ( | MatrixT< T > & | subcomponents, |
MatrixT< T > & | weights, | ||
const size_t | components = 0u , |
||
const unsigned int | iterations = 100u , |
||
const T | convergenceThreshold = T(0.0001) |
||
) | const |
Performs a non-negative matrix factorization with multiplicative update rules V = W * H, V is a matrix containing non-negative values
This matrix is V, and will be factorized into two matrices W (weights) and H (subcomponents).
subcomponents | Solution matrix containing base component vectors |
weights | Solution matrix containing weights to the component vectors |
components | Number of base component vectors (Number of components is usually much smaller than its rank). If set to 0, the rank of matrix is used [0, rank] |
iterations | Number of iterations maximal performed [1, infinity) |
convergenceThreshold | Differential threshold aborting the calculation (0, infinity) |
|
inline |
Determines the L1 norm (sum of absolute elements) of this matrix.
|
inlineexplicit |
Returns whether the matrix holds at least one element.
|
inline |
Returns whether two matrices are not identical up to a small epsilon.
right | The right matrix |
|
inline |
Element operator for the row aligned elements.
index | The index of the element to return, with range [0, elements()) |
|
inline |
Element operator for the row aligned elements.
index | The index of the element to return, with range [0, elements()) |
|
inline |
|
inline |
MatrixT<T> Ocean::MatrixT< T >::operator* | ( | const MatrixT< T > & | right | ) | const |
Multiplies two matrices.
right | The right matrix |
MatrixT<T> Ocean::MatrixT< T >::operator* | ( | const T | scalar | ) | const |
Multiplies the matrix with a scalar.
scalar | The scalar to multiply |
|
inline |
Multiplies and assigns two matrices.
right | The right matrix |
MatrixT<T>& Ocean::MatrixT< T >::operator*= | ( | const T | scalar | ) |
Multiplies this matrix by a scalar.
scalar | The scalar to multiply |
MatrixT<T> Ocean::MatrixT< T >::operator+ | ( | const MatrixT< T > & | right | ) | const |
Adds two matrices.
right | The right matrix |
MatrixT<T>& Ocean::MatrixT< T >::operator+= | ( | const MatrixT< T > & | right | ) |
Adds and assigns two matrices.
right | The right matrix |
MatrixT<T> Ocean::MatrixT< T >::operator- | ( | const MatrixT< T > & | right | ) | const |
Subtracts two matrices.
right | The right matrix |
MatrixT<T>& Ocean::MatrixT< T >::operator-= | ( | const MatrixT< T > & | right | ) |
Subtracts and assigns two matrices.
right | The right matrix |
MatrixT<T>& Ocean::MatrixT< T >::operator= | ( | const MatrixT< T > & | matrix | ) |
Assigns a matrix to this one.
matrix | The matrix to assign |
|
noexcept |
Move assign operator.
matrix | The matrix to moved |
|
inline |
Returns whether two matrices are identical up to a small epsilon.
right | The right matrix |
|
inline |
Element operator for the row aligned elements.
row | Index of the element to return, with range [0, rows()) |
|
inline |
Returns the pointer to the elements of a specified row.
row | Index of the row to return, with range [0, rows()) |
MatrixT<T> Ocean::MatrixT< T >::pseudoInverted | ( | const T | epsilon = NumericT< T >::eps() | ) | const |
Returns the pseudo inverse of this matrix by application of the singular value decomposition.
epsilon | The tolerance value, with range [0, infinity) |
bool Ocean::MatrixT< T >::qrDecomposition | ( | MatrixT< T > & | qMatrix, |
MatrixT< T > * | rMatrix = nullptr |
||
) | const |
Computes the QR decomposition for this matrix [m x n] while m >= n must hold.
This matrix is decomposed into two matrices as follows: q * r, where q is a orthogonal [m x m] matrix (m * m^T = I), and r is a upper triangular matrix [m x n].
qMatrix | Resulting q matrix, containing the null space in the last (m - rank) columns, the size of the matrix will be adjusted internally |
rMatrix | Optional resulting r matrix, upper triangle matrix, the size of the matrix will be adjusted internally, nullptr if the matrix is not needed |
|
inline |
|
static |
Computes the rank of given matrix data.
data | The elements of the matrix for which the rank will be calculated, provided in a row aligned order, must be valid |
rows | The number of rows of the provided matrix, with range [1, infinity) |
columns | The number of columns of the provided matrix, with range [1, infinity) |
void Ocean::MatrixT< T >::resize | ( | const size_t | rows, |
const size_t | columns | ||
) |
Resizes this matrix.
rows | Number of rows of the resized matrix |
columns | Number of columns of the resized matrix |
MatrixT<T> Ocean::MatrixT< T >::row | ( | const size_t | index | ) | const |
Returns a row of the matrix.
index | The index of the row to receive, with range [0, rows()) |
|
inline |
Returns the count of rows.
bool Ocean::MatrixT< T >::selfSquareDiagonalMatrixMultiply | ( | const MatrixT< T > & | right, |
MatrixT< T > & | result | ||
) | const |
Interprets this matrix as diagonal matrix and multiplies a second matrix on the right of the interpreted diagonal matrix.
The square sub matrices size is defined by the number of columns of this matrix.
Thus the number of rows must be a multiple of the number of columns of this matrix.
Actually, the following matrix will be returned: result = diag(*this) * right.
right | The right matrix to be multiplied with the interpreted diagonal matrix |
result | Resulting matrix |
bool Ocean::MatrixT< T >::selfSquareDiagonalMatrixMultiply | ( | const MatrixT< T > & | weightDiagonal, |
const MatrixT< T > & | right, | ||
MatrixT< T > & | result | ||
) | const |
Interprets this matrix as diagonal matrix and multiplies a second matrix on the right of the interpreted diagonal matrix.
Further, a diagonal weighting vector is applied.
The square sub matrices size is defined by the number of columns of this matrix.
Thus the number of rows must be a multiple of the number of columns of this matrix.
Actually, the following matrix will be returned: result = diag(*this) * diag(weightDiagonal) * right.
right | The right matrix to be multiplied with the interpreted diagonal matrix |
weightDiagonal | Weight vector defining the diagonal of the weighting matrix, with one column |
result | Resulting matrix |
MatrixT<T> Ocean::MatrixT< T >::selfSquareMatrix | ( | ) | const |
Returns the matrix product of this matrix and the transposed matrix of this matrix.
The result will be a square matrix with size: rows() x rows().
Actually, the following matrix will be returned: (*this) * (*this).transposed().
MatrixT<T> Ocean::MatrixT< T >::selfTransposedSquareMatrix | ( | ) | const |
Returns the matrix product of transposed matrix of this matrix and this matrix.
The result will be a square matrix with size: columns() x columns().
Actually, the following matrix will be returned: (*this).transposed() * (*this).
void Ocean::MatrixT< T >::selfTransposedSquareMatrix | ( | MatrixT< T > & | result | ) | const |
Returns the matrix product of transposed matrix of this matrix and this matrix.
The result will be a square matrix with size: columns() x columns().
Actually, the following matrix will be returned: (*this).transposed() * (*this).
result | Resulting matrix |
bool Ocean::MatrixT< T >::singularValueDecomposition | ( | MatrixT< T > & | u, |
MatrixT< T > & | w, | ||
MatrixT< T > & | v | ||
) | const |
Computes the singular value decomposition for this matrix.
This matrix is decomposed into three matrices as follows: u * w * v.transposed().
The diagonal values of w are ordered in descending order already.
u | Resulting u matrix |
w | Resulting w vector holding the values of the diagonal matrix |
v | Resulting v matrix |
|
inline |
Solves the given linear system.
M * x = b, with M and b known and M is a square matrix
This matrix is M, the given vector is b and the result will be x.
Note: If a non-square matrix should be solved, use: (M.transposed() * M) * x = M.transposed() * b
b | Vector defining the linear system, with size columns() x 1 |
x | Solution vector receiving the solution if existing, with size columns() x 1 |
tMatrixProperty | The property of the matrix allowing to improve the solving performance and stability, MP_UNKNOWN to apply a standard solving |
|
inline |
Solves the given linear system.
M * x = b, with M and b known and M is a square matrix
This matrix is M, the given vector is b and the result will be x.
Note: If a non-square matrix should be solved, use: (M.transposed() * M) * x = M.transposed() * b
b | Vector defining the linear system, with size columns() x 1 |
x | Solution vector receiving the solution if existing, with size columns() x 1 |
matrixProperty | The property of the matrix allowing to improve the solving performance and stability, MP_UNKNOWN to apply a standard solving |
bool Ocean::MatrixT< T >::solve | ( | const T * | b, |
T * | x | ||
) | const |
Solves the given linear system.
M * x = b, with M and b known and M is a square matrix
This matrix is M, the given vector is b and the result will be x..
Note: If a non-square matrix should be solved, use: (M.transposed() * M) * x = M.transposed() * b
b | Pointer to the vector defining the linear system, ensure that the number of provided values is equal to columns() |
x | Pointer to the solution vector receiving the solution if existing, ensure that the number of elements is equal to columns() |
tMatrixProperty | The property of the matrix allowing to improve the solving performance and stability, MP_UNKNOWN to apply a standard solving |
|
inline |
Solves the given linear system.
M * x = b, with M and b known and M is a square matrix
This matrix is M, the given vector is b and the result will be x..
Note: If a non-square matrix should be solved, use: (M.transposed() * M) * x = M.transposed() * b
b | Pointer to the vector defining the linear system, ensure that the number of provided values is equal to columns() |
x | Pointer to the solution vector receiving the solution if existing, ensure that the number of elements is equal to columns() |
matrixProperty | The property of the matrix allowing to improve the solving performance and stability, MP_UNKNOWN to apply a standard solving |
MatrixT<T> Ocean::MatrixT< T >::subMatrix | ( | const size_t | row, |
const size_t | column, | ||
const size_t | rows, | ||
const size_t | columns | ||
) |
Returns a sub matrix of this one.
row | The start row at which the sub matrix will start, with range [0, row() - 1] |
column | The start column at which the sub matrix will start, with range [0, columns() - 1] |
rows | The number of rows in the sub matrix, with range [1, rows() - row] |
columns | The number of columns in the sub matrix, with range [1, columns() - row] |
|
inline |
Determines the sum of all elements of this matrix.
|
protected |
|
protected |
|
inline |
Transposes this matrix.
MatrixT<T> Ocean::MatrixT< T >::transposed | ( | ) | const |
Returns the transposed of this matrix.
MatrixT<T> Ocean::MatrixT< T >::transposedMultiply | ( | const MatrixT< T > & | right | ) | const |
Multiplies this transposed matrix with a second matrix.
Actually, the following matrix will be returned: (*this).transposed() * right.
The resulting matrix will have the size: columns() x right.columns().
right | Matrix to multiply |
void Ocean::MatrixT< T >::transposedMultiply | ( | const MatrixT< T > & | right, |
MatrixT< T > & | result | ||
) | const |
Multiplies this transposed matrix with a second matrix.
Actually, the following matrix will be returned: (*this).transposed() * right.
The resulting matrix will have the size: columns() x right.columns().
right | Matrix to multiply |
result | Resulting matrix product |
MatrixT<T> Ocean::MatrixT< T >::vector | ( | const size_t | column | ) | const |
Returns a column vector of the matrix.
column | The column to receive the vector from, with range [0, columns()) |
void Ocean::MatrixT< T >::weightedSelfTransposedSquareMatrix | ( | const MatrixT< T > & | weightDiagonal, |
MatrixT< T > & | result | ||
) | const |
Returns the matrix product of transposed matrix of this matrix and this matrix and applies a further squared diagonal weighting matrix.
The result will be a square matrix with size: columns() x columns().
Actually, the following matrix will be returned: (*this).transposed() * diag(weightDiagonal) * (*this).
weightDiagonal | Weight vector defining the diagonal of the weighting matrix, with one column |
result | Resulting matrix |
|
protected |
Number of columns.
|
protected |
Number of rows.
|
protected |
Elements of the matrix.