Class AbstractMatrix<R,C,V>
- java.lang.Object
-
- ubic.basecode.dataStructure.matrix.AbstractMatrix<R,C,V>
-
- All Implemented Interfaces:
Serializable,Matrix2D<R,C,V>
- Direct Known Subclasses:
CompressedBitMatrix,DoubleMatrix,IntegerMatrix,ObjectMatrixImpl,StringMatrix
public abstract class AbstractMatrix<R,C,V> extends Object implements Matrix2D<R,C,V>, Serializable
- Author:
- pavlidis
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static intMAX_ROWS_TO_PRINT
-
Constructor Summary
Constructors Constructor Description AbstractMatrix()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddColumnName(C s)Add a column name when we don't care what the index will be.voidaddRowName(R s)Add a row name when we don't care what the index will be.double[][]asDoubles()Attempt to coerce the entries into doubles.voidassign(V value)Set all values in the matrix to the given value.protected voidcheckColRange(int startCol, int endCol)protected voidcheckRowRange(int startRow, int endRow)booleancontainsColumnName(C columnName)booleancontainsRowName(R rowName)intgetColIndexByName(C columnKey)Get the index of a column by name.CgetColName(int i)Gte the column name for an index.List<C>getColNames()intgetRowIndexByName(R s)Get the index of a row by name..RgetRowName(int i)Get the row name for an indexIterator<R>getRowNameMapIterator()List<R>getRowNames()booleanhasColNames()Check if this matrix has a valid set of column names.booleanhasMissingValues()Test for the presence of missing values (null, or in the case of numbers, NaN)booleanhasRow(R r)booleanhasRowNames()intnumMissing()Return the number of missing values in the matrix.voidsetColumnName(C s, int i)Add a column name associated with an index.voidsetColumnNames(List<C> v)voidsetRowName(R s, int i)Add a row name associated with a row index.voidsetRowNames(List<R> v)abstract intsize()
-
-
-
Field Detail
-
MAX_ROWS_TO_PRINT
protected static final int MAX_ROWS_TO_PRINT
- See Also:
- Constant Field Values
-
-
Method Detail
-
addColumnName
public final void addColumnName(C s)
Add a column name when we don't care what the index will be. The index will be set by the method. This is useful for when we need to set up a matrix before we know how many column or rows there are.- Specified by:
addColumnNamein interfaceMatrix2D<R,C,V>- Parameters:
s-
-
addRowName
public final void addRowName(R s)
Add a row name when we don't care what the index will be. The index will be set by the method. This is useful for when we need to set up a matrix before we know how many column or rows there are.- Parameters:
s-
-
asDoubles
public double[][] asDoubles()
Description copied from interface:Matrix2DAttempt to coerce the entries into doubles.Numeric entries (Double, BigDecimal, Integer, BigInteger) and Strings that can be parsed as doubles are converted. Booleans are converted to 1 or 0. Dates are converted via Date.getDate(). Null entries are rendered as Double.NaN. For entries that are other types of objects, the HashCode is used.
-
assign
public void assign(V value)
Description copied from interface:Matrix2DSet all values in the matrix to the given value.
-
containsColumnName
public final boolean containsColumnName(C columnName)
- Specified by:
containsColumnNamein interfaceMatrix2D<R,C,V>- Returns:
-
containsRowName
public final boolean containsRowName(R rowName)
- Specified by:
containsRowNamein interfaceMatrix2D<R,C,V>- Returns:
-
getColIndexByName
public final int getColIndexByName(C columnKey)
Description copied from interface:Matrix2DGet the index of a column by name.- Specified by:
getColIndexByNamein interfaceMatrix2D<R,C,V>- Parameters:
columnKey- String- Returns:
- int
-
getColName
public final C getColName(int i)
Description copied from interface:Matrix2DGte the column name for an index.- Specified by:
getColNamein interfaceMatrix2D<R,C,V>- Parameters:
i- int- Returns:
- java.lang.String
-
getColNames
public final List<C> getColNames()
- Specified by:
getColNamesin interfaceMatrix2D<R,C,V>- Returns:
- list of column names. Do not modify this list. Use the addColumnName methods.
-
getRowIndexByName
public final int getRowIndexByName(R s)
Description copied from interface:Matrix2DGet the index of a row by name..- Specified by:
getRowIndexByNamein interfaceMatrix2D<R,C,V>- Parameters:
s- String- Returns:
- int
-
getRowName
public final R getRowName(int i)
Description copied from interface:Matrix2DGet the row name for an index- Specified by:
getRowNamein interfaceMatrix2D<R,C,V>- Parameters:
i- int- Returns:
- java.lang.String
-
getRowNameMapIterator
public final Iterator<R> getRowNameMapIterator()
- Specified by:
getRowNameMapIteratorin interfaceMatrix2D<R,C,V>- Returns:
- java.util.Iterator
-
getRowNames
public final List<R> getRowNames()
- Specified by:
getRowNamesin interfaceMatrix2D<R,C,V>- Returns:
-
hasColNames
public final boolean hasColNames()
Description copied from interface:Matrix2DCheck if this matrix has a valid set of column names.- Specified by:
hasColNamesin interfaceMatrix2D<R,C,V>- Returns:
- boolean
-
hasMissingValues
public boolean hasMissingValues()
Test for the presence of missing values (null, or in the case of numbers, NaN)- Returns:
-
hasRow
public final boolean hasRow(R r)
-
hasRowNames
public final boolean hasRowNames()
- Specified by:
hasRowNamesin interfaceMatrix2D<R,C,V>- Returns:
- boolean
-
numMissing
public final int numMissing()
Description copied from interface:Matrix2DReturn the number of missing values in the matrix.- Specified by:
numMissingin interfaceMatrix2D<R,C,V>- Returns:
-
setColumnName
public final void setColumnName(C s, int i)
Description copied from interface:Matrix2DAdd a column name associated with an index.- Specified by:
setColumnNamein interfaceMatrix2D<R,C,V>- Parameters:
s- Object a column namei- int the column index associated with this name
-
setColumnNames
public void setColumnNames(List<C> v)
- Specified by:
setColumnNamesin interfaceMatrix2D<R,C,V>
-
setRowName
public final void setRowName(R s, int i)
Description copied from interface:Matrix2DAdd a row name associated with a row index.- Specified by:
setRowNamein interfaceMatrix2D<R,C,V>- Parameters:
s- Objecti- int
-
setRowNames
public final void setRowNames(List<R> v)
- Specified by:
setRowNamesin interfaceMatrix2D<R,C,V>
-
size
public abstract int size()
-
checkColRange
protected void checkColRange(int startCol, int endCol)
-
checkRowRange
protected void checkRowRange(int startRow, int endRow)
-
-