Package hlcd.operations
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.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanTo check if the matrix contains at least a single row of0.bytegetBase()Returns the base of the current matrix which is equivalent to the base of the code \(\mathsf{C}\).bytegetCell(byte r, byte c)Returns the value of a cell based on the row index and column index specified.bytegetCell(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.byteReturns 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[]Returns a column in the matrix specified based on the index specified.byteUses Bareiss Algorithm to find the determinant of \(G^{\prime}\), which is \(G^{\kern0pt}_{k \times n} \overline{G}^{T}_{n \times k}\).bytegetDeterminant(Matrix m)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.bytegetK()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.bytegetN()Returns the number of columns in the current matrix which is equivalent to the length \(n\) of the codeword in the code \(\mathsf{C}\).longgetRow(byte index)Returns a row in the current matrix based on the index specified.longgetRow(long[] matrixArray, byte index)Returns a row in the matrix array specified based on the index specified.longReturns 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.booleanReturnstrueif the current matrix is invertible (i.e., the determinant of the current matrix is not \(0\)),falseif the determinant is \(0\).booleanisInvertible(Matrix m)Returnstrueif the specified matrix is invertible (i.e., the determinant of the matrix is not \(0\)),falseif 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.Multiplies two specified matrices and returns the result as a new matrix.bytemultiplyRowByCol(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.bytemultiplyRowByCol(Matrix rightMatrix, byte rowIndex, byte columnIndex)Multiplies a row from current matrix by a column from specified matrix which yields a single digit.bytemultiplyRowByCol(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.longmultiplyRowByDigit(byte index, byte digit)Multiplies the row vector at the index specified in the current matrix by the digit specified.longmultiplyRowByDigit(long rowVector, byte digit, byte n, byte base)Multiplies the row vector specified by the digit specified.voidPrints 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.voidprintMatrix(boolean addBrackets, Style style, boolean showSize)Prints the current matrix on console with columns separated by a single space.voidprintMatrix(long[] matrixArray, byte n, byte base, String delimiter, boolean addBrackets, Style style, boolean showSize)Prints the specified matrix array on console.voidprintMatrix(String delimiter, boolean addBrackets, Style style, boolean showSize)Prints the current matrix on console.voidPrints the parameters (\(n\), \(k\) and \(base\)) of the code on console.voidsetCell(byte r, byte c, byte value)Sets the value of a cell based on its row index and column index in the current matrix.voidsetCell(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.voidSets the value of a cell based on the specified matrix, row index, column index and value.voidsetColumn(byte index, byte[] newColumnVector)Sets a specific column in the current matrix based on the specified column index and new column vector.voidsetColumn(long[] matrixArray, byte index, byte[] newColumnVector, byte base)Sets a specific column based on the specified matrix array, column index and new column vector.voidSets a specific column based on the specified matrix, column index and new column vector.voidsetMatrixArray(long[] matrixArray, byte n, byte k, boolean deepCopy)Sets the matrix array of the current matrix to the specified matrix array.voidsetRow(byte index, long newRowVector)Sets a specific row in the current matrix based on the specified row index and new row vector.voidsetRow(long[] matrixArray, byte index, long newRowVector)Sets a specific row based on the specified matrix array, row index and new row vector.voidSets 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.longtransposeColToRow(byte index)Returns the transpose of the column vector at the index in the current matrix.longtransposeColToRow(byte[] columnVector, byte base)Returns the transpose of the column vector specified.longtransposeColToRow(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
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 transposedn- 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
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 transposedn- the number of columns in the matrix arrayk- the number of rows in the matrix arraybase- 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
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 abytearray 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 abytearray 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 transposedx- the number of rows in the resultbase- the base of the code (could be either \(2\) or \(4\))- Returns:
- a column vector of size \(x \times 1\)
-
transposeRowToCol
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 abytearray 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 fromindex- 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 transposedbase- 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
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 fromindex- 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
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 fromrowIndex- the row index (zero-based) from current matrix to use for multiplicationcolumnIndex- 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
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 fromrightMatrix- The matrix to extract the column fromrowIndex- the row index (zero-based) fromleftMatrixto use for multiplicationcolumnIndex- the column index (zero-based) fromrightMatrixto use for multiplication- Returns:
- the result when the row from
leftMatrixis multiplied by the column fromrightMatrix
-
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 fromrightMatrixArray- The matrix to extract the column fromleftMatrixArrayN- the number of columns inleftMatrixArrayrightMatrixArrayN- the number of columns inrightMatrixArrayleftMatrixArrayK- the number of rows inleftMatrixArrayrightMatrixArrayK- the number of rows inrightMatrixArrayleftMatrixArrayBase- the base ofleftMatrixArray(could be either \(2\) or \(4\))rightMatrixArrayBase- the base ofrightMatrixArray(could be either \(2\) or \(4\))rowIndex- the row index (zero-based) fromleftMatrixArrayto use for multiplicationcolumnIndex- the column index (zero-based) fromrightMatrixArrayto use for multiplication- Returns:
- the result when the row from
leftMatrixArrayis multiplied by the column fromrightMatrixArray
-
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
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
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
Multiplies two specified matrices and returns the result as a new matrix. Both matrices will not be altered.- Parameters:
left- the left-hand-side matrixright- 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 arrayrightMatrix- the right-hand-side matrix arrayleftMatrixN- the number of columns in the left-hand-side matrix arrayrightMatrixN- the number of columns in the right-hand-side matrix arrayleftMatrixK- the number of rows in the left-hand-side matrix arrayrightMatrixK- the number of rows in the right-hand-side matrix arrayleftMatrixBase- the base ofleftMatrix(could be either \(2\) or \(4\))rightMatrixBase- the base ofrightMatrix(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 multiplieddigit- 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 multiplieddigit- 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 vectorbase- the base ofrowVector(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 fromindex- the index of the row (zero-based) in the matrix- Returns:
- the row in the matrix array specified based on the index specified
-
getRow
Returns a row in the matrix specified based on the index specified.- Parameters:
m- the matrix to obtain the row fromindex- 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 fromn- 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 matrixbase- 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
Returns a column in the matrix specified based on the index specified.- Parameters:
m- the matrix to obtain the column fromindex- 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 fromr- 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 arraybase- the base of the matrix array (could be either \(2\) or \(4\))- Returns:
- the value in cell \((r, c)\) of the matrix array
-
getCell
Returns the value of a cell based on the specified matrix, row index and column index.- Parameters:
m- the matrix to retrieve the cell fromr- 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
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 inr- 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 inr- 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 arraybase- 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 ton- the number of columns in the matrix arrayk- the number of rows in the matrix arraydeepCopy- 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 inindex- 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
Sets a specific row based on the specified matrix, row index and new row vector.- Parameters:
m- the matrix to set the row inindex- 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 inindex- the index of the column in the matrix array to be altered (zero-based)newColumnVector- the value of the new column to set asbase- the base of the matrix array (could be either \(2\) or \(4\))
-
setColumn
Sets a specific column based on the specified matrix, column index and new column vector.- Parameters:
m- the matrix to set the column inindex- 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()Returnstrueif the current matrix is invertible (i.e., the determinant of the current matrix is not \(0\)),falseif the determinant is \(0\).- Returns:
trueif the current matrix is invertible (i.e., the determinant of is not \(0\)),falseotherwise
-
containsZeroRow
boolean containsZeroRow()To check if the matrix contains at least a single row of0.- Returns:
trueif there exists a row that is0,falseotherwise
-
isInvertible
Returnstrueif the specified matrix is invertible (i.e., the determinant of the matrix is not \(0\)),falseif the determinant is \(0\).- Parameters:
m- the matrix to find the determinant of- Returns:
trueif the specified matrix is invertible (i.e., the determinant of is not \(0\)),falseotherwise
-
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
Prints the current matrix on console with columns separated by a single space. The brackets surrounding the matrix will be displayed ifaddBracketsistrue. Each digit is displayed based on the style specified. It will show the size of the matrix in the bottom-right corner ifshowSizeistrue.- Parameters:
addBrackets- should brackets around the matrix be displayedstyle- 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
Prints the current matrix on console. The columns will be separated by the delimiter specified. The brackets surrounding the matrix will be displayed ifaddBracketsistrue. Each digit is displayed based on the style specified. It will show the size of the matrix in the bottom-right corner ifshowSizeistrue.- Parameters:
delimiter- the delimiter between columns of current matrixaddBrackets- should brackets around the matrix be displayedstyle- 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 ifaddBracketsistrue. Each digit is displayed based on the style specified. It will show the size of the matrix in the bottom-right corner ifshowSizeistrue.- Parameters:
matrixArray- the matrix array to be displayed on consolen- the number of columns in the matrix arraybase- the base of the matrix array (could be either \(2\) or \(4\))delimiter- the delimiter between columns of current matrixaddBrackets- should brackets around the matrix be displayedstyle- 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
-