public class CompressedBitMatrix<R,C> extends AbstractMatrix<R,C,double[]> implements ObjectMatrix<R,C,double[]>
| Modifier and Type | Field and Description |
|---|---|
static long |
BIT1 |
static int |
BITS_PER_ELEMENT |
MAX_ROWS_TO_PRINT| Constructor and Description |
|---|
CompressedBitMatrix(int rows,
int cols,
int totalBitsPerItem)
Constructs a matrix with specified rows, columns, and total bits per cell
Implementation note: this is created by maintaining one or more Double matrices; the Doubles are used as bit
fields.
|
| Modifier and Type | Method and Description |
|---|---|
int |
bitCount(int r,
int c)
Count the number of one-bits at the specified cell position
|
int |
columns()
Get the number of columns the matrix has.
|
double[] |
get(int row,
int col) |
boolean |
get(int row,
int col,
int index)
Checks the bit of the specified cell at the specified index.
|
long[] |
getAllBits(int row,
int col)
Returns all of the bits for a cell
|
int |
getBitNum()
Returns the total number of bits in a matrix cell
|
double[] |
getByKeys(R r,
C c) |
double[][] |
getColumn(int i) |
double[] |
getEntry(int row,
int column) |
double[][] |
getRow(int i) |
int[] |
getRowBitCount(int row) |
boolean |
isMissing(int i,
int j)
Check if the value at a given index is missing.
|
int |
overlap(int row1,
int col1,
int row2,
int col2)
Counts the number of one-bits that are in common between the two specified cells; i.e. performs an AND operation
on the two bit vectors and counts the remaining 1 bits.
|
void |
reset(int r,
int c) |
int |
rows()
Get the number of rows the matrix has
|
void |
set(int row,
int col,
double[] val)
Set the matrix cell to the specified bit vector
|
void |
set(int row,
int col,
int index)
Sets the bit of the specified cell at the specified index to 1.
|
void |
setByKeys(R r,
C c,
double[] v) |
int |
size() |
ObjectMatrix<R,C,double[]> |
subset(int startRow,
int startCol,
int numRow,
int numCol) |
ObjectMatrix<R,C,double[]> |
subsetColumns(List<C> columns) |
void |
toFile(String fileName)
Save the matrix to the specified file
|
long |
totalBitCount()
Number of ones in the entire matrix.
|
void |
unset(int row,
int col,
int index) |
addColumnName, addRowName, asDoubles, assign, checkColRange, checkRowRange, containsColumnName, containsRowName, getColIndexByName, getColName, getColNames, getRowIndexByName, getRowName, getRowNameMapIterator, getRowNames, hasColNames, hasMissingValues, hasRow, hasRowNames, numMissing, setColumnName, setColumnNames, setRowName, setRowNamesclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddColumnName, asDoubles, assign, containsColumnName, containsRowName, getColIndexByName, getColName, getColNames, getRowIndexByName, getRowName, getRowNameMapIterator, getRowNames, hasColNames, hasRow, hasRowNames, numMissing, setColumnName, setColumnNames, setRowName, setRowNamespublic CompressedBitMatrix(int rows,
int cols,
int totalBitsPerItem)
Implementation note: this is created by maintaining one or more Double matrices; the Doubles are used as bit fields.
rows - - number of rows in the matrixcols - - number of columns in the matrixtotalBitsPerItem - - the number of bits for each cellpublic int bitCount(int r,
int c)
r - c - public int columns()
Matrix2Dpublic double[] get(int row,
int col)
get in interface ObjectMatrix<R,C,double[]>public boolean get(int row,
int col,
int index)
row - - matrix rowcol - - matrix columnindex - - bit vector indexpublic long[] getAllBits(int row,
int col)
row - - the cell rowcol - - the cell columnlongspublic int getBitNum()
public double[][] getColumn(int i)
getColumn in interface ObjectMatrix<R,C,double[]>public double[] getEntry(int row,
int column)
public double[][] getRow(int i)
getRow in interface ObjectMatrix<R,C,double[]>public int[] getRowBitCount(int row)
row - public boolean isMissing(int i,
int j)
Matrix2Dpublic int overlap(int row1,
int col1,
int row2,
int col2)
row1 - - cell 1 rowcol1 - - cell 1 columnrow2 - - cell 2 rowcol2 - - cell 2 columnpublic void reset(int r,
int c)
public int rows()
Matrix2Dpublic void set(int row,
int col,
double[] val)
public void set(int row,
int col,
int index)
row - - matrix rowcol - - matrix columnindex - - bit vector indexpublic int size()
size in class AbstractMatrix<R,C,double[]>public ObjectMatrix<R,C,double[]> subset(int startRow, int startCol, int numRow, int numCol)
subset in interface ObjectMatrix<R,C,double[]>public ObjectMatrix<R,C,double[]> subsetColumns(List<C> columns)
subsetColumns in interface ObjectMatrix<R,C,double[]>columns - public void toFile(String fileName) throws IOException
fileName - - save fileIOExceptionpublic long totalBitCount()
public void unset(int row,
int col,
int index)
Copyright © 2003–2023 UBC Michael Smith Laboratories. All rights reserved.