Represents a matrix of elements of the given type T. More...
#include <nmatrix.h>
Public Member Functions | |
NMatrix (unsigned long rows, unsigned long cols) | |
Creates a new matrix of the given size. | |
NMatrix (const NMatrix &cloneMe) | |
Creates a new matrix that is a clone of the given matrix. | |
virtual | ~NMatrix () |
Destroys this matrix. | |
void | initialise (const T &value) |
Sets every entry in the matrix to the given value. | |
void | initialise (List allValues) |
A Python-only routine that fills the matrix with the given set of elements. | |
unsigned long | rows () const |
Returns the number of rows in this matrix. | |
unsigned long | columns () const |
Returns the number of columns in this matrix. | |
T & | entry (unsigned long row, unsigned long column) |
Returns the entry at the given row and column. | |
const T & | entry (unsigned long row, unsigned long column) const |
Returns the entry at the given row and column. | |
bool | operator== (const NMatrix< T > &other) const |
Determines whether this and the given matrix are identical. | |
bool | operator!= (const NMatrix< T > &other) const |
Determines whether this and the given matrix are different. | |
virtual void | writeMatrix (std::ostream &out) const |
Writes a complete representation of the matrix to the given output stream. | |
void | swapRows (unsigned long first, unsigned long second) |
Swaps the elements of the two given rows in the matrix. | |
void | swapColumns (unsigned long first, unsigned long second) |
Swaps the elements of the two given columns in the matrix. | |
Protected Attributes | |
unsigned long | nRows |
The number of rows in the matrix. | |
unsigned long | nCols |
The number of columns in the matrix. | |
T ** | data |
The actual entries in the matrix. |
Represents a matrix of elements of the given type T.
=
) operator. out << t
.regina::NMatrix< T >::NMatrix | ( | unsigned long | rows, | |
unsigned long | cols | |||
) | [inline] |
Creates a new matrix of the given size.
All entries will be initialised using their default constructors.
rows | the number of rows in the new matrix. | |
cols | the number of columns in the new matrix. |
regina::NMatrix< T >::NMatrix | ( | const NMatrix< T > & | cloneMe | ) | [inline] |
Creates a new matrix that is a clone of the given matrix.
cloneMe | the matrix to clone. |
virtual regina::NMatrix< T >::~NMatrix | ( | ) | [inline, virtual] |
Destroys this matrix.
unsigned long regina::NMatrix< T >::columns | ( | ) | const [inline] |
Returns the number of columns in this matrix.
const T& regina::NMatrix< T >::entry | ( | unsigned long | row, | |
unsigned long | column | |||
) | const [inline] |
Returns the entry at the given row and column.
Rows and columns are numbered beginning at zero.
row | the row of the desired entry. | |
column | the column of the desired entry. |
T& regina::NMatrix< T >::entry | ( | unsigned long | row, | |
unsigned long | column | |||
) | [inline] |
Returns the entry at the given row and column.
Rows and columns are numbered beginning at zero.
matrix.entry(row, column) = value
still cannot be used in python to set a matrix element directly. For this, you can use the syntax matrix.set(row, column, value)
. This set() routine returns nothing, and is provided for python only (i.e., it is not part of the C++ calculation engine).row | the row of the desired entry. | |
column | the column of the desired entry. |
void regina::NMatrix< T >::initialise | ( | List | allValues | ) |
A Python-only routine that fills the matrix with the given set of elements.
The argument allValues must be a Python list of length rows() * columns(). Its values will be inserted into the matrix row by row (i.e., the first row will be filled, then the second row, and so on).
allValues | the individual elements to place into the matrix. |
void regina::NMatrix< T >::initialise | ( | const T & | value | ) | [inline] |
Sets every entry in the matrix to the given value.
value | the value to assign to each entry. |
bool regina::NMatrix< T >::operator!= | ( | const NMatrix< T > & | other | ) | const [inline] |
Determines whether this and the given matrix are different.
Two matrices are different if either (i) their dimensions differ, or (ii) the corresponding elements of each matrix differ in at least one location.
Note that this routine can happily deal with two matrices of different dimensions (in which case it will always return true
).
This routine returns true
if and only if the equality operator (==) returns false
.
other | the matrix to compare with this. |
true
if the matrices are different as described above, or false
otherwise. bool regina::NMatrix< T >::operator== | ( | const NMatrix< T > & | other | ) | const [inline] |
Determines whether this and the given matrix are identical.
Two matrices are identical if and only if (i) their dimensions are the same, and (ii) the corresponding elements of each matrix are equal.
Note that this routine can happily deal with two matrices of different dimensions (in which case it will always return false
).
This routine returns true
if and only if the inequality operator (!=) returns false
.
other | the matrix to compare with this. |
true
if the matrices are equal as described above, or false
otherwise. unsigned long regina::NMatrix< T >::rows | ( | ) | const [inline] |
Returns the number of rows in this matrix.
void regina::NMatrix< T >::swapColumns | ( | unsigned long | first, | |
unsigned long | second | |||
) | [inline] |
Swaps the elements of the two given columns in the matrix.
first | the first column to swap. | |
second | the second column to swap. |
void regina::NMatrix< T >::swapRows | ( | unsigned long | first, | |
unsigned long | second | |||
) | [inline] |
Swaps the elements of the two given rows in the matrix.
first | the first row to swap. | |
second | the second row to swap. |
virtual void regina::NMatrix< T >::writeMatrix | ( | std::ostream & | out | ) | const [inline, virtual] |
Writes a complete representation of the matrix to the given output stream.
Each row will be written on a separate line with elements in each row separated by single spaces.
out | the output stream to which to write. |
T** regina::NMatrix< T >::data [protected] |
The actual entries in the matrix.
data[r][c]
is the element in row r, column c.
unsigned long regina::NMatrix< T >::nCols [protected] |
The number of columns in the matrix.
unsigned long regina::NMatrix< T >::nRows [protected] |
The number of rows in the matrix.