![]() |
AuD
Lecture 'Algorithmen und Datenstrukturen' (code examples)
|
Simple sparse matrix data structure. More...
Public Member Functions | |
SparseMatrix () | |
create empty matrix More... | |
SparseMatrix (boolean symmetric) | |
create empty matrix (see isSymmetricMatrix ) More... | |
SparseMatrix (SparseMatrix< T > other) | |
copy constructor More... | |
SparseMatrix (SparseMatrix< T > other, boolean transpose) | |
copy constructor More... | |
boolean | isSymmetricMatrix () |
Was matrix created explicitly as symmetric matrix? More... | |
int | getNumRows () |
computed from maximum column index [O(1)] More... | |
int | getMinRowIndex () |
get minimum column index [O(1)] More... | |
T | set (int i, int j, T data) |
Set entry (i,j) to data [O(log(nnz ))]. More... | |
Vector< T > | getRowEntries (int i) |
get entries in row i as array More... | |
int[] | getRowColumnIndices (int i) |
get column indices in row i as array More... | |
int | rowDegree (int i) |
get number of nonzero entries in row i More... | |
SparseMatrixCS< T > | getTransposed () |
get transposed matrix More... | |
![]() | |
SparseMatrixCS () | |
create empty matrix with "arbitrarily growing" dimensions More... | |
SparseMatrixCS (SparseMatrixCS< T > other) | |
copy constructor More... | |
int | nnz () |
get number of nonzero entries More... | |
int | getNumRows () |
computes from maximium row index [O(nnz )] More... | |
int | getMinRowIndex () |
get minimum row index [O(nnz )] More... | |
int | getNumColumns () |
computed from maximum column index [O(1)] More... | |
int | getMinColumnIndex () |
get minimum row index [O(1)] More... | |
T | get (int i, int j) |
get entry (i,j) [O(log(nnz ))] More... | |
T | set (int i, int j, T data) |
Set entry (i,j) to data [O(log(nnz ))]. More... | |
Vector< T > | getColumnEntries (int j) |
get entries in column j as array More... | |
int[] | getColumnRowIndices (int j) |
get row indices in column j as array More... | |
int | columnDegree (int j) |
get number of nonzero entries in column j More... | |
SparseMatrixCS< T > | getTransposed () |
get transposed matrix More... | |
SparseMatrixCS< Integer > | spones () |
Get nonzero pattern. More... | |
int[] | getRowIndices () |
Get array of row indices. More... | |
int[] | getColumnIndices () |
Get array of column indices in same order as for getRowIndices . More... | |
T[] | getValues () |
Get array of values in same order as for getRowIndices . More... | |
String | toString () |
String | toLaTeX (String name) |
get LaTeX code for displaying (TikZ) matrix More... | |
File | renderSpySVG (File svgfile, Colormap< T > colormap) |
String | spyTikZ (boolean rulers, Colormap< T > colormap) |
SVGViewer | spy (String caption, Colormap< T > colormap) |
render spy plot in new window More... | |
Static Public Member Functions | |
static void | main (String args[]) |
Example and test: show aud.util.ColormapCount color map. More... | |
Protected Attributes | |
SparseMatrixCS< T > | rmat_ = null |
Store transposed. More... | |
![]() | |
TreeMap< Coordinate, T > | mat_ |
Simple sparse matrix data structure.
Sparse matrix with efficient access to column and row vectors based on SparseMatrixCS
: the implementation essentially stores the transposed SparseMatrixCS
for row access.
No extra matrix is stored if the matrix is declared symmetric at construction. However, to keep the code simple, the upper and lower triangular matrices are stored in this case.
Definition at line 19 of file SparseMatrix.java.
aud.graph.matrix.SparseMatrix< T >.SparseMatrix | ( | boolean | symmetric | ) |
create empty matrix (see isSymmetricMatrix
)
Definition at line 37 of file SparseMatrix.java.
References aud.graph.matrix.SparseMatrix< T >.rmat_.
aud.graph.matrix.SparseMatrix< T >.SparseMatrix | ( | SparseMatrix< T > | other | ) |
copy constructor
Definition at line 42 of file SparseMatrix.java.
References aud.graph.matrix.SparseMatrix< T >.isSymmetricMatrix(), and aud.graph.matrix.SparseMatrix< T >.rmat_.
aud.graph.matrix.SparseMatrix< T >.SparseMatrix | ( | SparseMatrix< T > | other, |
boolean | transpose | ||
) |
copy constructor
Definition at line 48 of file SparseMatrix.java.
References aud.graph.matrix.SparseMatrix< T >.isSymmetricMatrix(), and aud.graph.matrix.SparseMatrix< T >.rmat_.
int aud.graph.matrix.SparseMatrix< T >.getMinRowIndex | ( | ) |
get minimum column index [O(1)]
Reimplemented from aud.graph.matrix.SparseMatrixCS< T >.
Definition at line 65 of file SparseMatrix.java.
References aud.graph.matrix.SparseMatrix< T >.rmat_.
Referenced by aud.test.SparseMatrixTest.testMatrix(), and aud.test.SparseMatrixTest.testSymmatrixMatrix().
int aud.graph.matrix.SparseMatrix< T >.getNumRows | ( | ) |
computed from maximum column index [O(1)]
Reimplemented from aud.graph.matrix.SparseMatrixCS< T >.
Definition at line 61 of file SparseMatrix.java.
References aud.graph.matrix.SparseMatrix< T >.rmat_.
Referenced by aud.test.SparseMatrixTest.testMatrix(), and aud.test.SparseMatrixTest.testSymmatrixMatrix().
int[] aud.graph.matrix.SparseMatrix< T >.getRowColumnIndices | ( | int | i | ) |
get column indices in row i as array
IndexOutOfBoundsException | on error (non-positive index) |
Definition at line 87 of file SparseMatrix.java.
References aud.graph.matrix.SparseMatrix< T >.rmat_.
Referenced by aud.graph.AdjacencyMatrix< Edge >.clearColumnAndRow(), aud.test.SparseMatrixTest.testMatrix(), and aud.test.SparseMatrixTest.testSymmatrixMatrix().
Vector< T > aud.graph.matrix.SparseMatrix< T >.getRowEntries | ( | int | i | ) |
get entries in row i as array
IndexOutOfBoundsException | on error (non-positive index) |
Definition at line 80 of file SparseMatrix.java.
References aud.graph.matrix.SparseMatrix< T >.rmat_.
Referenced by aud.graph.matrix.SparseMatrix< T >.rowDegree(), aud.test.SparseMatrixTest.testMatrix(), and aud.test.SparseMatrixTest.testSymmatrixMatrix().
SparseMatrixCS< T > aud.graph.matrix.SparseMatrix< T >.getTransposed | ( | ) |
get transposed matrix
Reimplemented from aud.graph.matrix.SparseMatrixCS< T >.
Definition at line 97 of file SparseMatrix.java.
References aud.graph.matrix.SparseMatrix< T >.rmat_.
boolean aud.graph.matrix.SparseMatrix< T >.isSymmetricMatrix | ( | ) |
Was matrix created explicitly as symmetric matrix?
Definition at line 58 of file SparseMatrix.java.
References aud.graph.matrix.SparseMatrix< T >.rmat_.
Referenced by aud.graph.AdjacencyMatrix< Edge >.clearColumnAndRow(), aud.graph.AdjacencyMatrix< Edge >.iterator(), aud.graph.matrix.SparseMatrix< T >.SparseMatrix(), aud.test.AdjacencyMatrixTest.testMatrix(), aud.test.SparseMatrixTest.testMatrix(), aud.test.AdjacencyMatrixTest.testSymmatrixMatrix(), and aud.test.SparseMatrixTest.testSymmatrixMatrix().
|
static |
Example and test: show aud.util.ColormapCount
color map.
Definition at line 106 of file SparseMatrix.java.
References aud.graph.matrix.SparseMatrix< T >.set(), aud.graph.matrix.SparseMatrixCS< T >.spy(), and aud.graph.matrix.SparseMatrixCS< T >.spyTikZ().
int aud.graph.matrix.SparseMatrix< T >.rowDegree | ( | int | i | ) |
get number of nonzero entries in row i
IndexOutOfBoundsException | on error (non-positive index) |
getRowEntries
Definition at line 95 of file SparseMatrix.java.
References aud.graph.matrix.SparseMatrix< T >.getRowEntries().
Referenced by aud.test.SparseMatrixTest.testMatrix().
T aud.graph.matrix.SparseMatrix< T >.set | ( | int | i, |
int | j, | ||
T | data | ||
) |
Set entry (i,j) to data [O(log(nnz
))].
i | row index (>=0) |
j | column index (>=0) |
data | new value; if data==null , then the entry will be erased from the matrix. |
IndexOutOfBoundsException | on error (non-positive indices)a |
null
Reimplemented from aud.graph.matrix.SparseMatrixCS< T >.
Definition at line 69 of file SparseMatrix.java.
References aud.graph.matrix.SparseMatrix< T >.rmat_.
Referenced by aud.graph.matrix.SparseMatrix< T >.main(), aud.test.AdjacencyMatrixTest.testMatrix(), aud.test.SparseMatrixTest.testMatrix(), aud.test.AdjacencyMatrixTest.testSymmatrixMatrix(), and aud.test.SparseMatrixTest.testSymmatrixMatrix().
|
protected |
Store transposed.
rmat_
stores the transposed matrix to enable efficient access to rows. For symmetric matrices (isSymmetricMatrix
, rmat_
is a reference to
! (This convention keeps the implementation simple but doubles the number of entries to be stored.)
this
Definition at line 29 of file SparseMatrix.java.
Referenced by aud.graph.matrix.SparseMatrix< T >.getMinRowIndex(), aud.graph.matrix.SparseMatrix< T >.getNumRows(), aud.graph.matrix.SparseMatrix< T >.getRowColumnIndices(), aud.graph.matrix.SparseMatrix< T >.getRowEntries(), aud.graph.matrix.SparseMatrix< T >.getTransposed(), aud.graph.matrix.SparseMatrix< T >.isSymmetricMatrix(), aud.graph.matrix.SparseMatrix< T >.set(), and aud.graph.matrix.SparseMatrix< T >.SparseMatrix().