Interface MatrixOperations

All Known Implementing Classes:
Matrix

public interface MatrixOperations
Defines the operations of a matrix. A more in-depth explanation of how matrices are stored in this program can be found in the Matrix class that implements this interface.

TODO: create a method to transform the generator matrix to the parity check matrix.

Since:
1.8
Version:
1.0 (February 7th, 2022)
Author:
Maysara Al Jumaily
See Also:
Long, Matrix
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    To check if the matrix contains at least a single row of 0.
    byte
    Returns the base of the current matrix which is equivalent to the base of the code \(\mathsf{C}\).
    byte
    getCell​(byte r, byte c)
    Returns the value of a cell based on the row index and column index specified.
    byte
    getCell​(long[] matrixArray, byte r, byte c, byte n, byte base)
    Returns the value of a cell based on the specified matrix array, row index and column index.
    byte
    getCell​(Matrix m, byte r, byte c)
    Returns the value of a cell based on the specified matrix, row index and column index.
    byte[]
    getColumn​(byte index)
    Returns a column in the current matrix based on the index specified.
    byte[]
    getColumn​(long[] matrixArray, byte n, byte index, byte base)
    Returns a column in the matrix array specified based on the index specified.
    byte[]
    getColumn​(Matrix m, byte index)
    Returns a column in the matrix specified based on the index specified.
    byte
    Uses Bareiss Algorithm to find the determinant of \(G^{\prime}\), which is \(G^{\kern0pt}_{k \times n} \overline{G}^{T}_{n \times k}\).
    byte
    Uses Bareiss Algorithm to find the determinant of the matrix specified.
    Returns the matrix \(G^{\prime}_{k \times k} = G^{\kern0pt}_{k \times n} \overline{G}^{T}_{n \times k}\) without altering the current matrix.
    getGPrime​(byte lastPopulatedRowIndex)
    Returns the submatrix of \(G^{\prime}_{sub} = G^{\kern0pt}_{x \times n} \overline{G}^{T}_{n \times x}\), where \(x\) is the largest row index in \(G\) that is nonzero.
    byte
    Returns the number of rows in the current matrix which is equivalent to the dimension \(k\) of the code \(\mathsf{C}\).
    Returns the current matrix but not as a brand-new copy.
    long[]
    Returns the current matrix array but not as a brand-new instance.
    long[]
    Returns a brand-new copy of the current matrix array.
    long[]
    getMatrixArrayCopy​(long[] matrixArray)
    Returns a brand-new copy of the matrix array specified.
    byte
    Returns the number of columns in the current matrix which is equivalent to the length \(n\) of the codeword in the code \(\mathsf{C}\).
    long
    getRow​(byte index)
    Returns a row in the current matrix based on the index specified.
    long
    getRow​(long[] matrixArray, byte index)
    Returns a row in the matrix array specified based on the index specified.
    long
    getRow​(Matrix m, byte index)
    Returns a row in the matrix specified based on the index specified.
    Returns a new matrix that is the Hermitian transpose of the current matrix.
    long[]
    hermitianTranspose​(long[] matrixArray, byte n, byte k, byte base)
    Returns a new matrix that is the Hermitian transpose of the matrix array specified.
    Returns a new matrix that is the Hermitian transpose of the specified matrix.
    boolean
    Returns true if the current matrix is invertible (i.e., the determinant of the current matrix is not \(0\)), false if the determinant is \(0\).
    boolean
    Returns true if the specified matrix is invertible (i.e., the determinant of the matrix is not \(0\)), false if the determinant is \(0\).
    multiply​(long[] leftMatrix, long[] rightMatrix, byte leftMatrixN, byte rightMatrixN, byte leftMatrixK, byte rightMatrixK, byte leftMatrixBase, byte rightMatrixBase)
    Multiplies two specified matrix arrays and returns the result as a new matrix.
    Multiplies two matrices and returns the result as a new matrix.
    multiply​(Matrix left, Matrix right)
    Multiplies two specified matrices and returns the result as a new matrix.
    byte
    multiplyRowByCol​(long[] leftMatrixArray, long[] rightMatrixArray, byte leftMatrixArrayN, byte rightMatrixArrayN, byte leftMatrixArrayK, byte rightMatrixArrayK, byte leftMatrixArrayBase, byte rightMatrixArrayBase, byte rowIndex, byte columnIndex)
    Multiplies a row from matrix array specified by a column from the other specified matrix array which yields a single digit.
    byte
    multiplyRowByCol​(Matrix rightMatrix, byte rowIndex, byte columnIndex)
    Multiplies a row from current matrix by a column from specified matrix which yields a single digit.
    byte
    multiplyRowByCol​(Matrix leftMatrix, Matrix rightMatrix, byte rowIndex, byte columnIndex)
    Multiplies a row from matrix specified by a column from the other specified matrix which yields a single digit.
    long
    multiplyRowByDigit​(byte index, byte digit)
    Multiplies the row vector at the index specified in the current matrix by the digit specified.
    long
    multiplyRowByDigit​(long rowVector, byte digit, byte n, byte base)
    Multiplies the row vector specified by the digit specified.
    void
    Prints the current matrix on console with brackets surrounding the matrix, a single space between columns, each digit is written in base 10 as well as the size of the matrix.
    void
    printMatrix​(boolean addBrackets, Style style, boolean showSize)
    Prints the current matrix on console with columns separated by a single space.
    void
    printMatrix​(long[] matrixArray, byte n, byte base, String delimiter, boolean addBrackets, Style style, boolean showSize)
    Prints the specified matrix array on console.
    void
    printMatrix​(String delimiter, boolean addBrackets, Style style, boolean showSize)
    Prints the current matrix on console.
    void
    Prints the parameters (\(n\), \(k\) and \(base\)) of the code on console.
    void
    setCell​(byte r, byte c, byte value)
    Sets the value of a cell based on its row index and column index in the current matrix.
    void
    setCell​(long[] matrixArray, byte r, byte c, byte value, byte n, byte base)
    Sets the value of a cell based on its row index and column index in the current matrix.
    void
    setCell​(Matrix m, byte r, byte c, byte value)
    Sets the value of a cell based on the specified matrix, row index, column index and value.
    void
    setColumn​(byte index, byte[] newColumnVector)
    Sets a specific column in the current matrix based on the specified column index and new column vector.
    void
    setColumn​(long[] matrixArray, byte index, byte[] newColumnVector, byte base)
    Sets a specific column based on the specified matrix array, column index and new column vector.
    void
    setColumn​(Matrix m, byte index, byte[] newColumnVector)
    Sets a specific column based on the specified matrix, column index and new column vector.
    void
    setMatrixArray​(long[] matrixArray, byte n, byte k, boolean deepCopy)
    Sets the matrix array of the current matrix to the specified matrix array.
    void
    setRow​(byte index, long newRowVector)
    Sets a specific row in the current matrix based on the specified row index and new row vector.
    void
    setRow​(long[] matrixArray, byte index, long newRowVector)
    Sets a specific row based on the specified matrix array, row index and new row vector.
    void
    setRow​(Matrix m, byte index, long newRowVector)
    Sets a specific row based on the specified matrix, row index and new row vector.
    Returns a new matrix that is the transpose of the current matrix.
    long[]
    transpose​(long[] matrixArray, byte n, byte k, byte base)
    Returns a new matrix that is the transpose of specified matrix array.
    Will return a new matrix that is the transpose of the matrix specified.
    long
    transposeColToRow​(byte index)
    Returns the transpose of the column vector at the index in the current matrix.
    long
    transposeColToRow​(byte[] columnVector, byte base)
    Returns the transpose of the column vector specified.
    long
    transposeColToRow​(Matrix m, byte index)
    Returns the transpose of a specific column in the matrix specified matrix.
    byte[]
    transposeRowToCol​(byte index)
    Returns the transpose of the row vector at the index in the current matrix.
    byte[]
    transposeRowToCol​(long rowVector, byte x, byte base)
    Returns the transpose of the row vector specified.
    byte[]
    transposeRowToCol​(Matrix m, byte index)
    Returns the transpose of a specific row in the matrix specified matrix.
  • Method Details

    • transpose

      Matrix transpose()
      Returns a new matrix that is the transpose of the current matrix. The current matrix will not be altered.
      Returns:
      a new instance of the matrix transposed
      See Also:
      hermitianTranspose()
    • transpose

      Matrix transpose(Matrix m)
      Will return a new matrix that is the transpose of the matrix specified. The matrix specified will not be altered.
      Parameters:
      m - the matrix to be transposed
      Returns:
      a new instance of the matrix transposed
      See Also:
      hermitianTranspose(Matrix)
    • transpose

      long[] transpose(long[] matrixArray, byte n, byte k, byte base)
      Returns a new matrix that is the transpose of specified matrix array. The matrix array specified will not be altered.
      Parameters:
      matrixArray - the matrix array to be transposed
      n - the number of columns in the matrix array which is the same as the length of code \(\mathsf{C}\)
      k - the number of rows in the matrix array which is the same as the dimension of code \(\mathsf{C}\)
      base - the base of the code (could be either \(2\) or \(4\))
      Returns:
      a new instance of the matrix array transposed
      See Also:
      hermitianTranspose(long[], byte, byte, byte)
    • hermitianTranspose

      Matrix hermitianTranspose()
      Returns a new matrix that is the Hermitian transpose of the current matrix. The current matrix will not be altered. Essentially, it will apply the transpose of the current matrix and swap cells containing \(\omega\) with \(\overline{\omega}\) and vice-versa.
      Returns:
      a new instance of the Hermitian transpose of the current matrix
      See Also:
      transpose()
    • hermitianTranspose

      Matrix hermitianTranspose(Matrix m)
      Returns a new matrix that is the Hermitian transpose of the specified matrix. The matrix array will not be altered. Essentially, it will apply the transpose of the matrix and swap cells containing \(\omega\) with \(\overline{\omega}\) and vice-versa.
      Parameters:
      m - the matrix to be Hermitian transposed
      Returns:
      a new instance of the Hermitian transpose of specified matrix
      See Also:
      transpose(Matrix)
    • hermitianTranspose

      long[] hermitianTranspose(long[] matrixArray, byte n, byte k, byte base)
      Returns a new matrix that is the Hermitian transpose of the matrix array specified. The matrix array will not be altered. Essentially, it will apply the transpose of the matrix array and swap cells containing \(\omega\) with \(\overline{\omega}\) and vice-versa.
      Parameters:
      matrixArray - the matrix array to be Hermitian transposed
      n - the number of columns in the matrix array
      k - the number of rows in the matrix array
      base - the base of the code (could be either \(2\) or \(4\))
      Returns:
      a new instance of the Hermitian transpose of specified matrix array
      See Also:
      transpose(long[], byte, byte, byte)
    • getGPrime

      Matrix getGPrime(byte lastPopulatedRowIndex)
      Returns the submatrix of \(G^{\prime}_{sub} = G^{\kern0pt}_{x \times n} \overline{G}^{T}_{n \times x}\), where \(x\) is the largest row index in \(G\) that is nonzero. Since the generator matrix might contain zero vectors as it is defined like this by default, only nonzero vectors should be included in order to find \(G^{\prime}\). The single parameter denotes the number of valid codewords in \(G\). We can use this to create a new matrix \(G_{sub}\) with fewer rows, find its transpose \(\overline{G}^{T}_{sub}\), then multiply them together to get the submatrix \(G^{\prime}_{sub}\).
      Parameters:
      lastPopulatedRowIndex - the index of the last valid row in the generator matrix (zero-based). The index specified is also included.
      Returns:
      the submatrix of \(G^{\prime}_{sub} = G^{\kern0pt}_{x \times n} \overline{G}^{T}_{n \times x}\)
      See Also:
      getGPrime()
    • getGPrime

      Matrix getGPrime()
      Returns the matrix \(G^{\prime}_{k \times k} = G^{\kern0pt}_{k \times n} \overline{G}^{T}_{n \times k}\) without altering the current matrix.
      Returns:
      the matrix \(G^{\prime}_{k \times k} = G^{\kern0pt}_{k \times n} \overline{G}^{T}_{n \times k}\)
      See Also:
      getGPrime(byte)
    • transposeRowToCol

      byte[] transposeRowToCol(byte index)
      Returns the transpose of the row vector at the index in the current matrix. The current matrix will not be altered. For example, say that the current code is \(\left[n, \, k\right]_{base} = \left[5, \, 1\right]_{4}\). Assume the row specified is \begin{equation} \begin{bmatrix} 01 & 11 & 10 & 01 & 00 \end{bmatrix}, \end{equation} the transpose will be \begin{equation} \begin{bmatrix} 01 \\ 11 \\ 10 \\ 01 \\ 00 \end{bmatrix}. \end{equation} In this example, the row vector is stored as the following in Java: \begin{equation} \begin{bmatrix} 0b & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 01 & 11 & 10 & 01 & 00 \end{bmatrix}, \end{equation} and the output, which is a byte array will be \begin{equation} \begin{bmatrix} 0b & 00 & 00 & 00 & 01\\ 0b & 00 & 00 & 00 & 11\\ 0b & 00 & 00 & 00 & 10\\ 0b & 00 & 00 & 00 & 01\\ 0b & 00 & 00 & 00 & 00\\ \end{bmatrix}. \end{equation}
      Parameters:
      index - row index of the row in current matrix to be transposed (zero-based)
      Returns:
      a column vector of size \(n \times 1\)
    • transposeRowToCol

      byte[] transposeRowToCol(long rowVector, byte x, byte base)
      Returns the transpose of the row vector specified. For example, say that the current code is \(\left[n, \, k\right]_{base} = \left[5, \, 1\right]_{4}\). Assume the row specified is \begin{equation} \begin{bmatrix} 01 & 11 & 10 & 01 & 00 \end{bmatrix}, \end{equation} the transpose will be \begin{equation} \begin{bmatrix} 01 \\ 11 \\ 10 \\ 01 \\ 00 \end{bmatrix}. \end{equation} In this example, the row vector is stored as the following in Java: \begin{equation} \begin{bmatrix} 0b & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 01 & 11 & 10 & 01 & 00 \end{bmatrix}, \end{equation} and the output, which is a byte array will be \begin{equation} \begin{bmatrix} 0b & 00 & 00 & 00 & 01\\ 0b & 00 & 00 & 00 & 11\\ 0b & 00 & 00 & 00 & 10\\ 0b & 00 & 00 & 00 & 01\\ 0b & 00 & 00 & 00 & 00\\ \end{bmatrix}. \end{equation}
      Parameters:
      rowVector - the row vector to be transposed
      x - the number of rows in the result
      base - the base of the code (could be either \(2\) or \(4\))
      Returns:
      a column vector of size \(x \times 1\)
    • transposeRowToCol

      byte[] transposeRowToCol(Matrix m, byte index)
      Returns the transpose of a specific row in the matrix specified matrix. The matrix specified will not be altered. For example, say that the current code is \(\left[n, \, k\right]_{base} = \left[5, \, 1\right]_{4}\). Assume the row specified is \begin{equation} \begin{bmatrix} 01 & 11 & 10 & 01 & 00 \end{bmatrix}, \end{equation} the transpose will be \begin{equation} \begin{bmatrix} 01 \\ 11 \\ 10 \\ 01 \\ 00 \end{bmatrix}. \end{equation} In this example, the row vector is stored as the following in Java: \begin{equation} \begin{bmatrix} 0b & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 01 & 11 & 10 & 01 & 00 \end{bmatrix}, \end{equation} and the output, which is a byte array will be \begin{equation} \begin{bmatrix} 0b & 00 & 00 & 00 & 01\\ 0b & 00 & 00 & 00 & 11\\ 0b & 00 & 00 & 00 & 10\\ 0b & 00 & 00 & 00 & 01\\ 0b & 00 & 00 & 00 & 00\\ \end{bmatrix}. \end{equation}
      Parameters:
      m - the matrix to obtain the row vector from
      index - row index of the row in matrix specified to be transposed (zero-based)
      Returns:
      a column vector of size \(n \times 1\)
    • transposeColToRow

      long transposeColToRow(byte index)
      Returns the transpose of the column vector at the index in the current matrix. The current matrix will not be altered. For example, say that the current code is \(\left[n, \, k\right]_{base} = \left[1, \, 5\right]_{4}\). Assume the column specified is \begin{equation} \begin{bmatrix} 01 \\ 11 \\ 10 \\ 01 \\ 00 \end{bmatrix}, \end{equation} the transpose will be \begin{equation} \begin{bmatrix} 01 & 11 & 10 & 01 & 00 \end{bmatrix}. \end{equation} In this example, the column vector is stored as the following in Java: \begin{equation} \begin{bmatrix} 0b & 00 & 00 & 00 & 01\\ 0b & 00 & 00 & 00 & 11\\ 0b & 00 & 00 & 00 & 10\\ 0b & 00 & 00 & 00 & 01\\ 0b & 00 & 00 & 00 & 00\\ \end{bmatrix}, \end{equation} and the output stored as \begin{equation} \begin{bmatrix} 0b & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 01 & 11 & 10 & 01 & 00 \end{bmatrix}. \end{equation}
      Parameters:
      index - column index of the column in current matrix to be transposed (zero-based)
      Returns:
      a row vector of size \(1 \times k\) with non-used entries as zeros
    • transposeColToRow

      long transposeColToRow(byte[] columnVector, byte base)
      Returns the transpose of the column vector specified. For example, say that the current code is \(\left[n, \, k\right]_{base} = \left[1, \, 5\right]_{4}\). Assume the column specified is \begin{equation} \begin{bmatrix} 01 \\ 11 \\ 10 \\ 01 \\ 00 \end{bmatrix}, \end{equation} the transpose will be \begin{equation} \begin{bmatrix} 01 & 11 & 10 & 01 & 00 \end{bmatrix}. \end{equation} In this example, the column vector is stored as the following in Java: \begin{equation} \begin{bmatrix} 0b & 00 & 00 & 00 & 01\\ 0b & 00 & 00 & 00 & 11\\ 0b & 00 & 00 & 00 & 10\\ 0b & 00 & 00 & 00 & 01\\ 0b & 00 & 00 & 00 & 00\\ \end{bmatrix}, \end{equation} and the output stored as \begin{equation} \begin{bmatrix} 0b & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 01 & 11 & 10 & 01 & 00 \end{bmatrix}. \end{equation}
      Parameters:
      columnVector - the column vector to be transposed
      base - the base of the code (could be either \(2\) or \(4\))
      Returns:
      a row vector of size \(1 \times k\) with non-used entries as zeros
    • transposeColToRow

      long transposeColToRow(Matrix m, byte index)
      Returns the transpose of a specific column in the matrix specified matrix. The matrix specified will not be altered. For example, say that the current code is \(\left[n, \, k\right]_{base} = \left[1, \, 5\right]_{4}\). Assume the column specified is \begin{equation} \begin{bmatrix} 01 \\ 11 \\ 10 \\ 01 \\ 00 \end{bmatrix}, \end{equation} the transpose will be \begin{equation} \begin{bmatrix} 01 & 11 & 10 & 01 & 00 \end{bmatrix}. \end{equation} In this example, the column vector is stored as the following in Java: \begin{equation} \begin{bmatrix} 0b & 00 & 00 & 00 & 01\\ 0b & 00 & 00 & 00 & 11\\ 0b & 00 & 00 & 00 & 10\\ 0b & 00 & 00 & 00 & 01\\ 0b & 00 & 00 & 00 & 00\\ \end{bmatrix}, \end{equation} and the output stored as \begin{equation} \begin{bmatrix} 0b & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 01 & 11 & 10 & 01 & 00 \end{bmatrix}. \end{equation}
      Parameters:
      m - the matrix to obtain the column vector from
      index - column index of the column in matrix specified to be transposed (zero-based)
      Returns:
      a row vector of size \(1 \times k\) with non-used entries as zeros
    • multiplyRowByCol

      byte multiplyRowByCol(Matrix rightMatrix, byte rowIndex, byte columnIndex)
      Multiplies a row from current matrix by a column from specified matrix which yields a single digit. The digit can either be a \(0\) or \(1\) in base \(2\) or \(0\), \(1\), \(2\) or \(3\) in base \(4\). The row will be extracted from the current matrix whereas the column will be extracted from the matrix specified.
      Parameters:
      rightMatrix - The matrix to extract the column from
      rowIndex - the row index (zero-based) from current matrix to use for multiplication
      columnIndex - the column index (zero-based) from matrix specified to use for multiplication
      Returns:
      the result when the row from current matrix is multiplied by the column from the matrix specified
    • multiplyRowByCol

      byte multiplyRowByCol(Matrix leftMatrix, Matrix rightMatrix, byte rowIndex, byte columnIndex)
      Multiplies a row from matrix specified by a column from the other specified matrix which yields a single digit. The digit can either be a \(0\) or \(1\) in base \(2\) or \(0\), \(1\), \(2\) or \(3\) in base \(4\). The row will be extracted from the left matrix specified whereas the column will be extracted from the right matrix specified.
      Parameters:
      leftMatrix - The matrix to extract the row from
      rightMatrix - The matrix to extract the column from
      rowIndex - the row index (zero-based) from leftMatrix to use for multiplication
      columnIndex - the column index (zero-based) from rightMatrix to use for multiplication
      Returns:
      the result when the row from leftMatrix is multiplied by the column from rightMatrix
    • multiplyRowByCol

      byte multiplyRowByCol(long[] leftMatrixArray, long[] rightMatrixArray, byte leftMatrixArrayN, byte rightMatrixArrayN, byte leftMatrixArrayK, byte rightMatrixArrayK, byte leftMatrixArrayBase, byte rightMatrixArrayBase, byte rowIndex, byte columnIndex)
      Multiplies a row from matrix array specified by a column from the other specified matrix array which yields a single digit. The digit can either be a \(0\) or \(1\) in base \(2\) or \(0\), \(1\), \(2\) or \(3\) in base \(4\). The row will be extracted from the left matrix array specified whereas the column will be extracted from the right matrix specified.
      Parameters:
      leftMatrixArray - The matrix to extract the row from
      rightMatrixArray - The matrix to extract the column from
      leftMatrixArrayN - the number of columns in leftMatrixArray
      rightMatrixArrayN - the number of columns in rightMatrixArray
      leftMatrixArrayK - the number of rows in leftMatrixArray
      rightMatrixArrayK - the number of rows in rightMatrixArray
      leftMatrixArrayBase - the base of leftMatrixArray (could be either \(2\) or \(4\))
      rightMatrixArrayBase - the base of rightMatrixArray (could be either \(2\) or \(4\))
      rowIndex - the row index (zero-based) from leftMatrixArray to use for multiplication
      columnIndex - the column index (zero-based) from rightMatrixArray to use for multiplication
      Returns:
      the result when the row from leftMatrixArray is multiplied by the column from rightMatrixArray
    • getDeterminant

      byte getDeterminant()
      Uses Bareiss Algorithm to find the determinant of \(G^{\prime}\), which is \(G^{\kern0pt}_{k \times n} \overline{G}^{T}_{n \times k}\). It uses the current matrix stored and multiplies it by its complex conjugation and finds the determinant of that resulting matrix after multiplication. This will not alter any matrices in the program and should be used for quaternary codes.
      Returns:
      the determinant of \(G^{\prime} = G^{\kern0pt}_{k \times n} \overline{G}^{T}_{n \times k}\), which could either be \(0\), \(1\), \(2\) or \(3\) in base \(4\)
    • getDeterminant

      byte getDeterminant(Matrix m)
      Uses Bareiss Algorithm to find the determinant of the matrix specified. This will not alter the matrix specified and should be used for quaternary codes.
      Parameters:
      m - the matrix to find the determinant of
      Returns:
      the determinant of the matrix specified
    • multiply

      Matrix multiply(Matrix m)
      Multiplies two matrices and returns the result as a new matrix. The current matrix will be the left-hand-side matrix and the matrix specified will be the right-hand-side matrix. Both matrices will not be altered.

      Note: It is common to have the left-hand-side matrix to be the generator matrix \(G\) of the code \(\mathsf{C}\) whereas the left-hand-side matrix to be \(\overline{G}^{T}_{n \times k}\) or \(G^{T}_{n \times k}\).

      Parameters:
      m - the right-hand-side matrix
      Returns:
      a new instance of a matrix representing the result when the current matrix (left) multiplied by the matrix specified (right)
    • multiply

      Matrix multiply(Matrix left, Matrix right)
      Multiplies two specified matrices and returns the result as a new matrix. Both matrices will not be altered.
      Parameters:
      left - the left-hand-side matrix
      right - the right-hand-side matrix
      Returns:
      a new instance of a matrix representing the result when the left matrix specified is multiplied by the right matrix specified
    • multiply

      Matrix multiply(long[] leftMatrix, long[] rightMatrix, byte leftMatrixN, byte rightMatrixN, byte leftMatrixK, byte rightMatrixK, byte leftMatrixBase, byte rightMatrixBase)
      Multiplies two specified matrix arrays and returns the result as a new matrix. Both matrix arrays will not be altered.
      Parameters:
      leftMatrix - the left-hand-side matrix array
      rightMatrix - the right-hand-side matrix array
      leftMatrixN - the number of columns in the left-hand-side matrix array
      rightMatrixN - the number of columns in the right-hand-side matrix array
      leftMatrixK - the number of rows in the left-hand-side matrix array
      rightMatrixK - the number of rows in the right-hand-side matrix array
      leftMatrixBase - the base of leftMatrix (could be either \(2\) or \(4\))
      rightMatrixBase - the base of rightMatrix (could be either \(2\) or \(4\))
      Returns:
      a new instance of a matrix representing the result when the left matrix array specified is multiplied by the right matrix array specified
    • multiplyRowByDigit

      long multiplyRowByDigit(byte index, byte digit)
      Multiplies the row vector at the index specified in the current matrix by the digit specified.
      Parameters:
      index - the index of the row vector to be multiplied
      digit - the digit the row vector to be multiplied by. When the base is \(2\), only \(0\) and \(1\) are the valid digits. For base \(4\), only \(0\), \(1\), \(2\) and \(3\) are the valid digits
      Returns:
      the result when the specified digit is multiplied by the specified index of the row vector
    • multiplyRowByDigit

      long multiplyRowByDigit(long rowVector, byte digit, byte n, byte base)
      Multiplies the row vector specified by the digit specified.
      Parameters:
      rowVector - the row vector to be multiplied
      digit - the digit the row vector to be multiplied by. When the base is \(2\), only \(0\) and \(1\) are the valid digits. For base \(4\), only \(0\), \(1\), \(2\) and \(3\) are the valid digits.
      n - the number of columns in the row vector
      base - the base of rowVector (could be either \(2\) or \(4\))
      Returns:
      the result when the specified digit is multiplied by the specified row vector
    • getMatrix

      Matrix getMatrix()
      Returns the current matrix but not as a brand-new copy.
      Returns:
      the current matrix
      See Also:
      Matrix.clone()
    • getMatrixArray

      long[] getMatrixArray()
      Returns the current matrix array but not as a brand-new instance.
      Returns:
      the current matrix array
      See Also:
      Matrix.getMatrixArrayCopy()
    • getMatrixArrayCopy

      long[] getMatrixArrayCopy()
      Returns a brand-new copy of the current matrix array.
      Returns:
      the current matrix array as a brand-new copy
      See Also:
      Matrix.getMatrixArray()
    • getMatrixArrayCopy

      long[] getMatrixArrayCopy(long[] matrixArray)
      Returns a brand-new copy of the matrix array specified.
      Parameters:
      matrixArray - the matrix array to be copy
      Returns:
      a brand-new copy of matrix array specified
    • getBase

      byte getBase()
      Returns the base of the current matrix which is equivalent to the base of the code \(\mathsf{C}\). It is either \(2\) or \(4\).
      Returns:
      the base of the current matrix which is either \(2\) or \(4\)
    • getN

      byte getN()
      Returns the number of columns in the current matrix which is equivalent to the length \(n\) of the codeword in the code \(\mathsf{C}\).
      Returns:
      the number of columns in the current matrix which is equivalent to the length of the codeword in the code
    • getK

      byte getK()
      Returns the number of rows in the current matrix which is equivalent to the dimension \(k\) of the code \(\mathsf{C}\).
      Returns:
      the number of rows in the current matrix which is equivalent to the dimension of the code
    • getRow

      long getRow(byte index)
      Returns a row in the current matrix based on the index specified.
      Parameters:
      index - the index of the row (zero-based) in the matrix
      Returns:
      the row in the current matrix based on the index specified
    • getRow

      long getRow(long[] matrixArray, byte index)
      Returns a row in the matrix array specified based on the index specified.
      Parameters:
      matrixArray - the matrix array to obtain the row from
      index - the index of the row (zero-based) in the matrix
      Returns:
      the row in the matrix array specified based on the index specified
    • getRow

      long getRow(Matrix m, byte index)
      Returns a row in the matrix specified based on the index specified.
      Parameters:
      m - the matrix to obtain the row from
      index - the index of the row (zero-based) in the matrix
      Returns:
      the row in the matrix specified based on the index specified
    • getColumn

      byte[] getColumn(byte index)
      Returns a column in the current matrix based on the index specified.
      Parameters:
      index - the index of the column (zero-based) in the matrix
      Returns:
      the column in the current matrix based on the index specified
    • getColumn

      byte[] getColumn(long[] matrixArray, byte n, byte index, byte base)
      Returns a column in the matrix array specified based on the index specified.
      Parameters:
      matrixArray - the matrix array to obtain the column from
      n - the number of columns in the matrix array which is the same as the length of code \(\mathsf{C}\)
      index - the index of the column (zero-based) in the matrix
      base - the base of the matrix array (could be either \(2\) or \(4\))
      Returns:
      the column in the matrix array specified based on the index specified
    • getColumn

      byte[] getColumn(Matrix m, byte index)
      Returns a column in the matrix specified based on the index specified.
      Parameters:
      m - the matrix to obtain the column from
      index - the index of the column (zero-based) in the matrix
      Returns:
      the column in the matrix specified based on the index specified
    • getCell

      byte getCell(byte r, byte c)
      Returns the value of a cell based on the row index and column index specified.
      Parameters:
      r - the row index of the cell in the current matrix to retrieve from (zero-based)
      c - the column index of the cell in the current matrix to retrieve from (zero-based)
      Returns:
      the value in cell \((r, c)\)
    • getCell

      byte getCell(long[] matrixArray, byte r, byte c, byte n, byte base)
      Returns the value of a cell based on the specified matrix array, row index and column index.
      Parameters:
      matrixArray - the matrix array to retrieve the cell from
      r - the row index of the cell in the matrix array to retrieve from (zero-based)
      c - the column index of the cell in the matrix array to retrieve from (zero-based)
      n - the number of columns in the matrix array
      base - the base of the matrix array (could be either \(2\) or \(4\))
      Returns:
      the value in cell \((r, c)\) of the matrix array
    • getCell

      byte getCell(Matrix m, byte r, byte c)
      Returns the value of a cell based on the specified matrix, row index and column index.
      Parameters:
      m - the matrix to retrieve the cell from
      r - the row index of the cell in the matrix to retrieve from (zero-based)
      c - the column index of the cell in the matrix to retrieve from (zero-based)
      Returns:
      the value in cell \((r, c)\) of the matrix
    • setCell

      void setCell(byte r, byte c, byte value)
      Sets the value of a cell based on its row index and column index in the current matrix.
      Parameters:
      r - the row index of the cell in the current matrix to set (zero-based)
      c - the column index of the cell in the current matrix to set (zero-based)
      value - the value to be set to which can be a \(0\) or \(1\) when the base is \(2\) or \(0\), \(1\), \(2\), or \(3\) in base \(4\)
    • setCell

      void setCell(Matrix m, byte r, byte c, byte value)
      Sets the value of a cell based on the specified matrix, row index, column index and value.
      Parameters:
      m - the matrix to set the cell in
      r - the row index of the cell in the matrix to set (zero-based)
      c - the column index of the cell in the matrix to set (zero-based)
      value - the value to be set to which can be a \(0\) or \(1\) when the base is \(2\) or \(0\), \(1\), \(2\), or \(3\) in base \(4\)
    • setCell

      void setCell(long[] matrixArray, byte r, byte c, byte value, byte n, byte base)
      Sets the value of a cell based on its row index and column index in the current matrix.
      Parameters:
      matrixArray - the matrix array to set the cell in
      r - the row index of the cell in the current matrix to set (zero-based)
      c - the column index of the cell in the current matrix to set (zero-based)
      value - the value to be set to which can be a \(0\) or \(1\) when the base is \(2\) or \(0\), \(1\), \(2\), or \(3\) in base \(4\)
      n - the number of columns in the matrix array
      base - the base of matrix array (could be either \(2\) or \(4\))
    • setMatrixArray

      void setMatrixArray(long[] matrixArray, byte n, byte k, boolean deepCopy)
      Sets the matrix array of the current matrix to the specified matrix array. There are two ways to achieve that: either assign the array passed (non-deep copy) or reinitialized the array in the matrix, loop through the specified matrix array and copy each cell individually. The dimension of the specified matrix array must match the current one. Otherwise, the operation will not be applied.
      Parameters:
      matrixArray - the new matrix array to set to
      n - the number of columns in the matrix array
      k - the number of rows in the matrix array
      deepCopy - whether a deep copy is desired
    • setRow

      void setRow(byte index, long newRowVector)
      Sets a specific row in the current matrix based on the specified row index and new row vector.
      Parameters:
      index - the index of the row in current matrix to be altered (zero-based)
      newRowVector - the value of the new row to set as
    • setRow

      void setRow(long[] matrixArray, byte index, long newRowVector)
      Sets a specific row based on the specified matrix array, row index and new row vector.
      Parameters:
      matrixArray - the matrix array to set the row in
      index - the index of the row in the matrix array to be altered (zero-based)
      newRowVector - the value of the new row to set as
    • setRow

      void setRow(Matrix m, byte index, long newRowVector)
      Sets a specific row based on the specified matrix, row index and new row vector.
      Parameters:
      m - the matrix to set the row in
      index - the index of the row in matrix to be altered (zero-based)
      newRowVector - the value of the new row to set as
    • setColumn

      void setColumn(byte index, byte[] newColumnVector)
      Sets a specific column in the current matrix based on the specified column index and new column vector.
      Parameters:
      index - the index of the column in current matrix to be altered (zero-based)
      newColumnVector - the value of the new column to set as
    • setColumn

      void setColumn(long[] matrixArray, byte index, byte[] newColumnVector, byte base)
      Sets a specific column based on the specified matrix array, column index and new column vector.
      Parameters:
      matrixArray - the matrix array to set the column in
      index - the index of the column in the matrix array to be altered (zero-based)
      newColumnVector - the value of the new column to set as
      base - the base of the matrix array (could be either \(2\) or \(4\))
    • setColumn

      void setColumn(Matrix m, byte index, byte[] newColumnVector)
      Sets a specific column based on the specified matrix, column index and new column vector.
      Parameters:
      m - the matrix to set the column in
      index - the index of the column in the matrix to be altered (zero-based)
      newColumnVector - the value of the new column to set as
    • isInvertible

      boolean isInvertible()
      Returns true if the current matrix is invertible (i.e., the determinant of the current matrix is not \(0\)), false if the determinant is \(0\).
      Returns:
      true if the current matrix is invertible (i.e., the determinant of is not \(0\)), false otherwise
    • containsZeroRow

      boolean containsZeroRow()
      To check if the matrix contains at least a single row of 0.
      Returns:
      true if there exists a row that is 0, false otherwise
    • isInvertible

      boolean isInvertible(Matrix m)
      Returns true if the specified matrix is invertible (i.e., the determinant of the matrix is not \(0\)), false if the determinant is \(0\).
      Parameters:
      m - the matrix to find the determinant of
      Returns:
      true if the specified matrix is invertible (i.e., the determinant of is not \(0\)), false otherwise
    • printParameters

      void printParameters()
      Prints the parameters (\(n\), \(k\) and \(base\)) of the code on console.
    • printMatrix

      void printMatrix()
      Prints the current matrix on console with brackets surrounding the matrix, a single space between columns, each digit is written in base 10 as well as the size of the matrix.
    • printMatrix

      void printMatrix(boolean addBrackets, Style style, boolean showSize)
      Prints the current matrix on console with columns separated by a single space. The brackets surrounding the matrix will be displayed if addBrackets is true. Each digit is displayed based on the style specified. It will show the size of the matrix in the bottom-right corner if showSize is true.
      Parameters:
      addBrackets - should brackets around the matrix be displayed
      style - the style format which could either be binary, quaternary, decimal or \(\LaTeX\)
      showSize - should the dimension of the matrix be shown at the bottom-right
    • printMatrix

      void printMatrix(String delimiter, boolean addBrackets, Style style, boolean showSize)
      Prints the current matrix on console. The columns will be separated by the delimiter specified. The brackets surrounding the matrix will be displayed if addBrackets is true. Each digit is displayed based on the style specified. It will show the size of the matrix in the bottom-right corner if showSize is true.
      Parameters:
      delimiter - the delimiter between columns of current matrix
      addBrackets - should brackets around the matrix be displayed
      style - the style format which could either be binary, quaternary, decimal or \(\LaTeX\)
      showSize - should the dimension of the matrix be shown at the bottom-right
    • printMatrix

      void printMatrix(long[] matrixArray, byte n, byte base, String delimiter, boolean addBrackets, Style style, boolean showSize)
      Prints the specified matrix array on console. The columns will be separated by the delimiter specified. The brackets surrounding the matrix will be displayed if addBrackets is true. Each digit is displayed based on the style specified. It will show the size of the matrix in the bottom-right corner if showSize is true.
      Parameters:
      matrixArray - the matrix array to be displayed on console
      n - the number of columns in the matrix array
      base - the base of the matrix array (could be either \(2\) or \(4\))
      delimiter - the delimiter between columns of current matrix
      addBrackets - should brackets around the matrix be displayed
      style - the style format which could either be binary, quaternary, decimal or \(\LaTeX\)
      showSize - should the dimension of the matrix be shown at the bottom-right