public class BooleanMatrix extends Object
| Modifier and Type | Field and Description |
|---|---|
static byte |
FALSE |
static byte |
TRUE |
static byte |
UNKNOWN |
| Constructor and Description |
|---|
BooleanMatrix(BooleanMatrix b)
Creates a deep copy of another matrix
|
BooleanMatrix(byte[][] rowMajor)
Constructs dense boolean matrix from given array in
row major format.
|
BooleanMatrix(weka.core.Instances instances)
Constructs dense boolean matrix from weka instances,
that is expected to be filled with values 0, ?, 1
|
BooleanMatrix(int h,
int w)
Constructs new empty matrix with given dimensions, filled with FALSE
|
| Modifier and Type | Method and Description |
|---|---|
byte |
apply(int c) |
byte |
apply(int r,
int c) |
void |
baxoy(byte alpha,
BooleanMatrix x)
In-place operation on two row vectors, corresponding to SAXPY in
linear algebra
|
BooleanMatrix |
booleanProduct(BooleanMatrix other)
Calculates the boolean product with the other matrix.
|
int[] |
elementCount()
Counts ones, unknowns, and zeros contained in this matrix
|
int |
getHeight() |
BooleanMatrix |
getRow(int r)
Extracts single row as separate matrix.
|
BooleanMatrix |
getRows(List<Integer> indices) |
int |
getWidth() |
BooleanMatrix |
mapBoolean(Function<Byte,Byte> function)
Map-method, restricted to boolean matrices as output.
|
static byte |
not(byte b) |
double |
reconstructionError(BooleanMatrix reconstruction,
double onesWeight)
Calculates the reconstruction error between this matrix and the
reconstruction.
|
Tuple<Double,Double> |
relativeOneZeroZeroOneReconstructionError(BooleanMatrix reconstruction,
double onesWeight)
Calculates the relative
1->0 and 0->1
reconstruction error, that is, the total error divided by total
maximum possible error. |
double |
relativeReconstructionError(BooleanMatrix reconstruction,
double onesWeight)
Calculates the relative error
(error divided by the maximum possible error).
|
void |
setRow(int r,
BooleanMatrix row)
Analogous to get row: no values are copied
|
Tuple<Integer,Integer> |
size()
Returns width and height of the matrix.
|
Image |
toImage()
Draws this matrix as image.
|
weka.core.Instances |
toInstances()
Converts the matrix to Weka-Instances
|
RowMajor<Byte> |
toRowMajor()
Transforms this matrix to a generic matrix.
|
String |
toString() |
void |
update(int c,
byte b) |
void |
update(int r,
int c,
byte b)
Sets the entry at position
(r, c)
to b |
public static final byte TRUE
public static final byte UNKNOWN
public static final byte FALSE
public BooleanMatrix(int h,
int w)
h - heightw - widthpublic BooleanMatrix(BooleanMatrix b)
b - public BooleanMatrix(byte[][] rowMajor)
rowMajor - entries in column major formatpublic BooleanMatrix(weka.core.Instances instances)
public static byte not(byte b)
public int getWidth()
public int getHeight()
public void update(int r,
int c,
byte b)
(r, c)
to br - rowc - columnb - 0, 1 or 2public byte apply(int r,
int c)
public byte apply(int c)
public void update(int c,
byte b)
public BooleanMatrix getRows(List<Integer> indices)
public void baxoy(byte alpha,
BooleanMatrix x)
alpha - factorx - other rowpublic BooleanMatrix getRow(int r)
r - index of the rowpublic void setRow(int r,
BooleanMatrix row)
r - index of the rowrow - row vectorpublic BooleanMatrix booleanProduct(BooleanMatrix other)
other - boolean matrix with compatible dimensionpublic RowMajor<Byte> toRowMajor()
public double reconstructionError(BooleanMatrix reconstruction, double onesWeight)
reconstruction - some other matrixonesWeight - weight of 1->0 errors
relative to 0->1 errorspublic Tuple<Double,Double> relativeOneZeroZeroOneReconstructionError(BooleanMatrix reconstruction, double onesWeight)
1->0 and 0->1
reconstruction error, that is, the total error divided by total
maximum possible error.
Assumes, that there are no unknowns in the reconstruction.
The total weight equals #0 + onesWeight * #1.
Each 1->0 error costs onesWeight.
Each 0->1 error costs 1.reconstruction - onesWeight - 1->0 and 0->1 errorspublic double relativeReconstructionError(BooleanMatrix reconstruction, double onesWeight)
reconstruction - onesWeight - relative weight of 1->0 errorspublic Image toImage()
public weka.core.Instances toInstances()
public BooleanMatrix mapBoolean(Function<Byte,Byte> function)
function - public int[] elementCount()
Copyright © 2015. All rights reserved.