GestureRecognitionToolkit  Version: 0.1.0
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
Matrix< T > Class Template Reference

Public Member Functions

 Matrix ()
 
 Matrix (const unsigned int rows, const unsigned int cols)
 
 Matrix (const Matrix &rhs)
 
 Matrix (const Vector< Vector< T > > &data)
 
virtual ~Matrix ()
 
Matrixoperator= (const Matrix &rhs)
 
T * operator[] (const unsigned int r)
 
const T * operator[] (const unsigned int r) const
 
Vector< T > getRowVector (const unsigned int r) const
 
Vector< T > getColVector (const unsigned int c) const
 
Vector< T > getConcatenatedVector (const bool concatByRow=true) const
 
virtual bool resize (const unsigned int r, const unsigned int c)
 
virtual bool copy (const Matrix< T > &rhs)
 
bool setAllValues (const T &value)
 
bool setAll (const T &value)
 
bool setRowVector (const Vector< T > &row, const unsigned int rowIndex)
 
bool setColVector (const Vector< T > &column, const unsigned int colIndex)
 
bool push_back (const Vector< T > &sample)
 
bool reserve (const unsigned int capacity)
 
void clear ()
 
unsigned int getNumRows () const
 
unsigned int getNumCols () const
 
unsigned int getCapacity () const
 
unsigned int getSize () const
 
T ** getDataPointer () const
 
T * getData () const
 

Protected Attributes

unsigned int rows
 The number of rows in the Matrix.
 
unsigned int cols
 The number of columns in the Matrix.
 
unsigned int size
 Stores rows * cols.
 
unsigned int capacity
 The capacity of the Matrix, this will be the number of rows, not the actual memory size.
 
T * dataPtr
 A pointer to the raw data.
 
T ** rowPtr
 A pointer to each row in the data.
 
ErrorLog errorLog
 

Detailed Description

template<class T>
class Matrix< T >

Definition at line 39 of file Matrix.h.

Constructor & Destructor Documentation

template<class T>
Matrix< T >::Matrix ( )
inline

Default Constructor

Definition at line 44 of file Matrix.h.

template<class T>
Matrix< T >::Matrix ( const unsigned int  rows,
const unsigned int  cols 
)
inline

Constructor, sets the size of the matrix to [rows cols]

Parameters
rowssets the number of rows in the matrix, must be a value greater than zero
colssets the number of columns in the matrix, must be a value greater than zero

Definition at line 59 of file Matrix.h.

template<class T>
Matrix< T >::Matrix ( const Matrix< T > &  rhs)
inline

Copy Constructor, copies the values from the rhs Matrix to this Matrix instance

Parameters
rhsthe Matrix from which the values will be copied

Definition at line 70 of file Matrix.h.

template<class T>
Matrix< T >::Matrix ( const Vector< Vector< T > > &  data)
inline

Copy Constructor, copies the values from the input vector to this Matrix instance. The input vector must be a vector< vector< T > > in a [rows cols] format. The number of columns in each row must be consistent. Both the rows and columns must be greater than 0.

Parameters
datathe input data which will be copied to this Matrix instance

Definition at line 87 of file Matrix.h.

template<class T>
virtual Matrix< T >::~Matrix ( )
inlinevirtual

Destructor, cleans up any memory

Definition at line 127 of file Matrix.h.

Member Function Documentation

template<class T>
void Matrix< T >::clear ( )
inline

Cleans up any dynamic memory and sets the number of rows and columns in the matrix to zero

Definition at line 522 of file Matrix.h.

template<class T>
virtual bool Matrix< T >::copy ( const Matrix< T > &  rhs)
inlinevirtual

Copies the data from the rhs matrix to this matrix.

Parameters
rhsthe matrix you want to copy into this matrix
Returns
returns true or false, indicating if the copy was successful

Definition at line 306 of file Matrix.h.

template<class T>
unsigned int Matrix< T >::getCapacity ( ) const
inline

Gets the capacity of the Matrix. This is the number of rows that have been reserved for the Matrix. You can control the capacity using the reserve function

Returns
returns the number of columns in the Matrix

Definition at line 557 of file Matrix.h.

template<class T>
Vector<T> Matrix< T >::getColVector ( const unsigned int  c) const
inline

Gets a column vector [rows 1] from the Matrix at the column index c

Parameters
cthe index of the column, this should be in the range [0 cols-1]
Returns
returns a column vector from the Matrix at the column index c

Definition at line 184 of file Matrix.h.

template<class T>
Vector<T> Matrix< T >::getConcatenatedVector ( const bool  concatByRow = true) const
inline

Concatenates the entire matrix into a single vector and returns the vector. The data can either be concatenated by row or by column, by setting the respective concatByRow parameter to true of false. If concatByRow is true then the data in the matrix will be added to the vector row-vector by row-vector, otherwise the data will be added column-vector by column-vector.

Parameters
concatByRowsets if the matrix data will be added to the vector row-vector by row-vector
Returns
returns a vector containing the entire matrix data

Definition at line 200 of file Matrix.h.

template<class T>
T* Matrix< T >::getData ( ) const
inline

