Class SparseDoubleMatrix<R,C>
- java.lang.Object
-
- ubic.basecode.dataStructure.matrix.AbstractMatrix<R,C,Double>
-
- ubic.basecode.dataStructure.matrix.DoubleMatrix<R,C>
-
- ubic.basecode.dataStructure.matrix.SparseDoubleMatrix<R,C>
-
- All Implemented Interfaces:
Serializable,Matrix2D<R,C,Double>,PrimitiveMatrix<R,C,Double>
public class SparseDoubleMatrix<R,C> extends DoubleMatrix<R,C>
A sparse matrix that knows about row and column names.- Author:
- Paul 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 SparseDoubleMatrix(double[][] T)SparseDoubleMatrix(int rows, int cols)SparseDoubleMatrix(int rows, int cols, int initialCapacity, double minLoadFactor, double maxLoadFactor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double[][]asArray()intcardinality()intcolumns()Get the number of columns the matrix has.DoubleMatrix<R,C>copy()Create a deep copy of thisdoubleget(int row, int column)Double[]getColObj(int col)DoubleMatrix<R,C>getColRange(int startCol, int endCol)double[]getColumn(int col)DoublegetObject(int row, int col)double[]getRow(int row)Return a reference to a specific row.cern.colt.list.DoubleArrayListgetRowArrayList(int i)double[]getRowByName(R s)Double[]getRowObj(int row)DoubleMatrix<R,C>getRowRange(int startRow, int endRow)booleanisMissing(int i, int j)Check if the value at a given index is missing.introws()Get the number of rows the matrix hasvoidset(int row, int column, Double value)intsize()DoubleMatrix<R,C>subsetColumns(List<C> columns)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()voidtrimToSize()cern.colt.matrix.DoubleMatrix1DviewColumn(int column)cern.colt.matrix.DoubleMatrix1DviewRow(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 Detail
-
SparseDoubleMatrix
public SparseDoubleMatrix(double[][] T)
- Parameters:
T- double[][]
-
SparseDoubleMatrix
public SparseDoubleMatrix(int rows, int cols)- Parameters:
rows- intcols- int
-
SparseDoubleMatrix
public SparseDoubleMatrix(int rows, int cols, int initialCapacity, double minLoadFactor, double maxLoadFactor)- Parameters:
rows- intcols- intinitlalCapacity- intminLoadFactor- doublemaxLoadFactor- double
-
-
Method Detail
-
asArray
public double[][] asArray()
- Specified by:
asArrayin classDoubleMatrix<R,C>- Returns:
- double[][]
-
cardinality
public int cardinality()
- Returns:
-
columns
public int columns()
Description copied from interface:Matrix2DGet the number of columns the matrix has.- Returns:
-
copy
public DoubleMatrix<R,C> copy()
Description copied from class:DoubleMatrixCreate a deep copy of this- Specified by:
copyin classDoubleMatrix<R,C>- Returns:
- a deep copy of this
-
get
public double get(int row, int column)- Specified by:
getin 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:
getColRangein 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:
getColumnin classDoubleMatrix<R,C>
-
getObject
public Double getObject(int row, int col)
- Returns:
-
getRow
public double[] getRow(int row)
Return a reference to a specific row.- Specified by:
getRowin classDoubleMatrix<R,C>- Parameters:
row- int- Returns:
- double[]
-
getRowArrayList
public cern.colt.list.DoubleArrayList getRowArrayList(int i)
- Specified by:
getRowArrayListin classDoubleMatrix<R,C>
-
getRowByName
public double[] getRowByName(R s)
- Overrides:
getRowByNamein classDoubleMatrix<R,C>- Parameters:
s- String- Returns:
- double[]
-
getRowObj
public Double[] getRowObj(int row)
- Returns:
-
getRowRange
public DoubleMatrix<R,C> getRowRange(int startRow, int endRow)
- Specified by:
getRowRangein classDoubleMatrix<R,C>- Parameters:
startRow- inclusive, numbered from zeroendRow- inclusive- Returns:
-
isMissing
public boolean isMissing(int i, int j)Description copied from interface:Matrix2DCheck 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:Matrix2DGet the number of rows the matrix has- Returns:
-
set
public void set(int row, int column, Double value)
-
size
public int size()
- Specified by:
sizein classAbstractMatrix<R,C,Double>- Returns:
-
subsetColumns
public DoubleMatrix<R,C> subsetColumns(List<C> columns)
Description copied from class:DoubleMatrixCreate a copy of this matrix with only the selected columns, in the selected order.- Specified by:
subsetColumnsin classDoubleMatrix<R,C>- Returns:
-
subsetRows
public DoubleMatrix<R,C> subsetRows(List<R> rowNames)
Description copied from class:DoubleMatrixCreate a copy of this matrix with only the selected rows, in the selected order.- Specified by:
subsetRowsin classDoubleMatrix<R,C>- Returns:
-
transpose
public DoubleMatrix<C,R> transpose()
- Specified by:
transposein classDoubleMatrix<R,C>
-
trimToSize
public void trimToSize()
-
viewColumn
public cern.colt.matrix.DoubleMatrix1D viewColumn(int column)
- Specified by:
viewColumnin classDoubleMatrix<R,C>- Parameters:
column-- Returns:
-
viewRow
public cern.colt.matrix.DoubleMatrix1D viewRow(int row)
- Specified by:
viewRowin classDoubleMatrix<R,C>- Parameters:
row-- Returns:
-
-