#include <Matrix.h>
Public Types | |
| typedef Matrix< T, NumberTraits > | matrix_type |
| A shorthand for Matrix< T, NumberTraits >. | |
| typedef T | number_type |
| The type of the elements the matrix holds. | |
| typedef NumberTraits | traits_type |
| The AlgebraicTraits type associated to the type of matrix elements. | |
| typedef NumberTraits::norm_type | norm_type |
| A type for the norm of a matrix. | |
Public Member Functions | |
| Matrix () | |
| operator const number_type *const * () const | |
| operator number_type ** () | |
| const matrix_type | zero () const |
| const matrix_type | one () const |
| unsigned int | rows () const |
| unsigned int | cols () const |
| bool | isNull () const |
| bool | resize (unsigned int r, unsigned int c) |
| void | swapRows (unsigned int i, unsigned int j) |
| void | swapCols (unsigned int i, unsigned int j) |
| void | multiplyRow (unsigned int row, const number_type &value) |
| void | multiplyRowAndAddToRow (unsigned int source, unsigned int dest, const number_type &value) |
| void | multiplyCol (unsigned int col, const number_type &value) |
| void | multiplyColAndAddToCol (unsigned int source, unsigned int dest, const number_type &value) |
| void | fill (const number_type &value) |
| Matrix (unsigned int nRows, unsigned int nCols) | |
| Matrix (unsigned int dim) | |
| Matrix (const matrix_type &other) | |
| ~Matrix () | |
| matrix_type & | operator= (const matrix_type &other) |
| number_type | determinant () const |
| void | getCofactor (unsigned int i, unsigned int j, matrix_type &cofactor) const |
| void | getMinor (const IndexSet &keep_rows, const IndexSet &keep_cols, matrix_type &minor) const |
| matrix_type & | transpose () |
| matrix_type | operator * (const matrix_type &rhs) const |
| matrix_type | operator- () const |
| matrix_type | operator+ (const matrix_type &rhs) const |
| matrix_type | operator- (const matrix_type &rhs) const |
| matrix_type | operator/ (const matrix_type &rhs) const |
| matrix_type & | operator+= (const matrix_type &rhs) |
| matrix_type & | operator-= (const matrix_type &rhs) |
| matrix_type & | operator *= (const matrix_type &rhs) |
| matrix_type & | operator/= (const matrix_type &rhs) |
| bool | operator== (const matrix_type &rhs) const |
| bool | operator!= (const matrix_type &rhs) const |
| bool | operator< (const matrix_type &rhs) const |
| matrix_type | inverse () const |
| number_type | getNorm () const |
| number_type | getEuclideanNorm () const |
| void | display (std::ostream &os=std::cout) const |
| void | load (std::istream &is) |
| void | save (std::ostream &os) const |
Classes | |
| struct | Int2Type |
Definition at line 30 of file Matrix.h.
| Matrix< T, NumberTraits >::Matrix | ( | const matrix_type & | other | ) | [inline] |
Copy constructor
| other | matrix to copy |
Definition at line 393 of file Matrix.h.
References Matrix< T, NumberTraits >::m_nCols, and Matrix< T, NumberTraits >::m_nRows.
| Matrix< T, NumberTraits >::operator const number_type *const * | ( | ) | const [inline] |
| Matrix< T, NumberTraits >::operator number_type ** | ( | ) | [inline] |
| const matrix_type Matrix< T, NumberTraits >::zero | ( | ) | const [inline] |
Create the zero matrix having the same dimensions as this matrix. This matrix can not be empty.
Definition at line 79 of file Matrix.h.
Referenced by Matrix< T, NumberTraits >::one().
Here is the caller graph for this function:

| const matrix_type Matrix< T, NumberTraits >::one | ( | ) | const [inline] |
Create the identity matrix having the same dimensions as this matrix. This matrix can not be empty.
Definition at line 101 of file Matrix.h.
References Matrix< T, NumberTraits >::zero().
Referenced by Matrix< T, NumberTraits >::inverse().
Here is the call graph for this function:

