Package io.odilon.rs

Class Matrix


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

      Constructors 
      Constructor Description
      Matrix​(byte[][] initData)
      Initializes a matrix with the given row-major data.
      Matrix​(int initRows, int initColumns)
      Initialize a matrix of zeros.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Matrix augment​(Matrix right)
      Returns the concatenation of this matrix and the matrix on the right.
      boolean equals​(Object other)
      Returns true iff this matrix is identical to the other.
      byte get​(int r, int c)
      Returns the value at row r, column c.
      int getColumns()
      Returns the number of columns in this matrix.
      byte[] getRow​(int row)
      Returns one row of the matrix as a byte array.
      int getRows()
      Returns the number of rows in this matrix.
      static Matrix identity​(int size)
      Returns an identity matrix of the given size.
      Matrix invert()
      Returns the inverse of this matrix.
      void set​(int r, int c, byte value)
      Sets the value at row r, column c.
      Matrix submatrix​(int rmin, int cmin, int rmax, int cmax)
      Returns a part of this matrix.
      void swapRows​(int r1, int r2)
      Exchanges two rows in the matrix.
      Matrix times​(Matrix right)
      Multiplies this matrix (the one on the left) by another matrix (the one on the right).
      String toBigString()
      Returns a human-readable string of the matrix contents.
      String toString()
      Returns a human-readable string of the matrix contents.
    • Constructor Detail

      • 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 Detail

      • identity

        public static Matrix identity​(int size)
        Returns an identity matrix of the given size.
      • 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
      • 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

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

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

        public Matrix augment​(Matrix right)
        Returns the concatenation of this matrix and the matrix on the right.
      • submatrix

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

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