|
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 |
|
template<class T>
class GRT::Matrix< T >
Definition at line 41 of file Matrix.h.
Default Constructor
Definition at line 46 of file Matrix.h.
Constructor, sets the size of the matrix to [rows cols]
- Parameters
-
const | UINT rows: sets the number of rows in the matrix, must be a value greater than zero |
const | UINT cols: sets the number of columns in the matrix, must be a value greater than zero |
Definition at line 61 of file Matrix.h.
Copy Constructor, copies the values from the rhs Matrix to this Matrix instance
- Parameters
-
const | Matrix &rhs: the Matrix from which the values will be copied |
Definition at line 72 of file Matrix.h.
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
-
const | vector< vector< T > > &data: the input data which will be copied to this Matrix instance |
Definition at line 89 of file Matrix.h.
Destructor, cleans up any memory
Definition at line 129 of file Matrix.h.
Cleans up any dynamic memory and sets the number of rows and columns in the matrix to zero
Definition at line 511 of file Matrix.h.
Copies the data from the rhs matrix to this matrix.
- Parameters
-
const | Matrix<T> &rhs: the matrix you want to copy into this matrix |
- Returns
- returns true or false, indicating if the copy was successful
Definition at line 308 of file Matrix.h.
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 546 of file Matrix.h.
template<class T>
std::vector<T> GRT::Matrix< T >::getColVector |
( |
const unsigned int |
c | ) |
const |
|
inline |
Gets a column vector [rows 1] from the Matrix at the column index c
- Parameters
-
const | UINT c: the 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 186 of file Matrix.h.
template<class T>
std::vector<T> GRT::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
-
const | bool concatByRow: sets 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 202 of file Matrix.h.
Gets a pointer to the
- Returns
- returns the number of columns in the Matrix
Definition at line 560 of file Matrix.h.
Gets the number of columns in the Matrix
- Returns
- returns the number of columns in the Matrix
Definition at line 538 of file Matrix.h.
Gets the number of rows in the Matrix
- Returns
- returns the number of rows in the Matrix
Definition at line 531 of file Matrix.h.
template<class T>
std::vector<T> GRT::Matrix< T >::getRowVector |
( |
const unsigned int |
r | ) |
const |
|
inline |
Gets a row vector [1 cols] from the Matrix at the row index r
- Parameters
-
const | UINT r: the 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 173 of file Matrix.h.
Gets the size of the Matrix. This is rows * size.
- Returns
- returns the number of columns in the Matrix
Definition at line 553 of file Matrix.h.
Defines how the data from the rhs Matrix should be copied to this Matrix
- Parameters
-
- Returns
- returns a reference to this instance of the Matrix
Definition at line 139 of file Matrix.h.
template<class T>
T* GRT::Matrix< T >::operator[] |
( |
const unsigned int |
r | ) |
|
|
inline |
Returns a pointer to the data at row r
- Parameters
-
const | UINT r: the 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 153 of file Matrix.h.
template<class T>
const T* GRT::Matrix< T >::operator[] |
( |
const unsigned int |
r | ) |
const |
|
inline |
Returns a const pointer to the data at row r
- Parameters
-
const | UINT r: the 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 163 of file Matrix.h.
template<class T>
bool GRT::Matrix< T >::push_back |
( |
const std::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
-
const | std::vector<T> &sample: the 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 390 of file Matrix.h.
template<class T>
bool GRT::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
-
const | unsigned int capacity: the new capacity value |
- Returns
- returns true if the data was reserved, false otherwise
Definition at line 469 of file Matrix.h.
template<class T>
virtual bool GRT::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
-
const | UINT r: the number of rows, must be greater than zero |
const | UINT c: the number of columns, must be greater than zero |
- Returns
- returns true or false, indicating if the resize was successful
Definition at line 234 of file Matrix.h.
Sets all the values in the Matrix to the input value
- Parameters
-
const | T &value: the value you want to set all the Matrix values to |
- Returns
- returns true or false, indicating if the set was successful
Definition at line 335 of file Matrix.h.
template<class T>
bool GRT::Matrix< T >::setColVector |
( |
const std::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
-
const | std::vector<T> &column: the vector of column values you want to add |
const | unsigned int colIndex: the 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 372 of file Matrix.h.
template<class T>
bool GRT::Matrix< T >::setRowVector |
( |
const std::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
-
const | std::vector<T> &row: the vector of row values you want to add |
const | unsigned int rowIndex: the 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 353 of file Matrix.h.
The documentation for this class was generated from the following file:
- /Users/ngillian/Documents/dev/libs/grt/GRT/Util/Matrix.h