cyjax.polynomial#

Methods for manipulating polynomials.

The base class Poly builds on top of sympy.Poly and adds numerically efficient evaluation. In addition, it groups (scalar) input variables into groups which represent some complex vector space (later \(\mathbb{P}^n\)). For example, \(z_0, z_1, z_2, z_3 \in \mathbb{C}\) are grouped into a single vectorial input variable \(z\). Besides input variables, the class also tracks a list of scalar parameters which are passed together as a single array when evaluating the polynomial.

As a subclass of Poly, a homogeneous polynomial class HomPoly is given, which can be evaluated efficiently given affine coordinates.

General polynomials#

The base functionality is implemented in the Poly class:

Poly(sympy_poly, variable_names, parameters, ...)

It can be constructed either based on a (sympy) expression of the equation, or given matrices of powers and coefficients:

Poly.from_sympy(poly[, variable_names, ...])

Construct a Poly object from a sympy/string expression.

Poly.from_coeffs_and_powers(coeffs, powers)

Construct Poly object from arrays of powers and coeffs.

Poly.to_coeffs_and_powers()

Extract powers of variables and lists of coefficients.

Several helper functions are implemented that are used inside Poly:

compute_monomials(values, coeffs, powers, *)

Compute monomial terms of a polynomial.

split_subscript(var)

Split variable into main name and integer subscript (or None).

merge_subscript(name, sub)

Join variable name and subscript to sympy symbol.

any_symbolic(*args)

Check if any of the arguments are symbolic instead of numerical.

Extract coefficients from multivariate polynomial#

univariate_coefficients(poly, var)

Polynomials for coefficients in each order for a single variable.

Homogeneous polynomials#

Based on the Poly class, a homogeneous polynomial class is defined which itself inherits from Poly.

HomPoly(sympy_poly, variable_names, ...)

The Dwork family and the Fermat polynomial are given for convenience.

DworkPoly([poly_degree, factor])

FermatPoly([poly_degree])