def gen_irreducible_Z_polys(n): polys = [] for i in range(n): k = i // 2 + 1 if i % 2 == 1: k = -k polys.append(cratylus.poly_from_var('x', modulo=0) + cratylus.poly_from_constant(k, modulo=0)) return polys
def translate_monomial(table, monomial, options): key, coef = monomial.coefficients().items()[0] res = cratylus.poly_from_constant(1, OPTIONS['target_modulo']) for var, power in key: if var in table: res = res * table[var] ** power else: assert var in options['initial_table'] res = res * options['initial_table'][var] ** power return res
def gen_irreducible_Z_polys(n): polys = [] for i in range(n): k = i // 2 + 1 if i % 2 == 1: k = -k polys.append( cratylus.poly_from_var('x', modulo=0) + cratylus.poly_from_constant(k, modulo=0)) return polys
def translate_monomial(table, monomial, options): key, coef = monomial.coefficients().items()[0] res = cratylus.poly_from_constant(1, OPTIONS['target_modulo']) for var, power in key: if var in table: res = res * table[var]**power else: assert var in options['initial_table'] res = res * options['initial_table'][var]**power return res
def irreducible_elements(n, translation_type): "Return n irreducible elements appropiate for the given translation type" if translation_type == 'fractran': return [cratylus.poly_from_constant(p, modulo=0) for p in gen_primes(n)] elif translation_type == 'univariate': return gen_irreducible_Z_polys(n) elif translation_type == 'binary': return gen_irreducible_Zk_polys(n, k=2) elif translation_type == 'vars_compact': return gen_compact_vars(n) elif translation_type == 'words': return gen_words(n) elif translation_type == 'mixed': return gen_mixed(n) else: assert False
def irreducible_elements(n, translation_type): "Return n irreducible elements appropiate for the given translation type" if translation_type == 'fractran': return [ cratylus.poly_from_constant(p, modulo=0) for p in gen_primes(n) ] elif translation_type == 'univariate': return gen_irreducible_Z_polys(n) elif translation_type == 'binary': return gen_irreducible_Zk_polys(n, k=2) elif translation_type == 'vars_compact': return gen_compact_vars(n) elif translation_type == 'words': return gen_words(n) elif translation_type == 'mixed': return gen_mixed(n) else: assert False