SSJ
3.3.1
Stochastic Simulation in Java
|
This class implements matrices of bits of arbitrary dimensions. More...
Classes | |
class | IncompatibleDimensionException |
Runtime exception raised when the dimensions of the BitMatrix are not appropriate for the operation. More... | |
Public Member Functions | |
BitMatrix (int r, int c) | |
Creates a new BitMatrix with r rows and c columns filled with 0’s. More... | |
BitMatrix (BitVector[] rows) | |
Creates a new BitMatrix using the data in rows . More... | |
BitMatrix (int[][] data, int r, int c) | |
Creates a new BitMatrix with r rows and c columns using the data in data . More... | |
BitMatrix (BitMatrix that) | |
Copy constructor. More... | |
Object | clone () |
Creates a copy of the BitMatrix . More... | |
boolean | equals (BitMatrix that) |
Verifies that this and that are strictly identical. More... | |
String | toString () |
Creates a String containing all the data of the BitMatrix . More... | |
String | printData () |
Creates a String containing all the data of the BitMatrix . More... | |
int | numRows () |
Returns the number of rows of the BitMatrix . More... | |
int | numColumns () |
Returns the number of columns of the BitMatrix . More... | |
boolean | getBool (int row, int column) |
Returns the value of the bit in the specified row and column. More... | |
void | setBool (int row, int column, boolean value) |
Changes the value of the bit in the specified row and column. More... | |
BitMatrix | transpose () |
Returns the transposed matrix. More... | |
BitMatrix | not () |
Returns the BitMatrix resulting from the application of the not operator on the original BitMatrix . More... | |
BitMatrix | and (BitMatrix that) |
Returns the BitMatrix resulting from the application of the and operator on the original BitMatrix and that . More... | |
BitMatrix | or (BitMatrix that) |
Returns the BitMatrix resulting from the application of the or operator on the original BitMatrix and that . More... | |
BitMatrix | xor (BitMatrix that) |
Returns the BitMatrix resulting from the application of the xor operator on the original BitMatrix and that . More... | |
BitVector | multiply (BitVector vect) |
Multiplies the column BitVector by a BitMatrix and returns the result. More... | |
int | multiply (int vect) |
Multiplies vect , seen as a column BitVector, by a BitMatrix . More... | |
BitMatrix | multiply (BitMatrix that) |
Multiplies two BitMatrix ’s together. More... | |
BitMatrix | power (long p) |
Raises the BitMatrix to the power p . More... | |
BitMatrix | power2e (int e) |
Raises the BitMatrix to power \(2^{\mathtt{e}}\). More... | |
Package Attributes | |
int | c |
Static Package Attributes | |
static final long | serialVersionUID = 2472769969919959608L |
This class implements matrices of bits of arbitrary dimensions.
Basic facilities for bits operations, multiplications and exponentiations are provided.
BitMatrix | ( | int | r, |
int | c | ||
) |
Creates a new BitMatrix
with r
rows and c
columns filled with 0’s.
r | the number of rows |
c | the number of columns |
BitMatrix | ( | int | data[][], |
int | r, | ||
int | c | ||
) |
Creates a new BitMatrix
with r
rows and c
columns using the data in data
.
Note that the orders of the bits for the rows are using the same order than for the BitVector. This does mean that the first bit is the lowest order bit of the last int
in the row and the last bit is the highest order bit of the first int
int the row.
data | the data of the new BitMatrix |
r | the number of rows |
c | the number of columns |
Returns the BitMatrix
resulting from the application of the and
operator on the original BitMatrix
and that
.
Only bits which were at 1 in both BitMatrix
are set at 1 in the result. All others are set to 0.
that | the second operand of the and operator |
and
operatorIncompatibleDimensionException | if the two BitMatrix are not of the same dimensions |
boolean equals | ( | BitMatrix | that | ) |
boolean getBool | ( | int | row, |
int | column | ||
) |
Returns the value of the bit in the specified row and column.
If the value is 1, return true
. If it is 0, return false
.
row | the row of the selected bit |
column | the column of the selected bit |
IndexOutOfBoundsException | if the selected bit would be outside the BitMatrix |
int multiply | ( | int | vect | ) |
Multiplies vect
, seen as a column BitVector, by a BitMatrix
.
(See BitVector to see the conversion between int
and BitVector.) The result is \(A \times v\), where \(A\) is the BitMatrix
, and \(v\) is the BitVector.
vect | the vector to multiply |
int
Multiplies two BitMatrix
’s together.
The result is \(A \times B\), where \(A\) is the this BitMatrix
and \(B\) is the that BitMatrix
.
that | the other BitMatrix to multiply |
IncompatibleDimensionException | if the number of columns of the first BitMatrix is not equal to the number of rows of the second BitMatrix |
BitMatrix not | ( | ) |
int numColumns | ( | ) |
Returns the number of columns of the BitMatrix
.
int numRows | ( | ) |
Returns the number of rows of the BitMatrix
.
Returns the BitMatrix
resulting from the application of the or
operator on the original BitMatrix
and that
.
Only bits which were at 0 in both BitMatrix
are set at 0 in the result. All others are set to 1.
that | the second operand of the or operator |
or
operatorIncompatibleDimensionException | if the two BitMatrix are not of the same dimensions |
BitMatrix power | ( | long | p | ) |
Raises the BitMatrix
to the power p
.
p | the power up to which to raise the BitMatrix |
BitMatrix
IncompatibleDimensionException | if the BitMatrix is not square |
IllegalArgumentException | if p is negative |
BitMatrix power2e | ( | int | e | ) |
Raises the BitMatrix
to power \(2^{\mathtt{e}}\).
e | the exponent of the power up to which to raise the BitMatrix |
BitMatrix
IncompatibleDimensionException | if the BitMatrix is not square |
String printData | ( | ) |
Creates a String containing all the data of the BitMatrix
.
The data is displayed in the same format as are the int[][]
in Java
code. This allows the user to print the representation of a BitMatrix
to be put, directly in the source code, in the constructor BitMatrix(int[][], int, int)
. The output is not designed to be human-readable.
BitMatrix
void setBool | ( | int | row, |
int | column, | ||
boolean | value | ||
) |
Changes the value of the bit in the specified row and column.
If value
is true
, changes it to 1. If value
is false
changes it to 0.
row | the row of the selected bit |
column | the column of the selected bit |
value | the new value of the bit as a boolean |
IndexOutOfBoundsException | if the selected bit would be outside the BitMatrix |
String toString | ( | ) |
Creates a String containing all the data of the BitMatrix
.
The result is displayed in a matrix form, with each row being put on a different line. Note that the bit at (0,0) is at the upper left of the matrix, while the bit at (0) in a BitVector is the least significant bit.
BitMatrix
BitMatrix transpose | ( | ) |
Returns the transposed matrix.
The rows and columns are interchanged.
Returns the BitMatrix
resulting from the application of the xor
operator on the original BitMatrix
and that
.
Only bits which were at 1 in only one of the two BitMatrix
are set at 1 in the result. All others are set to 0.
that | the second operand of the xor operator |
xor
operatorIncompatibleDimensionException | if the two BitMatrix are not of the same dimensions |