|
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 Matrix< T >
Definition at line 39 of file Matrix.h.
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
-
rows | sets the number of rows in the matrix, must be a value greater than zero |
cols | sets 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 unsigned int |
rows, |
|
|
const unsigned int |
cols, |
|
|
const T & |
data |
|
) |
| |
|
inline |
Constructor, sets the size of the matrix to [rows cols] and initalizes all the data to data
- Parameters
-
rows | sets the number of rows in the matrix, must be a value greater than zero |
cols | sets the number of columns in the matrix, must be a value greater than zero |
data | default value that will be used to initalize all the values in the matrix |
Definition at line 72 of file Matrix.h.
Copy Constructor, copies the values from the rhs Matrix to this Matrix instance
- Parameters
-
rhs | the Matrix from which the values will be copied |
Definition at line 83 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
-
data | the input data which will be copied to this Matrix instance |
Definition at line 100 of file Matrix.h.
Destructor, cleans up any memory
Definition at line 140 of file Matrix.h.
Cleans up any dynamic memory and sets the number of rows and columns in the matrix to zero
- Returns
- returns true if the data was cleared successfully
Definition at line 553 of file Matrix.h.
Copies the data from the rhs matrix to this matrix.
- Parameters
-
rhs | the matrix you want to copy into this matrix |
- Returns
- returns true or false, indicating if the copy was successful
Definition at line 336 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 589 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
-
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 197 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
-
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 213 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 615 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 603 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 581 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 574 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
-
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 184 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 596 of file Matrix.h.
Defines how the data from the rhs Matrix should be copied to this Matrix
- Parameters
-
rhs | another instance of a Matrix |
- Returns
- returns a reference to this instance of the Matrix
Definition at line 150 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
-
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 164 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
-
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 174 of file Matrix.h.
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
-
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 431 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
-
capacity | the new capacity value |
- Returns
- returns true if the data was reserved, false otherwise
Definition at line 510 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
-
r | the number of rows, must be greater than zero |
c | the number of columns, must be greater than zero |
- Returns
- returns true or false, indicating if the resize was successful
Definition at line 245 of file Matrix.h.
template<class T>
virtual bool Matrix< T >::resize |
( |
const unsigned int |
r, |
|
|
const unsigned int |
c, |
|
|
const T & |
value |
|
) |
| |
|
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
-
r | the number of rows, must be greater than zero |
c | the number of columns, must be greater than zero |
value | the default value that will be set across all values in the buffer |
- Returns
- returns true or false, indicating if the resize was successful
Definition at line 321 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
-
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 376 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
-
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 366 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
-
column | the vector of column values you want to add |
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 413 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
-
row | the vector of row values you want to add |
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 394 of file Matrix.h.
The documentation for this class was generated from the following file: