donuts module

Python binding to the Donuts wrapper for the Rings library.

class donuts.Polynomial(value=None)[source]

Polynomial.

property as_integer: int

Cast the polynomial to an integer.

property as_variable: Variable

Cast the polynomial to a variable.

coeff(variables, exponents)[source]

Return the coefficient specified by variables and exponents.

Return type:

Polynomial

coeff_dict(*variables)[source]

Cast this polynomial to a map from exponents to coefficients.

Return type:

Dict[Sequence[int], Polynomial]

degree(*variables)[source]

Return the degree with respect to the specified variables.

Return type:

int

diff(x, n=1)[source]

Differentiate this polynomial.

Return type:

Polynomial

divide_exact(other)[source]

Return `self / other` if divisible.

Return type:

Polynomial

evaluate(variables, values)[source]

Return the result of setting the given variables to the specified values.

Return type:

Polynomial

evaluate_at_one(*variables)[source]

Return the result of setting all the given variables to unity.

Return type:

Polynomial

evaluate_at_zero(*variables)[source]

Return the result of setting all the given variables to zero.

Return type:

Polynomial

property factors: Sequence[Polynomial]

Return the factorization of this polynomial.

gcd(other)[source]

Return GCD(self, other).

Return type:

Polynomial

property is_integer: bool

Return True if the polynomial is an integer.

property is_minus_one: bool

Return True if the polynomial is minus one.

property is_monic: bool

Return True if the polynomial is monic.

property is_monomial: bool

Return True if the polynomial is monomial.

property is_one: bool

Return True if the polynomial is one.

property is_variable: bool

Return True if the polynomial is a variable.

property is_zero: bool

Return True if the polynomial is zero.

lcm(other)[source]

Return LCM(self, other).

Return type:

Polynomial

property min_variables: FrozenSet[Variable]

Return the set of actually used variables in this polynomial.

shift(variables, values)[source]

Return the result of the given variable shifts.

Return type:

Polynomial

property signum: int

Return the signum of the leading coefficient.

subs(lhs, rhs)[source]

Return the result of the given substitution.

Return type:

Polynomial

translate(*variables)[source]

Translate the polynomial in terms of the given set of variables.

Return type:

Polynomial

property variables: FrozenSet[Variable]

Return the set of variables.

class donuts.RationalFunction(numerator=None, denominator=None)[source]

Rational function.

property as_fraction: Fraction

Cast the rational function to a rational number.

property as_integer: int

Cast the rational function to an integer.

property as_polynomial: Polynomial

Cast the rational function to a polynomial.

property as_variable: Variable

Cast the rational function to a variable.

property denominator: Polynomial

Return the denominator.

diff(x, n=1)[source]

Differentiate this rational function.

Return type:

RationalFunction

evaluate(variables, values)[source]

Return the result of setting the given variables to the specified values.

Return type:

RationalFunction

evaluate_at_one(*variables)[source]

Return the result of setting all the given variables to unity.

Return type:

RationalFunction

evaluate_at_zero(*variables)[source]

Return the result of setting all the given variables to zero.

Return type:

RationalFunction

property is_fraction: bool

Return True if the rational function is a rational number.

property is_integer: bool

Return True if the rational function is an integer.

property is_minus_one: bool

Return True if the rational function is minus one.

property is_one: bool

Return True if the rational function is one.

property is_polynomial: bool

Return True if the rational function is a polynomial.

property is_variable: bool

Return True if the rational function is a variable.

property is_zero: bool

Return True if the rational function is zero.

property min_variables: FrozenSet[Variable]

Return the set of actually used variables in this polynomial.

property numerator: Polynomial

Return the numerator.

shift(variables, values)[source]

Return the result of the given variable shifts.

Return type:

RationalFunction

subs(lhs, rhs)[source]

Return the result of the given substitution.

Return type:

RationalFunction

translate(*variables)[source]

Translate the rational function in terms of the given set of variables.

Return type:

RationalFunction

property variables: FrozenSet[Variable]

Return the set of variables.

class donuts.Variable(name: str)[source]
class donuts.Variable(variable: Variable)

Variable.

donuts.gcd(*polynomials)[source]

Return the GCD of the given polynomials.

Return type:

Polynomial

donuts.lcm(*polynomials)[source]

Return the LCM of the given polynomials.

Return type:

Polynomial

donuts.product(*polynomials)[source]

Return the product of the given polynomials.

Return type:

Polynomial