Ejemplo n.º 1
0
def generate_d_disjunct(universe_size):
    k = estitmate_code_length(universe_size)
    code = hamming_code.get_code(k)
    generator = code.generate_code_words()
    code_words_set = []
    try:
        while len(code_words_set) < universe_size:
            code_word = generator.next()
            if linear_codes.code_weight(code_word) == 3:
                code_words_set.append(linear_codes.make_set(code_word))
    except StopIteration:
        raise
    return matrix_operations.NumpyMatrix.make_matrix_from_columns(code_words_set)
def test_hamming_matrix():
    assert (hamming_code.get_code(7) == linear_codes.Code(numpy.array([[ 1.,  1.,  0.,  1.,  0.,  0., 0.],
                                                      [ 1.,  0.,  1.,  0.,  1.,  0., 0.],
                                                      [ 0.,  1.,  1.,  0.,  0.,  1., 0.],
                                                      [ 1.,  1.,  1.,  0.,  0.,  0., 1.]]), 3))