Class VectorGenerator

java.lang.Object
hlcd.operations.VectorGenerator

public class VectorGenerator extends Object
The generator of potential codewords in a sequential order. It uses the method getNextVector() to return the next valid vector. A valid vector is a vector that satisfies the minimum distance. A vector is of type long, which is a 64-bit value. In general, the vectors are going to be generated so that the first digit starts far-right, i.e., \(00...00\), \(00...01\), \(00...10\), \(00...11\), etc.

Here, indices are zero based. The important thought is that the zeroth column is the far-right column.

A quaternary digit is composed of a left digit and a right digit:

The representation of an quaternary digit
Quaternary Digit Left Digit Right Digit
\(0_4 \, = \, 00_2\) \(0\) \(0\)
\(1_4 \, = \, 01_2\) \(0\) \(1\)
\(\omega_4 \, = \, 10_2\) \(1\) \(0\)
\(\overline{\omega}_4 \, = \, 11_2\) \(1\) \(1\)

The \(i^{th}\) quaternary digit in a long datatype is given by: leftDigit = i * 2 + 1 and rightDigit = i * 2.

The implementation of this class only works for base \(4\) but can be modified to also include base \(2\).

Having minimum distance to be 0 or 1 will generate the exact set of valid vectors.

An important property in this class is RESTRICT_GENERATION. This should always be true as it will cut down the search space by an exponential factor when the base is \(4\). In addition, this requires to have the property ADD_IDENTITY to be true as well. The basic explanation is that the top row will be hardcoded so that it will have a weight of \(d\) consisting of \(1\)'s. The subvector in \(I\) will have a weight if \(1\) and the subvector in \(P\) will have \(d - 1\) as the weight, assuming the generator matrix is in the following form: \(G = \left[\begin{array} {@{}c|c@{}} I & P \end{array}\right]\). For each row, other than the top row in \(P\), the left-most nonzero digit will be \(1\) (not \(\omega\) nor \(\overline{\omega}\)). This construction guarantees that all possible inequivalent matrices will be generated. An explanation of how this is achieved can be found on page page 3 of Some optimal entanglement-assisted quantum codes constructed from quaternary Hermitian linear complementary dual codes by Masaaki Harada (Dec 2019).

TODO: When RESTRICT_GENERATION is true, the minimum distance must be less than or equal to \(3\). Implement \(d = 2\).

TODO: test binary implementation (regrading everything)

TODO: test quaternary implementation when having both RESTRICT_GENERATION and ADD_IDENTITY as false.

 //minimal example to execute this class:
 public static void main(String[] args) {
     System.out.println("Running VectorGenerator...");
     byte n = 20;
     byte k = 9;
     byte d = 9;
     byte minimumWeight = (byte) (d - 1);
     byte base = 4;
     boolean addIdentity = true;
     boolean restrictGeneration = true;
     long counter = 0;
     String ns = String.format("%" + 2 + "s", n + "");
     String ks = String.format("%" + 2 + "s", k + "");
     String ds = String.format("%" + 2 + "s", d + "");
     System.out.print("The code (" + ns + ", " + ks + ", " + ds + ") has ");
     VectorGenerator vg = new VectorGenerator(
         n, k, d, minimumWeight, base, addIdentity, restrictGeneration
     );
     while (true) {
         long vector = vg.getNextFullVector((byte) 0);
         if (vg.isCurrentSubvectorValid()) {
             counter++;
         } else {
             break;
         }
     }
     System.out.format("%,d%s\n", counter, " vectors to check.");
     System.out.println("VectorGenerator completed.");
 }
