Ocean
|
This class implements a matrix with static dimensions. More...
Public Types | |
typedef T | Type |
Definition of the matrix element type. More... | |
Public Member Functions | |
StaticMatrix () | |
Creates a new matrix object without initializing the matrix elements. More... | |
StaticMatrix (const T &value) | |
Creates a new matrix object and sets all elements to one unique value. More... | |
StaticMatrix (const bool toIdentity) | |
Creates a new matrix and initializes the elements of the matrix so that we receive an identity matrix or a zero matrix. More... | |
StaticMatrix (const T *values) | |
Creates a new matrix element and initialized the matrix elements by a given data buffer with row aligned elements. More... | |
StaticMatrix (const T *values, const bool valuesRowAligned) | |
Creates a new matrix element and initialized the matrix elements by a given data buffer. More... | |
const T * | row (const size_t index) const |
Returns a pointer to a specified row. More... | |
T * | row (const size_t index) |
Returns a pointer to a specified row. More... | |
template<size_t tIndex> | |
const T * | row () const |
Returns a pointer to a specified row. More... | |
template<size_t tIndex> | |
T * | row () |
Returns a pointer to a specified row. More... | |
template<size_t tRow, size_t tColumn> | |
const T & | element () const |
Returns a pointer to a specified element. More... | |
template<size_t tRow, size_t tColumn> | |
T & | element () |
Returns a pointer to a specified element. More... | |
const T * | data () const |
Returns the pointer to the internal element buffer. More... | |
T * | data () |
Returns the pointer to the internal element buffer. More... | |
bool | isNull () const |
Returns whether all elements of this matrix are zero. More... | |
bool | isIdentity () const |
Returns whether this matrix is an identity matrix. More... | |
bool | isEqual (const StaticMatrix< T, tRows, tColumns > &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... | |
void | toNull () |
Sets the matrix to a zero matrix. More... | |
void | setData (const T *values, const bool valuesRowAligned) |
Sets the elements of this matrix by copying the values from a given buffer. More... | |
bool | solveCholesky (const StaticMatrix< T, tRows, 1 > &vectorB, StaticMatrix< T, tRows, 1 > &vectorX) const |
Solves the given linear system by application of the cholesky distribution. More... | |
void | add (StaticMatrix< T, tRows, tColumns > &target) const |
Adds this matrix to a given matrix. More... | |
void | addTransposed (StaticMatrix< T, tColumns, tRows > &target) const |
Adds this matrix transposed to a given matrix. More... | |
template<size_t tColumns2> | |
void | multiply (const StaticMatrix< T, tColumns, tColumns2 > &matrix, StaticMatrix< T, tRows, tColumns2 > &result) const |
Multiplies this matrix with a second matrix and assigns the results to a matrix. More... | |
template<size_t tColumns2> | |
void | multiply (const StaticMatrix< T, tColumns, tColumns2 > &matrix, T *result) const |
Multiplies this matrix with a second matrix and assigns the results to a given buffer. More... | |
template<size_t tColumns2> | |
void | multiply (const StaticMatrix< T, tColumns, tColumns2 > &matrix, const size_t rowOffset, T *result) const |
Multiplies this matrix with a second matrix and assigns the results to a given buffer. More... | |
StaticMatrix< T, tColumns, tColumns > | multiplyWithTransposedLeft () const |
Multiplies this matrix (right) with the transposed matrix (left). More... | |
void | multiplyWithTransposedLeft (StaticMatrix< T, tColumns, tColumns > &result) const |
Multiplies this matrix (right) with the transposed matrix (left) and stores the result in a provided matrix. More... | |
StaticMatrix< T, tRows, tRows > | multiplyWithTransposedRight () const |
Multiplies this matrix (left) with the transposed matrix (right). More... | |
void | multiplyWithTransposedRight (StaticMatrix< T, tRows, tRows > &result) const |
Multiplies this matrix (left) with the transposed matrix (right) and stores the result in a provided matrix. More... | |
void | multiplyWithTransposedLeftAndAdd (StaticMatrix< T, tColumns, tColumns > &target) const |
Multiplies this matrix (right) with the transposed matrix (left) and adds the resulting matrix to a given matrix. More... | |
void | multiplyWithTransposedRightAndAdd (StaticMatrix< T, tRows, tRows > &target) const |
Multiplies this matrix (left) with the transposed matrix (right) and adds the resulting matrix to a given matrix. More... | |
StaticMatrix< T, tColumns, tRows > | transposed () const |
Returns the transposed matrix of this matrix. More... | |
void | transposed (StaticMatrix< T, tColumns, tRows > &result) const |
Transposes this matrix. More... | |
StaticMatrix< T, tRows, tColumns > | operator+ (const StaticMatrix< T, tRows, tColumns > &matrix) const |
Adds a given matrix to this matrix. More... | |
StaticMatrix< T, tRows, tColumns > & | operator+= (const StaticMatrix< T, tRows, tColumns > &matrix) |
Adds a given matrix to this matrix. More... | |
StaticMatrix< T, tRows, tColumns > | operator- (const StaticMatrix< T, tRows, tColumns > &matrix) const |
Subtracts a given matrix from this matrix. More... | |
StaticMatrix< T, tRows, tColumns > & | operator-= (const StaticMatrix< T, tRows, tColumns > &matrix) |
Subtracts a given matrix from this matrix. More... | |
template<size_t tColumns2> | |
StaticMatrix< T, tRows, tColumns2 > | operator* (const StaticMatrix< T, tColumns, tColumns2 > &matrix) const |
Multiplies this matrix with a second matrix objects and returns the result. More... | |
StaticMatrix< T, tRows, tColumns > | operator* (const T &value) const |
Multiplies this matrix with a scalar value element-wise and returns the new matrix. More... | |
StaticMatrix< T, tRows, tColumns > & | operator*= (const T &value) |
Multiplies this matrix with a scalar value element-wise. More... | |
T | operator() (const size_t row, const size_t column) const |
Returns a specified element of this matrix object. More... | |
T & | operator() (const size_t row, const size_t column) |
Returns a specified element of this matrix object. More... | |
T | operator[] (const size_t index) const |
Returns a specified element of this matrix object. More... | |
T & | operator[] (const size_t index) |
Returns a specified element of this matrix object. More... | |
OCEAN_FORCE_INLINE StaticMatrix< double, 4, 1 > | operator* (const StaticMatrix< double, 4, 1 > &vector) const |
OCEAN_FORCE_INLINE StaticMatrix< double, 4, 1 > | operator* (const StaticMatrix< double, 4, 1 > &vector) const |
OCEAN_FORCE_INLINE StaticMatrix< float, 4, 1 > | operator* (const StaticMatrix< float, 4, 1 > &vector) const |
Static Public Member Functions | |
static size_t | rows () |
Returns the number of rows this matrix holds. More... | |
static size_t | columns () |
Returns the number of columsn this matrix holds. More... | |
static size_t | elements () |
Returns the number of elements this matrix stores. More... | |
Private Attributes | |
T | matrixValues [tRows *tColumns] |
Matrix elements. More... | |
This class implements a matrix with static dimensions.
In contrast to a dynamic matrix the size of this matrix cannot be changed because the dimension is defined as template parameter.
The elements inside the matrix are stored in a row aligned order.
A StaticMatrix<double, 2, 4> would hold 2 rows and 4 columns.
The indices of the internal elements would be: | 0 1 2 3 | | 4 5 6 7 |
T | Data type of the matrix elements |
tRows | Number of rows the matrix holds |
tColumns | Number of columns this matrix holds |
typedef T Ocean::StaticMatrix< T, tRows, tColumns >::Type |
Definition of the matrix element type.
|
inline |
Creates a new matrix object without initializing the matrix elements.
|
inlineexplicit |
Creates a new matrix object and sets all elements to one unique value.
value | The value used to initialize each elements of the new matrix |
|
explicit |
Creates a new matrix and initializes the elements of the matrix so that we receive an identity matrix or a zero matrix.
toIdentity | True, to initialize the matrix as identity matrix; False, to initialize the matrix as zero matrix |
|
explicit |
Creates a new matrix element and initialized the matrix elements by a given data buffer with row aligned elements.
Beware: The given buffer must be large enough.
values | Values to be copied to the matrix element buffer |
Ocean::StaticMatrix< T, tRows, tColumns >::StaticMatrix | ( | const T * | values, |
const bool | valuesRowAligned | ||
) |
Creates a new matrix element and initialized the matrix elements by a given data buffer.
Beware: The given buffer must be large enough.
values | Values to be copied to the matrix element buffer |
valuesRowAligned | True, if the given values are stored in a row aligned order; False, if the values are stored in a column aligned order |
void Ocean::StaticMatrix< T, tRows, tColumns >::add | ( | StaticMatrix< T, tRows, tColumns > & | target | ) | const |
Adds this matrix to a given matrix.
Thus, this function calculates: result += thisMatrix.
target | The matrix to which this matrix will be added |
void Ocean::StaticMatrix< T, tRows, tColumns >::addTransposed | ( | StaticMatrix< T, tColumns, tRows > & | target | ) | const |
Adds this matrix transposed to a given matrix.
Thus, this function calculates: result += thisMatrix.transposed().
target | The matrix to which this (transposed) matrix will be added |
|
inlinestatic |
|
inline |
Returns the pointer to the internal element buffer.
|
inline |
Returns the pointer to the internal element buffer.
|
inline |
|
inline |
|
inlinestatic |
Returns the number of elements this matrix stores.
bool Ocean::StaticMatrix< T, tRows, tColumns >::isEqual | ( | const StaticMatrix< T, tRows, tColumns > & | 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::StaticMatrix< T, tRows, tColumns >::isIdentity |
Returns whether this matrix is an identity matrix.
bool Ocean::StaticMatrix< T, tRows, tColumns >::isNull |
Returns whether all elements of this matrix are zero.
bool Ocean::StaticMatrix< T, tRows, tColumns >::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 colums) is symmetric.
eps | The epsilon threshold to be used, with range [0, infinity) |
|
inline |
Multiplies this matrix with a second matrix and assigns the results to a given buffer.
The given buffer is interpreted as if the given pointer points to the first element of a resulting matrix object.
However, after one row of the target buffer has been computed the given pointer is shifted by a given offset value.
Thus, the multiplication product may be assigned into a matrix even larger than the product matrix itself.
matrix | Second matrix to multiply this matrix with |
rowOffset | Number of element the target pointer will be shifted after one row of the multiplication matrix has been created before the next row will be assigned |
result | Target buffer receiving the matrix result |
|
inline |
Multiplies this matrix with a second matrix and assigns the results to a matrix.
This function calculates: result = this * matrix.
matrix | Second matrix to multiply this matrix with |
result | Resulting multiplication matrix |
|
inline |
Multiplies this matrix with a second matrix and assigns the results to a given buffer.
The given buffer is interpreted as if the given pointer points to the first element of a resulting matrix object.
matrix | Second matrix to multiply this matrix with |
result | Target buffer receiving the matrix result |
|
inline |
Multiplies this matrix (right) with the transposed matrix (left).
Thus, this function returns matrix.transposed() * matrix.
|
inline |
Multiplies this matrix (right) with the transposed matrix (left) and stores the result in a provided matrix.
Thus, this function calculates: result = matrix.transposed() * matrix.
result | The resulting matrix |
|
inline |
Multiplies this matrix (right) with the transposed matrix (left) and adds the resulting matrix to a given matrix.
Thus, this function calculates target += matrix.transposed() * matrix.
target | The matrix to which the result will be added |
|
inline |
Multiplies this matrix (left) with the transposed matrix (right).
Thus, this function returns matrix * matrix.transposed().
|
inline |
Multiplies this matrix (left) with the transposed matrix (right) and stores the result in a provided matrix.
Thus, this function calculates: result = matrix * matrix.transposed().
result | The resulting matrix |
|
inline |
Multiplies this matrix (left) with the transposed matrix (right) and adds the resulting matrix to a given matrix.
Thus, this function calculates target += matrix * matrix.transposed().
target | The matrix to which the result will be added |
|
inline |
|
inline |
OCEAN_FORCE_INLINE StaticMatrix< double, 4, 1 > Ocean::StaticMatrix< double, 4, 4 >::operator* | ( | const StaticMatrix< double, 4, 1 > & | vector | ) | const |
OCEAN_FORCE_INLINE StaticMatrix< double, 4, 1 > Ocean::StaticMatrix< double, 4, 4 >::operator* | ( | const StaticMatrix< double, 4, 1 > & | vector | ) | const |
OCEAN_FORCE_INLINE StaticMatrix< float, 4, 1 > Ocean::StaticMatrix< float, 4, 4 >::operator* | ( | const StaticMatrix< float, 4, 1 > & | vector | ) | const |
|
inline |
Multiplies this matrix with a second matrix objects and returns the result.
matrix | Matrix to be multiplied with this matrix |
|
inline |
Multiplies this matrix with a scalar value element-wise and returns the new matrix.
value | Scalar value to multiply each element with |
|
inline |
Multiplies this matrix with a scalar value element-wise.
value | Scalar value to multiply each element with |
|
inline |
Adds a given matrix to this matrix.
matrix | Matrix to be added to this matrix |
|
inline |
Adds a given matrix to this matrix.
matrix | Matrix to be added to this matrix |
|
inline |
Subtracts a given matrix from this matrix.
matrix | Matrix to be subtracted from this matrix |
|
inline |
Subtracts a given matrix from this matrix.
matrix | Matrix to be subtracted from this matrix |
|
inline |
|
inline |
|
inline |
Returns a pointer to a specified row.
tIndex | The index of the row, with range [0, rows()) |
|
inline |
Returns a pointer to a specified row.
tIndex | The index of the row, with range [0, rows()) |
|
inline |
Returns a pointer to a specified row.
index | The index of the row, with range [0, rows()) |
|
inline |
Returns a pointer to a specified row.
index | The index of the row, with range [0, rows()) |
|
inlinestatic |
|
inline |
Sets the elements of this matrix by copying the values from a given buffer.
values | The elements to set, ensure that enough values are provided |
valuesRowAligned | True, if the given values are stored in a row aligned order; False, if the values are stored in a column aligned order |
bool Ocean::StaticMatrix< T, tRows, tColumns >::solveCholesky | ( | const StaticMatrix< T, tRows, 1 > & | vectorB, |
StaticMatrix< T, tRows, 1 > & | vectorX | ||
) | const |
Solves the given linear system by application of the cholesky distribution.
M * x = b, with M and b known.
This matrix is M and M must be a symmetric positive-definite matrix, the given vector is b and the result will be x.
vectorB | Vector defining the linear system, with size tRows x 1 |
vectorX | Solution vector receiving the solution if existing, ensure that the number of elements is equal to tRows x 1 |
|
inline |
Sets the matrix to a zero matrix.
|
inline |
Returns the transposed matrix of this matrix.
|
inline |
Transposes this matrix.
result | The resulting transposed matrix |
|
private |
Matrix elements.