Пример #1
0
 def from_polynomial(cls, pol):
     pol = PolynomialRing(QQ, 'x')(str(pol))
     pol *= pol.denominator()
     R = pol.parent()
     pol = R(pari(pol).polredbest().polredabs())
     return cls.from_coeffs(
         [int(c) for c in pol.coefficients(sparse=False)])
Пример #2
0
def pol_string_to_list(pol, deg=None, var=None):
    if var is None:
        from lmfdb.hilbert_modular_forms.hilbert_field import findvar
        var = findvar(pol)
        if not var:
            var = 'a'
    pol = PolynomialRing(QQ, var)(str(pol))
    if deg is None:
        fill = 0
    else:
        fill = deg - pol.degree() - 1
    return [str(c) for c in pol.coefficients(sparse=False)] + ['0'] * fill
Пример #3
0
def pol_string_to_list(pol, deg=None, var=None):
    if var is None:
        from lmfdb.hilbert_modular_forms.hilbert_field import findvar
        var = findvar(pol)
        if not var:
            var = 'a'
    pol = PolynomialRing(QQ, var)(str(pol))
    if deg is None:
        fill = 0
    else:
        fill = deg - pol.degree() - 1
    return [str(c) for c in pol.coefficients(sparse=False)] + ['0']*fill
Пример #4
0
 def from_polynomial(cls, pol):
     try:
         # try to cast to ring
         pol = PolynomialRing(QQ, 'x')(pol)
     except Exception:
         # try again as a string
         pol = PolynomialRing(QQ, 'x')(str(pol))
     pol *= pol.denominator()
     R = pol.parent()
     pol = R(pari(pol).polredbest().polredabs())
     return cls.from_coeffs(
         [int(c) for c in pol.coefficients(sparse=False)])
Пример #5
0
 def from_polynomial(cls, pol):
     try:
         # try to cast to ring
         pol = PolynomialRing(QQ, 'x')(pol)
     except Exception:
         # try again as a string
         pol = PolynomialRing(QQ, 'x')(str(pol))
     pol *= pol.denominator()
     # For some reason the error raised by Pari on a constant polynomial is not being caught
     if pol.degree() < 1:
         raise ValueError("Polynomial cannot be constant")
     R = pol.parent()
     pol = R(pari(pol).polredbest().polredabs())
     return cls.from_coeffs([int(c) for c in pol.coefficients(sparse=False)])
Пример #6
0
 def from_polynomial(cls, pol):
     pol = PolynomialRing(QQ, 'x')(str(pol))
     pol *= pol.denominator()
     R = pol.parent()
     pol = R(pari(pol).polredbest().polredabs())
     return cls.from_coeffs([int(c) for c in pol.coefficients(sparse=False)])