Since:
1.8
Version:
1.0 (February 1st, 2022)
Author:
Maysara Al Jumaily
See Also:
Long, Page 91 of the M.Sc. thesis, Page 93 of the M.Sc. thesis, Masaaki Harada's paper (Dec 2019)
  • Constructor Summary

    Constructors
    Constructor
    Description
    VectorGenerator​(byte n, byte k, byte d, byte rhsWeight, byte base, boolean appendIdentity, boolean restrictGeneration)
    Initializes the vector generator for the code.
    VectorGenerator​(byte n, byte k, byte d, byte rhsWeight, byte base, long startingSubvector, long resetPoint, boolean appendIdentity, boolean restrictGeneration)
    Initializes the vector generator for the code.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the base of the code which could either be \(2\) or \(4\).
    long
    getCurrentFullVector​(byte currentRow)
    Returns the current subvector with the identity row attached.
    long
    returns the current subvector without the identity subvector.
    long
    Returns the minimum weight of the right-hand-side of a valid vector.
    long
    getNextFullVector​(byte currentRow)
    Returns the next subvector with the identity row attached.
    long
    Returns the next subvector that satisfy the weight RHS_WEIGHT, which is \(d - 1\).
    long
    The current reset point which is a vector of Hamming weight of \(1\).
    byte
    getWeight​(long vector, byte base)
    Returns the weight of non-zero digits in the value passed.
    boolean
    Returns whether the current subvector is valid Hamming weight wise.

    Methods inherited from class java.lang.Object

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

    • VectorGenerator

      public VectorGenerator(byte n, byte k, byte d, byte rhsWeight, byte base, boolean appendIdentity, boolean restrictGeneration)
      Initializes the vector generator for the code. This particular constructor is used with base 4 only.
      Parameters:
      n - the length of the code
      k - the dimension of the code
      d - the minimum distance of the code
      rhsWeight - the Hamming weight of the subvector that is not a part of the identity submatrix. This must be \(d - 1\) assuming the identity matrix is appended
      base - the base of the code which could either be \(2\) or \(4\)
      appendIdentity - should the identity matrix be appended. This should always be true as it will significantly cut down the search space
      restrictGeneration - should a shortcut be used so that all the inequivalent generator matrices be generated This should always be true as it will further cut down the search space
    • VectorGenerator

      public VectorGenerator(byte n, byte k, byte d, byte rhsWeight, byte base, long startingSubvector, long resetPoint, boolean appendIdentity, boolean restrictGeneration)
      Initializes the vector generator for the code. This particular constructor is used with base 4 only. This is used when a recursive call has been made to find the next codeword to be placed in the generator matrix.
      Parameters:
      n - the length of the code
      k - the dimension of the code
      d - the minimum distance of the code
      rhsWeight - the Hamming weight of the subvector that is not a part of the identity submatrix. This must be \(d - 1\) assuming the identity matrix is appended.
      base - the base of the code which could either be \(2\) or \(4\)
      startingSubvector - the starting position of the subvector that is not a part of the identity matrix
      resetPoint - a binary value that will have a weight of \(1\) where once reached, it denotes that some vectors can be skipped (assuming that the restriction generation property is on)
      appendIdentity - should the identity matrix be appended. This should always be true as it will significantly cut down the search space
      restrictGeneration - should a shortcut be used so that all the inequivalent generator matrices be generated This should always be true as it will further cut down the search space
  • Method Details

    • getCurrentSubvector

      public long getCurrentSubvector()
      returns the current subvector without the identity subvector.
      Returns:
      the current subvector without the identity subvector
    • getBase

      public long getBase()
      Returns the base of the code which could either be \(2\) or \(4\).
      Returns:
      the base of the code which could either be \(2\) or \(4\)
    • getMinimumRHSWeight

      public long getMinimumRHSWeight()
      Returns the minimum weight of the right-hand-side of a valid vector.
      Returns:
      the minimum weight of the right-hand-side of a valid vector.
    • getCurrentFullVector

      public long getCurrentFullVector(byte currentRow)
      Returns the current subvector with the identity row attached.
      Parameters:
      currentRow - the current row to place \(1\) in the valid position of the identity row portion
      Returns:
      The current subvector with the identity row attached
    • getNextFullVector

      public long getNextFullVector(byte currentRow)
      Returns the next subvector with the identity row attached.
      Parameters:
      currentRow - the current row to place \(1\) in the valid position of the identity row portion
      Returns:
      The next vector with the identity row attached
    • getNextSubVector

      public long getNextSubVector()
      Returns the next subvector that satisfy the weight RHS_WEIGHT, which is \(d - 1\).
      Returns:
      the next subvector that satisfy the weight RHS_WEIGHT, which is \(d - 1\)
    • isCurrentSubvectorValid

      public boolean isCurrentSubvectorValid()
      Returns whether the current subvector is valid Hamming weight wise.
      Returns:
      true if the current subvector satisfy the Hamming weight, false otherwise
    • getWeight

      public byte getWeight(long vector, byte base)
      Returns the weight of non-zero digits in the value passed. It will achieve that by going the binary representation of the value and increment a counter every time a digit (in base \(2\) or base \(4\) depending on the base passed) is not the digit \(0\).
      Parameters:
      vector - the vector to find the weight for
      base - the base the value should be treated as
      Returns:
      the number of non-zero digits in the vector passed
    • getResetPoint

      public long getResetPoint()
      The current reset point which is a vector of Hamming weight of \(1\). It is used to generate vectors whose left-most on-zero digit is \(1\) (i.e., not 2 nor 3).
      Returns:
      the current reset point which is a vector of Hamming weight of \(1\)