|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mymedialite.datatype.SparseBooleanMatrixStatic
public class SparseBooleanMatrixStatic
Sparse representation of a boolean matrix, using binary search (memory efficient). This data structure is static, which means that rows are represented as int arrays, a can be assigned, but not modified. Fast row-wise access is possible. Indexes are zero-based.
Field Summary | |
---|---|
protected java.util.List<int[]> |
row_list
Internal representation of this data: list of rows. |
Constructor Summary | |
---|---|
SparseBooleanMatrixStatic()
|
Method Summary | |
---|---|
IMatrix<java.lang.Boolean> |
createMatrix(int x,
int y)
Create a matrix with a given number of rows and columns. |
IntSet |
get(int x)
Get a row of the matrix. |
java.lang.Boolean |
get(int x,
int y)
Get the value at (i,j) |
IntList |
getEntriesByColumn(int column_id)
Takes O(N log(M)) worst-case time, where N is the number of rows and M is the number of columns. |
IntList |
getEntriesByRow(int row_id)
Get all true entries (column IDs) of a row. |
java.util.List<Pair<java.lang.Integer,int[]>> |
getNonEmptyRows()
The non-empty rows of the matrix (the ones that contain at least one true entry), with their IDs. |
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. |
IntCollection |
nonEmptyColumnIDs()
The IDs of the non-empty columns in the matrix (the ones that contain at least one true entry). |
IntCollection |
nonEmptyRowIDs()
The IDs of the non-empty rows in the matrix (the ones that contain at least one true entry). |
int |
numberOfColumns()
The number of columns in the matrix. |
int |
numberOfEntries()
The number of (true) entries. |
int |
numberOfRows()
The number of rows in the matrix. |
int |
numEntriesByColumn(int column_id)
Get all the number of entries in a column. |
int |
numEntriesByRow(int row_id)
Get all the number of entries in a row. |
int |
overlap(IBooleanMatrix s)
Get the overlap of two matrices, i.e. |
void |
set(int x,
int y,
java.lang.Boolean value)
Set the value at (i,j) |
void |
setRow(int x,
int[] row)
|
IMatrix<java.lang.Boolean> |
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<int[]> row_list
Constructor Detail |
---|
public SparseBooleanMatrixStatic()
Method Detail |
---|
public java.lang.Boolean get(int x, int y)
IMatrix
get
in interface IMatrix<java.lang.Boolean>
x
- the row IDy
- the column ID
public void set(int x, int y, java.lang.Boolean value)
IMatrix
set
in interface IMatrix<java.lang.Boolean>
x
- the row IDy
- the column IDvalue
- the valuepublic IntSet get(int x)
IBooleanMatrix
get
in interface IBooleanMatrix
x
- the row IDpublic void setRow(int x, int[] row)
public boolean isSymmetric()
IMatrix
isSymmetric
in interface IMatrix<java.lang.Boolean>
public IMatrix<java.lang.Boolean> createMatrix(int x, int y)
IMatrix
createMatrix
in interface IMatrix<java.lang.Boolean>
x
- the number of rowsy
- the number of columns
public IntList getEntriesByRow(int row_id)
IBooleanMatrix
getEntriesByRow
in interface IBooleanMatrix
row_id
- the row ID
public int numEntriesByRow(int row_id)
IBooleanMatrix
numEntriesByRow
in interface IBooleanMatrix
row_id
- the row ID
public IntList getEntriesByColumn(int column_id)
getEntriesByColumn
in interface IBooleanMatrix
column_id
- the column ID
public int numEntriesByColumn(int column_id)
IBooleanMatrix
numEntriesByColumn
in interface IBooleanMatrix
column_id
- the column ID
public java.util.List<Pair<java.lang.Integer,int[]>> getNonEmptyRows()
public IntCollection nonEmptyRowIDs()
IBooleanMatrix
nonEmptyRowIDs
in interface IBooleanMatrix
public IntCollection nonEmptyColumnIDs()
IBooleanMatrix
nonEmptyColumnIDs
in interface IBooleanMatrix
public int numberOfRows()
numberOfRows
in interface IMatrix<java.lang.Boolean>
public int numberOfColumns()
numberOfColumns
in interface IMatrix<java.lang.Boolean>
public int numberOfEntries()
numberOfEntries
in interface IBooleanMatrix
public void grow(int num_rows, int num_cols)
IMatrix
grow
in interface IMatrix<java.lang.Boolean>
num_rows
- the minimum number of rowsnum_cols
- the minimum number of columnspublic IMatrix<java.lang.Boolean> transpose()
transpose
in interface IMatrix<java.lang.Boolean>
public int overlap(IBooleanMatrix s)
IBooleanMatrix
overlap
in interface IBooleanMatrix
s
- the
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |