#include <matrix.h>
Inheritance diagram for GVectors::Matrix:

Public Member Functions | |
| Matrix (matindex_t r, matindex_t c) | |
| Constructor. | |
| Matrix (const Matrix &m) | |
| Copy constructor. | |
| const Matrix & | operator= (const Matrix &m) |
| Assignment operator. | |
| virtual | ~Matrix () |
| Destructor. | |
| void | set (matindex_t r, matindex_t c, double v) |
| Set a value at the given position. | |
| double | get (matindex_t r, matindex_t c) const |
| Get a value from the given position. | |
| void | fill (double v) |
| Fill the matrix with the given value. | |
Public Attributes | |
| const matindex_t | rows |
| The number of rows. | |
| const matindex_t | columns |
| The number of columns. | |
Protected Member Functions | |
| void | alloc () |
| Allocates memory for the matrix. | |
| void | free () |
| Frees the memory occupied by the matrix. | |
| void | copy (double **const src) |
| Copies the matrix to another memory location. | |
| bool | valid_index (matindex_t r, matindex_t c) const |
| Indicates whether or not the given index is valid. | |
Protected Attributes | |
| double ** | matrix |
| The pointer to the matrix in memory. | |
| Matrix::Matrix | ( | matindex_t | r, | |
| matindex_t | c | |||
| ) |
Constructor. Initializes a 'r-by-c' matrix and fills it with zeros.
| r | The number of rows. | |
| c | The number of columns. |
| Matrix::~Matrix | ( | ) | [virtual] |
Destructor. Frees all memory occupied by the matrix.
| void Matrix::alloc | ( | ) | [protected] |
Allocates memory for the matrix to hold a matrix of the dimension specified when creating the object.
It uses the C function malloc() for this purpose.
| void Matrix::free | ( | ) | [protected] |
Frees the memory occupied by the matrix.
It uses the C function free() for this purpose.
| void Matrix::copy | ( | double **const | src | ) | [protected] |
Copies the memory content of one matrix to the matrix of this object.
| src | Pointer to an array of doubleS holding the source matrix. |
| bool GVectors::Matrix::valid_index | ( | matindex_t | r, | |
| matindex_t | c | |||
| ) | const [inline, protected] |
Indicates whether or not the given matrix index is valid.
| r | Row index. | |
| c | Column index. |
| true | The index provided is valid. | |
| false | The index provided is not valid. |
Assigns one matrix to another. The dimensions have to be identical, else an exception is thrown. In other words, you cannot assign a 4x1 matrix to a 4x4 matrix and vice versa.
| m | A const reference to a Matrix object. |
| GVEInvalidMDimension | if the dimensions of the matrices are not identical. |
| void Matrix::set | ( | matindex_t | r, | |
| matindex_t | c, | |||
| double | v | |||
| ) |
Sets a value v at the given position r, c. If the position is not within the dimension of the matrix, an exception is thrown.
| r | Row index. | |
| c | Column index. | |
| v | Value to set at the position specified. |
| GVEInvalidMatrixIndex | if the indices specified are not within the bounds of the matrix dimension. |
| double Matrix::get | ( | matindex_t | r, | |
| matindex_t | c | |||
| ) | const |
Get the value at the specified position. If the position is not within the dimension of the matrix, an exception is thrown.
| r | Row index. | |
| c | Column index. |
| GVEInvalidMatrixIndex | if the indices specified are not within the bounds of the matrix dimension. |
| void Matrix::fill | ( | double | v | ) |
Fills the entire matrix with the value given.
| v | The value used to fill the matrix. |
double** GVectors::Matrix::matrix [protected] |
This is the pointer to the matrix in memory. Use this together with the Matrix::alloc_matrix(), Matrix::free_matrix(), and Matrix::copy_matrix() methods.
The number of rows of the matrix.
The number of columns of the matrix.
1.4.7