Here is the caller graph for this function:

| unsigned int Matrix< T, NumberTraits >::rows | ( | ) | const [inline] |
Get the count of rows of this matrix
Definition at line 129 of file Matrix.h.
Referenced by checkColumn(), checkSmithForm(), getMinimumDegreeElemIndexesInMatrix(), processColumn3(), processRow3(), recursiveSmithNormalForm3(), and smithNormalForm3().
Here is the caller graph for this function:

| unsigned int Matrix< T, NumberTraits >::cols | ( | ) | const [inline] |
Get the count of columns of this matrix
Definition at line 137 of file Matrix.h.
Referenced by checkRow(), checkSmithForm(), getMinimumDegreeElemIndexesInMatrix(), processColumn3(), processRow3(), recursiveSmithNormalForm3(), and smithNormalForm3().
Here is the caller graph for this function:

| bool Matrix< T, NumberTraits >::isNull | ( | ) | const [inline] |
Determine if this matrix is empty
Definition at line 145 of file Matrix.h.
Referenced by Matrix< T, NumberTraits >::operator=().
Here is the caller graph for this function:

| bool Matrix< T, NumberTraits >::resize | ( | unsigned int | r, | |
| unsigned int | c | |||
| ) | [inline] |
Resize the matrix to have the given number of rows and columns. The original data in the matrix will be lost if either the number of rows or the number of columns is increased.
| r | new number of rows | |
| c | new number of columns |
Definition at line 247 of file Matrix.h.
Referenced by Matrix< T, NumberTraits >::getCofactor(), Matrix< T, NumberTraits >::getMinor(), and smithNormalForm3().
Here is the caller graph for this function:

| void Matrix< T, NumberTraits >::swapRows | ( | unsigned int | i, | |
| unsigned int | j | |||
| ) | [inline] |
Swap two rows in this matrix.
| i | row to swap | |
| j | the other row to swap |
Definition at line 272 of file Matrix.h.
Referenced by Matrix< T, NumberTraits >::inverse(), and processColumn3().
Here is the caller graph for this function:

| void Matrix< T, NumberTraits >::swapCols | ( | unsigned int | i, | |
| unsigned int | j | |||
| ) | [inline] |
Swap two columns in this matrix.
| i | column to swap | |
| j | the other column to swap |
Definition at line 284 of file Matrix.h.
Referenced by processRow3(), and recursiveSmithNormalForm3().
Here is the caller graph for this function:

| void Matrix< T, NumberTraits >::multiplyRow | ( | unsigned int | row, | |
| const number_type & | value | |||
| ) | [inline] |
| void Matrix< T, NumberTraits >::multiplyRowAndAddToRow | ( | unsigned int | source, | |
| unsigned int | dest, | |||
| const number_type & | value | |||
| ) | [inline] |
| void Matrix< T, NumberTraits >::multiplyCol | ( | unsigned int | col, | |
| const number_type & | value | |||
| ) | [inline] |
| void Matrix< T, NumberTraits >::multiplyColAndAddToCol | ( | unsigned int | source, | |
| unsigned int | dest, | |||
| const number_type & | value | |||
| ) | [inline] |
Multiply all elements of a column by a constant and add to another column
| source | source column index | |
| dest | destination column index | |
| value | multiplier |
Definition at line 342 of file Matrix.h.
Referenced by recursiveSmithNormalForm3().
Here is the caller graph for this function:

| void Matrix< T, NumberTraits >::fill | ( | const number_type & | value | ) | [inline] |
Set all elements of this matrix to the given value
| value | value to set all matrix elements |
Definition at line 362 of file Matrix.h.
Referenced by smithNormalForm3().
Here is the caller graph for this function:

| matrix_type& Matrix< T, NumberTraits >::operator= | ( | const matrix_type & | other | ) | [inline] |
Assignment operator.
If the matrices don't have the same dimensions it's probably a user mistake so the function report an error and return this matrix unchanged. If this matrix is null it allocates memory and copies source matrix
| other | matrix to copy |
Definition at line 431 of file Matrix.h.
References Matrix< T, NumberTraits >::isNull(), Matrix< T, NumberTraits >::m_nCols, and Matrix< T, NumberTraits >::m_nRows.
Here is the call graph for this function:

