class galois.Poly

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

Examples

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

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


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

In : GF = galois.GF(3**5)

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


See Polynomials and Polynomial Arithmetic for more examples.

## Constructors¶

Poly(field: = None, ...)

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

classmethod Degrees(degrees: , ...) Self

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

classmethod Identity(field: = None) Self

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

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

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

classmethod One(field: = None) Self

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

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

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

classmethod Roots(...) Self

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

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

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

classmethod Zero(field: = None) Self

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

## Special methods¶

__call__(at: , ...)
__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.

## 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.

## Methods¶

derivative(k: int = 1) Poly

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

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)
roots(multiplicity: True) tuple[Array, np.ndarray]

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

## Factorization methods¶

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)$$.

square_free_factors() tuple[list[Poly], list[int]]

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

## Coefficients¶

coefficients(size: = None, ...)

Returns the polynomial coefficients in the order and size specified.

property coeffs : Array

The coefficients of the polynomial in degree-descending order.

property degrees : ndarray

An array of the polynomial degrees in descending order.

property nonzero_coeffs : Array

The non-zero coefficients of the polynomial in degree-descending order.

property nonzero_degrees : ndarray

An array of the polynomial degrees that have non-zero coefficients in descending order.

## Properties¶

property degree : int

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

property field :

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

## Attributes¶

is_conway(search: bool = False) bool

Checks whether the degree-$$m$$ polynomial $$f(x)$$ over $$\mathrm{GF}(p)$$ is the Conway polynomial $$C_{p,m}(x)$$.

is_conway_consistent(search: bool = False) bool

Determines whether the degree-$$m$$ polynomial $$f(x)$$ over $$\mathrm{GF}(p)$$ is consistent with smaller Conway polynomials $$C_{p,n}(x)$$ for all $n\ |m$.

is_irreducible() bool

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

property is_monic : bool

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

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.