コード例 #1
0
def test_example():
    """ From Lecture 7 - 01 """
    v = program.binary_matrix([[1, 1, 0, 0, 0, 0, 0]])
    H = program.get_parity_check(3)
    syndromes = program.create_syndrome_dict(7, 3)
    vH = program.calculate_syndrome(v, H)
    assert vH == [0, 1, 1]
コード例 #2
0
def test_example():
    """ Example from Lecture 7 - 01 """
    v = program.binary_matrix([[1, 1, 0, 0, 0, 0, 0]])
    H = program.get_parity_check(3)
    syndromes = program.create_syndrome_dict(7, 3)
    res = program.decode_syndrome(v, syndromes, H)
    assert res == [1, 1, 1, 0, 0, 0, 0]
コード例 #3
0
def test_small_example():
    s = program.binary_matrix([[1, 1, 1]])
    G = program.create_generator_matrix(2, 1)
    v = program.binary_matrix([program.get_encoding(s, G)])
    H = program.get_parity_check(2)
    syndromes = program.create_syndrome_dict(3, 2)
    res = program.decode_syndrome(v, syndromes, H)
    assert res == v[0]
コード例 #4
0
def test_larger_example():
    start = program.binary_matrix([[1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0]])
    G = program.create_generator_matrix(4, 11)
    v = program.binary_matrix([program.get_encoding(start, G)])
    H = program.get_parity_check(4)
    syndromes = program.create_syndrome_dict(15, 4)
    res = program.decode_syndrome(v, syndromes, H)
    assert res == v[0]
コード例 #5
0
def test_r_3():
    """ This example is taken from Lecture 7 - 01 """
    results = program.create_syndrome_dict(7, 3)
    syndromes = {0: 0, 1: 1, 2: 2, 4: 4, 7: 8, 3: 16, 5: 32, 6: 64}
    assert results == syndromes