Class MatrixOptimized

java.lang.Object
com.reve.reed.solomon.matrix.MatrixOptimized

public class MatrixOptimized extends Object
A matrix over the 8-bit Galois field. This class is not performance-critical, so the implementations are simple and straightforward.
  • Field Details

  • 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

      public static MatrixOptimized identity(int size)
      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

      public String toString()
      Returns a human-readable string of the matrix contents. Example: [[1, 2], [3, 4]]
      Overrides:
      toString in class Object
    • toBigString

      public String toBigString()
      Returns a human-readable string of the matrix contents. Example: 00 01 02 03 04 05 06 07 08 09 0a 0b
    • equals

      public boolean equals(Object other)
      Returns true iff this matrix is identical to the other.
      Overrides:
      equals in class Object
    • times

      public MatrixOptimized times(MatrixOptimized right)
      Multiplies this matrix (the one on the left) by another matrix (the one on the right).
    • times

      public MatrixOptimized times(MatrixOptimized right, MatrixOptimized result)
      Multiplies this matrix (the one on the left) by another matrix (the one on the right).
    • augment

      public MatrixOptimized augment(MatrixOptimized right)
      Returns the concatenation of this matrix and the matrix on the right.
    • augment

      public MatrixOptimized augment(MatrixOptimized right, MatrixOptimized result)
      Returns the concatenation of this matrix and the matrix on the right.
    • submatrix

      public MatrixOptimized submatrix(int rmin, int cmin, int rmax, int cmax)
      Returns a part of this matrix.
    • submatrix

      public MatrixOptimized submatrix(int rmin, int cmin, int rmax, int cmax, MatrixOptimized result)
      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

      public MatrixOptimized invert()
      Returns the inverse of this matrix.
      Throws:
      IllegalArgumentException - when the matrix is singular and doesn't have an inverse.
    • invert

      public void invert(MatrixOptimized result, MatrixOptimized identity, MatrixOptimized work)
      Returns the inverse of this matrix.
      Throws:
      IllegalArgumentException - when the matrix is singular and doesn't have an inverse.
    • getData

      public byte[][] getData()