0
votes

I'm trying to compare three different decoders for Hamming codes in python: brute force, local search, and syndrome. I am having issues with my brute force implementation:

def bruteForce(v):
    n = len(v)
    r = int(math.log(n+1,2))
    k = n-r
    m = []
    d = []
    c = []
    for i in range(2**k):
        m.append(decimalToVector(i,k))
    for j in range(2**k):
        d.append(hammingDistance(matrixMult(m[j], HammingG(r)),v))
    for l in range(2**k):
        if d[l] <= 1:
             c = matrixMult(m[l], HammingG(r))
    return c

This runs without error, but the output is simply [], instead of any sequence of binary numbers, when the input is a vector such as bruteForce([1,0,0,0,0,0,1]).

1
What exactly is your problem? Errors (provide traceback)? Unexpected outputs (provide inputs, expected outputs, actual outputs)?jonrsharpe
The brute force compiles fine, but the output is simply "[]" instead of any sequence of binary numbers when the input is a vector such as bruteForce([1,0,0,0,0,0,1])user3236854
Is [] unexpected as output? If so, why do you initialize c to []? In your code, the value returned is either this empty list (if d[l] > 1 for all l), or the result of the last computation in the last loop.Armin Rigo

1 Answers

0
votes

This is only guessing, but you might as well check if d[l] <= 1 is really correct. One of the hallmarks of Hamming code is error correction and it is possible because the minimal distance is 3. Your code looks as if you implemented a mere parity check code (minimal distance == 1.)