/usr/lib/python2.7/dist-packages/brial/easy_polynomials.py is in python-brial 0.8.5-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | from .interpolate import variety_lex_leading_terms, nf_lex_points
from .PyPolyBoRi import easy_linear_factors
def easy_linear_polynomials(p):
""" Get linear polynomials implied by given polynomial.
>>> from brial.frontend import *
>>> easy_linear_polynomials(x(1)*x(2) + 1)
[x(1) + 1, x(2) + 1]
>>> easy_linear_polynomials(x(1)*x(2) + 0)
[]
>>> easy_linear_polynomials(x(0)*x(1) + x(0)*x(2) + 1)
[x(0) + 1, x(1) + x(2) + 1]
"""
res = []
if p.deg() >= 2:
if p.vars_as_monomial().deg() > 8:
opp = p + 1
for q in easy_linear_factors(opp):
res.append(q + 1)
else:
res = easy_linear_polynomials_via_interpolation(p)
return res
def easy_linear_polynomials_via_interpolation(p):
""" Get linear polynomials implied by given polynomial using interpolation
of the variety.
>>> from brial.frontend import *
>>> easy_linear_polynomials_via_interpolation(x(1)*x(2) + 1)
[x(1) + 1, x(2) + 1]
>>> easy_linear_polynomials_via_interpolation(x(1)*x(2) + 0)
[]
>>> easy_linear_polynomials_via_interpolation(x(0)*x(1) + x(0)*x(2) + 1)
[x(0) + 1, x(1) + x(2) + 1]
"""
res = []
p_vars = p.vars_as_monomial()
space = p_vars.divisors()
zeros = p.zeros_in(space)
lex_leads = variety_lex_leading_terms(zeros, p_vars)
for m in lex_leads:
if m.deg() == 1:
red = m + nf_lex_points(m, zeros)
if red.lead_deg() == 1: # normal ordering
res.append(red)
return res
|