SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.util.BitMatrix Class Reference

This class implements matrices of bits of arbitrary dimensions. More...

Inheritance diagram for umontreal.ssj.util.BitMatrix:

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.
 BitMatrix (BitVector[] rows)
 Creates a new BitMatrix using the data in rows.
 BitMatrix (int[][] data, int r, int c)
 Creates a new BitMatrix with r rows and c columns using the data in data.
 BitMatrix (BitMatrix that)
 Copy constructor.
Object clone ()
 Creates a copy of the BitMatrix.
boolean equals (BitMatrix that)
 Verifies that this and that are strictly identical.
String toString ()
 Creates a String containing all the data of the BitMatrix.
String printData ()
 Creates a String containing all the data of the BitMatrix.
int numRows ()
 Returns the number of rows of the BitMatrix.
int numColumns ()
 Returns the number of columns of the BitMatrix.
boolean getBool (int row, int column)
 Returns the value of the bit in the specified row and column.
void setBool (int row, int column, boolean value)
 Changes the value of the bit in the specified row and column.
BitMatrix transpose ()
 Returns the transposed matrix.
BitMatrix not ()
 Returns the BitMatrix resulting from the application of the not operator on the original BitMatrix.
BitMatrix and (BitMatrix that)
 Returns the BitMatrix resulting from the application of the and operator on the original BitMatrix and that.
BitMatrix or (BitMatrix that)
 Returns the BitMatrix resulting from the application of the or operator on the original BitMatrix and that.
BitMatrix xor (BitMatrix that)
 Returns the BitMatrix resulting from the application of the xor operator on the original BitMatrix and that.
BitVector multiply (BitVector vect)
 Multiplies the column BitVector by a BitMatrix and returns the result.
int multiply (int vect)
 Multiplies vect, seen as a column BitVector, by a BitMatrix.
BitMatrix multiply (BitMatrix that)
 Multiplies two BitMatrix’s together.
BitMatrix power (long p)
 Raises the BitMatrix to the power p.
BitMatrix power2e (int e)
 Raises the BitMatrix to power \(2^{\mathtt{e}}\).

Detailed Description

This class implements matrices of bits of arbitrary dimensions.

Basic facilities for bits operations, multiplications and exponentiations are provided. Each matrix is represented as a array of BitVector.

Definition at line 36 of file BitMatrix.java.

Constructor & Destructor Documentation

◆ BitMatrix() [1/4]

umontreal.ssj.util.BitMatrix.BitMatrix ( int r,
int c )

Creates a new BitMatrix with r rows and c columns filled with 0’s.

Parameters
rthe number of rows
cthe number of columns

Definition at line 50 of file BitMatrix.java.

◆ BitMatrix() [2/4]

umontreal.ssj.util.BitMatrix.BitMatrix ( BitVector[] rows)

Creates a new BitMatrix using the data in rows.

Each of the

BitVector will be one of the rows of the BitMatrix.

Parameters
rowsthe rows of the new BitMatrix

Definition at line 64 of file BitMatrix.java.

◆ BitMatrix() [3/4]

umontreal.ssj.util.BitMatrix.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.

Parameters
datathe data of the new BitMatrix
rthe number of rows
cthe number of columns

Definition at line 83 of file BitMatrix.java.

◆ BitMatrix() [4/4]

umontreal.ssj.util.BitMatrix.BitMatrix ( BitMatrix that)

Copy constructor.

Parameters
thatthe BitMatrix to copy

Definition at line 96 of file BitMatrix.java.

Member Function Documentation

◆ and()

BitMatrix umontreal.ssj.util.BitMatrix.and ( BitMatrix that)

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.

Parameters
thatthe second operand of the and operator
Returns
the result of the and operator
Exceptions
IncompatibleDimensionExceptionif the two `BitMatrix` are not of the same dimensions

Definition at line 292 of file BitMatrix.java.

◆ clone()

Object umontreal.ssj.util.BitMatrix.clone ( )

Creates a copy of the BitMatrix.

Returns
a deep copy of the BitMatrix

Definition at line 109 of file BitMatrix.java.

◆ equals()

boolean umontreal.ssj.util.BitMatrix.equals ( BitMatrix that)

Verifies that this and that are strictly identical.

They must both have the same dimensions and data.

Parameters
thatthe BitMatrix to compare
Returns
if the two BitMatrix are identical

Definition at line 130 of file BitMatrix.java.

◆ getBool()

boolean umontreal.ssj.util.BitMatrix.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.

