switch to BooleanPolynomialRing
This commit is contained in:
@@ -1,38 +1,20 @@
|
||||
### print
|
||||
|
||||
def monomial_to_str(exp, names):
|
||||
factors = []
|
||||
for i, e in enumerate(exp):
|
||||
if e == 0:
|
||||
continue
|
||||
name = names[i]
|
||||
if e == 1:
|
||||
factors.append(name)
|
||||
else:
|
||||
factors.append(f"{name}^{e}")
|
||||
return "*".join(factors) if factors else "1"
|
||||
|
||||
|
||||
def pretty_print(poly):
|
||||
ring = poly.parent()
|
||||
names = ring.variable_names()
|
||||
|
||||
R_terms = []
|
||||
r_terms = []
|
||||
x_terms = []
|
||||
mixed_terms = []
|
||||
has_const = False
|
||||
|
||||
for exp, coeff in poly.dict().items():
|
||||
if coeff == 0:
|
||||
has_const = bool(poly.constant_coefficient())
|
||||
|
||||
for monom in poly:
|
||||
vars_in_term = [str(v) for v in monom.variables()]
|
||||
|
||||
if not vars_in_term:
|
||||
continue
|
||||
|
||||
if sum(exp) == 0:
|
||||
has_const = True
|
||||
continue
|
||||
|
||||
term = monomial_to_str(exp, names)
|
||||
vars_in_term = [names[i] for i, e in enumerate(exp) if e != 0]
|
||||
term = "*".join(vars_in_term)
|
||||
families = {v[0] for v in vars_in_term}
|
||||
|
||||
if families == {"R"}:
|
||||
|
||||
Reference in New Issue
Block a user