print("profile: " + str(tuple(map(lambda num: "2^%d" % num, span_straight.span_profile())))) print("") print('=== generating minimal span form for dual code ===') span_dual = H.to_minimal_span_form() print(str(span_dual)) print("profile: " + str(tuple(map(lambda num: "2^%d" % num, span_straight.span_profile())))) print("") print('=== computing field ===') oct_parsed = int(str(input_polynom), 8) modulus = oct_parsed if rtl else int(tobin(oct_parsed).zfill(len(str(input_polynom)) * 3)[::-1], 2) binary_modulus = tobin(modulus) print("modulus = %s" % binary_modulus) mod_length = len(binary_modulus) field = Field(modulus) elements = field.get_all_elems() bin_elements = list(map(lambda it: tobin(it).zfill(mod_length - 1), elements)) for i, item in enumerate(bin_elements): print("%s: %s" % (str(i).zfill(2), item)) print("") upper = Sum(Mult(Num(input_a), Var(1)), Num(input_b)).calc({"x": input_x0}, field) bottom = Sum(Mult(Num(input_c), Var(1)), Num(input_d)).calc({"x": input_x0}, field) bottom_inverted = field.reciprocal(bottom) upper_div_bottom = field.multiply(upper, bottom_inverted) print('f(x) = ( %d * x + %d ) / ( %d * x + %d )' % (input_a, input_b, input_c, input_d)) print('f(%d) = %d / %d = %d * %d = %d' % (input_x0, upper, bottom, upper, bottom_inverted, upper_div_bottom))