#include <SparseMatrix.h>
Public Member Functions | |
SparseMatrix () | |
SparseMatrix (unsigned int nrows, unsigned int ncolumns) | |
unsigned int | nRows () const |
unsigned int | nColumns () const |
unsigned int | nEntries () const |
void | setSize (unsigned int nrows, unsigned int ncolumns) |
void | set (unsigned int row, unsigned int column, T value) |
void | unset (unsigned int row, unsigned int column) |
T | get (unsigned int row, unsigned int column) const |
unsigned int | getRow (unsigned int row, const T **entry, const unsigned int **colIndex) const |
unsigned int | getRow (unsigned int row, vector< T > &e, vector< unsigned int > &c) const |
unsigned int | getColumn (unsigned int col, vector< T > &entry, vector< unsigned int > &rowIndex) const |
void | rowOperation (unsigned int row, unary_function< T, void > &f) |
void | addRow (unsigned int rowNum, const vector< T > &row) |
void | addRow (unsigned int rowNum, const vector< T > &entry, const vector< unsigned int > &colIndexArg) |
void | clear () |
void | transpose () |
void | reorderColumns (const vector< unsigned int > &colMap) |
void | tripletFill (const vector< unsigned int > &row, const vector< unsigned int > &col, const vector< T > &z) |
void | pairFill (const vector< unsigned int > &row, const vector< unsigned int > &col, T value) |
void | printTriplet (const vector< Triplet< T > > &t) |
void | print () const |
void | printInternal () const |
Protected Attributes | |
unsigned int | nrows_ |
unsigned int | ncolumns_ |
vector< T > | N_ |
vector< unsigned int > | colIndex_ |
Non-zero entries in the SparseMatrix. | |
vector< unsigned int > | rowStart_ |
Start index in the N_ and colIndex_ vectors, of each row. |
SparseMatrix< T >::SparseMatrix | ( | ) | [inline] |
SparseMatrix< T >::SparseMatrix | ( | unsigned int | nrows, | |
unsigned int | ncolumns | |||
) | [inline] |
void SparseMatrix< T >::addRow | ( | unsigned int | rowNum, | |
const vector< T > & | entry, | |||
const vector< unsigned int > & | colIndexArg | |||
) | [inline] |
Used to set an entire row of entries, already in sparse form. Assumes that the SparseMatrix has been suitably allocated. rowNum must be done in increasing order in successive calls.
void SparseMatrix< T >::addRow | ( | unsigned int | rowNum, | |
const vector< T > & | row | |||
) | [inline] |
Adds a row to the sparse matrix, must go strictly in row order. This is dangerous as there is a test for an empty entry ~0. For many types, ~0 may actually be a perfectly legal entry.
Referenced by SparseMsg::randomConnect(), SparseMatrix< unsigned int >::reorderColumns(), and SparseMatrix< unsigned int >::tripletFill().
void SparseMatrix< T >::clear | ( | ) | [inline] |
Referenced by SparseMsg::clear(), SparseMsg::randomConnect(), MeshCompt::setStencilSize(), and testSparseMatrix2().
T SparseMatrix< T >::get | ( | unsigned int | row, | |
unsigned int | column | |||
) | const [inline] |
Returns the entry identified by row, column. Returns T(0) if not found
Referenced by Stoich::installAndUnschedFuncRate(), printSparseMatrix(), testSparseMatrix2(), testSparseMatrixFill(), and testSparseMatrixReorder().
unsigned int SparseMatrix< T >::getColumn | ( | unsigned int | col, | |
vector< T > & | entry, | |||
vector< unsigned int > & | rowIndex | |||
) | const [inline] |
This is an unnatural lookup here, across the grain of the sparse matrix. Ideally should use copy_if, but the C++ chaps forgot it.
Referenced by SparseMsg::findOtherEnd().
unsigned int SparseMatrix< T >::getRow | ( | unsigned int | row, | |
vector< T > & | e, | |||
vector< unsigned int > & | c | |||
) | const [inline] |
getRow: vector version. Used to get an entire row of entries. Returns # entries.
unsigned int SparseMatrix< T >::getRow | ( | unsigned int | row, | |
const T ** | entry, | |||
const unsigned int ** | colIndex | |||
) | const [inline] |
Used to get an entire row of entries. Returns # entries. Passes back iterators for the row and for the column index.
Ideally I should provide a forall type function so that the user passes in their operation as a functor, and it is applied to the entire row.
Referenced by fillErefsFromMatrix(), Gsolve::fillMathDep(), Gsolve::fillMmEnzDep(), SparseMsg::findOtherEnd(), SparseMsg::firstTgt(), MeshCompt::getNeighbors(), MeshCompt::getStencilRow(), MeshCompt::innerGetStencilRate(), printSparseMatrix(), SparseMatrix< unsigned int >::reorderColumns(), testSparseMatrix(), and SparseMsg::updateAfterFill().
unsigned int SparseMatrix< T >::nColumns | ( | ) | const [inline] |
unsigned int SparseMatrix< T >::nEntries | ( | ) | const [inline] |
Referenced by SparseMsg::firstTgt(), SparseMsg::getNumEntries(), and testSparseMatrixFill().
unsigned int SparseMatrix< T >::nRows | ( | ) | const [inline] |
void SparseMatrix< T >::pairFill | ( | const vector< unsigned int > & | row, | |
const vector< unsigned int > & | col, | |||
T | value | |||
) | [inline] |
void SparseMatrix< T >::print | ( | ) | const [inline] |
Prints out the contents in matrix form
Referenced by Stoich::print().
void SparseMatrix< T >::printInternal | ( | ) | const [inline] |
Prints out the contents in internal form
void SparseMatrix< T >::printTriplet | ( | const vector< Triplet< T > > & | t | ) | [inline] |
void SparseMatrix< T >::reorderColumns | ( | const vector< unsigned int > & | colMap | ) | [inline] |
Reorder columns from the matrix based on a map of old to new column indices. newCols contains the indices of columns from the old matrix that are to be retained, in the order that they will occupy in the new matrix. It can have fewer or more indices than the original.
Referenced by testSparseMatrix(), testSparseMatrix2(), and testSparseMatrixReorder().
void SparseMatrix< T >::rowOperation | ( | unsigned int | row, | |
unary_function< T, void > & | f | |||
) | [inline] |
void SparseMatrix< T >::set | ( | unsigned int | row, | |
unsigned int | column, | |||
T | value | |||
) | [inline] |
Assigns and if necessary adds an entry in the matrix. This variant does NOT remove any existing entry.
Referenced by Stoich::installAndUnschedFuncRate(), SparseMsg::setEntry(), testSparseMatrix(), testSparseMatrix2(), and testSparseMatrixReorder().
void SparseMatrix< T >::setSize | ( | unsigned int | nrows, | |
unsigned int | ncolumns | |||
) | [inline] |
Should be called only at the start. Subsequent resizing destroys the contents.
Referenced by SparseMatrix< unsigned int >::reorderColumns(), Stoich::resizeArrays(), MeshCompt::setStencilSize(), SparseMatrix< unsigned int >::SparseMatrix(), SparseMsg::SparseMsg(), testSparseMatrix2(), testSparseMatrixReorder(), and SparseMatrix< unsigned int >::tripletFill().
void SparseMatrix< T >::transpose | ( | ) | [inline] |
Does a transpose, using as workspace a vector of size 3 N_ 0257 -> 0011122
Referenced by SparseMsg::randomConnect(), Gsolve::rebuildGssaSystem(), testSparseMatrix(), testSparseMatrix2(), and SparseMsg::transpose().
void SparseMatrix< T >::tripletFill | ( | const vector< unsigned int > & | row, | |
const vector< unsigned int > & | col, | |||
const vector< T > & | z | |||
) | [inline] |
Referenced by SparseMatrix< unsigned int >::pairFill(), and testSparseMatrixFill().
void SparseMatrix< T >::unset | ( | unsigned int | row, | |
unsigned int | column | |||
) | [inline] |
Removes specified entry.
Referenced by SparseMsg::unsetEntry().
vector< unsigned int > SparseMatrix< T >::colIndex_ [protected] |
Non-zero entries in the SparseMatrix.
Referenced by SparseMatrix< unsigned int >::addRow(), SparseMatrix< unsigned int >::clear(), SparseMatrix< unsigned int >::get(), SparseMatrix< unsigned int >::getColumn(), SparseMatrix< unsigned int >::getRow(), SparseMatrix< unsigned int >::print(), SparseMatrix< unsigned int >::printInternal(), SparseMatrix< unsigned int >::rowOperation(), SparseMatrix< unsigned int >::set(), SparseMatrix< unsigned int >::setSize(), SparseMatrix< unsigned int >::SparseMatrix(), SparseMatrix< unsigned int >::transpose(), and SparseMatrix< unsigned int >::unset().
vector< T > SparseMatrix< T >::N_ [protected] |
Referenced by SparseMatrix< unsigned int >::addRow(), SparseMatrix< unsigned int >::clear(), SparseMatrix< unsigned int >::get(), SparseMatrix< unsigned int >::getColumn(), SparseMatrix< unsigned int >::getRow(), SparseMatrix< unsigned int >::nEntries(), SparseMatrix< unsigned int >::print(), SparseMatrix< unsigned int >::printInternal(), SparseMatrix< unsigned int >::rowOperation(), SparseMatrix< unsigned int >::set(), SparseMatrix< unsigned int >::setSize(), SparseMatrix< unsigned int >::SparseMatrix(), SparseMatrix< unsigned int >::transpose(), and SparseMatrix< unsigned int >::unset().
unsigned int SparseMatrix< T >::ncolumns_ [protected] |
Referenced by SparseMatrix< unsigned int >::addRow(), SparseMatrix< unsigned int >::get(), SparseMatrix< unsigned int >::getRow(), SparseMatrix< unsigned int >::nColumns(), SparseMatrix< unsigned int >::print(), SparseMatrix< unsigned int >::reorderColumns(), SparseMatrix< unsigned int >::set(), SparseMatrix< unsigned int >::setSize(), SparseMatrix< unsigned int >::transpose(), and SparseMatrix< unsigned int >::unset().
unsigned int SparseMatrix< T >::nrows_ [protected] |
Referenced by SparseMatrix< unsigned int >::addRow(), SparseMatrix< unsigned int >::clear(), SparseMatrix< unsigned int >::get(), SparseMatrix< unsigned int >::getRow(), SparseMatrix< unsigned int >::nRows(), SparseMatrix< unsigned int >::print(), SparseMatrix< unsigned int >::printInternal(), SparseMatrix< unsigned int >::reorderColumns(), SparseMatrix< unsigned int >::rowOperation(), SparseMatrix< unsigned int >::set(), SparseMatrix< unsigned int >::setSize(), SparseMatrix< unsigned int >::transpose(), and SparseMatrix< unsigned int >::unset().
vector< unsigned int > SparseMatrix< T >::rowStart_ [protected] |
Start index in the N_ and colIndex_ vectors, of each row.
Referenced by SparseMatrix< unsigned int >::addRow(), SparseMatrix< unsigned int >::clear(), SparseMatrix< unsigned int >::get(), SparseMatrix< unsigned int >::getColumn(), SparseMatrix< unsigned int >::getRow(), SparseMatrix< unsigned int >::print(), SparseMatrix< unsigned int >::printInternal(), SparseMatrix< unsigned int >::rowOperation(), SparseMatrix< unsigned int >::set(), SparseMatrix< unsigned int >::setSize(), SparseMatrix< unsigned int >::transpose(), and SparseMatrix< unsigned int >::unset().