Represents a two-dimensional array of objects. More...
#include <matrix.h>


Public Member Functions | |
| matrix (int rows=0, int cols=0, contents *data=NIL) | |
| the "data" array must have at least "rows" * "cols" contents in it. | |
| matrix (const matrix &to_copy) | |
| ~matrix () | |
| int | rows () const |
| int | columns () const |
| matrix & | operator= (const matrix &to_copy) |
| contents & | get (int row, int column) |
| const contents & | get (int row, int column) const |
| retrieves the contents from the specified "row" and "column". | |
| bool | put (int row, int column, const contents &to_put) |
| stores "to_put" into the matrix at "row" and "column". | |
| contents * | operator[] (int row) |
| dangerous: indexes by "row" into the underlying contents. | |
| const contents * | operator[] (int row) const |
| dangerous: constant peek into data for "row" in underlying contents. | |
| matrix | submatrix (int row, int column, int rows, int columns) const |
| returns a submatrix of this one starting at "row" and "column". | |
| void | submatrix (matrix &sub, int row, int column, int rows, int cols) const |
| like submatrix() above, but stores into the "sub" parameter. | |
| matrix | transpose () const |
| provides the transposed form of this matrix. | |
| void | transpose (matrix &resultant) const |
| stores the transpose of this matrix in "resultant". | |
| basis::array< contents > | get_row (int row) |
| return the vector at the "row", or an empty array if "row" is invalid. | |
| basis::array< contents > | get_column (int column) |
| return the vector at the "column", or an empty array if it's invalid. | |
| bool | insert_row (int before_row) |
| inserts a row before the "before_" parameter. | |
| bool | insert_column (int before_column) |
| inserts a column before the "before_" parameter. | |
| void | reset (int rows=0, int columns=0) |
| empties the matrix and changes its size. | |
| void | redimension (int new_rows, int new_columns) |
| changes the size to contain "new_rows" by "new_columns" elements. | |
| bool | zap_row (int row_to_zap) |
| bool | zap_column (int column_to_zap) |
| removes a row or column from the matrix. | |
Represents a two-dimensional array of objects.
The indices range from zero to (maximum_value - 1) for rows and columns.
Definition at line 31 of file matrix.h.
| structures::matrix< contents >::matrix | ( | int | rows = 0, |
|
| int | cols = 0, |
|||
| contents * | data = NIL | |||
| ) | [inline] |
| structures::matrix< contents >::matrix | ( | const matrix< contents > & | to_copy | ) | [inline] |
| structures::matrix< contents >::~matrix | ( | ) | [inline] |
| int structures::matrix< contents >::columns | ( | ) | const [inline] |
Definition at line 41 of file matrix.h.
Referenced by structures::matrix< contents >::get_column(), structures::matrix< contents >::get_row(), structures::matrix< contents >::insert_column(), structures::matrix< contents >::insert_row(), structures::matrix< contents >::put(), structures::matrix< contents >::redimension(), structures::matrix< contents >::submatrix(), structures::matrix< contents >::transpose(), structures::matrix< contents >::zap_column(), and structures::matrix< contents >::zap_row().
| const contents & structures::matrix< contents >::get | ( | int | row, | |
| int | column | |||
| ) | const [inline] |
retrieves the contents from the specified "row" and "column".
Definition at line 176 of file matrix.h.
References structures::matrix< contents >::get().
| contents & structures::matrix< contents >::get | ( | int | row, | |
| int | column | |||
| ) | [inline] |
Definition at line 180 of file matrix.h.
References structures::matrix< contents >::operator[]().
Referenced by structures::matrix< contents >::get().
| basis::array< contents > structures::matrix< contents >::get_column | ( | int | column | ) | [inline] |
return the vector at the "column", or an empty array if it's invalid.
Definition at line 277 of file matrix.h.
References structures::matrix< contents >::columns(), basis::array< contents >::reset(), and structures::matrix< contents >::rows().
| basis::array< contents > structures::matrix< contents >::get_row | ( | int | row | ) | [inline] |
return the vector at the "row", or an empty array if "row" is invalid.
Definition at line 266 of file matrix.h.
References structures::matrix< contents >::columns(), basis::array< contents >::reset(), and structures::matrix< contents >::rows().
| bool structures::matrix< contents >::insert_column | ( | int | before_column | ) | [inline] |
inserts a column before the "before_" parameter.
Definition at line 333 of file matrix.h.
References bounds_halt, structures::matrix< contents >::columns(), FUNCDEF, structures::matrix< contents >::put(), and structures::matrix< contents >::rows().
| bool structures::matrix< contents >::insert_row | ( | int | before_row | ) | [inline] |
inserts a row before the "before_" parameter.
all existing data is preserved in the matrix, although it may get moved over depending on where it's located with respect to "before_row".
Definition at line 319 of file matrix.h.
References bounds_halt, structures::matrix< contents >::columns(), FUNCDEF, basis::array< contents >::insert(), structures::matrix< contents >::put(), and structures::matrix< contents >::rows().
| matrix< contents > & structures::matrix< contents >::operator= | ( | const matrix< contents > & | to_copy | ) | [inline] |
| const contents * structures::matrix< contents >::operator[] | ( | int | row | ) | const [inline] |
dangerous: constant peek into data for "row" in underlying contents.
Reimplemented from basis::array< contents >.
Definition at line 172 of file matrix.h.
References structures::matrix< contents >::operator[]().
| contents * structures::matrix< contents >::operator[] | ( | int | row | ) | [inline] |
dangerous: indexes by "row" into the underlying contents.
the result can be used as a pointer to the whole row of data, or it can be indexed into by column to find a row/column position. this is dangerous if one is not careful about ensuring that the column used is within bounds. if the "row" parameter is out of bounds, then NIL is returned.
Reimplemented from basis::array< contents >.
Definition at line 168 of file matrix.h.
Referenced by structures::matrix< contents >::get(), structures::matrix< contents >::operator[](), and structures::matrix< contents >::put().
| bool structures::matrix< contents >::put | ( | int | row, | |
| int | column, | |||
| const contents & | to_put | |||
| ) | [inline] |
stores "to_put" into the matrix at "row" and "column".
Definition at line 218 of file matrix.h.
References structures::matrix< contents >::columns(), structures::matrix< contents >::operator[](), and structures::matrix< contents >::rows().
Referenced by structures::matrix< contents >::insert_column(), and structures::matrix< contents >::insert_row().
| void structures::matrix< contents >::redimension | ( | int | new_rows, | |
| int | new_columns | |||
| ) | [inline] |
changes the size to contain "new_rows" by "new_columns" elements.
data that was held previously stays in the array as long as its row and column indices are still valid.
Definition at line 207 of file matrix.h.
References structures::matrix< contents >::columns(), basis::minimum(), and structures::matrix< contents >::rows().
| void structures::matrix< contents >::reset | ( | int | rows = 0, |
|
| int | columns = 0 | |||
| ) | [inline] |
empties the matrix and changes its size.
Definition at line 188 of file matrix.h.
References basis::array< contents >::insert().
Referenced by structures::matrix< contents >::submatrix(), and structures::matrix< contents >::transpose().
| int structures::matrix< contents >::rows | ( | ) | const [inline] |
Definition at line 40 of file matrix.h.
Referenced by structures::matrix< contents >::get_column(), structures::matrix< contents >::get_row(), structures::matrix< contents >::insert_column(), structures::matrix< contents >::insert_row(), structures::matrix< contents >::put(), structures::matrix< contents >::redimension(), structures::matrix< contents >::submatrix(), structures::matrix< contents >::transpose(), structures::matrix< contents >::zap_column(), and structures::matrix< contents >::zap_row().
| void structures::matrix< contents >::submatrix | ( | matrix< contents > & | sub, | |
| int | row, | |||
| int | column, | |||
| int | rows, | |||
| int | cols | |||
| ) | const [inline] |
like submatrix() above, but stores into the "sub" parameter.
Definition at line 236 of file matrix.h.
References structures::matrix< contents >::columns(), structures::matrix< contents >::reset(), and structures::matrix< contents >::rows().
| matrix< contents > structures::matrix< contents >::submatrix | ( | int | row, | |
| int | column, | |||
| int | rows, | |||
| int | columns | |||
| ) | const [inline] |
| void structures::matrix< contents >::transpose | ( | matrix< contents > & | resultant | ) | const [inline] |
stores the transpose of this matrix in "resultant".
Definition at line 257 of file matrix.h.
References structures::matrix< contents >::columns(), structures::matrix< contents >::reset(), and structures::matrix< contents >::rows().
| matrix< contents > structures::matrix< contents >::transpose | ( | ) | const [inline] |
| bool structures::matrix< contents >::zap_column | ( | int | column_to_zap | ) | [inline] |
removes a row or column from the matrix.
the matrix becomes one row or column less than before and all data from the deleted vector is lost.
Definition at line 304 of file matrix.h.
References bounds_halt, structures::matrix< contents >::columns(), FUNCDEF, structures::matrix< contents >::rows(), and basis::array< contents >::zap().
| bool structures::matrix< contents >::zap_row | ( | int | row_to_zap | ) | [inline] |
Definition at line 288 of file matrix.h.
References bounds_halt, structures::matrix< contents >::columns(), FUNCDEF, structures::matrix< contents >::rows(), and basis::array< contents >::zap().
1.6.3