class galois.Poly

A univariate polynomial \(f(x)\) over \(\mathrm{GF}(p^m)\).

Examples

Create a polynomial over \(\mathrm{GF}(2)\).

In [1]: galois.Poly([1, 0, 1, 1])
Out[1]: Poly(x^3 + x + 1, GF(2))

Create a polynomial over \(\mathrm{GF}(3^5)\).

In [2]: GF = galois.GF(3**5)

In [3]: galois.Poly([124, 0, 223, 0, 0, 15], field=GF)
Out[3]: Poly(124x^5 + 223x^3 + 15, GF(3^5))

See Polynomials and Polynomial Arithmetic for more examples.

Constructors

Poly(coeffs: ArrayLike, field: Type[Array] | None = None, ...)

Creates a polynomial \(f(x)\) over \(\mathrm{GF}(p^m)\).

classmethod Degrees(degrees: Sequence[int] | ndarray, ...) Poly

Constructs a polynomial over \(\mathrm{GF}(p^m)\) from its non-zero degrees.

classmethod Identity(field: Type[Array] | None = None) Poly

Constructs the polynomial \(f(x) = x\) over \(\mathrm{GF}(p^m)\).

classmethod Int(integer: int, ...) Poly

Constructs a polynomial over \(\mathrm{GF}(p^m)\) from its integer representation.

classmethod One(field: Type[Array] | None = None) Poly

Constructs the polynomial \(f(x) = 1\) over \(\mathrm{GF}(p^m)\).

classmethod Random(degree: int, ...) Poly

Constructs a random polynomial over \(\mathrm{GF}(p^m)\) with degree \(d\).

classmethod Roots(roots: ArrayLike, ...) Poly

Constructs a monic polynomial over \(\mathrm{GF}(p^m)\) from its roots.

classmethod Str(string: str, ...) Poly

Constructs a polynomial over \(\mathrm{GF}(p^m)\) from its string representation.

classmethod Zero(field: Type[Array] | None = None) Poly

Constructs the polynomial \(f(x) = 0\) over \(\mathrm{GF}(p^m)\).

String representation

__repr__() str

A representation of the polynomial and the finite field it’s over.

__str__() str

The string representation of the polynomial, without specifying the finite field it’s over.

Special methods

__call__(at: ElementLike | ArrayLike, ...) Array
__call__(at: Poly) Poly

Evaluates the polynomial \(f(x)\) at \(x_0\) or the polynomial composition \(f(g(x))\).

__eq__(other: PolyLike) bool

Determines if two polynomials are equal.

__int__() int

The integer representation of the polynomial.

__len__() int

Returns the length of the coefficient array, which is equivalent to Poly.degree + 1.

Methods

coefficients(size: int | None = None, ...) Array

Returns the polynomial coefficients in the order and size specified.

derivative(k: int = 1) Poly

Computes the \(k\)-th formal derivative \(\frac{d^k}{dx^k} f(x)\) of the polynomial \(f(x)\).

distinct_degree_factors() Tuple[List[Poly], List[int]]

Factors the monic, square-free polynomial \(f(x)\) into a product of polynomials whose irreducible factors all have the same degree.

equal_degree_factors(degree: int) List[Poly]

Factors the monic, square-free polynomial \(f(x)\) of degree \(rd\) into a product of \(r\) irreducible factors with degree \(d\).

factors() Tuple[List[Poly], List[int]]

Computes the irreducible factors of the non-constant, monic polynomial \(f(x)\).

is_irreducible() bool

Determines whether the polynomial \(f(x)\) over \(\mathrm{GF}(p^m)\) is irreducible.

is_primitive() bool

Determines whether the polynomial \(f(x)\) over \(\mathrm{GF}(q)\) is primitive.

is_square_free() bool

Determines whether the polynomial \(f(x)\) over \(\mathrm{GF}(q)\) is square-free.

reverse() Poly

Returns the \(d\)-th reversal \(x^d f(\frac{1}{x})\) of the polynomial \(f(x)\) with degree \(d\).

roots(multiplicity: False = False) Array
roots(multiplicity: True) Tuple[Array, ndarray]

Calculates the roots \(r\) of the polynomial \(f(x)\), such that \(f(r) = 0\).

square_free_factors() Tuple[List[Poly], List[int]]

Factors the monic polynomial \(f(x)\) into a product of square-free polynomials.

Properties

property coeffs : Array

The coefficients of the polynomial in degree-descending order. The entries of coeffs are paired with degrees.

property degree : int

The degree of the polynomial. The degree of a polynomial is the highest degree with a non-zero coefficient.

property degrees : ndarray

An array of the polynomial degrees in descending order. The entries of coeffs are paired with degrees.

property field : Type[Array]

The Array subclass for the finite field the coefficients are over.

property is_monic : bool

Returns whether the polynomial is monic, meaning its highest-degree coefficient is one.

property nonzero_coeffs : Array

The non-zero coefficients of the polynomial in degree-descending order. The entries of nonzero_coeffs are paired with nonzero_degrees.

property nonzero_degrees : ndarray

An array of the polynomial degrees that have non-zero coefficients in descending order. The entries of nonzero_coeffs are paired with nonzero_degrees.


Last update: Aug 27, 2022