Interface Matrix2D<R,C,V>
-
- All Known Subinterfaces:
ObjectMatrix<R,C,V>
,PrimitiveMatrix<R,C,V>
- All Known Implementing Classes:
AbstractMatrix
,CompressedBitMatrix
,CompressedSparseDoubleMatrix
,DenseDoubleMatrix
,DoubleMatrix
,FastRowAccessDoubleMatrix
,IntegerMatrix
,ObjectMatrixImpl
,SparseDoubleMatrix
,SparseRaggedDoubleMatrix
,StringMatrix
public interface Matrix2D<R,C,V>
Represents a matrix with index columns and rows. The keys are generic.- Author:
- Paul Pavlidis
- See Also:
for matrix storing objects.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addColumnName(C s)
Add a column name, to the end of the current column names.double[][]
asDoubles()
Attempt to coerce the entries into doubles.void
assign(V value)
Set all values in the matrix to the given value.int
columns()
Get the number of columns the matrix has.boolean
containsColumnName(C columnName)
boolean
containsRowName(R rowName)
V
getByKeys(R r, C c)
int
getColIndexByName(C s)
Get the index of a column by name.C
getColName(int i)
Gte the column name for an index.List<C>
getColNames()
V
getEntry(int i, int j)
int
getRowIndexByName(R s)
Get the index of a row by name..R
getRowName(int i)
Get the row name for an indexIterator<R>
getRowNameMapIterator()
List<R>
getRowNames()
boolean
hasColNames()
Check if this matrix has a valid set of column names.boolean
hasRow(R r)
boolean
hasRowNames()
boolean
isMissing(int i, int j)
Check if the value at a given index is missing.int
numMissing()
Return the number of missing values in the matrix.int
rows()
Get the number of rows the matrix hasvoid
set(int row, int column, V value)
void
setByKeys(R r, C c, V v)
void
setColumnName(C s, int index)
Add a column name associated with an index.void
setColumnNames(List<C> v)
void
setRowName(R s, int index)
Add a row name associated with a row index.void
setRowNames(List<R> v)
-
-
-
Method Detail
-
addColumnName
void addColumnName(C s)
Add a column name, to the end of the current column names. Useful when building up a matrix in stages.- Parameters:
s
- Object a column name
-
asDoubles
double[][] asDoubles()
Attempt 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.
- Returns:
-
assign
void assign(V value)
Set all values in the matrix to the given value.- Parameters:
value
-
-
columns
int columns()
Get the number of columns the matrix has.- Returns:
- int
-
containsColumnName
boolean containsColumnName(C columnName)
- Parameters:
columnName
-- Returns:
-
containsRowName
boolean containsRowName(R rowName)
- Parameters:
rowName
-- Returns:
-
getColIndexByName
int getColIndexByName(C s)
Get the index of a column by name.- Parameters:
s
- Object- Returns:
- int
-
getColName
C getColName(int i)
Gte the column name for an index.- Parameters:
i
- int- Returns:
- java.lang.Object
-
getColNames
List<C> getColNames()
- Returns:
- list of column names. Do not modify this list. Use the addColumnName methods.
-
getEntry
V getEntry(int i, int j)
- Parameters:
i
-j
-- Returns:
-
getRowIndexByName
int getRowIndexByName(R s)
Get the index of a row by name..- Parameters:
s
- Object- Returns:
- int
-
getRowName
R getRowName(int i)
Get the row name for an index- Parameters:
i
- int- Returns:
- java.lang.Object
-
hasColNames
boolean hasColNames()
Check if this matrix has a valid set of column names.- Returns:
- boolean
-
hasRow
boolean hasRow(R r)
- Parameters:
r
- Object- Returns:
- boolean
-
hasRowNames
boolean hasRowNames()
- Returns:
- boolean
-
isMissing
boolean isMissing(int i, int j)
Check if the value at a given index is missing.- Parameters:
i
- rowj
- column- Returns:
- true if the value is missing, false otherwise.
-
numMissing
int numMissing()
Return the number of missing values in the matrix.- Returns:
-
rows
int rows()
Get the number of rows the matrix has- Returns:
- int
-
set
void set(int row, int column, V value)
- Parameters:
row
-column
-value
-
-
setColumnName
void setColumnName(C s, int index)
Add a column name associated with an index.- Parameters:
s
- Object a column nameindex
- int the column index associated with this name
-
setRowName
void setRowName(R s, int index)
Add a row name associated with a row index.- Parameters:
s
- Objectindex
- int
-
-