Class SparseRaggedDoubleMatrix<R,C>
- java.lang.Object
-
- ubic.basecode.dataStructure.matrix.AbstractMatrix<R,C,Double>
-
- ubic.basecode.dataStructure.matrix.DoubleMatrix<R,C>
-
- ubic.basecode.dataStructure.matrix.SparseRaggedDoubleMatrix<R,C>
-
- All Implemented Interfaces:
Serializable
,Matrix2D<R,C,Double>
,PrimitiveMatrix<R,C,Double>
public class SparseRaggedDoubleMatrix<R,C> extends DoubleMatrix<R,C>
A sparse matrix class where the rows are ragged and compressed.- Author:
- pavlidis
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class ubic.basecode.dataStructure.matrix.AbstractMatrix
MAX_ROWS_TO_PRINT
-
-
Constructor Summary
Constructors Constructor Description SparseRaggedDoubleMatrix()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRow(R name, cern.colt.list.IntArrayList indexes, cern.colt.list.DoubleArrayList values)
void
addRow(R name, cern.colt.matrix.DoubleMatrix1D matrix1D)
double[][]
asArray()
int
columns()
Returns the size of the widest row.DoubleMatrix<R,C>
copy()
Create a deep copy of thisdouble
get(int i, int j)
Double[]
getColObj(int col)
DoubleMatrix<R,C>
getColRange(int startCol, int endCol)
double[]
getColumn(int col)
Double
getObject(int row, int col)
double[]
getRow(int i)
cern.colt.list.DoubleArrayList
getRowArrayList(int row)
This gives just the list of values in the row - make sure this is what you want.Double[]
getRowObj(int i)
DoubleMatrix<R,C>
getRowRange(int startRow, int endRow)
boolean
isMissing(int i, int j)
(non-Javadoc) Note that in a sparse matrix, zero values are considered "missing"!int
rows()
Get the number of rows the matrix hasvoid
set(int i, int j, Double d)
int
size()
DoubleMatrix<R,C>
subsetColumns(List<C> c)
Create a copy of this matrix with only the selected columns, in the selected order.DoubleMatrix<R,C>
subsetRows(List<R> rowNames)
Create a copy of this matrix with only the selected rows, in the selected order.DoubleMatrix<C,R>
transpose()
cern.colt.matrix.DoubleMatrix1D
viewColumn(int column)
cern.colt.matrix.DoubleMatrix1D
viewRow(int i)
-
Methods inherited from class ubic.basecode.dataStructure.matrix.DoubleMatrix
getByKeys, getColumnByName, getEntry, getRawMatrix, getRowByName, 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
-
-
-
-
Method Detail
-
addRow
public void addRow(R name, cern.colt.matrix.DoubleMatrix1D matrix1D)
- Parameters:
matrix1D
-
-
addRow
public void addRow(R name, cern.colt.list.IntArrayList indexes, cern.colt.list.DoubleArrayList values)
- Parameters:
name
-indexes
-values
-
-
asArray
public double[][] asArray()
- Specified by:
asArray
in classDoubleMatrix<R,C>
- Returns:
- double[][]
-
columns
public int columns()
Returns the size of the widest row.- Returns:
- int
- See Also:
basecode.dataStructure.matrix.Matrix2D#columns()
-
copy
public DoubleMatrix<R,C> 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 i, int j)
- Specified by:
get
in classDoubleMatrix<R,C>
- Parameters:
row
-column
-- Returns:
-
getColObj
public Double[] getColObj(int col)
- Returns:
-
getColRange
public DoubleMatrix<R,C> getColRange(int startCol, int endCol)
- 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
public Double getObject(int row, int col)
- Returns:
-
getRow
public double[] getRow(int i)
- Specified by:
getRow
in classDoubleMatrix<R,C>
-
getRowArrayList
public cern.colt.list.DoubleArrayList getRowArrayList(int row)
This gives just the list of values in the row - make sure this is what you want. It does not include the zero values.- Specified by:
getRowArrayList
in classDoubleMatrix<R,C>
- Parameters:
row
-- Returns:
-
getRowObj
public Double[] getRowObj(int i)
- Returns:
-
getRowRange
public DoubleMatrix<R,C> getRowRange(int startRow, int endRow)
- Specified by:
getRowRange
in classDoubleMatrix<R,C>
- Parameters:
startRow
- inclusive, numbered from zeroendRow
- inclusive- Returns:
-
isMissing
public boolean isMissing(int i, int j)
(non-Javadoc) Note that in a sparse matrix, zero values are considered "missing"!- Parameters:
i
- rowj
- column- Returns:
- true if the value is missing, false otherwise.
- See Also:
basecode.dataStructure.matrix.Matrix2D#isMissing(int, int)
-
rows
public int rows()
Description copied from interface:Matrix2D
Get the number of rows the matrix has- Returns:
- int
-
set
public void set(int i, int j, Double d)
-
size
public int size()
- Specified by:
size
in classAbstractMatrix<R,C,Double>
-
subsetColumns
public DoubleMatrix<R,C> subsetColumns(List<C> c)
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>
- Returns:
-
subsetRows
public DoubleMatrix<R,C> subsetRows(List<R> rowNames)
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>
- Returns:
-
transpose
public DoubleMatrix<C,R> transpose()
- Specified by:
transpose
in classDoubleMatrix<R,C>
-
viewColumn
public cern.colt.matrix.DoubleMatrix1D viewColumn(int column)
- Specified by:
viewColumn
in classDoubleMatrix<R,C>
-
viewRow
public cern.colt.matrix.DoubleMatrix1D viewRow(int i)
- Specified by:
viewRow
in classDoubleMatrix<R,C>
- Returns:
-
-