public abstract class AbstractMatrix<R,C,V> extends Object implements Matrix2D<R,C,V>, Serializable
Modifier and Type | Field and Description |
---|---|
protected static int |
MAX_ROWS_TO_PRINT |
Constructor and Description |
---|
AbstractMatrix() |
Modifier and Type | Method and Description |
---|---|
void |
addColumnName(C s)
Add a column name when we don't care what the index will be.
|
void |
addRowName(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.
|
void |
assign(V value)
Set all values in the matrix to the given value.
|
protected void |
checkColRange(int startCol,
int endCol) |
protected void |
checkRowRange(int startRow,
int endRow) |
boolean |
containsColumnName(C columnName) |
boolean |
containsRowName(R rowName) |
int |
getColIndexByName(C columnKey)
Get the index of a column by name.
|
C |
getColName(int i)
Gte the column name for an index.
|
List<C> |
getColNames() |
int |
getRowIndexByName(R s)
Get the index of a row by name..
|
R |
getRowName(int i)
Get the row name for an index
|
Iterator<R> |
getRowNameMapIterator() |
List<R> |
getRowNames() |
boolean |
hasColNames()
Check if this matrix has a valid set of column names.
|
boolean |
hasMissingValues()
Test for the presence of missing values (null, or in the case of numbers, NaN)
|
boolean |
hasRow(R r) |
boolean |
hasRowNames() |
int |
numMissing()
Return the number of missing values in the matrix.
|
void |
setColumnName(C s,
int i)
Add a column name associated with an index.
|
void |
setColumnNames(List<C> v) |
void |
setRowName(R s,
int i)
Add a row name associated with a row index.
|
void |
setRowNames(List<R> v) |
abstract int |
size() |
protected static final int MAX_ROWS_TO_PRINT
public final void addColumnName(C s)
addColumnName
in interface Matrix2D<R,C,V>
s
- public final void addRowName(R s)
s
- public double[][] asDoubles()
Matrix2D
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.
public void assign(V value)
Matrix2D
public final boolean containsColumnName(C columnName)
containsColumnName
in interface Matrix2D<R,C,V>
public final boolean containsRowName(R rowName)
containsRowName
in interface Matrix2D<R,C,V>
public final int getColIndexByName(C columnKey)
Matrix2D
getColIndexByName
in interface Matrix2D<R,C,V>
columnKey
- Stringpublic final C getColName(int i)
Matrix2D
getColName
in interface Matrix2D<R,C,V>
i
- intpublic final List<C> getColNames()
getColNames
in interface Matrix2D<R,C,V>
public final int getRowIndexByName(R s)
Matrix2D
getRowIndexByName
in interface Matrix2D<R,C,V>
s
- Stringpublic final R getRowName(int i)
Matrix2D
getRowName
in interface Matrix2D<R,C,V>
i
- intpublic final Iterator<R> getRowNameMapIterator()
getRowNameMapIterator
in interface Matrix2D<R,C,V>
public final List<R> getRowNames()
getRowNames
in interface Matrix2D<R,C,V>
public final boolean hasColNames()
Matrix2D
hasColNames
in interface Matrix2D<R,C,V>
public boolean hasMissingValues()
public final boolean hasRow(R r)
public final boolean hasRowNames()
hasRowNames
in interface Matrix2D<R,C,V>
public final int numMissing()
Matrix2D
numMissing
in interface Matrix2D<R,C,V>
public final void setColumnName(C s, int i)
Matrix2D
setColumnName
in interface Matrix2D<R,C,V>
s
- Object a column namei
- int the column index associated with this namepublic void setColumnNames(List<C> v)
setColumnNames
in interface Matrix2D<R,C,V>
public final void setRowName(R s, int i)
Matrix2D
setRowName
in interface Matrix2D<R,C,V>
s
- Objecti
- intpublic final void setRowNames(List<R> v)
setRowNames
in interface Matrix2D<R,C,V>
public abstract int size()
protected void checkColRange(int startCol, int endCol)
protected void checkRowRange(int startRow, int endRow)
Copyright © 2003–2023 UBC Michael Smith Laboratories. All rights reserved.