Package hlcd.operations
Class Functions
java.lang.Object
hlcd.operations.Functions
A class contains static variables and methods to be used globally across
the classes in this program. It deals mostly with checking if the values
being used for matrix dimension, bases, indices, etc. are valid.
- Since:
- February 2nd, 2022
- Version:
- 1.0
- Author:
- Maysara Al Jumaily
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic longContains 64 1's:0b11111111_11111111_11111111_11111111_11111111_11111111_11111111_11111111static byte[][]The division logic in base \(4\).static longThe decimal value "15" repeated in binary:0b00001111_00001111_00001111_00001111_00001111_00001111_00001111_00001111static byte[][]The multiplication logic in base \(4\).static longThe decimal value "1" repeated in binary:0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101static longThe decimal value "3" repeated in binary:0b00110011_00110011_00110011_00110011_00110011_00110011_00110011_00110011static longThe decimal value "2" repeated in binary:0b10101010_10101010_10101010_10101010_10101010_10101010_10101010_10101010 -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisValidBase(byte base)Checks whether the base of the code is valid.static booleanisValidColIndex(byte index, byte maxCol)Checks whether the specified column index is valid.static booleanisValidColumnVectorDimension(byte columnVectorRowCount, byte k)Checks if a column vector is appropriate in the sense that its length should be between \(1\) and \(k\) (one-based).static booleanisValidDigit(byte digit, byte base)Checks whether the digit specified is a valid digit in the base passed.static booleanisValidIdentityRowIndex(byte index, byte k)Checks whether the specified row index is valid row in an identity matrix.static booleanisValidMatrixMultiplicationDimension(long[] leftMatrixArray, byte leftMatrixArrayN, byte leftMatrixArrayK, long[] rightMatrixArray, byte rightMatrixArrayN, byte rightMatrixArrayK)Checks if the dimension of two matricesleftMatrixArrayandrightMatrixArrayis valid for performing the multiplication.static booleanisValidMinimumDistance(byte minimumDistance)Checks whether the passed minimum distance is valid.static booleanisValidNAndKValues(byte n, byte k)Checks whether the \(n\) and \(k\) values being used are valid.static booleanisValidRowIndex(byte index, byte maxRow)Checks whether the specified row index is valid.static booleanisValidSettingColumnInMatrix(byte columnVectorRowCount, byte matrixRowCount)Checks if a column vector is appropriate to be placed inside a matrix.static longpower(long x, long n)Efficiently finds the result of \(x^n\).static StringAn aesthetic way to draw a solid (non-dashed) line on console by using the character─.static StringwriteConsoleLineSeparator(byte length)An aesthetic way to draw a solid (non-dashed) line on console by using the character─.
-
Field Details
-
ONE
public static final long ONEThe decimal value "1" repeated in binary:0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101- See Also:
- Constant Field Values
-
TWO
public static final long TWOThe decimal value "2" repeated in binary:0b10101010_10101010_10101010_10101010_10101010_10101010_10101010_10101010- See Also:
- Constant Field Values
-
THREE
public static final long THREEThe decimal value "3" repeated in binary:0b00110011_00110011_00110011_00110011_00110011_00110011_00110011_00110011- See Also:
- Constant Field Values
-
F
public static final long FThe decimal value "15" repeated in binary:0b00001111_00001111_00001111_00001111_00001111_00001111_00001111_00001111- See Also:
- Constant Field Values
-
ALL_ONES
public static final long ALL_ONESContains 64 1's:0b11111111_11111111_11111111_11111111_11111111_11111111_11111111_11111111- See Also:
- Constant Field Values
-
MUL_ARRAY
public static final byte[][] MUL_ARRAYThe multiplication logic in base \(4\). It is given as:The multiplication table in base \(4\) \(\times\) \(0\) \(1\) \(\omega\) \(\overline{\omega}\) \(0\) \(0\) \(0\) \(0\) \(0\) \(1\) \(0\) \(1\) \(\omega\) \(\overline{\omega}\) \(\omega\) \(0\) \(\omega\) \(\overline{\omega}\) \(1\) \(\overline{\omega}\) \(0\) \(\overline{\omega}\) \(1\) \(\omega\) -
DIV_ARRAY
public static final byte[][] DIV_ARRAYThe division logic in base \(4\). Note that the far-left column is not defined (division by 0), hence, denoted as "\(-\)" and in code, assigned the number-99. It is given as:The division table in base \(4\) \(\div\) \(0\) \(1\) \(\omega\) \(\overline{\omega}\) \(0\) \(-\) \(0\) \(0\) \(0\) \(1\) \(-\) \(1\) \(\overline{\omega}\) \(\omega\) \(\omega\) \(-\) \(\omega\) \(1\) \(\overline{\omega}\) \(\overline{\omega}\) \(-\) \(\overline{\omega}\) \(\omega\) \(1\)
-
-
Method Details
-
isValidBase
public static boolean isValidBase(byte base)Checks whether the base of the code is valid. A valid base is either \(2\) or \(4\).- Parameters:
base- the base of the code (could be either \(2\) or \(4\))- Returns:
trueif the base is valid (i.e., \(2\) or \(4\)),falseotherwise
-
isValidNAndKValues
public static boolean isValidNAndKValues(byte n, byte k)Checks whether the \(n\) and \(k\) values being used are valid. They are valid in base \(2\) if \(1 \leq k \leq 62\), \(1 \leq n \leq 62\), \(1 \leq k \leq n\) and valid in base \(4\) if \(1 \leq k \leq 30\), \(1 \leq n \leq 30\) and \(1 \leq k \leq n\).- Parameters:
n- the length of a codeword in the codek- the dimension of the code- Returns:
trueif \(n\) and \(k\) are valid,falseotherwise
-
isValidMinimumDistance
public static boolean isValidMinimumDistance(byte minimumDistance)Checks whether the passed minimum distance is valid. The implementation of this program doesn't support minimum distance of \(d \lt 3\).- Parameters:
minimumDistance- the minimum distance to be checked- Returns:
trueif the minimum distance bigger or equal to \(3\),falseotherwise
-
isValidColIndex
public static boolean isValidColIndex(byte index, byte maxCol)Checks whether the specified column index is valid. A column index is zero-based.- Parameters:
index- the column index to checkmaxCol- the maximum valid column that is accessible. This is one-based so the column index must be strictly less than- Returns:
trueif the column index is within the appropriate range,falseotherwise
-
isValidRowIndex
public static boolean isValidRowIndex(byte index, byte maxRow)Checks whether the specified row index is valid. A row index is zero-based.- Parameters:
index- the row index to checkmaxRow- the maximum valid row that is accessible. This is one-based so the row index must be strictly less than- Returns:
trueif the row index is within the appropriate range,falseotherwise
-
isValidIdentityRowIndex
public static boolean isValidIdentityRowIndex(byte index, byte k)Checks whether the specified row index is valid row in an identity matrix. A row index is zero-based.- Parameters:
index- the row index to checkk- the maximum valid row that is accessible. This is one-based so the row index must be strictly less than- Returns:
trueif the row index is within the appropriate range,falseotherwise
-
isValidSettingColumnInMatrix
public static boolean isValidSettingColumnInMatrix(byte columnVectorRowCount, byte matrixRowCount)Checks if a column vector is appropriate to be placed inside a matrix. The number of rows in the column vector must match the number of rows in the matrix. It doesn't matter if it is zero-based or one-based as long as both use the same convention. Keep it as one-based if in doubt.- Parameters:
columnVectorRowCount- the number of rows in the column vectormatrixRowCount- the number of rows in the matrix- Returns:
trueif both the column vector and matrix have the same number of rows,falseotherwise
-
isValidColumnVectorDimension
public static boolean isValidColumnVectorDimension(byte columnVectorRowCount, byte k)Checks if a column vector is appropriate in the sense that its length should be between \(1\) and \(k\) (one-based).- Parameters:
columnVectorRowCount- the number of rows in the column vectork- the length of the code- Returns:
trueif the column vector has a valid size,falseotherwise
-
isValidDigit
public static boolean isValidDigit(byte digit, byte base)Checks whether the digit specified is a valid digit in the base passed.- Parameters:
digit- the digit to checkbase- the base of the code- Returns:
trueif the digit is valid in the base passed,falseotherwise
-
isValidMatrixMultiplicationDimension
public static boolean isValidMatrixMultiplicationDimension(long[] leftMatrixArray, byte leftMatrixArrayN, byte leftMatrixArrayK, long[] rightMatrixArray, byte rightMatrixArrayN, byte rightMatrixArrayK)Checks if the dimension of two matricesleftMatrixArrayandrightMatrixArrayis valid for performing the multiplication.- Parameters:
leftMatrixArray- the left matrix to be multipliedleftMatrixArrayN- the number of columns in the left matrixleftMatrixArrayK- the number of rows in the left matrixrightMatrixArray- the right matrix to be multipliedrightMatrixArrayN- the number of columns in the right matrixrightMatrixArrayK- the number of rows in the right matrix- Returns:
trueif the multiplication can be performed,falseotherwise
-
writeConsoleLineSeparator
An aesthetic way to draw a solid (non-dashed) line on console by using the character─. It will automatically draw a horizontal line consisting of 80 characters.- Returns:
- A string containing 80 characters of
─.
-
writeConsoleLineSeparator
An aesthetic way to draw a solid (non-dashed) line on console by using the character─. It will create a horizontal line consisting of the specified length.- Parameters:
length- the length of the line- Returns:
- A string of the length specified containing characters of
─.
-
power
public static long power(long x, long n)Efficiently finds the result of \(x^n\). In the case where \(n=63\) or \(n=64\), then the maximum value that will be return is \(2^{63} - 1 = 9223372036854775807\). Since this only return positive values, we cannot have a binary vector of length \(63\) nor \(64\) or a quaternary vector of length \(31\) nor \(32\). In the case where an invalid length is passed, then a warning message will be displayed on console. All in all, the valid lengths for a binary code is between \(1\) and \(62\) (including both) and for a quaternary code is between \(1\) and \(30\) (including both).- Parameters:
x- the base of the powern- the number to raise to- Returns:
- the result of \(x^n\)
-