GestureRecognitionToolkit  Version: 1.0 Revision: 04-03-15
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
GRT::MatrixDouble Class Reference
Inheritance diagram for GRT::MatrixDouble:
GRT::Matrix< double >

Public Member Functions

 MatrixDouble ()
 
 MatrixDouble (const unsigned int rows, const unsigned int cols)
 
 MatrixDouble (const MatrixDouble &rhs)
 
 MatrixDouble (const Matrix< double > &rhs)
 
virtual ~MatrixDouble ()
 
MatrixDoubleoperator= (const MatrixDouble &rhs)
 
MatrixDoubleoperator= (const Matrix< double > &rhs)
 
MatrixDoubleoperator= (const vector< VectorDouble > &rhs)
 
bool save (const string &filename) const
 
bool load (const string &filename, const char seperator= ',')
 
bool saveToCSVFile (const string &filename) const
 
bool loadFromCSVFile (const string &filename, const char seperator= ',')
 
bool print (const string title="") const
 
bool transpose ()
 
bool scale (const double minTarget, const double maxTarget)
 
bool scale (const vector< MinMax > &ranges, const double minTarget, const double maxTarget)
 
bool znorm (const double alpha=0.001)
 
MatrixDouble multiple (const double value) const
 
VectorDouble multiple (const VectorDouble &b) const
 
MatrixDouble multiple (const MatrixDouble &b) const
 
bool multiple (const MatrixDouble &a, const MatrixDouble &b, const bool aTranspose=false)
 
bool add (const MatrixDouble &b)
 
bool add (const MatrixDouble &a, const MatrixDouble &b)
 
bool subtract (const MatrixDouble &b)
 
bool subtract (const MatrixDouble &a, const MatrixDouble &b)
 
double getMinValue () const
 
double getMaxValue () const
 
VectorDouble getMean () const
 
VectorDouble getStdDev () const
 
MatrixDouble getCovarianceMatrix () const
 
std::vector< MinMaxgetRanges () const
 
double getTrace () const
 
- Public Member Functions inherited from GRT::Matrix< double >
 Matrix ()
 
 Matrix (const unsigned int rows, const unsigned int cols)
 
 Matrix (const Matrix &rhs)
 
 Matrix (const std::vector< std::vector< double > > &data)
 
virtual ~Matrix ()
 
Matrixoperator= (const Matrix &rhs)
 
double * operator[] (const unsigned int r)
 
const double * operator[] (const unsigned int r) const
 
std::vector< double > getRowVector (const unsigned int r) const
 
std::vector< double > getColVector (const unsigned int c) const
 
std::vector< double > getConcatenatedVector (const bool concatByRow=true) const
 
virtual bool resize (const unsigned int r, const unsigned int c)
 
virtual bool copy (const Matrix< double > &rhs)
 
bool setAllValues (const double &value)
 
bool setRowVector (const std::vector< double > &row, const unsigned int rowIndex)
 
bool setColVector (const std::vector< double > &column, const unsigned int colIndex)
 
