|
ESP-IDF Firmware
Firmware architecture and call graph
|
Matrix. More...
#include <mat.h>
Data Structures | |
| struct | Rect |
| Rectangular area. More... | |
Public Member Functions | |
| Mat (int rows, int cols) | |
| Mat (float *data, int rows, int cols) | |
| Mat (float *data, int rows, int cols, int stride) | |
| Mat () | |
| virtual | ~Mat () |
| Mat (const Mat &src) | |
| Make copy of matrix. | |
| Mat | getROI (int startRow, int startCol, int roiRows, int roiCols) |
| Create a subset of matrix as ROI (Region of Interest). | |
| Mat | getROI (int startRow, int startCol, int roiRows, int roiCols, int stride) |
| Create a subset of matrix as ROI (Region of Interest). | |
| Mat | getROI (const Mat::Rect &rect) |
| Create a subset of matrix as ROI (Region of Interest). | |
| void | Copy (const Mat &src, int row_pos, int col_pos) |
| void | CopyHead (const Mat &src) |
| copy header of matrix | |
| void | PrintHead (void) |
| print matrix header | |
| Mat | Get (int row_start, int row_size, int col_start, int col_size) |
| Mat | Get (const Mat::Rect &rect) |
| Mat & | operator= (const Mat &src) |
| float & | operator() (int row, int col) |
| const float & | operator() (int row, int col) const |
| Mat & | operator+= (const Mat &A) |
| Mat & | operator+= (float C) |
| Mat & | operator-= (const Mat &A) |
| Mat & | operator-= (float C) |
| Mat & | operator*= (const Mat &A) |
| Mat & | operator*= (float C) |
| Mat & | operator/= (float C) |
| Mat & | operator/= (const Mat &B) |
| Mat | operator^ (int C) |
| void | swapRows (int row1, int row2) |
| Mat | t () |
| Mat | block (int startRow, int startCol, int blockRows, int blockCols) |
| void | normalize (void) |
| float | norm (void) |
| void | clear (void) |
| Mat | gaussianEliminate () |
| Gaussian Elimination. | |
| Mat | rowReduceFromGaussian () |
| Mat | inverse () |
| Mat | pinv () |
| float | det (int n) |
Static Public Member Functions | |
| static Mat | eye (int size) |
| static Mat | ones (int size) |
| static Mat | ones (int rows, int cols) |
| static Mat | solve (Mat A, Mat b) |
| Solve the matrix. | |
| static Mat | bandSolve (Mat A, Mat b, int k) |
| Band solve the matrix. | |
| static Mat | roots (Mat A, Mat y) |
| Solve the matrix. | |
| static float | dotProduct (Mat A, Mat B) |
| Dotproduct of two vectors. | |
| static Mat | augment (Mat A, Mat B) |
| Augmented matrices. | |
Data Fields | |
| int | rows |
| int | cols |
| int | stride |
| int | padding |
| float * | data |
| int | length |
| bool | ext_buff |
| bool | sub_matrix |
Static Public Attributes | |
| static float | abs_tol = 1e-10 |
Private Member Functions | |
| Mat | cofactor (int row, int col, int n) |
| Mat | adjoint () |
| void | allocate () |
| Mat | expHelper (const Mat &m, int num) |
Matrix.
The Mat class provides basic matrix operations on single-precision floating point values.
| dspm::Mat::Mat | ( | int | rows, |
| int | cols ) |
Constructor allocate internal buffer.
Definition at line 69 of file mat.cpp.
References allocate(), cols, data, ESP_LOGD, length, padding, rows, stride, and sub_matrix.
Referenced by adjoint(), augment(), bandSolve(), block(), cofactor(), Copy(), CopyHead(), det(), dotProduct(), expHelper(), eye(), gaussianEliminate(), Get(), Get(), getROI(), getROI(), getROI(), inverse(), Mat(), ones(), ones(), operator*=(), operator*=(), operator+=(), operator+=(), operator-=(), operator-=(), operator/=(), operator/=(), operator=(), operator^(), pinv(), roots(), rowReduceFromGaussian(), solve(), and t().
| dspm::Mat::Mat | ( | float * | data, |
| int | rows, | ||
| int | cols ) |
Constructor use external buffer.
| [in] | data | external buffer with row-major matrix data |
| [in] | rows | amount of matrix rows |
| [in] | cols | amount of matrix columns |
Definition at line 81 of file mat.cpp.
References allocate(), cols, data, ESP_LOGD, ext_buff, length, padding, rows, stride, and sub_matrix.
| dspm::Mat::Mat | ( | float * | data, |
| int | rows, | ||
| int | cols, | ||
| int | stride ) |
Constructor
| [in] | data | external buffer with row-major matrix data |
| [in] | rows | amount of matrix rows |
| [in] | cols | amount of matrix columns |
| [in] | stride | col stride |
Definition at line 57 of file mat.cpp.
References cols, data, ext_buff, length, padding, rows, stride, and sub_matrix.
| dspm::Mat::Mat | ( | ) |
Allocate matrix with undefined size.
Definition at line 98 of file mat.cpp.
References allocate(), cols, data, ESP_LOGD, padding, rows, stride, and sub_matrix.
Referenced by det().
|
virtual |
| dspm::Mat::Mat | ( | const Mat & | src | ) |
Make copy of matrix.
if src matrix is sub matrix, only the header is copied if src matrix is matrix, header and data are copied
| [in] | src | source matrix |
Definition at line 119 of file mat.cpp.
References allocate(), cols, data, ext_buff, length, m, Mat(), padding, rows, stride, and sub_matrix.
|
private |
Definition at line 783 of file mat.cpp.
References cofactor(), cols, det(), Mat(), and rows.
Referenced by inverse().
|
private |
Augmented matrices.
Augmented matrices
Definition at line 585 of file mat.cpp.
References A, B, cols, Mat(), and rows.
Referenced by pinv(), and roots().
Band solve the matrix.
Solve band matrix. Find roots for the matrix A*x = b with bandwidth k.
| [in] | A | matrix [N]x[N] with input coefficients |
| [in] | b | vector [N]x[1] with result values |
| [in] | k | upper bandwidth value |
Definition at line 514 of file mat.cpp.
References A, abs_tol, data, k, Mat(), rows, and x.
| Mat dspm::Mat::block | ( | int | startRow, |
| int | startCol, | ||
| int | blockRows, | ||
| int | blockCols ) |
Return part of matrix from defined position (startRow, startCol) as a matrix[blockRows x blockCols].
| [in] | startRow | start row position |
| [in] | startCol | start column position |
| [in] | blockRows | amount of rows in result matrix |
| [in] | blockCols | amount of columns in the result matrix |
Definition at line 433 of file mat.cpp.
References Mat().
| void dspm::Mat::clear | ( | void | ) |
|
private |
Definition at line 722 of file mat.cpp.
References Mat(), n, and rows.
Referenced by adjoint().
| void dspm::Mat::Copy | ( | const Mat & | src, |
| int | row_pos, | ||
| int | col_pos ) |
Make copy of matrix.
| [in] | src | source matrix |
| [in] | row_pos | start row position of destination matrix |
| [in] | col_pos | start col position of destination matrix |
Definition at line 168 of file mat.cpp.
References cols, data, Mat(), rows, and stride.
Referenced by ekf_imu13states::StateXdot(), ekf_imu13states::UpdateRefMeasurement(), ekf_imu13states::UpdateRefMeasurement(), and ekf_imu13states::UpdateRefMeasurementMagn().
| void dspm::Mat::CopyHead | ( | const Mat & | src | ) |
copy header of matrix
Make a shallow copy of matrix (no data copy)
| [in] | src | source matrix |
Definition at line 182 of file mat.cpp.
References cols, data, ext_buff, length, Mat(), padding, rows, stride, and sub_matrix.
| float dspm::Mat::det | ( | int | n | ) |
Find determinant
| [in] | n | element number in first row |
Definition at line 746 of file mat.cpp.
References det(), k, Mat(), Mat(), n, and swapRows().
Referenced by adjoint(), det(), and inverse().
Dotproduct of two vectors.
The method returns dotproduct of two vectors
Definition at line 576 of file mat.cpp.
Definition at line 842 of file mat.cpp.
References expHelper(), eye(), m, and Mat().
Referenced by expHelper(), and operator^().
|
static |
Create identity matrix. Create a square matrix and fill diagonal with 1.
| [in] | size | matrix size |
Definition at line 394 of file mat.cpp.
References cols, Mat(), and rows.
Referenced by ekf::CovariancePrediction(), dispaly_esp_text(), dispaly_esp_text(), dispaly_esp_text(), dispaly_esp_text(), draw_3d_image(), draw_3d_image(), draw_3d_image(), draw_3d_image(), draw_3d_image_task(), draw_3d_image_task(), draw_3d_image_task(), draw_3d_image_task(), draw_3d_image_task(), draw_3d_image_task(), draw_3d_image_task(), draw_3d_image_task(), expHelper(), ekf_imu13states::Init(), ekf_imu13states::LinearizeFG(), pinv(), ekf_imu13states::TestFull(), ekf::UpdateRef(), ekf_imu13states::UpdateRefMeasurement(), and ekf_imu13states::UpdateRefMeasurementMagn().
| Mat dspm::Mat::gaussianEliminate | ( | ) |
Gaussian Elimination.
Gaussian Elimination of matrix
Definition at line 600 of file mat.cpp.
References abs_tol, cols, k, Mat(), rows, swapRows(), and t().
Referenced by pinv().
Make copy of matrix.
| [in] | rect | rectangular area of interest |
Definition at line 226 of file mat.cpp.
References Get(), dspm::Mat::Rect::height, Mat(), dspm::Mat::Rect::width, dspm::Mat::Rect::x, and dspm::Mat::Rect::y.
| Mat dspm::Mat::Get | ( | int | row_start, |
| int | row_size, | ||
| int | col_start, | ||
| int | col_size ) |
Make copy of matrix.
| [in] | row_start | start row position of source matrix to copy |
| [in] | row_size | size of wor elements of source matrix to copy |
| [in] | col_start | start col position of source matrix to copy |
| [in] | col_size | size of wor elements of source matrix to copy |
Definition at line 209 of file mat.cpp.
References cols, data, Mat(), and rows.
Referenced by Get(), ekf_imu13states::LinearizeFG(), and operator*=().
Create a subset of matrix as ROI (Region of Interest).
| [in] | rect | rectangular area of interest |
Definition at line 158 of file mat.cpp.
References getROI(), dspm::Mat::Rect::height, Mat(), dspm::Mat::Rect::width, dspm::Mat::Rect::x, and dspm::Mat::Rect::y.
| Mat dspm::Mat::getROI | ( | int | startRow, |
| int | startCol, | ||
| int | roiRows, | ||
| int | roiCols ) |
Create a subset of matrix as ROI (Region of Interest).
| [in] | startRow | start row position of source matrix to get the subset matrix from |
| [in] | startCol | start col position of source matrix to get the subset matrix from |
| [in] | roiRows | size of row elements of source matrix to get the subset matrix from |
| [in] | roiCols | size of col elements of source matrix to get the subset matrix from |
Definition at line 163 of file mat.cpp.
References cols, getROI(), and Mat().
Referenced by getROI(), and getROI().
| Mat dspm::Mat::getROI | ( | int | startRow, |
| int | startCol, | ||
| int | roiRows, | ||
| int | roiCols, | ||
| int | stride ) |
Create a subset of matrix as ROI (Region of Interest).
| [in] | startRow | start row position of source matrix to get the subset matrix from |
| [in] | startCol | start col position of source matrix to get the subset matrix from |
| [in] | roiRows | size of row elements of source matrix to get the subset matrix from |
| [in] | roiCols | size of col elements of source matrix to get the subset matrix from |
| [in] | stride | number of cols + padding between 2 rows |
Definition at line 138 of file mat.cpp.
References cols, data, Mat(), padding, rows, and stride.
| Mat dspm::Mat::inverse | ( | ) |
Find the inverse matrix
Definition at line 812 of file mat.cpp.
References adjoint(), cols, det(), Mat(), and rows.
| float dspm::Mat::norm | ( | void | ) |
Return norm of the vector. If it's matrix, calculate matrix norm
Definition at line 456 of file mat.cpp.
Referenced by draw_3d_image_task(), draw_3d_image_task(), kalman_filter_task(), kalman_filter_task(), kalman_filter_task(), kalman_filter_task(), ekf::rotm2quat(), ekf_imu13states::TestFull(), ekf_imu13states::UpdateRefMeasurement(), ekf_imu13states::UpdateRefMeasurement(), and ekf_imu13states::UpdateRefMeasurementMagn().
| void dspm::Mat::normalize | ( | void | ) |
|
static |
Create matrix with all elements 1. Create a matrix and fill all elements with 1.
Definition at line 414 of file mat.cpp.
References cols, Mat(), and rows.
|
static |
Create matrix with all elements 1. Create a square matrix and fill all elements with 1.
| [in] | size | matrix size |
Definition at line 409 of file mat.cpp.
Referenced by ones().
|
inline |
|
inline |
*= operator The operator use DSP optimized implementation of multiplication.
| [in] | A | source matrix |
Definition at line 312 of file mat.cpp.
References cols, data, dspm_mult_ex_f32, dspm_mult_f32, Get(), m, Mat(), padding, rows, and sub_matrix.
| Mat & dspm::Mat::operator*= | ( | float | C | ) |
+= with constant operator The operator use DSP optimized implementation of multiplication.
| [in] | C | constant value |
Definition at line 329 of file mat.cpp.
References cols, data, dspm_mulc_f32, dsps_mulc_f32_ansi(), length, Mat(), padding, rows, and sub_matrix.
+= operator The operator use DSP optimized implementation of multiplication.
| [in] | A | source matrix |
Definition at line 262 of file mat.cpp.
References data, dspm_add_f32, dsps_add_f32, m, Mat(), rows, and sub_matrix.
| Mat & dspm::Mat::operator+= | ( | float | C | ) |
+= operator The operator use DSP optimized implementation of multiplication.
| [in] | C | constant |
Definition at line 277 of file mat.cpp.
References C, cols, data, dspm_addc_f32, dsps_addc_f32_ansi(), length, Mat(), padding, rows, and sub_matrix.
-= operator The operator use DSP optimized implementation of multiplication.
| [in] | A | source matrix |
Definition at line 287 of file mat.cpp.
References data, dspm_sub_f32, dsps_sub_f32, m, Mat(), rows, and sub_matrix.
| Mat & dspm::Mat::operator-= | ( | float | C | ) |
-= operator The operator use DSP optimized implementation of multiplication.
| [in] | C | constant |
Definition at line 302 of file mat.cpp.
References C, cols, data, dspm_addc_f32, dsps_addc_f32_ansi(), length, Mat(), padding, rows, and sub_matrix.
/= operator
| [in] | B | source matrix |
Definition at line 339 of file mat.cpp.
References B, cols, Mat(), and rows.
| Mat & dspm::Mat::operator/= | ( | float | C | ) |
/= with constant operator The operator use DSP optimized implementation of multiplication.
| [in] | C | constant value |
Definition at line 354 of file mat.cpp.
References cols, data, dspm_mulc_f32, dsps_mulc_f32_ansi(), length, Mat(), padding, rows, and sub_matrix.
Copy operator
| [in] | src | source matrix |
Definition at line 231 of file mat.cpp.
References allocate(), cols, data, ext_buff, m, Mat(), padding, rows, stride, and sub_matrix.
| Mat dspm::Mat::operator^ | ( | int | C | ) |
^= xor with constant operator The operator use DSP optimized implementation of multiplication.
| [in] | C | constant value |
Definition at line 364 of file mat.cpp.
References expHelper(), and Mat().
| Mat dspm::Mat::pinv | ( | ) |
Find pseudo inverse matrix
Definition at line 707 of file mat.cpp.
References augment(), cols, eye(), gaussianEliminate(), Mat(), rowReduceFromGaussian(), and rows.
Referenced by ekf::UpdateRef().
| void dspm::Mat::PrintHead | ( | void | ) |
Solve the matrix.
Different way to solve the matrix. Find roots for the matrix A*x = y
Definition at line 552 of file mat.cpp.
References A, augment(), k, Mat(), n, and y.
| Mat dspm::Mat::rowReduceFromGaussian | ( | ) |
Row reduction for Gaussian elimination
Definition at line 656 of file mat.cpp.
References abs_tol, cols, k, Mat(), rows, and t().
Referenced by pinv().
Solve the matrix.
Solve matrix. Find roots for the matrix A*x = b
| [in] | A | matrix [N]x[N] with input coefficients |
| [in] | b | vector [N]x[1] with result values |
Definition at line 468 of file mat.cpp.
References A, abs_tol, k, Mat(), rows, and x.
| void dspm::Mat::swapRows | ( | int | row1, |
| int | row2 ) |
Swap two rows between each other.
| [in] | row1 | position of first row |
| [in] | row2 | position of second row |
Definition at line 370 of file mat.cpp.
References cols, data, rows, and stride.
Referenced by det(), and gaussianEliminate().
| Mat dspm::Mat::t | ( | ) |
Matrix transpose. Change rows and columns between each other.
Definition at line 383 of file mat.cpp.
References cols, data, Mat(), rows, and stride.
Referenced by ekf::CovariancePrediction(), draw_3d_image_task(), draw_3d_image_task(), gaussianEliminate(), rowReduceFromGaussian(), ekf_imu13states::TestFull(), update_rotation_matrix(), ekf::UpdateRef(), ekf_imu13states::UpdateRefMeasurement(), ekf_imu13states::UpdateRefMeasurement(), and ekf_imu13states::UpdateRefMeasurementMagn().
|
static |
Max acceptable absolute tolerance
Definition at line 39 of file mat.h.
Referenced by bandSolve(), gaussianEliminate(), rowReduceFromGaussian(), and solve().
| int dspm::Mat::cols |
Amount of columns
Definition at line 34 of file mat.h.
Referenced by adjoint(), allocate(), augment(), clear(), Copy(), CopyHead(), draw_3d_image(), draw_3d_image(), draw_3d_image(), draw_3d_image(), eye(), gaussianEliminate(), Get(), getROI(), getROI(), init_perspective_matrix(), inverse(), Mat(), Mat(), Mat(), Mat(), Mat(), norm(), normalize(), ones(), dspm::operator*(), operator*=(), operator*=(), dspm::operator+(), operator+=(), dspm::operator-(), operator-=(), operator/=(), operator/=(), operator=(), dspm::operator==(), pinv(), print_matrix(), PrintHead(), rowReduceFromGaussian(), swapRows(), t(), update_perspective_matrix(), update_rotation_matrix(), and ~Mat().
| float* dspm::Mat::data |
Buffer with matrix data
Definition at line 37 of file mat.h.
Referenced by allocate(), bandSolve(), clear(), Copy(), CopyHead(), ekf::dFdq(), ekf::dFdq_inv(), draw_3d_image(), draw_3d_image(), draw_3d_image(), draw_3d_image(), draw_3d_image_task(), draw_3d_image_task(), Get(), getROI(), kalman_filter_calibration(), kalman_filter_calibration(), kalman_filter_calibration(), kalman_filter_calibration(), kalman_filter_task(), kalman_filter_task(), kalman_filter_task(), kalman_filter_task(), ekf_imu13states::LinearizeFG(), Mat(), Mat(), Mat(), Mat(), Mat(), operator()(), operator()(), dspm::operator*(), dspm::operator*(), operator*=(), operator*=(), dspm::operator+(), dspm::operator+(), operator+=(), operator+=(), dspm::operator-(), dspm::operator-(), operator-=(), operator-=(), dspm::operator/(), operator/=(), operator=(), PrintHead(), ekf::qProduct(), ekf::quat2eul(), ekf::SkewSym4x4(), swapRows(), t(), ekf_imu13states::TestFull(), update_rotation_matrix(), ekf_imu13states::UpdateRefMeasurement(), ekf_imu13states::UpdateRefMeasurement(), ekf_imu13states::UpdateRefMeasurementMagn(), and ~Mat().
| bool dspm::Mat::ext_buff |
Flag indicates that matrix use external buffer
Definition at line 40 of file mat.h.
Referenced by allocate(), CopyHead(), Mat(), Mat(), Mat(), operator=(), PrintHead(), and ~Mat().
| int dspm::Mat::length |
Total amount of data in data array
Definition at line 38 of file mat.h.
Referenced by allocate(), CopyHead(), Mat(), Mat(), Mat(), Mat(), operator*=(), operator+=(), operator-=(), operator/=(), and PrintHead().
| int dspm::Mat::padding |
Padding between 2 rows
Definition at line 36 of file mat.h.
Referenced by CopyHead(), getROI(), Mat(), Mat(), Mat(), Mat(), Mat(), dspm::operator*(), dspm::operator*(), operator*=(), operator*=(), dspm::operator+(), dspm::operator+(), operator+=(), dspm::operator-(), dspm::operator-(), operator-=(), dspm::operator/(), operator/=(), operator=(), and PrintHead().
| int dspm::Mat::rows |
Amount of rows
Definition at line 33 of file mat.h.
Referenced by adjoint(), allocate(), augment(), bandSolve(), clear(), cofactor(), Copy(), CopyHead(), dispaly_esp_text(), dispaly_esp_text(), dispaly_esp_text(), dispaly_esp_text(), display_3d_image(), display_3d_image(), display_3d_image(), display_3d_image(), display_3d_image(), display_3d_image(), display_3d_image(), display_3d_image(), display_3d_image(), display_3d_image(), dotProduct(), draw_3d_image(), draw_3d_image(), draw_3d_image(), draw_3d_image(), eye(), gaussianEliminate(), Get(), getROI(), init_perspective_matrix(), inverse(), Mat(), Mat(), Mat(), Mat(), Mat(), norm(), normalize(), ones(), dspm::operator*(), operator*=(), operator*=(), dspm::operator+(), operator+=(), operator+=(), dspm::operator-(), operator-=(), operator-=(), operator/=(), operator/=(), operator=(), dspm::operator==(), pinv(), print_matrix(), PrintHead(), rowReduceFromGaussian(), solve(), swapRows(), t(), ekf::Update(), update_perspective_matrix(), update_rotation_matrix(), ekf::UpdateRef(), and ~Mat().
| int dspm::Mat::stride |
Stride = (number of elements in a row) + padding
Definition at line 35 of file mat.h.
Referenced by clear(), Copy(), CopyHead(), getROI(), Mat(), Mat(), Mat(), Mat(), Mat(), operator=(), PrintHead(), swapRows(), and t().
| bool dspm::Mat::sub_matrix |
Flag indicates that matrix is a subset of another matrix
Definition at line 41 of file mat.h.
Referenced by CopyHead(), Mat(), Mat(), Mat(), Mat(), Mat(), dspm::operator*(), operator*=(), operator*=(), dspm::operator+(), operator+=(), operator+=(), dspm::operator-(), operator-=(), operator-=(), operator/=(), operator=(), and PrintHead().