#include <geometry/matrix.h>
Inheritance diagram for fawkes::Matrix:
Public Member Functions | |
Matrix (unsigned int num_rows=0, unsigned int num_cols=0, float *data=0, bool manage_own_memory=true) | |
Constructor. | |
Matrix (const Matrix &tbc) | |
Copy-constructor. | |
~Matrix () | |
Destructor. | |
void | size (unsigned int &num_rows, unsigned int &num_cols) const |
Determines the dimensions of the matrix. | |
unsigned int | num_rows () const |
Return the number of rows in the Matrix. | |
unsigned int | num_cols () const |
Return the number of columns in the Matrix. | |
Matrix & | id () |
Sets the diagonal elements to 1.0 and all other to 0.0. | |
Matrix & | transpose () |
Transposes the matrix. | |
Matrix | get_transpose () const |
Computes a matrix that is the transposed of this matrix. | |
Matrix & | invert () |
Inverts the matrix. | |
Matrix | get_inverse () const |
Computes a matrix that is the inverse of this matrix. | |
float | det () const |
Computes the determinant of the matrix. | |
const float * | get_data () const |
Returns the const data pointer. | |
float * | get_data () |
Returns the data pointer. | |
Matrix | get_submatrix (unsigned int row, unsigned int col, unsigned int num_rows, unsigned int num_cols) const |
Returns a submatrix of the matrix. | |
void | overlay (unsigned int row, unsigned int col, const Matrix &m) |
Overlays another matrix over this matrix. | |
float | operator() (unsigned int row, unsigned int col) const |
(Read-only) Access-operator. | |
float & | operator() (unsigned int row, unsigned int col) |
(RW) Access operator. | |
Matrix & | operator= (const Matrix &rhs) |
Assignment operator. | |
Matrix | operator * (const Matrix &rhs) const |
Matrix multiplication operator. | |
Matrix & | operator *= (const Matrix &rhs) |
Combined matrix-multipliation and assignement operator. | |
Vector | operator * (const Vector &cv) const |
Multiply the matrix with given vector. | |
Matrix | operator * (const float &f) const |
Mulitply every element of the matrix with the given scalar. | |
Matrix & | operator *= (const float &f) |
Combined scalar multiplication and assignment operator. | |
Matrix | operator/ (const float &f) const |
Divide every element of the matrix with the given scalar. | |
Matrix & | operator/= (const float &f) |
Combined scalar division and assignment operator. | |
Matrix | operator+ (const Matrix &rhs) const |
Addition operator. | |
Matrix & | operator+= (const Matrix &rhs) |
Add-assign operator. | |
Matrix | operator- (const Matrix &rhs) const |
Subtraction operator. | |
Matrix & | operator-= (const Matrix &rhs) |
Subtract-assign operator. | |
bool | operator== (const Matrix &rhs) const |
Comparison operator. | |
void | print_info (const char *name=0, const char *col_sep=0, const char *row_sep=0) const |
Print matrix to standard out. | |
Static Public Member Functions | |
static Matrix | get_id (unsigned int size, float *data_buffer=0) |
Creates a quadratic matrix with dimension size and sets the diagonal elements to 1.0. | |
static Matrix | get_diag (unsigned int size, float value, float *data_buffer=0) |
Creates a quadratic matrix with dimension size and sets the diagonal elements to value. |
It provides all the operations that are commonly used with a matrix, but has been optimized with typical robotic applications in mind. That meas especially that the chose data type is single-precision float and the class has been optimized for small matrices (up to about 10x10).
Masrur Doostdar
Christof Rath
Definition at line 33 of file matrix.h.
fawkes::Matrix::Matrix | ( | unsigned int | num_rows = 0 , |
|
unsigned int | num_cols = 0 , |
|||
float * | data = 0 , |
|||
bool | manage_own_memory = true | |||
) |
Constructor.
num_rows | number of rows | |
num_cols | number of columns | |
data | array containing elements of the matrix in row-by-row-order | |
manage_own_memory | if true, the Matrix will manage its memory on its own, else it will not allocate new memory but works with the provided array |
Definition at line 102 of file matrix.cpp.
Referenced by firevision::CCDCalibration::CCDCalibration().
fawkes::Matrix::Matrix | ( | const Matrix & | tbc | ) |
Copy-constructor.
tbc | matrix to be copied |
Definition at line 138 of file matrix.cpp.
References m_data, m_num_cols, m_num_elements, and m_num_rows.
fawkes::Matrix::~Matrix | ( | ) |
float fawkes::Matrix::det | ( | ) | const |
Computes the determinant of the matrix.
Definition at line 374 of file matrix.cpp.
References data(), mult_row(), and sub_row().
float * fawkes::Matrix::get_data | ( | ) | [inline] |
const float * fawkes::Matrix::get_data | ( | ) | const [inline] |
Returns the const data pointer.
Definition at line 57 of file matrix.h.
Referenced by get_submatrix(), get_transpose(), operator *(), operator+(), operator+=(), operator-(), operator-=(), operator/(), and operator==().
Matrix fawkes::Matrix::get_diag | ( | unsigned int | size, | |
float | value, | |||
float * | data_buffer = 0 | |||
) | [static] |
Creates a quadratic matrix with dimension size and sets the diagonal elements to value.
All other elements are set to 0.0.
size | dimension of the matrix | |
value | of the elements of the main diagonal | |
data_buffer | if != NULL the given float array will be used as data internal data store (the object will not perform any memory management in this case) |
Definition at line 207 of file matrix.cpp.
References data().
Referenced by get_id().
Matrix fawkes::Matrix::get_id | ( | unsigned int | size, | |
float * | data_buffer = 0 | |||
) | [static] |
Creates a quadratic matrix with dimension size and sets the diagonal elements to 1.0.
All other elements are set to 0.0.
size | dimension of the matrix | |
data_buffer | if != NULL the given float array will be used as data internal data store (the object will not perform any memory management in this case) |
Definition at line 193 of file matrix.cpp.
References get_diag().
Referenced by invert().
Matrix fawkes::Matrix::get_inverse | ( | ) | const |
Computes a matrix that is the inverse of this matrix.
Definition at line 362 of file matrix.cpp.
References invert().
Matrix fawkes::Matrix::get_submatrix | ( | unsigned int | row, | |
unsigned int | col, | |||
unsigned int | num_rows, | |||
unsigned int | num_cols | |||
) | const |
Returns a submatrix of the matrix.
row | the row in the original matrix of the top-left element in the submatrix | |
col | the column in the original matrix of the top-left element in the submatrix | |
num_rows | the number of rows of the submatrix | |
num_cols | the number of columns of the submatrix |
Definition at line 415 of file matrix.cpp.
References get_data().
Referenced by firevision::ProjectiveCam::get_GPA_p(), fawkes::HomTransform::invert(), firevision::Calibration::K(), and firevision::ProjectiveCam::set_location().
Matrix fawkes::Matrix::get_transpose | ( | ) | const |
Computes a matrix that is the transposed of this matrix.
Definition at line 294 of file matrix.cpp.
References get_data().
Matrix & fawkes::Matrix::id | ( | ) |
Sets the diagonal elements to 1.0 and all other to 0.0.
Definition at line 172 of file matrix.cpp.
References num_cols(), and num_rows().
Referenced by firevision::Calibration::Calibration(), fawkes::HomTransform::HomTransform(), firevision::Calibration::K(), and fawkes::HomTransform::reset().
Matrix & fawkes::Matrix::invert | ( | ) |
Inverts the matrix.
The algorithm that is implemented for computing the inverse of the matrix is the Gauss-Jordan-Algorithm. Hereby, the block- matrix (A|I) consisting of the matrix to be inverted (A) and the identity matrix (I) is transformed into (I|A^(-1)).
Definition at line 317 of file matrix.cpp.
References get_id(), mult_row(), overlay(), and sub_row().
Referenced by get_inverse(), and firevision::ProjectiveCam::set_location().
unsigned int fawkes::Matrix::num_cols | ( | ) | const [inline] |
Return the number of columns in the Matrix.
Definition at line 43 of file matrix.h.
Referenced by fawkes::HomTransform::HomTransform(), id(), operator *(), operator *=(), operator+(), operator+=(), operator-(), operator-=(), operator==(), print_info(), and size().
unsigned int fawkes::Matrix::num_rows | ( | ) | const [inline] |
Return the number of rows in the Matrix.
Definition at line 42 of file matrix.h.
Referenced by fawkes::HomTransform::HomTransform(), id(), operator *(), operator *=(), operator+(), operator+=(), operator-(), operator-=(), operator==(), print_info(), and size().
Matrix fawkes::Matrix::operator * | ( | const float & | f | ) | const |
Mulitply every element of the matrix with the given scalar.
f | a scalar |
Definition at line 659 of file matrix.cpp.
References get_data(), and m_num_elements.
Multiply the matrix with given vector.
v | a vector |
Definition at line 627 of file matrix.cpp.
References fawkes::Vector::data_ptr(), num_cols(), num_rows(), and fawkes::Vector::size().
Matrix multiplication operator.
(Matrix)a.operator*((Matrix)b) computes a * b; i.e., the 2nd matrix is right-multiplied to the 1st matrix
rhs | the right-hand-side matrix |
Definition at line 535 of file matrix.cpp.
References data(), m_num_cols, m_num_rows, num_cols(), and num_rows().
Matrix & fawkes::Matrix::operator *= | ( | const float & | f | ) |
Combined scalar multiplication and assignment operator.
f | a scalar |
Definition at line 677 of file matrix.cpp.
Combined matrix-multipliation and assignement operator.
rhs | the right-hand-side Matrix |
Definition at line 572 of file matrix.cpp.
References data(), m_num_cols, m_num_rows, num_cols(), and num_rows().
float & fawkes::Matrix::operator() | ( | unsigned int | row, | |
unsigned int | col | |||
) |
(RW) Access operator.
see the read-only access operator for operational details
row | the row of the element | |
col | the column of the element |
Definition at line 489 of file matrix.cpp.
float fawkes::Matrix::operator() | ( | unsigned int | row, | |
unsigned int | col | |||
) | const |
(Read-only) Access-operator.
With this operator it is possible to access a specific element of the matrix. (First element is at (0, 0)
row | the row of the element | |
col | the column of the element |
Definition at line 472 of file matrix.cpp.
Addition operator.
Adds the corresponding elements of the two matrices.
rhs | the right-hand-side matrix |
Definition at line 726 of file matrix.cpp.
References get_data(), m_num_cols, m_num_rows, num_cols(), and num_rows().
Add-assign operator.
rhs | the right-hand-side matrix |
Definition at line 751 of file matrix.cpp.
References get_data(), m_num_cols, m_num_rows, num_cols(), and num_rows().
Subtraction operator.
Subtracts the corresponding elements of the two matrices.
rhs | the right-hand-side matrix |
Definition at line 775 of file matrix.cpp.
References get_data(), num_cols(), and num_rows().
Subtract-assign operator.
rhs | the right-hand-side matrix |
Definition at line 801 of file matrix.cpp.
References get_data(), num_cols(), and num_rows().
Matrix fawkes::Matrix::operator/ | ( | const float & | f | ) | const |
Divide every element of the matrix with the given scalar.
f | a scalar |
Definition at line 692 of file matrix.cpp.
References get_data(), and m_num_elements.
Matrix & fawkes::Matrix::operator/= | ( | const float & | f | ) |
Combined scalar division and assignment operator.
f | a scalar |
Definition at line 710 of file matrix.cpp.
Assignment operator.
Copies the data form the rhs Matrix to the lhs Matrix.
m | the rhs Matrix |
Definition at line 506 of file matrix.cpp.
References m_data, m_num_cols, m_num_elements, and m_num_rows.
bool fawkes::Matrix::operator== | ( | const Matrix & | rhs | ) | const |
Comparison operator.
rhs | the right-hand-side Matrix |
Definition at line 825 of file matrix.cpp.
References get_data(), num_cols(), and num_rows().
void fawkes::Matrix::overlay | ( | unsigned int | row, | |
unsigned int | col, | |||
const Matrix & | over | |||
) |
Overlays another matrix over this matrix.
row | the top-most row from which onwards the the elements are exchanged for corresponding elements in the given matrix | |
col | the left-most column from which onwards the the elements are exchanged for corresponding elements in the given matrix | |
over | the matrix to be overlaid |
Definition at line 445 of file matrix.cpp.
References data(), m_num_cols, and m_num_rows.
Referenced by firevision::ProjectiveCam::get_GPA_p(), invert(), fawkes::HomTransform::invert(), firevision::Calibration::K(), and firevision::ProjectiveCam::set_location().
void fawkes::Matrix::print_info | ( | const char * | name = 0 , |
|
const char * | col_sep = 0 , |
|||
const char * | row_sep = 0 | |||
) | const |
Print matrix to standard out.
name | a name that is printed before the content of the matrix (not required) | |
col_sep | a string used to separate columns (defaults to '\t') | |
row_sep | a string used to separate rows (defaults to '\n') |
Definition at line 890 of file matrix.cpp.
References num_cols(), and num_rows().
Referenced by fawkes::HomTransform::print_info(), and firevision::ProjectiveCam::print_info().
void fawkes::Matrix::size | ( | unsigned int & | num_rows, | |
unsigned int & | num_cols | |||
) | const |
Determines the dimensions of the matrix.
num_cols | pointer to an unsigned int to where the number of columns is copied to | |
num_rows | pointer to an unsigned int to where the number of rows is copied to |
Definition at line 161 of file matrix.cpp.
References num_cols(), and num_rows().
Referenced by firevision::Calibration::K().
Matrix & fawkes::Matrix::transpose | ( | ) |
Transposes the matrix.
Definition at line 233 of file matrix.cpp.
Referenced by fawkes::HomTransform::invert().