26 #ifndef __GEOMETRY_MATRIX_H_
27 #define __GEOMETRY_MATRIX_H_
37 float *data = 0,
bool manage_own_memory =
true);
42 inline unsigned int num_rows()
const {
return m_num_rows; }
43 inline unsigned int num_cols()
const {
return m_num_cols; }
46 static Matrix get_id(
unsigned int size,
float *data_buffer = 0);
47 static Matrix get_diag(
unsigned int size,
float value,
float *data_buffer = 0);
57 const float*
get_data()
const {
return m_data; }
61 unsigned int num_rows,
unsigned int num_cols)
const;
63 void overlay(
unsigned int row,
unsigned int col,
const Matrix &m);
65 float operator()(
unsigned int row,
unsigned int col)
const;
66 float &
operator()(
unsigned int row,
unsigned int col);
89 void print_info(
const char *name = 0,
const char *col_sep = 0,
90 const char *row_sep = 0)
const;
93 void mult_row(
unsigned int row,
float factor);
94 void sub_row(
unsigned int row_a,
unsigned int row_b,
float factor);
95 inline float data(
unsigned int row,
unsigned int col)
const
97 return m_data[row * m_num_cols + col];
99 inline float& data(
unsigned int row,
unsigned int col)
101 return m_data[row * m_num_cols + col];
107 unsigned int m_num_rows;
108 unsigned int m_num_cols;
109 unsigned int m_num_elements;
Matrix & id()
Sets the diagonal elements to 1.0 and all other to 0.0.
unsigned int num_cols() const
Return the number of columns in the Matrix.
Matrix operator*(const Matrix &rhs) const
Matrix multiplication operator.
Matrix & operator-=(const Matrix &rhs)
Subtract-assign operator.
Matrix & operator*=(const Matrix &rhs)
Combined matrix-multipliation and assignement operator.
Fawkes library namespace.
float det() const
Computes the determinant of the matrix.
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.
unsigned int num_rows() const
Return the number of rows in the Matrix.
Matrix operator+(const Matrix &rhs) const
Addition operator.
void print_info(const char *name=0, const char *col_sep=0, const char *row_sep=0) const
Print matrix to standard out.
Matrix & operator+=(const Matrix &rhs)
Add-assign operator.
void overlay(unsigned int row, unsigned int col, const Matrix &m)
Overlays another matrix over this matrix.
const float * get_data() const
Returns the const data pointer.
void size(unsigned int &num_rows, unsigned int &num_cols) const
Determines the dimensions of the matrix.
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.
float * get_data()
Returns the data pointer.
bool operator==(const Matrix &rhs) const
Comparison operator.
Matrix & transpose()
Transposes the matrix.
Matrix get_inverse() const
Computes a matrix that is the inverse of this matrix.
Matrix & invert()
Inverts the matrix.
Matrix get_submatrix(unsigned int row, unsigned int col, unsigned int num_rows, unsigned int num_cols) const
Returns a submatrix of the matrix.
float operator()(unsigned int row, unsigned int col) const
(Read-only) Access-operator.
Matrix operator-(const Matrix &rhs) const
Subtraction operator.
Matrix get_transpose() const
Computes a matrix that is the transposed of this matrix.
Matrix & operator=(const Matrix &rhs)
Assignment operator.
Matrix(unsigned int num_rows=0, unsigned int num_cols=0, float *data=0, bool manage_own_memory=true)
Constructor.
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.