Package com.reve.reed.solomon.matrix
Class MatrixOptimized
java.lang.Object
com.reve.reed.solomon.matrix.MatrixOptimized
A matrix over the 8-bit Galois field.
This class is not performance-critical, so the implementations
are simple and straightforward.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInitialize a matrix of zeros.MatrixOptimized(byte[][] initData) Initializes a matrix with the given row-major data.MatrixOptimized(int initRows, int initColumns) Initialize a matrix of zeros. -
Method Summary
Modifier and TypeMethodDescriptionaugment(MatrixOptimized right) Returns the concatenation of this matrix and the matrix on the right.augment(MatrixOptimized right, MatrixOptimized result) Returns 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.intbyte[][]getData()byte[]getRow(int row) Returns one row of the matrix as a byte array.byte[]getRow(int row, byte[] output, int offset) Returns one row of the matrix as a byte array.intgetRows()static MatrixOptimizedidentity(int size) Returns an identity matrix of the given size.invert()Returns the inverse of this matrix.voidinvert(MatrixOptimized result, MatrixOptimized identity, MatrixOptimized work) Returns the inverse of this matrix.voidset(int r, int c, byte value) Sets the value at row r, column c.voidsetColumns(int columns) voidsetRows(int rows) submatrix(int rmin, int cmin, int rmax, int cmax) Returns a part of this matrix.submatrix(int rmin, int cmin, int rmax, int cmax, MatrixOptimized result) Returns a part of this matrix.voidswapRows(int r1, int r2) Exchanges two rows in the matrix.times(MatrixOptimized right) Multiplies this matrix (the one on the left) by another matrix (the one on the right).times(MatrixOptimized right, MatrixOptimized result) 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.
-
Field Details
-
MAX_LENGTH
public static final int MAX_LENGTH- See Also:
-
-
Constructor Details
-
MatrixOptimized
public MatrixOptimized()Initialize a matrix of zeros. -
MatrixOptimized
public MatrixOptimized(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.
-
MatrixOptimized
public MatrixOptimized(byte[][] initData) Initializes a matrix with the given row-major data.
-
-
Method Details
-
setRows
public void setRows(int rows) -
setColumns
public void setColumns(int columns) -
getRows
public int getRows() -
getColumns
public int getColumns() -
identity
Returns an identity matrix of the given size. -
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. -
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 -
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). -
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. -
augment
Returns the concatenation of this matrix and the matrix on the right. -
submatrix
Returns a part of this matrix. -
submatrix
Returns a part of this matrix. -
getRow
public byte[] getRow(int row) Returns one row of the matrix as a byte array. -
getRow
public byte[] getRow(int row, byte[] output, int offset) 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.
-
invert
Returns the inverse of this matrix.- Throws:
IllegalArgumentException- when the matrix is singular and doesn't have an inverse.
-
getData
public byte[][] getData()
-