Пример #1
0
def Exercise4_6():
    print("Exercise4_6")
    '''
    A binary cyclic BCH code CBCH(n, k) has code length n = 15 and generator
    polynomial g(X) = (X + 1)(1 + X + X4)(1 + X + X2 + X3 + X4).
    (a) What is the minimum Hamming distance of the code?
    '''
    p = np.array([1, 1, 0, 0, 1])
    GF16 = GaloisField(p)
    #GF16.printMinimalPolynomials()

    roots = GF16.conjugateRootGroups()
    part1 = GF16.multPoly(GF16.minimalPolynomial(roots[1]),
                          GF16.minimalPolynomial(roots[2]))
    part2 = GF16.multPoly(part1, GF16.minimalPolynomial(roots[3]))
    print("Reduced generator polynomial: ", GF16.polyToString(part2))
    print()
    print(
        "DMin is the number of exponents in the generator polynomial which is: ",
        GF16.dminOfPoly(part2))
Пример #2
0
def Exercise4_4():
    print("Exercise4_4")
    '''
    Determine the generator polynomial of the binary BCH code CBCH(31, 16) able
    to correct error patterns of size t = 3 or less.
    '''
    p = np.array([1, 0, 1, 0, 0, 1])
    GF25 = GaloisField(p)
    GF25.printInfo()

    roots = GF25.conjugateRootGroups()
    print()
    print("(", GF25.polyToString(GF25.minimalPolynomial(roots[2])), ") * (",
          GF25.polyToString(GF25.minimalPolynomial(roots[3])), ") * (",
          GF25.polyToString(GF25.minimalPolynomial(roots[4])), ")")
    print()
    # The roots create Φ_1,Φ_3,Φ_51
    part1 = GF25.multPoly(GF25.minimalPolynomial(roots[2]),
                          GF25.minimalPolynomial(roots[3]))
    part2 = GF25.multPoly(part1, GF25.minimalPolynomial(roots[4]))
    print(GF25.polyToString(part2))
    print("Exercise 4.5")
    print("------------")

    t = 2
    C_BCH = BCHCode(GF25, t, True)
    C_BCH.printInfo()

    print("Exercise 4.6 (a)")
    print("----------------")

    poly1 = np.array([1, 1])  # (1 + X)
    poly2 = np.array([1, 1, 0, 0, 1])  # (1 + X + X^4)
    poly3 = np.array([1, 1, 1, 1, 1])  # (1 + X + X^2 + X^3 + X^4)

    g = GF25.multPoly(GF25.multPoly(poly1, poly2), poly3)
    n = 15
    C_BCH = CyclicCode(g, n)  # use CyclicCode because it allows to specify n
    C_BCH.dmin(True)

    print("Exercise 4.9")
    print("------------")

    pX = np.array([1, 1, 0, 0, 1])  #  1 + X + X^4
    GF24 = GaloisField(pX)
    #GF24.printInfo()

    t = 2
    C_BCH = BCHCode(GF24, t, True)

    r = np.array([1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0])