Gets a pointer to the main data pointer

Returns
returns a pointer to the raw data

Definition at line 583 of file Matrix.h.

template<class T>
T** Matrix< T >::getDataPointer ( ) const
inline

Gets a pointer to the row buffer

Returns
returns the row pointer

Definition at line 571 of file Matrix.h.

template<class T>
unsigned int Matrix< T >::getNumCols ( ) const
inline

Gets the number of columns in the Matrix

Returns
returns the number of columns in the Matrix

Definition at line 549 of file Matrix.h.

template<class T>
unsigned int Matrix< T >::getNumRows ( ) const
inline

Gets the number of rows in the Matrix

Returns
returns the number of rows in the Matrix

Definition at line 542 of file Matrix.h.

template<class T>
Vector< T > Matrix< T >::getRowVector ( const unsigned int  r) const
inline

Gets a row vector [1 cols] from the Matrix at the row index r

Parameters
rthe index of the row, this should be in the range [0 rows-1]
Returns
returns a row vector from the Matrix at the row index r

Definition at line 171 of file Matrix.h.

template<class T>
unsigned int Matrix< T >::getSize ( ) const
inline

Gets the size of the Matrix. This is rows * size.

Returns
returns the number of columns in the Matrix

Definition at line 564 of file Matrix.h.

template<class T>
Matrix& Matrix< T >::operator= ( const Matrix< T > &  rhs)
inline

Defines how the data from the rhs Matrix should be copied to this Matrix

Parameters
rhsanother instance of a Matrix
Returns
returns a reference to this instance of the Matrix

Definition at line 137 of file Matrix.h.

template<class T>
T* Matrix< T >::operator[] ( const unsigned int  r)
inline

Returns a pointer to the data at row r

Parameters
rthe index of the row you want, should be in the range [0 rows-1]
Returns
a pointer to the data at row r

Definition at line 151 of file Matrix.h.

template<class T>
const T* Matrix< T >::operator[] ( const unsigned int  r) const
inline

Returns a const pointer to the data at row r

Parameters
rthe index of the row you want, should be in the range [0 rows-1]
Returns
a const pointer to the data at row r

Definition at line 161 of file Matrix.h.

template<class T>
bool Matrix< T >::push_back ( const Vector< T > &  sample)
inline

Adds the input sample to the end of the Matrix, extending the number of rows by 1. The number of columns in the sample must match the number of columns in the Matrix, unless the Matrix size has not been set, in which case the new sample size will define the number of columns in the Matrix.

Parameters
samplethe new column vector you want to add to the end of the Matrix. Its size should match the number of columns in the Matrix
Returns
returns true or false, indicating if the push was successful

Definition at line 401 of file Matrix.h.

template<class T>
bool Matrix< T >::reserve ( const unsigned int  capacity)
inline

This function reserves a consistent block of data so new rows can more effecitenly be pushed_back into the Matrix. The capacity variable represents the number of rows you want to reserve, based on the current number of columns.

Parameters
capacitythe new capacity value
Returns
returns true if the data was reserved, false otherwise

Definition at line 480 of file Matrix.h.

template<class T>
virtual bool Matrix< T >::resize ( const unsigned int  r,
const unsigned int  c 
)
inlinevirtual

Resizes the Matrix to the new size of [r c]. If [r c] matches the previous size then the matrix will not be resized but the function will return true.

Parameters
rthe number of rows, must be greater than zero
cthe number of columns, must be greater than zero
Returns
returns true or false, indicating if the resize was successful

Definition at line 232 of file Matrix.h.

template<class T>
bool Matrix< T >::setAll ( const T &  value)
inline

Sets all the values in the Matrix to the input value

Parameters
valuethe value you want to set all the Matrix values to
Returns
returns true or false, indicating if the set was successful

Definition at line 346 of file Matrix.h.

template<class T>
bool Matrix< T >::setAllValues ( const T &  value)
inline
Deprecated:
This function is now depreciated! You should use setAll(const T &value) instead.

Sets all the values in the Matrix to the input value

Parameters
valuethe value you want to set all the Matrix values to
Returns
returns true or false, indicating if the set was successful

Definition at line 336 of file Matrix.h.

template<class T>
bool Matrix< T >::setColVector ( const Vector< T > &  column,
const unsigned int  colIndex 
)
inline

Sets all the values in the column at colIndex with the values in the vector called column. The size of the column vector must match the number of rows in this Matrix.

Parameters
columnthe vector of column values you want to add
colIndexthe column index of the column you want to update, must be in the range [0 cols]
Returns
returns true or false, indicating if the set was successful

Definition at line 383 of file Matrix.h.

template<class T>
bool Matrix< T >::setRowVector ( const Vector< T > &  row,
const unsigned int  rowIndex 
)
inline

Sets all the values in the row at rowIndex with the values in the vector called row. The size of the row vector must match the number of columns in this Matrix.

Parameters
rowthe vector of row values you want to add
rowIndexthe row index of the row you want to update, must be in the range [0 rows]
Returns
returns true or false, indicating if the set was successful

Definition at line 364 of file Matrix.h.


The documentation for this class was generated from the following file: