Class HammingWeight

java.lang.Object
hlcd.operations.HammingWeight

public class HammingWeight extends Object
A way to find the Hamming weight for vectors in base \(2\) or \(4\). The approach uses the least amount of operations. The complexity is \(\mathcal{O}(C)\) and without looping through the vector.
Since:
February 1st, 2022
Version:
1.0
Author:
Maysara Al Jumaily
  • Constructor Summary

    Constructors
    Constructor
    Description
    HammingWeight​(byte base)
    Creates a Hamming weight calculator ready in the base specified.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte
    Returns the base the Hamming weight calculator is operating in.
    byte
    getWeight​(long vector)
    Returns the weight of the vector specified.
    static byte
    getWeight​(long vector, byte base)
    Finds the weight of the vector in the base specified.

    Methods inherited from class java.lang.Object

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

    • HammingWeight

      public HammingWeight(byte base)
      Creates a Hamming weight calculator ready in the base specified.
      Parameters:
      base - the base of the code which could either be \(2\) or \(4\)
  • Method Details

    • getWeight

      public byte getWeight(long vector)
      Returns the weight of the vector specified.
      Parameters:
      vector - the vector to find the weight of
      Returns:
      the Hamming weight of the vector
    • getWeight

      public static byte getWeight(long vector, byte base)
      Finds the weight of the vector in the base specified.
      Parameters:
      vector - the vector to find the weight of
      base - the base of the code which could either be \(2\) or \(4\)
      Returns:
      the Hamming weight of the vector
    • getBase

      public byte getBase()
      Returns the base the Hamming weight calculator is operating in.
      Returns:
      the base of the code