BoolMatrix¶
-
public class
BoolMatrix
¶ A matrix of booleans internally stored as an array of BoolVector’s (i.e. bit sets). Use conventions to reduce storage: “implicit-zero”:
rows == null
means matrix is full of “false” “implicit-identity”:rows[i] == null
means row i is an “identity” row.
Fields¶
rows¶
-
public BoolVector[]
rows
¶ The contents of the matrix, internally stored as an array of BoolVector’s, one per row.
Constructors¶
Methods¶
copy¶
-
public BoolMatrix
copy
()¶ Create a copy of this matrix.
cumulOr¶
-
public final void
cumulOr
(BoolMatrix orMatrix, boolean explicitIdentities, int len)¶ OR-accumulates “orMatrix” into this BoolMatrix. Does something reasonable when the sizes of matrices differ. Takes care of NOT using the dangling bits in the last number of each row of “orMatrix”. Tries to preserve the “implicit-zero” and “implicit-identity” conventions.
- Parameters
orMatrix – The BoolMatrix that must be OR-accumulated into this BoolMatrix.
explicitIdentities – false when expliciting of identity is already done (e.g. for pointers).
len – Unless equals -1, restricts this accumulation to the “len” first rows.
cumulOrTimes¶
-
protected void
cumulOrTimes
(BoolMatrix leftMatrix, BoolMatrix rightMatrix)¶ Matrix multiplication into a cumulative matrix. Multiplies the “leftMatrix” with the “rightMatrix”, and accumulates the result with a “or” into “this” BoolMatrix. Takes care of preserving the “implicit-identity” convention.
cumulRows¶
-
public final void
cumulRows
(TapIntList rowIndices, BoolVector orVector)¶
dump¶
-
public void
dump
()¶ Prints in detail the contents of this BoolMatrix, onto TapEnv.curOutputStream().
dump¶
-
public void
dump
(int[] rowMap, int[] colMap)¶ Prints in detail the contents of this BoolMatrix, onto TapEnv.curOutputStream(), knowing the Maps of its rows and columns.
- Parameters
rowMap – the map of the rows of this BoolMatrix
colMap – the map of the columns of this BoolMatrix.
equalsBoolMatrix¶
-
public final boolean
equalsBoolMatrix
(BoolMatrix otherMatrix)¶ - Returns
true when this BoolMatrix is equal to “otherMatrix”.
equalsBoolMatrix¶
-
public final boolean
equalsBoolMatrix
(BoolMatrix otherMatrix, int nrows, int ncols)¶ - Returns
true when this BoolMatrix is equal to “otherMatrix”, on their upper-left square of size “nrows” by “ncols”.
getExplicitRow¶
-
public final BoolVector
getExplicitRow
(int i)¶ Same as getRow(), but when the row found is implicit-identity (i.e. null), returns a new explicit identity row.
getImplicitIdentityIndices¶
-
public final TapIntList
getImplicitIdentityIndices
()¶ - Returns
the TapIntList of the row indices that are Implicit-Identity.
getRow¶
-
public final BoolVector
getRow
(int i)¶ - Returns
the i-th row of this BoolMatrix. If rows==null, returns a new empty row.
isImplicitIdentityRow¶
-
public final boolean
isImplicitIdentityRow
(int i)¶ - Returns
true if the row “i” of this BoolMatrix is implicitly identity, i.e. using the “implicit-identity” convention.
isImplicitZero¶
-
public final boolean
isImplicitZero
()¶ - Returns
true if this BoolMatrix is implicitly zero, i.e. using the “implicit-zero” convention.
isZero¶
-
public final boolean
isZero
(int rowNumber)¶ - Returns
true when this BoolMatrix is full of zero.
leftTimes¶
-
public final BoolVector
leftTimes
(BoolVector leftVector)¶ BoolVector * BoolMatrix multiplication.
- Returns
a new BoolVector, containing the product of the BoolVector “leftVector” with this BoolMatrix. It makes no sense to accept an “implicit-identity” leftVector, nor to return an “implicit-identity” result, since these vectors are not related to any BoolMatrix.
notImplicitRows¶
-
public final BoolVector
notImplicitRows
()¶ - Returns
a new BoolVector sized after the rows of this BoolMatrix, holding true for rows that are not implicit-Identity (i.e. that are non null).
numberOfOnes¶
-
public final int
numberOfOnes
()¶ (for debugging) @return the number of “true” elements in this matrix.
overwriteDeps¶
-
public final void
overwriteDeps
(TapIntList rowIndices, BoolVector cumulZ, boolean total)¶ Overwrites into this BoolMatrix, so that all rows in “rowIndices” are now set to depend on the given “cumulZ”. When “total” is true, this dependence overwrites the previous one, otherwise it just accumulates to it.
set¶
-
public final void
set
(int i, int j, boolean val)¶ Sets the (i,j) element of this matrix to “val”. This function assumes that (rows != null).
setExplicitIdentity¶
-
final void
setExplicitIdentity
()¶ Re-initializes this BoolMatrix explicitly to Identity. Does not use the “implicit-identity” convention.
setExplicitIdentityRow¶
-
public final void
setExplicitIdentityRow
(int i)¶ Re-initializes row “i” of this BoolMatrix explicitly to Identity. Does not use the “implicit-identity” convention. This function assumes that (rows != null).
setExplicitZero¶
-
public final void
setExplicitZero
()¶ Re-initializes this BoolMatrix explicitly to Zero. Does not use the “implicit-zero” convention.
setExplicitZeroRow¶
-
public final void
setExplicitZeroRow
(int i)¶ Sets row i of this BoolMatrix explicitly to Zero. Does not use the “implicit-zero” convention. Crashes (rightfully!) if matrix is “implicit-zero”.
setIdentity¶
-
public final void
setIdentity
()¶ Re-initializes this BoolMatrix to Identity. Each row of the matrix is initialized to null, using the “implicit-identity” convention.
setIdentityRow¶
-
public final void
setIdentityRow
(int i)¶ Re-initializes row “i” of this BoolMatrix to Identity. Row “i” is set to null, using “implicit-identity” convention. This function assumes that (rows != null).
setRow¶
-
public final void
setRow
(int i, BoolVector row)¶ Sets row “i” of this BoolMatrix to “row”. This function assumes that (rows != null).
times¶
-
public final BoolMatrix
times
(BoolMatrix rightMatrix)¶ - Returns
a new BoolMatrix, product of this BoolMatrix with the BoolMatrix “rightMatrix”.
times¶
-
public final BoolVector
times
(BoolVector rightVector)¶ BoolMatrix * BoolVector multiplication.
- Returns
a new BoolVector, containing the product of this BoolMatrix with the BoolVector “rightVector”. It makes no sense to accept an “implicit-identity” rightVector, nor to return an “implicit-identity” result, since these vectors are disconnected from any BoolMatrix.
timesTransposed¶
-
public final BoolMatrix
timesTransposed
(BoolMatrix rightMatrix)¶ - Returns
a new matrix containing “this” times the transposed of “rightMatrix”.