Package com.reve.reed.solomon.matrix
Class Matrix
java.lang.Object
com.reve.reed.solomon.matrix.Matrix
A matrix over the 8-bit Galois field.
This class is not performance-critical, so the implementations
are simple and straightforward.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the concatenation of this matrix and the matrix on the right.booleanReturns true iff this matrix is identical to the other.byteget(int r, int c) Returns the value at row r, column c.intReturns the number of columns in this matrix.byte[]getRow(int row) Returns one row of the matrix as a byte array.intgetRows()Returns the number of rows in this matrix.static Matrixidentity(int size) Returns an identity matrix of the given size.invert()Returns the inverse of this matrix.voidset(int r, int c, byte value) Sets the value at row r, column c.submatrix(int rmin, int cmin, int rmax, int cmax) Returns a part of this matrix.voidswapRows(int r1, int r2) Exchanges two rows in the matrix.Multiplies this matrix (the one on the left) by another matrix (the one on the right).Returns a human-readable string of the matrix contents.toString()Returns a human-readable string of the matrix contents.
-
Constructor Details
-
Matrix
public Matrix(int initRows, int initColumns) Initialize a matrix of zeros.- Parameters:
initRows- The number of rows in the matrix.initColumns- The number of columns in the matrix.
-
Matrix
public Matrix(byte[][] initData) Initializes a matrix with the given row-major data.
-
-
Method Details
-
identity
Returns an identity matrix of the given size. -
toString
Returns a human-readable string of the matrix contents. Example: [[1, 2], [3, 4]] -
toBigString
Returns a human-readable string of the matrix contents. Example: 00 01 02 03 04 05 06 07 08 09 0a 0b -
getColumns
public int getColumns()Returns the number of columns in this matrix. -
getRows
public int getRows()Returns the number of rows in this matrix. -
get
public byte get(int r, int c) Returns the value at row r, column c. -
set
public void set(int r, int c, byte value) Sets the value at row r, column c. -
equals
Returns true iff this matrix is identical to the other. -
times
Multiplies this matrix (the one on the left) by another matrix (the one on the right). -
augment
Returns the concatenation of this matrix and the matrix on the right. -
submatrix
Returns a part of this matrix. -
getRow
public byte[] getRow(int row) Returns one row of the matrix as a byte array. -
swapRows
public void swapRows(int r1, int r2) Exchanges two rows in the matrix. -
invert
Returns the inverse of this matrix.- Throws:
IllegalArgumentException- when the matrix is singular and doesn't have an inverse.
-