Class CompressedSparseDoubleMatrix<R,C>
java.lang.Object
ubic.basecode.dataStructure.matrix.AbstractMatrix<R,C,Double>
ubic.basecode.dataStructure.matrix.DoubleMatrix<R,C>
ubic.basecode.dataStructure.matrix.CompressedSparseDoubleMatrix<R,C>
- All Implemented Interfaces:
Serializable
,Matrix2D<R,
,C, Double> PrimitiveMatrix<R,
C, Double>
Supports sparse matrices (where sparse means most values are zero, not that they are missing).
- Author:
- xwan
- See Also:
-
Field Summary
Fields inherited from class ubic.basecode.dataStructure.matrix.AbstractMatrix
MAX_ROWS_TO_PRINT
-
Constructor Summary
ConstructorsConstructorDescriptionCompressedSparseDoubleMatrix
(double[][] mat) CompressedSparseDoubleMatrix
(int rows, int cols) -
Method Summary
Modifier and TypeMethodDescriptiondouble[][]
asArray()
int
int
columns()
Get the number of columns the matrix has.copy()
Create a deep copy of thisdouble
get
(int row, int column) Double[]
getColObj
(int col) getColRange
(int startCol, int endCol) double[]
getColumn
(int col) getObject
(int row, int col) double[]
getRow
(int row) Return a reference to a specific row.getRowArrayList
(int i) double[]
getRowByName
(R s) Double[]
getRowObj
(int row) getRowRange
(int startRow, int endRow) boolean
isMissing
(int i, int j) Check if the value at a given index is missing.int
rows()
Get the number of rows the matrix hasvoid
int
size()
subsetColumns
(List<C> columns) Create a copy of this matrix with only the selected columns, in the selected order.subsetRows
(List<R> rowNames) Create a copy of this matrix with only the selected rows, in the selected order.void
viewColumn
(int column) viewRow
(int row) Methods inherited from class ubic.basecode.dataStructure.matrix.DoubleMatrix
getByKeys, getColumnByName, getEntry, getRawMatrix, setByKeys, sortByColumnAbsoluteValues, toString
Methods inherited from class ubic.basecode.dataStructure.matrix.AbstractMatrix
addColumnName, addRowName, asDoubles, assign, checkColRange, checkRowRange, containsColumnName, containsRowName, getColIndexByName, getColName, getColNames, getRowIndexByName, getRowName, getRowNameMapIterator, getRowNames, hasColNames, hasMissingValues, hasRow, hasRowNames, numMissing, setColumnName, setColumnNames, setRowName, setRowNames
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface ubic.basecode.dataStructure.matrix.Matrix2D
addColumnName, asDoubles, assign, containsColumnName, containsRowName, getColIndexByName, getColName, getColNames, getRowIndexByName, getRowName, getRowNameMapIterator, getRowNames, hasColNames, hasRow, hasRowNames, numMissing, setColumnName, setColumnNames, setRowName, setRowNames
-
Constructor Details
-
CompressedSparseDoubleMatrix
public CompressedSparseDoubleMatrix(double[][] mat) - Parameters:
mat
-
-
CompressedSparseDoubleMatrix
public CompressedSparseDoubleMatrix(int rows, int cols) - Parameters:
rows
- intcols
- int
-
-
Method Details
-
asArray
public double[][] asArray()- Specified by:
asArray
in classDoubleMatrix<R,
C> - Returns:
- double[][]
-
cardinality
public int cardinality()- Returns:
-
columns
public int columns()Description copied from interface:Matrix2D
Get the number of columns the matrix has.- Returns:
-
copy
Description copied from class:DoubleMatrix
Create a deep copy of this- Specified by:
copy
in classDoubleMatrix<R,
C> - Returns:
- a deep copy of this
-
get
public double get(int row, int column) - Specified by:
get
in classDoubleMatrix<R,
C> - Parameters:
row
-column
-- Returns:
-
getColObj
- Parameters:
col
-- Returns:
-
getColRange
- Specified by:
getColRange
in classDoubleMatrix<R,
C> - Parameters:
startCol
- inclusive, numbered from zeroendCol
- inclusive, numbered from zero- Returns:
- new matrix with just the requested range of columns from this
-
getColumn
public double[] getColumn(int col) - Specified by:
getColumn
in classDoubleMatrix<R,
C>
-
getObject
- Parameters:
row
-col
-- Returns:
-
getRow
public double[] getRow(int row) Return a reference to a specific row.- Specified by:
getRow
in classDoubleMatrix<R,
C> - Parameters:
row
- int- Returns:
- double[]
-
getRowArrayList
- Specified by:
getRowArrayList
in classDoubleMatrix<R,
C>
-
getRowByName
- Overrides:
getRowByName
in classDoubleMatrix<R,
C> - Parameters:
s
- String- Returns:
- double[]
-
getRowObj
- Parameters:
row
-- Returns:
-
getRowRange
- Specified by:
getRowRange
in classDoubleMatrix<R,
C> - Parameters:
startRow
- inclusive, numbered from zeroendRow
- inclusive- Returns:
-
isMissing
public boolean isMissing(int i, int j) Description copied from interface:Matrix2D
Check if the value at a given index is missing.- Parameters:
i
- rowj
- column- Returns:
- true if the value is missing, false otherwise.
-
rows
public int rows()Description copied from interface:Matrix2D
Get the number of rows the matrix has- Returns:
- int
-
set
- Parameters:
row
-column
-value
-
-
size
public int size()- Specified by:
size
in classAbstractMatrix<R,
C, Double> - Returns:
-
subsetColumns
Description copied from class:DoubleMatrix
Create a copy of this matrix with only the selected columns, in the selected order.- Specified by:
subsetColumns
in classDoubleMatrix<R,
C> - Parameters:
columns
-- Returns:
-
subsetRows
Description copied from class:DoubleMatrix
Create a copy of this matrix with only the selected rows, in the selected order.- Specified by:
subsetRows
in classDoubleMatrix<R,
C> - Parameters:
rowNames
-- Returns:
-
transpose
- Specified by:
transpose
in classDoubleMatrix<R,
C>
-
trimToSize
public void trimToSize() -
viewColumn
- Specified by:
viewColumn
in classDoubleMatrix<R,
C> - Parameters:
column
-- Returns:
-
viewRow
- Specified by:
viewRow
in classDoubleMatrix<R,
C> - Parameters:
row
-- Returns:
-