| number_type Matrix< T, NumberTraits >::determinant | ( | ) | const [inline] |
Computes the determinant of this matrix
| void Matrix< T, NumberTraits >::getCofactor | ( | unsigned int | i, | |
| unsigned int | j, | |||
| matrix_type & | cofactor | |||
| ) | const [inline] |
Computes a cofactor for this matrix by removing line i and col j
| i | the line no. we remove from this matrix | |
| j | the column no. we remove from this matrix | |
| cofactor | a reference to the matrix that will contain the cofactor |
Definition at line 627 of file Matrix.h.
References Matrix< T, NumberTraits >::resize().
Referenced by recursiveSmithNormalForm3().
Here is the call graph for this function:

Here is the caller graph for this function:

| void Matrix< T, NumberTraits >::getMinor | ( | const IndexSet & | keep_rows, | |
| const IndexSet & | keep_cols, | |||
| matrix_type & | minor | |||
| ) | const [inline] |
Computes a minor for this matrix
Minors are always square matrices so keep_rows and keep_cols must contain the same number of indexes
| keep_rows | a set of row indexes to keep | |
| keep_cols | a set of column indexes to keep | |
| minor | a reference to the matrix that will contain the minor |
Definition at line 667 of file Matrix.h.
References IndexSet::find(), Matrix< T, NumberTraits >::m_nCols, Matrix< T, NumberTraits >::m_nRows, Matrix< T, NumberTraits >::resize(), and IndexSet::size().
Here is the call graph for this function:

| matrix_type& Matrix< T, NumberTraits >::transpose | ( | ) | [inline] |
| matrix_type Matrix< T, NumberTraits >::operator * | ( | const matrix_type & | rhs | ) | const [inline] |
Matrix multiplication.
Complexity = O(n^3)
| rhs | right hand side matrix |
Definition at line 826 of file Matrix.h.
References Matrix< T, NumberTraits >::m_nCols, and Matrix< T, NumberTraits >::m_nRows.
| matrix_type Matrix< T, NumberTraits >::operator- | ( | ) | const [inline] |
Unary minus
Definition at line 861 of file Matrix.h.
References Matrix< T, NumberTraits >::m_nCols, and Matrix< T, NumberTraits >::m_nRows.
| matrix_type Matrix< T, NumberTraits >::operator+ | ( | const matrix_type & | rhs | ) | const [inline] |
Matrix addition
Matrices must have the same number of rows and columns to perform addition
| rhs | right hand side matrix |
Definition at line 882 of file Matrix.h.
References Matrix< T, NumberTraits >::m_nCols, and Matrix< T, NumberTraits >::m_nRows.
| matrix_type Matrix< T, NumberTraits >::operator- | ( | const matrix_type & | rhs | ) | const [inline] |
Matrix subtraction
Matrices must have the same number of rows and columns to perform subtraction
| rhs | right hand side matrix |
Definition at line 912 of file Matrix.h.
References Matrix< T, NumberTraits >::m_nCols, and Matrix< T, NumberTraits >::m_nRows.
| matrix_type Matrix< T, NumberTraits >::operator/ | ( | const matrix_type & | rhs | ) | const [inline] |
Matrix division
Matrices must have the same number of rows and columns to perform division. If the right hand side matrix is not inversable an exception is thrown
| rhs | right hand side matrix |
Definition at line 941 of file Matrix.h.
References Matrix< T, NumberTraits >::inverse(), Matrix< T, NumberTraits >::m_nCols, and Matrix< T, NumberTraits >::m_nRows.
Here is the call graph for this function:

