Esempio n. 1
0
    def test_hard_decoding(self):
        H = np.array([[0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0],
                      [0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0],
                      [0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0],
                      [0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0],
                      [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1],
                      [1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
                      [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0],
                      [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1],
                      [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1],
                      [0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0],
                      [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0],
                      [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0]], dtype=np.int8)

        e = np.zeros((16, 3), dtype=np.int32)
        for i_trial in np.arange(3):
            t = np.random.permutation(16)
            e[t[:10], i_trial] = 1

        s = H.dot(e) % 2
        [hat_e, results] = ldpc.decode(s, H, 0.62, display=False)
        npt.assert_array_less(0, results['status'])
Esempio n. 2
0
    def test_easy_decoding(self):
        H = np.array([[0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0],
                      [0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0],
                      [0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0],
                      [0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0],
                      [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1],
                      [1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
                      [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0],
                      [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1],
                      [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1],
                      [0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0],
                      [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0],
                      [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0]], dtype=np.int8)

        e = np.zeros((16,3), dtype=np.int32)
        for i_trial in np.arange(3):
            t = np.random.randint(16)
            e[t, i_trial] = 1

        s = H.dot(e) % 2
        [hat_e, results] = ldpc.decode(s, H, 0.1, display=False)
        npt.assert_array_almost_equal(results['status'], 0)
Esempio n. 3
0
     [102, 76, 6, 110], [34, 126, 41, 35], [61, 90, 65, 22], [36, 23, 84, 38],
     [87, 70, 3, 64], [105, 26, 74, 25], [73, 33, 56, 115], [83, 28, 4, 68],
     [64, 112, 14, 55], [98, 127, 53, 32], [76, 73, 117, 124],
     [66, 26, 116, 100], [3, 17, 0, 2], [102, 8, 43, 72], [39, 5, 81, 107],
     [86, 38, 101, 105], [74, 90, 96, 28], [41, 6, 106, 57], [84, 12, 77, 48],
     [42, 9, 75, 49], [22, 15, 21, 108], [71, 68, 83, 92], [88, 13, 91, 58],
     [99, 35, 97, 40], [115, 78, 37, 27], [118, 114, 93, 33], [89, 4, 11, 30],
     [7, 56, 67, 45], [10, 126, 61, 1], [50, 80, 63, 20], [46, 94, 44, 121],
     [59, 65, 60, 95], [103, 87, 119, 125], [24, 29, 25,
                                             109], [34, 82, 36, 113],
     [31, 51, 23, 70], [52, 104, 54, 120], [62, 79, 111,
                                            122], [123, 47, 16, 85],
     [18, 69, 110, 19]]
w = BitArray(
    '0b10010111011100100000110010001110100010010001011001010011001010101100010001001010111111011110000100111011101100111011111110111010'
)
x = encode(K, P, w)
assert x == BitArray(
    '0b100101110111001000001100100011101000100100010110010100110010101011000100010010101111110111100001001110111011001110111111101110100100101010000001111100111101101111001111101110100000111100101000111110000101011011001100111100001110101110000010110000010110011010010110100100110100011000010100001010100011110011101000100100001100110111001111110101110100100000000000001011010010001110011100'
)
y = BitArray(
    '0b100001010011000000000100100010100000000100010010000100010000101010000000010000001101000000100000000010101000000000011101001010000100100010000001100100111101001010001111001010000000000100100000000110000000000000000000010000001000101110000010000000010100001000010110100100000000011000000000000010000010010011001000100100000000010010000000000101110000000000000000001001000010000110011100'
)
q = BitArray(
    '0b001110101100111110101010011101011100100001001101111000101010000001101101001010100010111111001011101101010111001110100010100101110001011000011100011000000000110101000000110100101010111001011100111000110101011011111111101100000111000001101001110001101011010011001000011010111101100101010100111100101001100000100010010011111100101101101111110010001111101000101011110010110001011000000001'
)
hat_y = decode(K, P, y, q)
assert hat_y is not None
hat_w = hat_y[:K]
assert hat_w == w