Parameters
rowthe row of the selected bit
columnthe column of the selected bit
Returns
the value of the bit as a boolean
Exceptions
IndexOutOfBoundsExceptionif the selected bit would be outside the BitMatrix

Definition at line 228 of file BitMatrix.java.

◆ multiply() [1/3]

BitMatrix umontreal.ssj.util.BitMatrix.multiply ( BitMatrix that)

Multiplies two BitMatrix’s together.

The result is \(A \times B\), where \(A\) is the this BitMatrix and \(B\) is the that BitMatrix.

Parameters
thatthe other BitMatrix to multiply
Returns
the result of the multiplication
Exceptions
IncompatibleDimensionExceptionif the number of columns of the first BitMatrix is not equal to the number of rows of the second BitMatrix

Definition at line 389 of file BitMatrix.java.

◆ multiply() [2/3]

BitVector umontreal.ssj.util.BitMatrix.multiply ( BitVector vect)

Multiplies the column BitVector by a BitMatrix and returns the result.

The result is \(A \times v\), where \(A\) is the BitMatrix, and \(v\) is the BitVector.

Parameters
vectthe vector to multiply
Returns
the result of the multiplication

Definition at line 352 of file BitMatrix.java.

◆ multiply() [3/3]

int umontreal.ssj.util.BitMatrix.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.

Parameters
vectthe vector to multiply
Returns
the result of the multiplication, as an int

Definition at line 370 of file BitMatrix.java.

◆ not()

BitMatrix umontreal.ssj.util.BitMatrix.not ( )

Returns the BitMatrix resulting from the application of the not operator on the original BitMatrix.

The effect is to swap all the bits of the BitMatrix, turning all 0 into 1 and all 1 into 0.

Returns
the result of the not operator

Definition at line 274 of file BitMatrix.java.

◆ numColumns()

int umontreal.ssj.util.BitMatrix.numColumns ( )

Returns the number of columns of the BitMatrix.

Returns
the number of columns

Definition at line 213 of file BitMatrix.java.

◆ numRows()

int umontreal.ssj.util.BitMatrix.numRows ( )

Returns the number of rows of the BitMatrix.

Returns
the number of rows

Definition at line 204 of file BitMatrix.java.

◆ or()

BitMatrix umontreal.ssj.util.BitMatrix.or ( BitMatrix that)

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.

Parameters
thatthe second operand of the or operator
Returns
the result of the or operator
Exceptions
IncompatibleDimensionExceptionif the two `BitMatrix` are not of the same dimensions

Definition at line 313 of file BitMatrix.java.

◆ power()

BitMatrix umontreal.ssj.util.BitMatrix.power ( long p)

Raises the BitMatrix to the power p.

Parameters
pthe power up to which to raise the BitMatrix
Returns
the power of the BitMatrix
Exceptions
IncompatibleDimensionExceptionif the `BitMatrix` is not square
IllegalArgumentExceptionif `p` is negative

Definition at line 427 of file BitMatrix.java.

◆ power2e()

BitMatrix umontreal.ssj.util.BitMatrix.power2e ( int e)

Raises the BitMatrix to power \(2^{\mathtt{e}}\).

Parameters
ethe exponent of the power up to which to raise the BitMatrix
Returns
the power of the BitMatrix
Exceptions
IncompatibleDimensionExceptionif the `BitMatrix` is not square

Definition at line 460 of file BitMatrix.java.

◆ printData()

String umontreal.ssj.util.BitMatrix.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.

Returns
the content of the BitMatrix

Definition at line 179 of file BitMatrix.java.

◆ setBool()

void umontreal.ssj.util.BitMatrix.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.

Parameters
rowthe row of the selected bit
columnthe column of the selected bit
valuethe new value of the bit as a boolean
Exceptions
IndexOutOfBoundsExceptionif the selected bit would be outside the BitMatrix

Definition at line 245 of file BitMatrix.java.

◆ toString()

String umontreal.ssj.util.BitMatrix.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.

Returns
the content of the BitMatrix

Definition at line 147 of file BitMatrix.java.

◆ transpose()

BitMatrix umontreal.ssj.util.BitMatrix.transpose ( )

Returns the transposed matrix.

The rows and columns are interchanged.

Returns
the transposed matrix

Definition at line 257 of file BitMatrix.java.

◆ xor()

BitMatrix umontreal.ssj.util.BitMatrix.xor ( BitMatrix that)

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.

Parameters
thatthe second operand of the xor operator
Returns
the result of the xor operator
Exceptions
IncompatibleDimensionExceptionif the two `BitMatrix` are not of the same dimensions

Definition at line 334 of file BitMatrix.java.


The documentation for this class was generated from the following file: