Package hlcd.operations
Class Matrix
java.lang.Object
hlcd.operations.Matrix
- All Implemented Interfaces:
MatrixOperations,Serializable,Cloneable
Defines a matrix as a 1-D array where there are 62 columns. The two
far-left columns (i.e., indices
0 and 1) are not
used. The indices 2 and above are used. A vector will start at the
appropriate column and span to the right direction \(n\) columns. Using this
approach, the columns that will be covered are: x, x+1,
..., 62 and 63 (far-right). For example, consider
the following randomly matrix of a \(\left[n, \, k\right]_{base} = \left[7,
\,4\right]_{4}\) code:
\begin{equation}
\begin{bmatrix}
\omega & \omega & \omega & 0 &
\overline{\omega} & 0 & 0\\
\omega & \overline{\omega} & \omega & 1 & 0 &
\overline{\omega} & \overline{\omega}\\
0 & \omega & \overline{\omega} & 1 & \omega &
\overline{\omega} & \omega\\
1 & \overline{\omega} & 1 & 0 &
0 & 1 &\overline{\omega}
\end{bmatrix}.
\end{equation}
In Java, the binary representation of each of the four vectors is written 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 & 10 & 10 & 10 & 00 & 11 & 00 & 00\\
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 & 10 & 11 & 10 & 01 & 00 & 11 & 11\\
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 & 10 & 11 & 01 & 10 & 11 & 10\\
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 & 01 & 11 & 01 & 00 & 00 & 01 & 11\\
\end{bmatrix}.
\end{equation}
It also has the ability to find the transpose of the current matrix,
complex conjugation transpose and the determinant. Finding the determinant
uses a modified version of Bareiss's Algorithm. A complete pseudocode can be
on page 96 of the
thesis. The algorithm is implemented in the private method of this
class getDeterminantEngine(Matrix).
TODO: create a method to return the parity check matrix when the generator matrix is in standard form.
//minimal example to execute this class:
public static void main(String[] args) {
System.out.println("Running the \"Matrix\" class...");
//generate a random matrix array
byte minN = 7;
byte maxN = 7;
byte minK = 4;
byte maxK = 4;
RandomMatrixGenerator rmg = new RandomMatrixGenerator(
minN, maxN, minK, maxK, (byte) 4
);
//convert matrix array to a Matrix object
Matrix g = new Matrix(
rmg.getMatrixArrayClone(), rmg.getN(), rmg.getK(), rmg.getBase()
);
//print the matrix using all possible styles
System.out.println("Printing matrix using binary style:");
g.printMatrix(" ", false, Style.BINARY, false);
System.out.println();
System.out.println("Printing matrix using decimal style:");
g.printMatrix(" ", false, Style.DECIMAL, true);
System.out.println();
System.out.println("Printing matrix using quaternary style:");
g.printMatrix(" ", true, Style.QUATERNARY, false);
System.out.println();
System.out.println("Printing matrix using LaTeX style:");
g.printMatrix(" ", true, Style.LATEX, true);
System.out.println("Transposing the top row of the matrix:");
byte[] col = g.transposeRowToCol((byte) 0);
for (int i = 0; i < col.length; i++) {
System.out.println(col[i]);
}
System.out.println("Transposing the far-left column of the matrix:");
long row = g.transposeColToRow((byte) 0);
System.out.println(MatrixPrinter.vectorAsString(
row, g.getK(), g.getN(), " ", Style.DECIMAL
));
System.out.println();
System.out.println("Transposing the matrix:");
Matrix transpose = g.transpose();
transpose.printMatrix(" ", true, Style.DECIMAL, true);
System.out.println();
System.out.println("Hermitian transposing the matrix:");
Matrix hermitianTranspose = g.hermitianTranspose();
hermitianTranspose.printMatrix(" ", true, Style.DECIMAL, true);
System.out.println("The \"Matrix\" class completed.");
}- Since:
- 1.8
- Version:
- 1.0 (February 8th, 2022)
- Author:
- Maysara Al Jumaily
- See Also:
Long, M.Sc. thesis, Serialized Form
-
Constructor Summary
ConstructorsConstructorDescriptionMatrix()Creates a random quaternary matrix with \(1 \leq k \leq 30\) and \(1 \leq n \leq 30\).Matrix(byte n, byte k)Creates a random quaternary matrix with the specified dimension.Matrix(byte n, byte k, byte base)Creates a matrix based on the specified values of \(n\), \(k\), \(d\) and \(base\).Matrix(long[] matrixArray, byte n, byte k, byte base)Creates a matrix based on the specified values of \(n\), \(k\), \(d\), \(base\) and the matrix array. -
Method Summary
Modifier and TypeMethodDescriptionclone()Returns the current matrix as a brand-new copy.booleanTo 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 examiningRow)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[] arrayMatrix, 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[] leftMatrixArray, long[] rightMatrixArray, byte leftMatrixArrayN, byte rightMatrixArrayN, byte leftMatrixArrayK, byte rightMatrixArrayK, byte leftMatrixArrayBase, byte rightMatrixArrayBase)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[] leftMatrix, long[] rightMatrix, byte leftMatrixArrayN, byte rightMatrixArrayN, byte leftMatrixArrayK, byte rightMatrixArrayK, byte leftMatrixArrayBase, byte rightMatrixArrayBase, byte row, byte column)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 row, byte column)Multiplies a row from current matrix by a column from specified matrix which yields a single digit.bytemultiplyRowByCol(Matrix leftMatrix, Matrix rightMatrix, byte row, byte column)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 row, byte column, 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 columnIndex, byte[] newColumn)Sets a specific column in the current matrix based on the specified column index and new column vector.voidsetColumn(long[] matrixArray, byte columnIndex, byte[] newColumn, 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 newRow)Sets a specific row in the current matrix based on the specified row index and new row vector.voidsetRow(long[] matrixArray, byte index, long newRow)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 columnIndex)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 columnIndex)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 row)Returns the transpose of a specific row in the matrix specified matrix.
-
Constructor Details
-
Matrix
public Matrix()Creates a random quaternary matrix with \(1 \leq k \leq 30\) and \(1 \leq n \leq 30\). This constructor can be used for testing. -
Matrix
public Matrix(byte n, byte k)Creates a random quaternary matrix with the specified dimension. This specific constructor can be used for testing.- Parameters:
n- the number of columns in the matrix (which should match the length of codewords in the code)k- the number of rows in the matrix (which should match the dimension of the code)
-
Matrix
public Matrix(byte n, byte k, byte base)Creates a matrix based on the specified values of \(n\), \(k\), \(d\) and \(base\). A null matrix will be created.- Parameters:
n- the number of columns in the matrix (which should match the length of codewords in the code)k- the number of rows in the matrix (which should match the dimension of the code)base- the base of the code (could be either \(2\) or \(4\))
-
Matrix
public Matrix(long[] matrixArray, byte n, byte k, byte base)Creates a matrix based on the specified values of \(n\), \(k\), \(d\), \(base\) and the matrix array.- Parameters:
matrixArray- the default values to assign the cells of the matrixn- the number of columns in the matrix (which should match the length of codewords in the code)k- the number of rows in the matrix (which should match the dimension of the code)base- the base of the code (could be either \(2\) or \(4\))
-
-
Method Details
-
transposeRowToCol
public byte[] transposeRowToCol(byte index)Description copied from interface:MatrixOperationsReturns 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}- Specified by:
transposeRowToColin interfaceMatrixOperations- 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
public byte[] transposeRowToCol(long rowVector, byte x, byte base)Description copied from interface:MatrixOperationsReturns 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}- Specified by:
transposeRowToColin interfaceMatrixOperations- 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
Description copied from interface:MatrixOperationsReturns 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}- Specified by:
transposeRowToColin interfaceMatrixOperations- Parameters:
m- the matrix to obtain the row vector fromrow- row index of the row in matrix specified to be transposed (zero-based)- Returns:
- a column vector of size \(n \times 1\)
-
transposeColToRow
public long transposeColToRow(byte columnIndex)Description copied from interface:MatrixOperationsReturns 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}- Specified by:
transposeColToRowin interfaceMatrixOperations- Parameters:
columnIndex- 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
public long transposeColToRow(byte[] columnVector, byte base)Description copied from interface:MatrixOperationsReturns 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}- Specified by:
transposeColToRowin interfaceMatrixOperations- 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
Description copied from interface:MatrixOperationsReturns 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}- Specified by:
transposeColToRowin interfaceMatrixOperations- Parameters:
m- the matrix to obtain the column vector fromcolumnIndex- 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
-
transpose
Description copied from interface:MatrixOperationsReturns a new matrix that is the transpose of the current matrix. The current matrix will not be altered.- Specified by:
transposein interfaceMatrixOperations- Returns:
- a new instance of the matrix transposed
- See Also:
MatrixOperations.hermitianTranspose()
-
transpose
Description copied from interface:MatrixOperationsWill return a new matrix that is the transpose of the matrix specified. The matrix specified will not be altered.- Specified by:
transposein interfaceMatrixOperations- Parameters:
m- the matrix to be transposed- Returns:
- a new instance of the matrix transposed
- See Also:
MatrixOperations.hermitianTranspose(Matrix)
-
transpose
public long[] transpose(long[] matrixArray, byte n, byte k, byte base)Description copied from interface:MatrixOperationsReturns a new matrix that is the transpose of specified matrix array. The matrix array specified will not be altered.- Specified by:
transposein interfaceMatrixOperations- 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:
MatrixOperations.hermitianTranspose(long[], byte, byte, byte)
-
hermitianTranspose
Description copied from interface:MatrixOperationsReturns 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.- Specified by:
hermitianTransposein interfaceMatrixOperations- Returns:
- a new instance of the Hermitian transpose of the current matrix
- See Also:
MatrixOperations.transpose()
-
hermitianTranspose
Description copied from interface:MatrixOperationsReturns 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.- Specified by:
hermitianTransposein interfaceMatrixOperations- Parameters:
m- the matrix to be Hermitian transposed- Returns:
- a new instance of the Hermitian transpose of specified matrix
- See Also:
MatrixOperations.transpose(Matrix)
-
hermitianTranspose
public long[] hermitianTranspose(long[] matrixArray, byte n, byte k, byte base)Description copied from interface:MatrixOperationsReturns 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.- Specified by:
hermitianTransposein interfaceMatrixOperations- 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:
MatrixOperations.transpose(long[], byte, byte, byte)
-
clone
Returns the current matrix as a brand-new copy. -
getMatrixArrayCopy
public long[] getMatrixArrayCopy()Description copied from interface:MatrixOperationsReturns a brand-new copy of the current matrix array.- Specified by:
getMatrixArrayCopyin interfaceMatrixOperations- Returns:
- the current matrix array as a brand-new copy
- See Also:
getMatrixArray()
-
getMatrixArrayCopy
public long[] getMatrixArrayCopy(long[] matrixArray)Description copied from interface:MatrixOperationsReturns a brand-new copy of the matrix array specified.- Specified by:
getMatrixArrayCopyin interfaceMatrixOperations- Parameters:
matrixArray- the matrix array to be copy- Returns:
- a brand-new copy of matrix array specified
-
multiplyRowByCol
Description copied from interface:MatrixOperationsMultiplies 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.- Specified by:
multiplyRowByColin interfaceMatrixOperations- Parameters:
rightMatrix- The matrix to extract the column fromrow- the row index (zero-based) from current matrix to use for multiplicationcolumn- 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
Description copied from interface:MatrixOperationsMultiplies 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.- Specified by:
multiplyRowByColin interfaceMatrixOperations- Parameters:
leftMatrix- The matrix to extract the row fromrightMatrix- The matrix to extract the column fromrow- the row index (zero-based) fromleftMatrixto use for multiplicationcolumn- the column index (zero-based) fromrightMatrixto use for multiplication- Returns:
- the result when the row from
leftMatrixis multiplied by the column fromrightMatrix
-
multiplyRowByCol
public byte multiplyRowByCol(long[] leftMatrix, long[] rightMatrix, byte leftMatrixArrayN, byte rightMatrixArrayN, byte leftMatrixArrayK, byte rightMatrixArrayK, byte leftMatrixArrayBase, byte rightMatrixArrayBase, byte row, byte column)Description copied from interface:MatrixOperationsMultiplies 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.- Specified by:
multiplyRowByColin interfaceMatrixOperations- Parameters:
leftMatrix- The matrix to extract the row fromrightMatrix- 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\))row- the row index (zero-based) fromleftMatrixArrayto use for multiplicationcolumn- the column index (zero-based) fromrightMatrixArrayto use for multiplication- Returns:
- the result when the row from
leftMatrixArrayis multiplied by the column fromrightMatrixArray
-
getDeterminant
public byte getDeterminant()Description copied from interface:MatrixOperationsUses 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.- Specified by:
getDeterminantin interfaceMatrixOperations- 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
Description copied from interface:MatrixOperationsUses Bareiss Algorithm to find the determinant of the matrix specified. This will not alter the matrix specified and should be used for quaternary codes.- Specified by:
getDeterminantin interfaceMatrixOperations- Parameters:
m- the matrix to find the determinant of- Returns:
- the determinant of the matrix specified
-
multiply
Description copied from interface:MatrixOperationsMultiplies 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}\).
- Specified by:
multiplyin interfaceMatrixOperations- 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
Description copied from interface:MatrixOperationsMultiplies two specified matrices and returns the result as a new matrix. Both matrices will not be altered.- Specified by:
multiplyin interfaceMatrixOperations- 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
public Matrix multiply(long[] leftMatrixArray, long[] rightMatrixArray, byte leftMatrixArrayN, byte rightMatrixArrayN, byte leftMatrixArrayK, byte rightMatrixArrayK, byte leftMatrixArrayBase, byte rightMatrixArrayBase)Description copied from interface:MatrixOperationsMultiplies two specified matrix arrays and returns the result as a new matrix. Both matrix arrays will not be altered.- Specified by:
multiplyin interfaceMatrixOperations- Parameters:
leftMatrixArray- the left-hand-side matrix arrayrightMatrixArray- the right-hand-side matrix arrayleftMatrixArrayN- the number of columns in the left-hand-side matrix arrayrightMatrixArrayN- the number of columns in the right-hand-side matrix arrayleftMatrixArrayK- the number of rows in the left-hand-side matrix arrayrightMatrixArrayK- the number of rows in the right-hand-side matrix arrayleftMatrixArrayBase- the base ofleftMatrix(could be either \(2\) or \(4\))rightMatrixArrayBase- 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
public long multiplyRowByDigit(byte index, byte digit)Description copied from interface:MatrixOperationsMultiplies the row vector at the index specified in the current matrix by the digit specified.- Specified by:
multiplyRowByDigitin interfaceMatrixOperations- 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
public long multiplyRowByDigit(long rowVector, byte digit, byte n, byte base)Description copied from interface:MatrixOperationsMultiplies the row vector specified by the digit specified.- Specified by:
multiplyRowByDigitin interfaceMatrixOperations- 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
-
getGPrime
Description copied from interface:MatrixOperationsReturns 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}\).- Specified by:
getGPrimein interfaceMatrixOperations- Parameters:
examiningRow- 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:
MatrixOperations.getGPrime()
-
getGPrime
Description copied from interface:MatrixOperationsReturns the matrix \(G^{\prime}_{k \times k} = G^{\kern0pt}_{k \times n} \overline{G}^{T}_{n \times k}\) without altering the current matrix.- Specified by:
getGPrimein interfaceMatrixOperations- Returns:
- the matrix \(G^{\prime}_{k \times k} = G^{\kern0pt}_{k \times n} \overline{G}^{T}_{n \times k}\)
- See Also:
MatrixOperations.getGPrime(byte)
-
printParameters
public void printParameters()Description copied from interface:MatrixOperationsPrints the parameters (\(n\), \(k\) and \(base\)) of the code on console.- Specified by:
printParametersin interfaceMatrixOperations
-
printMatrix
public void printMatrix()Description copied from interface:MatrixOperationsPrints 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.- Specified by:
printMatrixin interfaceMatrixOperations
-
printMatrix
Description copied from interface:MatrixOperationsPrints 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.- Specified by:
printMatrixin interfaceMatrixOperations- 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
Description copied from interface:MatrixOperationsPrints 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.- Specified by:
printMatrixin interfaceMatrixOperations- 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
public void printMatrix(long[] matrixArray, byte n, byte base, String delimiter, boolean addBrackets, Style style, boolean showSize)Description copied from interface:MatrixOperationsPrints 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.- Specified by:
printMatrixin interfaceMatrixOperations- 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
-
getMatrixArray
public long[] getMatrixArray()Description copied from interface:MatrixOperationsReturns the current matrix array but not as a brand-new instance.- Specified by:
getMatrixArrayin interfaceMatrixOperations- Returns:
- the current matrix array
- See Also:
getMatrixArrayCopy()
-
isInvertible
Description copied from interface:MatrixOperationsReturnstrueif the specified matrix is invertible (i.e., the determinant of the matrix is not \(0\)),falseif the determinant is \(0\).- Specified by:
isInvertiblein interfaceMatrixOperations- 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
-
containsZeroRow
public boolean containsZeroRow()Description copied from interface:MatrixOperationsTo check if the matrix contains at least a single row of0.- Specified by:
containsZeroRowin interfaceMatrixOperations- Returns:
trueif there exists a row that is0,falseotherwise
-
isInvertible
public boolean isInvertible()Description copied from interface:MatrixOperationsReturnstrueif the current matrix is invertible (i.e., the determinant of the current matrix is not \(0\)),falseif the determinant is \(0\).- Specified by:
isInvertiblein interfaceMatrixOperations- Returns:
trueif the current matrix is invertible (i.e., the determinant of is not \(0\)),falseotherwise
-
getBase
public byte getBase()Description copied from interface:MatrixOperationsReturns the base of the current matrix which is equivalent to the base of the code \(\mathsf{C}\). It is either \(2\) or \(4\).- Specified by:
getBasein interfaceMatrixOperations- Returns:
- the base of the current matrix which is either \(2\) or \(4\)
-
getN
public byte getN()Description copied from interface:MatrixOperationsReturns the number of columns in the current matrix which is equivalent to the length \(n\) of the codeword in the code \(\mathsf{C}\).- Specified by:
getNin interfaceMatrixOperations- Returns:
- the number of columns in the current matrix which is equivalent to the length of the codeword in the code
-
getK
public byte getK()Description copied from interface:MatrixOperationsReturns the number of rows in the current matrix which is equivalent to the dimension \(k\) of the code \(\mathsf{C}\).- Specified by:
getKin interfaceMatrixOperations- Returns:
- the number of rows in the current matrix which is equivalent to the dimension of the code
-
getMatrix
Description copied from interface:MatrixOperationsReturns the current matrix but not as a brand-new copy.- Specified by:
getMatrixin interfaceMatrixOperations- Returns:
- the current matrix
- See Also:
clone()
-
getCell
public byte getCell(byte r, byte c)Description copied from interface:MatrixOperationsReturns the value of a cell based on the row index and column index specified.- Specified by:
getCellin interfaceMatrixOperations- 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
public byte getCell(long[] matrixArray, byte r, byte c, byte n, byte base)Description copied from interface:MatrixOperationsReturns the value of a cell based on the specified matrix array, row index and column index.- Specified by:
getCellin interfaceMatrixOperations- 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
Description copied from interface:MatrixOperationsReturns the value of a cell based on the specified matrix, row index and column index.- Specified by:
getCellin interfaceMatrixOperations- 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
-
getRow
public long getRow(byte index)Description copied from interface:MatrixOperationsReturns a row in the current matrix based on the index specified.- Specified by:
getRowin interfaceMatrixOperations- 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
public long getRow(long[] arrayMatrix, byte index)Description copied from interface:MatrixOperationsReturns a row in the matrix array specified based on the index specified.- Specified by:
getRowin interfaceMatrixOperations- Parameters:
arrayMatrix- 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
Description copied from interface:MatrixOperationsReturns a row in the matrix specified based on the index specified.- Specified by:
getRowin interfaceMatrixOperations- 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
public byte[] getColumn(byte index)Description copied from interface:MatrixOperationsReturns a column in the current matrix based on the index specified.- Specified by:
getColumnin interfaceMatrixOperations- 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
public byte[] getColumn(long[] matrixArray, byte n, byte index, byte base)Description copied from interface:MatrixOperationsReturns a column in the matrix array specified based on the index specified.- Specified by:
getColumnin interfaceMatrixOperations- 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
Description copied from interface:MatrixOperationsReturns a column in the matrix specified based on the index specified.- Specified by:
getColumnin interfaceMatrixOperations- 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
-
setMatrixArray
public void setMatrixArray(long[] matrixArray, byte n, byte k, boolean deepCopy)Description copied from interface:MatrixOperationsSets 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.- Specified by:
setMatrixArrayin interfaceMatrixOperations- 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
public void setRow(byte index, long newRow)Description copied from interface:MatrixOperationsSets a specific row in the current matrix based on the specified row index and new row vector.- Specified by:
setRowin interfaceMatrixOperations- Parameters:
index- the index of the row in current matrix to be altered (zero-based)newRow- the value of the new row to set as
-
setRow
public void setRow(long[] matrixArray, byte index, long newRow)Description copied from interface:MatrixOperationsSets a specific row based on the specified matrix array, row index and new row vector.- Specified by:
setRowin interfaceMatrixOperations- Parameters:
matrixArray- the matrix array to set the row inindex- the index of the row in the matrix array to be altered (zero-based)newRow- the value of the new row to set as
-
setRow
Description copied from interface:MatrixOperationsSets a specific row based on the specified matrix, row index and new row vector.- Specified by:
setRowin interfaceMatrixOperations- Parameters:
m- the matrix to set the row inindex- the index of the row in matrix to be altered (zero-based)newRow- the value of the new row to set as
-
setCell
public void setCell(byte row, byte column, byte value)Description copied from interface:MatrixOperationsSets the value of a cell based on its row index and column index in the current matrix.- Specified by:
setCellin interfaceMatrixOperations- Parameters:
row- the row index of the cell in the current matrix to set (zero-based)column- 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
public void setCell(long[] matrixArray, byte r, byte c, byte value, byte n, byte base)Description copied from interface:MatrixOperationsSets the value of a cell based on its row index and column index in the current matrix.- Specified by:
setCellin interfaceMatrixOperations- 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\))
-
setCell
Description copied from interface:MatrixOperationsSets the value of a cell based on the specified matrix, row index, column index and value.- Specified by:
setCellin interfaceMatrixOperations- Parameters:
m- the matrix to set the cell inrow- the row index of the cell in the matrix to set (zero-based)column- 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\)
-
setColumn
public void setColumn(byte columnIndex, byte[] newColumn)Description copied from interface:MatrixOperationsSets a specific column in the current matrix based on the specified column index and new column vector.- Specified by:
setColumnin interfaceMatrixOperations- Parameters:
columnIndex- the index of the column in current matrix to be altered (zero-based)newColumn- the value of the new column to set as
-
setColumn
public void setColumn(long[] matrixArray, byte columnIndex, byte[] newColumn, byte base)Description copied from interface:MatrixOperationsSets a specific column based on the specified matrix array, column index and new column vector.- Specified by:
setColumnin interfaceMatrixOperations- Parameters:
matrixArray- the matrix array to set the column incolumnIndex- the index of the column in the matrix array to be altered (zero-based)newColumn- the value of the new column to set asbase- the base of the matrix array (could be either \(2\) or \(4\))
-
setColumn
Description copied from interface:MatrixOperationsSets a specific column based on the specified matrix, column index and new column vector.- Specified by:
setColumnin interfaceMatrixOperations- Parameters:
m- the matrix to set the column inindex- the index of the column in the matrix to be altered (zero-based)newColumn- the value of the new column to set as
-