|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mymedialite.datatype.SparseMatrix<T>
public class SparseMatrix<T>
Class for storing sparse matrices. The data is stored in row-major mode. Indexes are zero-based. T the matrix element type, must have a default constructor/value
Field Summary | |
---|---|
protected java.util.List<java.util.HashMap<java.lang.Integer,T>> |
row_list
List that stores the rows of the matrix. |
Constructor Summary | |
---|---|
SparseMatrix(int num_rows,
int num_cols)
Create a sparse matrix with a given number of rows. |
|
SparseMatrix(int num_rows,
int num_cols,
T d)
Create a sparse matrix with a given number of rows. |
Method Summary | |
---|---|
IMatrix<T> |
createMatrix(int num_rows,
int num_columns)
Create a matrix with a given number of rows and columns. |
java.util.HashMap<java.lang.Integer,T> |
get(int x)
Get a row of the matrix. |
T |
get(int x,
int y)
Access the elements of the sparse matrix. |
void |
grow(int num_rows,
int num_cols)
Grows the matrix to the requested size, if necessary. |
boolean |
isSymmetric()
True if the matrix is symmetric, false otherwise. |
java.util.List<Pair<java.lang.Integer,java.lang.Integer>> |
nonEmptyEntryIDs()
The row and column IDs of non-empty entries in the matrix. |
java.util.HashMap<java.lang.Integer,java.util.HashMap<java.lang.Integer,T>> |
nonEmptyRows()
The non-empty rows of the matrix (the ones that contain at least one non-zero entry), with their IDs . |
int |
numberOfColumns()
Get the number of columns of the matrix. |
int |
numberOfNonEmptyEntries()
The number of non-empty entries in the matrix. |
int |
numberOfRows()
Get the number of rows of the matrix. |
void |
set(int x,
int y,
T value)
Set the value at (i,j) |
IMatrix<T> |
transpose()
Get the transpose of the matrix, i.e. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.List<java.util.HashMap<java.lang.Integer,T>> row_list
Constructor Detail |
---|
public SparseMatrix(int num_rows, int num_cols)
num_rows
- the number of rowsnum_cols
- the number of columnspublic SparseMatrix(int num_rows, int num_cols, T d)
num_rows
- the number of rowsnum_cols
- the number of columnsd
- the default value for elementsMethod Detail |
---|
public IMatrix<T> createMatrix(int num_rows, int num_columns)
IMatrix
createMatrix
in interface IMatrix<T>
num_rows
- the number of rowsnum_columns
- the number of columns
public boolean isSymmetric()
IMatrix
isSymmetric
in interface IMatrix<T>
public int numberOfRows()
IMatrix
numberOfRows
in interface IMatrix<T>
public int numberOfColumns()
IMatrix
numberOfColumns
in interface IMatrix<T>
public IMatrix<T> transpose()
IMatrix
transpose
in interface IMatrix<T>
public java.util.HashMap<java.lang.Integer,T> get(int x)
x
- the row IDpublic T get(int x, int y)
get
in interface IMatrix<T>
x
- the row IDy
- the column ID
public void set(int x, int y, T value)
IMatrix
set
in interface IMatrix<T>
x
- the row IDy
- the column IDvalue
- the valuepublic java.util.HashMap<java.lang.Integer,java.util.HashMap<java.lang.Integer,T>> nonEmptyRows()
public java.util.List<Pair<java.lang.Integer,java.lang.Integer>> nonEmptyEntryIDs()
public int numberOfNonEmptyEntries()
public void grow(int num_rows, int num_cols)
IMatrix
grow
in interface IMatrix<T>
num_rows
- the minimum number of rowsnum_cols
- the minimum number of columns
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |