|
modm API documentation
|
Class for handling common matrix operations. More...
#include <modm/math/matrix.hpp>
Public Member Functions | |
| Matrix () = default | |
| Default Constructor. More... | |
| Matrix (const T *data) | |
| Create a matrix from an array. More... | |
| template<uint8_t MR, uint8_t MC> | |
| Matrix< T, MR, MC > | subMatrix (uint8_t row, uint8_t column) const |
| Create a new sub matrix. | |
| bool | operator== (const Matrix &m) const |
| bool | operator!= (const Matrix &m) const |
| const T * | operator[] (uint8_t row) const |
| T * | operator[] (uint8_t row) |
| uint8_t | getNumberOfRows () const |
| uint8_t | getNumberOfColumns () const |
| Matrix< T, 1, COLUMNS > | getRow (uint8_t index) const |
| Matrix< T, ROWS, 1 > | getColumn (uint8_t index) const |
| const T * | ptr () const |
| T * | ptr () |
| Matrix | operator- () |
| Matrix | operator+ (const Matrix &rhs) const |
| Matrix | operator- (const Matrix &rhs) const |
| Matrix | operator* (const T &rhs) const |
| Scalar multiplication. | |
| Matrix | operator/ (const T &rhs) const |
| Scalar division. | |
| Matrix & | operator+= (const Matrix &rhs) |
| Matrix & | operator-= (const Matrix &rhs) |
| Matrix & | operator*= (const T &rhs) |
| Scalar multiplication. | |
| Matrix & | operator/= (const T &rhs) |
| Scalar division. | |
| Matrix | operator*= (const Matrix &rhs) |
| Matrix multiplication with matrices with the same size. | |
| template<uint8_t RHSCOL> | |
| Matrix< T, ROWS, RHSCOL > | operator* (const Matrix< T, COLUMNS, RHSCOL > &rhs) const |
| Matrix multiplication with different size matrices. | |
| Matrix< T, COLUMNS, ROWS > | asTransposed () const |
| void | transpose () |
| Transpose the matrix. More... | |
| T | determinant () const |
| Calculate the determinant. More... | |
| bool | hasNan () const |
| bool | hasInf () const |
| template<typename U > | |
| Matrix & | replace (const U *data) |
Fill the matrix with the values in data. | |
| template<uint8_t MW, uint8_t MH> | |
| Matrix & | replace (uint8_t row, uint8_t column, const Matrix< T, MW, MH > &m) |
| Matrix & | replaceRow (uint8_t index, const Matrix< T, 1, COLUMNS > &m) |
| Matrix & | replaceColumn (uint8_t index, const Matrix< T, ROWS, 1 > &m) |
| Matrix< T, ROWS, COLUMNS+1 > | addColumn (uint8_t index, const Matrix< T, ROWS, 1 > &c) const |
| Matrix< T, ROWS+1, COLUMNS > | addRow (uint8_t index, const Matrix< T, 1, COLUMNS > &r) const |
| Matrix< T, ROWS, COLUMNS-1 > | removeColumn (uint8_t index) const |
| Matrix< T, ROWS-1, COLUMNS > | removeRow (uint8_t index) const |
Static Public Member Functions | |
| static const Matrix & | identityMatrix () |
| Get a identity matrix. More... | |
Public Attributes | |
| T | element [ROWS *COLUMNS] |
Class for handling common matrix operations.
Having the width and height as template parameters has several advantages over the tradition dynamic matrix class:
Adapted from the implementation of Gaspard Petit (gaspardpetit@gmail.com).
| ROWS | Number of rows |
| COLUMNS | Number of columns |
|
explicitconstexprdefault |
Default Constructor.
Create a matrix from an initializer list.
Creates a Matrix with uninitialized elements. Use zeroMatrix() to create a matrix with all elements set to zero.
Example:
Get a zero matrix
Creates an internal zero matrix and returns a reference to that internal matrix.
| modm::Matrix< T, ROWS, COLUMNS >::Matrix | ( | const T * | data | ) |
Create a matrix from an array.
Example:
|
inline |
Calculate the determinant.
Uses modm::determinant(*this);
|
static |
Get a identity matrix.
Creates an internal identity matrix and returns a reference to that internal matrix.
|
inline |
Transpose the matrix.