fawkes::Matrix Class Reference
A general matrix class. More...
#include <geometry/matrix.h>

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. | |
Detailed Description
A general matrix class.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).
Definition at line 33 of file matrix.h.
Constructor & Destructor Documentation
| fawkes::Matrix::Matrix | ( | unsigned int | num_rows = 0, |
|
| unsigned int | num_cols = 0, |
|||
| float * | data = 0, |
|||
| bool | manage_own_memory = true | |||
| ) |
Constructor.
- Parameters:
-
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 101 of file matrix.cpp.
Referenced by CCDCalibration::CCDCalibration().
| fawkes::Matrix::Matrix | ( | const Matrix & | tbc | ) |
| fawkes::Matrix::~Matrix | ( | ) |
Member Function Documentation
| float fawkes::Matrix::det | ( | ) | const |
Computes the determinant of the matrix.
- Returns:
- the determinant
Definition at line 373 of file matrix.cpp.
| float * fawkes::Matrix::get_data | ( | ) | [inline] |
| const float * fawkes::Matrix::get_data | ( | ) | const [inline] |
Returns the const data pointer.
- Returns:
- the 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.
- Parameters:
-
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)
- Returns:
- the diag matrix object
Definition at line 206 of file matrix.cpp.
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.
- Parameters:
-
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)
- Returns:
- the id matrix object
Definition at line 192 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.
- Returns:
- a matrix that is the inverse of this matrix
Definition at line 361 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.
- Parameters:
-
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
- Returns:
- the submatrix
Definition at line 414 of file matrix.cpp.
References get_data().
Referenced by ProjectiveCam::get_GPA_p(), fawkes::HomTransform::invert(), Calibration::K(), and ProjectiveCam::set_location().
| Matrix fawkes::Matrix::get_transpose | ( | ) | const |
Computes a matrix that is the transposed of this matrix.
- Returns:
- a matrix that is the transposed of this matrix
Definition at line 293 of file matrix.cpp.
References get_data().
| Matrix & fawkes::Matrix::id | ( | ) |
Sets the diagonal elements to 1.0 and all other to 0.0.
- Returns:
- a reference to the matrix object
Definition at line 171 of file matrix.cpp.
References num_cols(), and num_rows().
Referenced by Calibration::Calibration(), fawkes::HomTransform::HomTransform(), 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)).
- Returns:
- a reference to the matrix object which contains now the inverted matrix
Definition at line 316 of file matrix.cpp.
References get_id(), and overlay().
Referenced by get_inverse(), and ProjectiveCam::set_location().
| unsigned int fawkes::Matrix::num_cols | ( | ) | const [inline] |
Return the number of columns in the Matrix.
- Returns:
- the number of columns
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.
- Returns:
- the number of rows
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().
| float & fawkes::Matrix::operator() | ( | unsigned int | row, | |
| unsigned int | col | |||
| ) |
(RW) Access operator.
see the read-only access operator for operational details
- Parameters:
-
row the row of the element col the column of the element
- Returns:
- a reference to the specified element
Definition at line 488 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)
- Parameters:
-
row the row of the element col the column of the element
- Returns:
- the value of the specified element
Definition at line 471 of file matrix.cpp.
| Matrix fawkes::Matrix::operator* | ( | const float & | f | ) | const |
Mulitply every element of the matrix with the given scalar.
- Parameters:
-
f a scalar
- Returns:
- the result of the multiplication
Definition at line 658 of file matrix.cpp.
References get_data().
Multiply the matrix with given vector.
- Parameters:
-
v a vector
- Returns:
- the result of the matrix-vector multiplication
Definition at line 626 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
- Parameters:
-
rhs the right-hand-side matrix
- Returns:
- the product of the two matrices (a * b)
Definition at line 534 of file matrix.cpp.
References num_cols(), and num_rows().
| Matrix & fawkes::Matrix::operator*= | ( | const float & | f | ) |
Combined scalar multiplication and assignment operator.
- Parameters:
-
f a scalar
- Returns:
- reference to the result
Definition at line 676 of file matrix.cpp.
Combined matrix-multipliation and assignement operator.
- Parameters:
-
rhs the right-hand-side Matrix
- Returns:
- a reference to the Matrix that contains the result of the multiplication
Definition at line 571 of file matrix.cpp.
References num_cols(), and num_rows().
Addition operator.
Adds the corresponding elements of the two matrices.
- Parameters:
-
rhs the right-hand-side matrix
- Returns:
- the resulting matrix
Definition at line 725 of file matrix.cpp.
References get_data(), num_cols(), and num_rows().
Add-assign operator.
- Parameters:
-
rhs the right-hand-side matrix
- Returns:
- a reference to the resulting matrix (this)
Definition at line 750 of file matrix.cpp.
References get_data(), num_cols(), and num_rows().
Subtraction operator.
Subtracts the corresponding elements of the two matrices.
- Parameters:
-
rhs the right-hand-side matrix
- Returns:
- the resulting matrix
Definition at line 774 of file matrix.cpp.
References get_data(), num_cols(), and num_rows().
Subtract-assign operator.
- Parameters:
-
rhs the right-hand-side matrix
- Returns:
- a reference to the resulting matrix (this)
Definition at line 800 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.
- Parameters:
-
f a scalar
- Returns:
- the result of the divison
Definition at line 691 of file matrix.cpp.
References get_data().
| Matrix & fawkes::Matrix::operator/= | ( | const float & | f | ) |
Combined scalar division and assignment operator.
- Parameters:
-
f a scalar
- Returns:
- reference to the result
Definition at line 709 of file matrix.cpp.
| bool fawkes::Matrix::operator== | ( | const Matrix & | rhs | ) | const |
Comparison operator.
- Parameters:
-
rhs the right-hand-side Matrix
- Returns:
- true if every element of this matrix is equal to the corresponding element of the other matrix
Definition at line 824 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.
- Parameters:
-
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 444 of file matrix.cpp.
Referenced by ProjectiveCam::get_GPA_p(), invert(), fawkes::HomTransform::invert(), Calibration::K(), and 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.
- Parameters:
-
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 889 of file matrix.cpp.
References num_cols(), and num_rows().
Referenced by fawkes::HomTransform::print_info(), and ProjectiveCam::print_info().
| void fawkes::Matrix::size | ( | unsigned int & | num_rows, | |
| unsigned int & | num_cols | |||
| ) | const |
Determines the dimensions of the matrix.
- Parameters:
-
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 160 of file matrix.cpp.
References num_cols(), and num_rows().
Referenced by Calibration::K().
| Matrix & fawkes::Matrix::transpose | ( | ) |
Transposes the matrix.
- Returns:
- a reference to the matrix object now containing the transposed matrix
Definition at line 232 of file matrix.cpp.
Referenced by fawkes::HomTransform::invert().
The documentation for this class was generated from the following files:
- src/libs/geometry/matrix.h
- src/libs/geometry/matrix.cpp