bool push_back (const std::vector< double > &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
 
double ** getDataPointer () const
 

Protected Member Functions

double stringToDouble (const std::string &value)
 

Protected Attributes

WarningLog warningLog
 
ErrorLog errorLog
 
- Protected Attributes inherited from GRT::Matrix< double >
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.
 
double * dataPtr
 A pointer to the raw data.
 
double ** rowPtr
 A pointer to each row in the data.
 
ErrorLog errorLog
 

Detailed Description

Definition at line 42 of file MatrixDouble.h.

Constructor & Destructor Documentation

GRT::MatrixDouble::MatrixDouble ( )

Default Constructor

Definition at line 25 of file MatrixDouble.cpp.

GRT::MatrixDouble::MatrixDouble ( const unsigned int  rows,
const unsigned int  cols 
)

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

Parameters
constUINT rows: sets the number of rows in the matrix, must be a value greater than zero
constUINT cols: sets the number of columns in the matrix, must be a value greater than zero

Definition at line 33 of file MatrixDouble.cpp.

GRT::MatrixDouble::MatrixDouble ( const MatrixDouble rhs)

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

Parameters
constMatrixDouble &rhs: the MatrixDouble from which the values will be copied

Definition at line 42 of file MatrixDouble.cpp.

GRT::MatrixDouble::MatrixDouble ( const Matrix< double > &  rhs)

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

Parameters
constMatrix<double> &rhs: the Matrix from which the values will be copied

Definition at line 50 of file MatrixDouble.cpp.

GRT::MatrixDouble::~MatrixDouble ( )
virtual

Destructor, cleans up any memory

Definition at line 58 of file MatrixDouble.cpp.

Member Function Documentation

bool GRT::MatrixDouble::add ( const MatrixDouble b)

Adds the input matrix data (b) to this matrix (a), giving: a = a + b. This rows and cols of b must match that of this matrix.

Parameters
constMatrixDouble &a: the matrix to multiple with b
constMatrixDouble &b: the matrix to multiple with a
constbool aTranspose: a flag to indicate if matrix a should be transposed
Returns
true if the operation was completed successfully, false otherwise

Definition at line 316 of file MatrixDouble.cpp.

bool GRT::MatrixDouble::add ( const MatrixDouble a,
const MatrixDouble b 
)

Adds the input matrix data (a) to the input matrix (b), storing the data in this matrix (c) giving: c = a + b. The rows and cols in a and b must match. This will resize the current matrix if needed.

Parameters
constMatrixDouble &a: the matrix to add with b
constMatrixDouble &b: the matrix to add with a
Returns
true if the operation was completed successfully, false otherwise

Definition at line 340 of file MatrixDouble.cpp.

MatrixDouble GRT::MatrixDouble::getCovarianceMatrix ( ) const

Gets the covariance matrix of this matrix and returns this as a MatrixDouble.

Returns
a MatrixDouble with the covariance matrix of this matrix

Definition at line 481 of file MatrixDouble.cpp.

double GRT::MatrixDouble::getMaxValue ( ) const

Gets the ranges max value throughout the entire matrix.

Returns
a double value containing the maximum matrix value

Definition at line 444 of file MatrixDouble.cpp.

VectorDouble GRT::MatrixDouble::getMean ( ) const

Gets the mean of each column in the matrix and returns this as a VectorDouble.

Returns
a VectorDouble with the mean of each column

Definition at line 452 of file MatrixDouble.cpp.

double GRT::MatrixDouble::getMinValue ( ) const

Gets the ranges min value throughout the entire matrix.

Returns
a double value containing the minimum matrix value

Definition at line 436 of file MatrixDouble.cpp.

std::vector< MinMax > GRT::MatrixDouble::getRanges ( ) const

Gets the ranges (min and max values) of each column in the matrix.

Returns
a vector with the ranges (min and max values) of each column in the matrix

Definition at line 499 of file MatrixDouble.cpp.

VectorDouble GRT::MatrixDouble::getStdDev ( ) const

Gets the standard deviation of each column in the matrix and returns this as a VectorDouble.

Returns
a VectorDouble with the standard deviation of each column

Definition at line 467 of file MatrixDouble.cpp.

double GRT::MatrixDouble::getTrace ( ) const

Gets the trace of this matrix.

Returns
the trace of this matrix as a double

Definition at line 512 of file MatrixDouble.cpp.

bool GRT::MatrixDouble::load ( const string &  filename,
const char  seperator = ',' 
)

Loads a matrix from a CSV file. This assumes that the data has been saved as rows and columns in the CSV file and that there are an equal number of columns per row.

This replaces the deprecated loadFromCSVFile function.

Parameters
conststring &filename: the name of the CSV file
Returns
returns true or false, indicating if the data was loaded successful

Definition at line 540 of file MatrixDouble.cpp.

bool GRT::MatrixDouble::loadFromCSVFile ( const string &  filename,
const char  seperator = ',' 
)

Loads a matrix from a CSV file. This assumes that the data has been saved as rows and columns in the CSV file and that there are an equal number of columns per row.

Parameters
conststring &filename: the name of the CSV file
Returns
returns true or false, indicating if the data was loaded successful

Definition at line 644 of file MatrixDouble.cpp.

MatrixDouble GRT::MatrixDouble::multiple ( const double  value) const

Performs the multiplication of the data by the scalar value.

Returns
returns a new MatrixDouble with the results from the multiplcation

Definition at line 196 of file MatrixDouble.cpp.

VectorDouble GRT::MatrixDouble::multiple ( const VectorDouble &  b) const

Performs the multiplcation of this matrix (a) by the vector b. This will return a new vector (c): c = a * b

Parameters
constVectorDouble &b: the vector to multiple with this matrix
Returns
a VectorDouble with the results from the multiplcation

Definition at line 211 of file MatrixDouble.cpp.

MatrixDouble GRT::MatrixDouble::multiple ( const MatrixDouble b) const

Performs the multiplcation of this matrix (a) by the matrix b. This will return a new matrix (c): c = a * b

Parameters
constMatrixDouble &b: the matrix to multiple with this matrix
Returns
a new MatrixDouble with the results from the multiplcation

Definition at line 237 of file MatrixDouble.cpp.

bool GRT::MatrixDouble::multiple ( const MatrixDouble a,
const MatrixDouble b,
const bool  aTranspose = false 
)

Performs the multiplcation of the matrix a by the matrix b, directly storing the new data in the this matrix instance. This will resize the current matrix if needed. This makes this matrix c and gives: c = a * b, or if the aTransposed value is true: c = a' * b

Parameters
constMatrixDouble &a: the matrix to multiple with b
constMatrixDouble &b: the matrix to multiple with a
constbool aTranspose: a flag to indicate if matrix a should be transposed
Returns
true if the operation was completed successfully, false otherwise

Definition at line 266 of file MatrixDouble.cpp.

MatrixDouble & GRT::MatrixDouble::operator= ( const MatrixDouble rhs)

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

Parameters
constMatrixDouble &rhs: another instance of a MatrixDouble
Returns
returns a reference to this instance of the MatrixDouble

Definition at line 62 of file MatrixDouble.cpp.

MatrixDouble & GRT::MatrixDouble::operator= ( const Matrix< double > &  rhs)

Defines how the data from the rhs Matrix<double> should be copied to this MatrixDouble

Parameters
constMatrix<double> &rhs: an instance of a Matrix<double>
Returns
returns a reference to this instance of the MatrixDouble

Definition at line 70 of file MatrixDouble.cpp.

MatrixDouble & GRT::MatrixDouble::operator= ( const vector< VectorDouble > &  rhs)

Defines how the data from the rhs vector of VectorDoubles should be copied to this MatrixDouble

Parameters
constvector< VectorDouble> &rhs: a vector of VectorDoubles
Returns
returns a reference to this instance of the MatrixDouble

Definition at line 78 of file MatrixDouble.cpp.

bool GRT::MatrixDouble::print ( const string  title = "") const

Prints the MatrixDouble contents to std::cout

Parameters
conststring title: sets the title of the data that will be printed to std::cout
Returns
returns true or false, indicating if the print was successful

Definition at line 107 of file MatrixDouble.cpp.

bool GRT::MatrixDouble::save ( const string &  filename) const

Resizes the MatrixDouble to the new size of [rows cols]

Parameters
constUINT rows: the number of rows, must be greater than zero
constUINT cols: the number of columns, must be greater than zero
Returns
returns true or false, indicating if the resize was successful Saves the matrix to a CSV file. This replaces the deprecated saveToCSVFile function.
Parameters
conststring &filename: the name of the CSV file
Returns
returns true or false, indicating if the data was saved successful

Definition at line 521 of file MatrixDouble.cpp.

bool GRT::MatrixDouble::saveToCSVFile ( const string &  filename) const

Saves the matrix to a CSV file.

Parameters
conststring &filename: the name of the CSV file
Returns
returns true or false, indicating if the data was saved successful

Definition at line 640 of file MatrixDouble.cpp.

bool GRT::MatrixDouble::scale ( const double  minTarget,
const double  maxTarget 
)

Scales the matrix to a new range given by the min and max targets.

Returns
returns true if the matrix was scaled, false otherwise

Definition at line 140 of file MatrixDouble.cpp.

bool GRT::MatrixDouble::scale ( const vector< MinMax > &  ranges,
const double  minTarget,
const double  maxTarget 
)

Scales the matrix to a new range given by the min and max targets using the ranges as the source ranges.

Returns
returns true if the matrix was scaled, false otherwise

Definition at line 149 of file MatrixDouble.cpp.

bool GRT::MatrixDouble::subtract ( const MatrixDouble b)

Subtracts the input matrix data (b) from this matrix (a), giving: a = a - b. This rows and cols of b must match that of this matrix.

Parameters
constMatrixDouble &a: the matrix to subtract from this instance
Returns
true if the operation was completed successfully, false otherwise

Definition at line 374 of file MatrixDouble.cpp.

bool GRT::MatrixDouble::subtract ( const MatrixDouble a,
const MatrixDouble b 
)

Subtracts the input matrix data (b) from this matrix (a), giving (c): c = a - b. This rows and cols of b must match that of this matrix. This will resize the current matrix if needed.

Parameters
constMatrixDouble &a: the matrix to subtract with b
constMatrixDouble &b: the matrix to subtract from a
Returns
true if the operation was completed successfully, false otherwise

Definition at line 402 of file MatrixDouble.cpp.

bool GRT::MatrixDouble::transpose ( )

Transposes the data.

Returns
returns true or false, indicating if the transpose was successful

Definition at line 124 of file MatrixDouble.cpp.

bool GRT::MatrixDouble::znorm ( const double  alpha = 0.001)

Normalizes each row in the matrix by subtracting the row mean and dividing by the row standard deviation. A small amount (alpha) is added to the standard deviation to stop the normalization from exploding.

Parameters
constdouble alpha: a small value that will be added to the standard deviation
Returns
returns true if the matrix was normalized, false otherwise

Definition at line 165 of file MatrixDouble.cpp.


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