![]() |
WarpTwin
Documentation for WarpTwin models and classes.
|
Matrix math implementation. More...
#include <Matrix.hpp>
Public Member Functions | |
| Matrix () | |
| Default constructor to initialize a matrix to all zeroes for ease of use. | |
| Matrix (floating_point elements) | |
| Constructor to initialize a matrix with all the same element. | |
| Matrix (const floating_point(&initial)[R][C]) | |
| Matrix (const Matrix< R, C > &initial) | |
| Matrix (const std::array< std::array< floating_point, C >, R > &initial) | |
| Array constructor for the matrix class. Initializes from std::array. | |
| ~Matrix () | |
| int16 | str (char *output, size_t size) const |
| Function to dump information on matrix. | |
| int16 | fromStr (const char *val) |
| Set value of matrix from string in same format as str(). | |
| int16 | set (uint32 row, uint32 col, const floating_point &value) |
| Function to set a single value in the matrix. | |
| int16 | get (uint32 row, uint32 col, floating_point &result) const |
| Function to get a single value in the matrix. | |
| void | setFromArray (const floating_point *start_ptr, bool column_major=false) |
| Function to set the values of the matrix row-wise. | |
| void | getAsArray (floating_point *start_ptr, bool column_major=false) const |
| Function to get the values of the matrix row-wise. | |
| floating_point | get (uint32 row, uint32 col) const |
| Function to get a single value in the matrix. | |
| void | getCopy (Matrix< R, C > &result) const |
| Function to get a copy of the matrix. | |
| Matrix< R, C > & | operator= (const Matrix< R, C > &other) |
| Equals operator overload for matrix. | |
| floating_point * | operator[] (uint32 idx) |
| Function to return a matrix row or vector value. | |
| std::pair< uint32, uint32 > | size () const |
| Function to get the size of the matrix. | |
| void | max (floating_point &result, std::pair< uint32, uint32 > &index) const |
| Function to return the maximum value in the matrix. | |
| void | min (floating_point &result, std::pair< uint32, uint32 > &index) const |
| Function to return the minimum value in the matrix. | |
| int16 | det (floating_point &result) const |
| Function to return the determinant of the matrix. | |
| int16 | chol (Matrix< R, C > &retval) const |
| Take the cholesky decomposition of this matrix. | |
| Matrix< R, C > | chol () const |
| int16 | inverse (Matrix< R, C > &result) const |
| Function to return the inverse of the matrix. | |
| Matrix< R, C > | inverse () const |
| int16 | pseudoinverse (Matrix< C, R > &result) const |
| Matrix< C, R > | pseudoinverse () const |
| void | transpose (Matrix< C, R > &result) const |
| Function to return the transpose of the matrix. | |
| Matrix< C, R > | transpose () const |
| int16 | trace (floating_point &result) const |
| Function to return the trace of the matrix. | |
| void | setToZeros () |
| Function to set all elements of the matrix to zero. | |
| int16 | identity () |
| Function to set matrix to identity, if it is a square matrix. | |
| int16 | eye () |
Public Attributes | |
| std::array< std::array< floating_point, C >, R > | values |
Protected Member Functions | |
| int16 | _checkLookupBoundaries (uint32 start_r, uint32 end_r, uint32 start_c, uint32 end_c) const |
| int16 | _LUPDecompose (floating_point *A[R], uint32 P[R+1]) const |
| Function to take a 2-d matrix represented by A and decompose it into LU form. | |
Matrix math implementation.
This file defines a base class for computational matrix math. It is designed for use in real-time, embedded mode or with simulation. As such, it contains certain limitations on dynamic allocation to make it real-time compliant.
Note: The naming convention observed for matrix math is as follows:
Important: The matrix class is templated such that it can be used with a generic type floating_point, but should only be used on native types, as other implementations could result in undefined behavior.
| clockwerk::Matrix< R, C >::Matrix | ( | ) |
Default constructor to initialize a matrix to all zeroes for ease of use.
| clockwerk::Matrix< R, C >::Matrix | ( | floating_point | elements | ) |
Constructor to initialize a matrix with all the same element.
| clockwerk::Matrix< R, C >::Matrix | ( | const floating_point(&) | initial[R][C] | ) |
Constructor for Matrix class with initialization. Initializes matrix to values passed in via array
| clockwerk::Matrix< R, C >::Matrix | ( | const Matrix< R, C > & | initial | ) |
Copy constructor for Matrix class. Copies data from matrix object to the current instance
| clockwerk::Matrix< R, C >::Matrix | ( | const std::array< std::array< floating_point, C >, R > & | initial | ) |
Array constructor for the matrix class. Initializes from std::array.
|
inline |
Destructor – doesn't do anything because we don't dynamically allocate
|
protected |
Function to check, given a set of submatrix boundaries, that those boundaries are valid for the current matrix
|
protected |
Function to take a 2-d matrix represented by A and decompose it into LU form.
| A | A 2-d matrix represented as a double pointer After ops A contains a copy of both matrices L-E and U as A=(L-E)+U such that P*A=L*U. |
| P | The permutation matrix to hold info on matrix changes |
|
inline |
| int16 clockwerk::Matrix< R, C >::chol | ( | Matrix< R, C > & | retval | ) | const |
Take the cholesky decomposition of this matrix.
| retval | Implicit return of calculation result |
| int16 clockwerk::Matrix< R, C >::det | ( | floating_point & | result | ) | const |
|
inline |
| int16 clockwerk::Matrix< R, C >::fromStr | ( | const char * | val | ) |
Set value of matrix from string in same format as str().
| val | The value to set matrix from of the form [[1,2][3,4][5,6]] |
| floating_point clockwerk::Matrix< R, C >::get | ( | uint32 | row, |
| uint32 | col ) const |
Function to get a single value in the matrix.
| row | The row index |
| col | The column index |
| int16 clockwerk::Matrix< R, C >::get | ( | uint32 | row, |
| uint32 | col, | ||
| floating_point & | result ) const |
Function to get a single value in the matrix.
| row | The row index |
| col | The column index |
| value | PBR return of the value in the matrix |
| void clockwerk::Matrix< R, C >::getAsArray | ( | floating_point * | start_ptr, |
| bool | column_major = false ) const |
Function to get the values of the matrix row-wise.
| start_ptr | The data address at which write should begin. |
| column_major | Flag indicating whether matrix should output column major. Default is false |
| void clockwerk::Matrix< R, C >::getCopy | ( | Matrix< R, C > & | result | ) | const |
Function to get a copy of the matrix.
| result | PBR return of a copy of this matrix |
| int16 clockwerk::Matrix< R, C >::identity | ( | ) |
Function to set matrix to identity, if it is a square matrix.
|
inline |
| int16 clockwerk::Matrix< R, C >::inverse | ( | Matrix< R, C > & | result | ) | const |
Function to return the inverse of the matrix.
| result | PBR return of matrix inverse |
| void clockwerk::Matrix< R, C >::max | ( | floating_point & | result, |
| std::pair< uint32, uint32 > & | index ) const |
Function to return the maximum value in the matrix.
| result | PBR return of maximum value |
| void clockwerk::Matrix< R, C >::min | ( | floating_point & | result, |
| std::pair< uint32, uint32 > & | index ) const |
Function to return the minimum value in the matrix.
| result | PBR return of minimum value |
| Matrix< R, C > & clockwerk::Matrix< R, C >::operator= | ( | const Matrix< R, C > & | other | ) |
Equals operator overload for matrix.
| floating_point * clockwerk::Matrix< R, C >::operator[] | ( | uint32 | idx | ) |
Function to return a matrix row or vector value.
| idx | The row index to return |
|
inline |
| int16 clockwerk::Matrix< R, C >::pseudoinverse | ( | Matrix< C, R > & | result | ) | const |
| int16 clockwerk::Matrix< R, C >::set | ( | uint32 | row, |
| uint32 | col, | ||
| const floating_point & | value ) |
| void clockwerk::Matrix< R, C >::setFromArray | ( | const floating_point * | start_ptr, |
| bool | column_major = false ) |
Function to set the values of the matrix row-wise.
| start_ptr | The data address at which read should begin. |
| column_major | Flag indicating whether matrix should input column major. Default is false |
| void clockwerk::Matrix< R, C >::setToZeros | ( | ) |
Function to set all elements of the matrix to zero.
|
inline |
| int16 clockwerk::Matrix< R, C >::str | ( | char * | output, |
| size_t | size ) const |
Function to dump information on matrix.
Function to dump information on matrix to string
| int16 clockwerk::Matrix< R, C >::trace | ( | floating_point & | result | ) | const |
Function to return the trace of the matrix.
| result | PBR return of matrix trace |
| Matrix< C, R > clockwerk::Matrix< R, C >::transpose | ( | ) | const |
| void clockwerk::Matrix< R, C >::transpose | ( | Matrix< C, R > & | result | ) | const |
Function to return the transpose of the matrix.
| result | PBR return of matrix transpose |
| std::array<std::array<floating_point, C>, R> clockwerk::Matrix< R, C >::values |
The actual values held by the matrix – a two dimensional array of values indexed as (row, column). NOTE: Public for ease of access and speed (no need to use setter/getter), and functions in Matrix and Safemath libraries are tested safe. Behavior using matrices outside of clockwerk libraries should use setter/getter, rather than direct access, for safety.