Class RandomMatrixGenerator

java.lang.Object
hlcd.operations.RandomMatrixGenerator

public class RandomMatrixGenerator extends Object
Generates a random matrix based on the parameters specified.
 //minimal example to execute this class:
 public static void main(String[] args) {
     System.out.println("Running RandomMatrixGenerator...");
     RandomMatrixGenerator rmg = new RandomMatrixGenerator((byte) 20);
     rmg.printMatrix(" ", true, Style.DECIMAL, true);
     System.out.println("RandomMatrixGenerator completed.");
 }
Since:
1.8
Version:
1.0 (February 10th, 2022)
Author:
Maysara Al Jumaily
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initializes a random matrix with a random base, random \(k\) and \(n\) values.
    RandomMatrixGenerator​(byte size)
    Create a random square matrix with the assumption that the base is \(4\).
    RandomMatrixGenerator​(byte n, byte k, byte base)
    Randomly initializes the matrix based on the parameters specified.
    RandomMatrixGenerator​(byte minN, byte maxN, byte minK, byte maxK, byte base)
    Randomly creates a matrix based on the range of \(n\) and range of \(k\) specified.
    RandomMatrixGenerator​(long[] matrixArray, byte n, byte k, byte base)
    Initializes the current matrix array to the specified array and the other specified parameters to the current ones.
  • Method Summary

    Modifier and Type
    Method
    Description
    long[]
    convertByteArrayToLongArray​(byte[] matrixArray)
    Converts the specified byte matrix array to a long matrix array.
    byte[]
    convertLongArrayToByteArray​(long[] matrixArray)
    Converts the specified long matrix array to a byte matrix array.
    byte
    Returns the base which could either be \(2\) or \(4\).
    byte
    Returns the number of row in the matrix array.
    Returns the current matrix array as a Matrix type.
    long[]
    Returns the current matrix array.
    long[]
    Returns a clone of the current matrix array.
    byte
    Returns the maximum value of the \(k\) range.
    byte
    Returns the maximum value of the \(n\) range.
    byte
    Returns the minimum value of the \(k\) range.
    byte
    Returns the minimum value of the \(n\) range.
    byte
    Returns the number of columns in the matrix array.
    void
    Prints the matrix on console using the following default properties: the columns are separated by a space, the brackets are added, the style is base 10 and the size is shown.
    void
    printMatrix​(boolean addBrackets, Style style, boolean showSize)
    Prints the matrix on console while using the space character as the delimiter between the columns.
    void
    printMatrix​(long[] matrixArray, byte n, byte base, String delimiter, boolean addBrackets, Style style, boolean showSize)
    Prints the matrix array specified on console using the parameters passed.
    void
    printMatrix​(String delimiter, boolean addBrackets, Style style, boolean showSize)
    Prints the matrix array specified on console using the parameters passed.
    void
    Prints the \(n\), \(k\) and base values.
    byte[][]
    Returns a 2-D array of the current 1-D matrix array.
    byte[][]
    to2DArray​(long[] matrixArray, byte n, byte k, byte base)
    Returns a 2-D array of the 1-D matrix array specified.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RandomMatrixGenerator

      public RandomMatrixGenerator()
      Initializes a random matrix with a random base, random \(k\) and \(n\) values.
    • RandomMatrixGenerator

      public RandomMatrixGenerator(byte size)
      Create a random square matrix with the assumption that the base is \(4\).
      Parameters:
      size - the size of the random matrix to be created
    • RandomMatrixGenerator

      public RandomMatrixGenerator(byte n, byte k, byte base)
      Randomly initializes the matrix based on the parameters specified.
      Parameters:
      n - the length of each vector in the matrix
      k - the dimension of the matrix
      base - the base which could either be \(2\) or \(4\)
    • RandomMatrixGenerator

      public RandomMatrixGenerator(long[] matrixArray, byte n, byte k, byte base)
      Initializes the current matrix array to the specified array and the other specified parameters to the current ones.
      Parameters:
      matrixArray - the matrix array
      n - the length of each vector in the matrix
      k - the dimension of the matrix
      base - the base which could either be \(2\) or \(4\)
    • RandomMatrixGenerator

      public RandomMatrixGenerator(byte minN, byte maxN, byte minK, byte maxK, byte base)
      Randomly creates a matrix based on the range of \(n\) and range of \(k\) specified.
      Parameters:
      minN - the smallest \(n\) value to be generated
      maxN - the largest \(n\) value to be generated
      minK - the smallest \(k\) value to be generated
      maxK - the largest \(k\) value to be generated
      base - the base which could either be \(2\) or \(4\)
  • Method Details

    • convertByteArrayToLongArray

      public long[] convertByteArrayToLongArray(byte[] matrixArray)
      Converts the specified byte matrix array to a long matrix array.
      Parameters:
      matrixArray - the byte matrix array to be converted to long matrix array
      Returns:
      the specified matrix array as a long matrix array
    • convertLongArrayToByteArray

      public byte[] convertLongArrayToByteArray(long[] matrixArray)
      Converts the specified long matrix array to a byte matrix array.
      Parameters:
      matrixArray - the long matrix array to be converted to byte matrix array
      Returns:
      the specified matrix array as a byte matrix array
    • printParameters

      public void printParameters()
      Prints the \(n\), \(k\) and base values.
    • printMatrix

      public void printMatrix()
      Prints the matrix on console using the following default properties: the columns are separated by a space, the brackets are added, the style is base 10 and the size is shown.
    • printMatrix

      public void printMatrix(boolean addBrackets, Style style, boolean showSize)
      Prints the matrix on console while using the space character as the delimiter between the columns.
      Parameters:
      addBrackets - should surround the matrix with brackets
      style - the style format which could either be binary, quaternary, decimal or \(\LaTeX\)
      showSize - should the dimension of the matrix be displayed in the bottom-right corner
    • printMatrix

      public void printMatrix(String delimiter, boolean addBrackets, Style style, boolean showSize)
      Prints the matrix array specified on console using the parameters passed.
      Parameters:
      delimiter - the delimiter used to separate the column
      addBrackets - should surround the matrix array with brackets
      style - the style format which could either be binary, quaternary, decimal or \(\LaTeX\)
      showSize - should the dimension of the matrix array be displayed in the bottom-right corner
    • printMatrix

      public void printMatrix(long[] matrixArray, byte n, byte base, String delimiter, boolean addBrackets, Style style, boolean showSize)
      Prints the matrix array specified on console using the parameters passed.
      Parameters:
      matrixArray - the matrix array to be printed on console
      n - the length of each vector in the matrix
      base - the base of the code which could either be \(2\) or \(4\)
      delimiter - the delimiter used to separate the columns
      addBrackets - should surround the matrix with brackets
      style - the style format which could either be binary, quaternary, decimal or \(\LaTeX\)
      showSize - should the dimension of the matrix be displayed in the bottom-right corner
    • to2DArray

      public byte[][] to2DArray()
      Returns a 2-D array of the current 1-D matrix array.
      Returns:
      a 2-D array of the current 1-D matrix array
    • to2DArray

      public byte[][] to2DArray(long[] matrixArray, byte n, byte k, byte base)
      Returns a 2-D array of the 1-D matrix array specified.
      Parameters:
      matrixArray - the 1-D matrix array to transform to a 2-D matrix array
      n - the number of columns in the matrix array specified
      k - the number of rows in the matrix array specified
      base - the base which can either be \(2\) or \(4\)
      Returns:
      a 2-D array equivalent of the matrix array specified
    • getMatrixArray

      public long[] getMatrixArray()
      Returns the current matrix array.
      Returns:
      the current matrix array
    • getMatrixArrayClone

      public long[] getMatrixArrayClone()
      Returns a clone of the current matrix array.
      Returns:
      a clone of the current matrix array
    • getN

      public byte getN()
      Returns the number of columns in the matrix array.
      Returns:
      the number of columns in the matrix array
    • getK

      public byte getK()
      Returns the number of row in the matrix array.
      Returns:
      the number of row in the matrix array
    • getBase

      public byte getBase()
      Returns the base which could either be \(2\) or \(4\).
      Returns:
      the base which could either be \(2\) or \(4\)
    • getMinK

      public byte getMinK()
      Returns the minimum value of the \(k\) range.
      Returns:
      the minimum value of the \(k\) range
    • getMaxK

      public byte getMaxK()
      Returns the maximum value of the \(k\) range.
      Returns:
      the maximum value of the \(k\) range
    • getMinN

      public byte getMinN()
      Returns the minimum value of the \(n\) range.
      Returns:
      the minimum value of the \(n\) range
    • getMaxN

      public byte getMaxN()
      Returns the maximum value of the \(n\) range.
      Returns:
      the maximum value of the \(n\) range
    • getMatrix

      public Matrix getMatrix()
      Returns the current matrix array as a Matrix type.
      Returns:
      the current matrix array as a Matrix type