| matrix_type& Matrix< T, NumberTraits >::operator+= | ( | const matrix_type & | rhs | ) | [inline] |
Addition assignment
Matrices must have the same number of rows and columns to perform addition.
| rhs | right hand side matrix |
Definition at line 960 of file Matrix.h.
References Matrix< T, NumberTraits >::m_nCols, and Matrix< T, NumberTraits >::m_nRows.
| matrix_type& Matrix< T, NumberTraits >::operator-= | ( | const matrix_type & | rhs | ) | [inline] |
Subtraction assignment
Matrices must have the same number of rows and columns to perform subtraction.
| rhs | right hand side matrix |
Definition at line 986 of file Matrix.h.
References Matrix< T, NumberTraits >::m_nCols, and Matrix< T, NumberTraits >::m_nRows.
| matrix_type& Matrix< T, NumberTraits >::operator *= | ( | const matrix_type & | rhs | ) | [inline] |
Multiplication assignment
Matrices should be compatible to perform multiplication i.e. the number of columns of the first matrix should be equal to the number of rows of the second matrix.
| rhs | right hand side matrix |
Definition at line 1014 of file Matrix.h.
References Matrix< T, NumberTraits >::m_nRows.
| matrix_type& Matrix< T, NumberTraits >::operator/= | ( | const matrix_type & | rhs | ) | [inline] |
Division assignment
Matrices should be square and have the same dimensions. If the second matrix is not inversable an exception is thrown.
| rhs | right hand side matrix |
Definition at line 1034 of file Matrix.h.
References Matrix< T, NumberTraits >::m_nCols, and Matrix< T, NumberTraits >::m_nRows.
| bool Matrix< T, NumberTraits >::operator== | ( | const matrix_type & | rhs | ) | const [inline] |
Equality operator
Matrices should have the same number of columns and rows.
| rhs | right hand side matrix |
Definition at line 1055 of file Matrix.h.
References Matrix< T, NumberTraits >::m_nCols, and Matrix< T, NumberTraits >::m_nRows.
Referenced by Matrix< T, NumberTraits >::operator!=().
Here is the caller graph for this function:

| bool Matrix< T, NumberTraits >::operator!= | ( | const matrix_type & | rhs | ) | const [inline] |
Inequality operator
Matrices should have the same number of columns and rows.
| rhs | right hand side matrix |
Definition at line 1083 of file Matrix.h.
References Matrix< T, NumberTraits >::operator==().
Here is the call graph for this function:

| bool Matrix< T, NumberTraits >::operator< | ( | const matrix_type & | rhs | ) | const [inline] |
Comparison operator
This function merely compares the norms of the matrices.
| rhs | right hand side matrix |
Definition at line 1096 of file Matrix.h.
References Matrix< T, NumberTraits >::getNorm(), and Matrix< T, NumberTraits >::m_nRows.
Here is the call graph for this function:

| matrix_type Matrix< T, NumberTraits >::inverse | ( | ) | const [inline] |
Compute the inverse of this matrix
Algorithm uses the relation obtained through elementary transformations) between the composed matrices [A:I] and [I:A^-1]. Complexity = O(n^3). This matrix must be a square matrix. If this matrix is not inversable an exception is thrown
Definition at line 1114 of file Matrix.h.
References Matrix< T, NumberTraits >::m_nCols, Matrix< T, NumberTraits >::m_nRows, Matrix< T, NumberTraits >::one(), Matrix< T, NumberTraits >::swapRows(), and AlgebraicTraits< T >::zero().
Referenced by Matrix< T, NumberTraits >::operator/().
Here is the call graph for this function:

Here is the caller graph for this function:

| number_type Matrix< T, NumberTraits >::getNorm | ( | ) | const [inline] |
Compute the euclidean norm of this matrix
Definition at line 1234 of file Matrix.h.
Referenced by Matrix< T, NumberTraits >::operator<().
Here is the caller graph for this function:

| number_type Matrix< T, NumberTraits >::getEuclideanNorm | ( | ) | const [inline] |
| void Matrix< T, NumberTraits >::display | ( | std::ostream & | os = std::cout |
) | const [inline] |
| void Matrix< T, NumberTraits >::load | ( | std::istream & | is | ) | [inline] |
| void Matrix< T, NumberTraits >::save | ( | std::ostream & | os | ) | const [inline] |