- 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, ...) Self
Constructs a polynomial over \(\mathrm{GF}(p^m)\) from its non-zero degrees.
-
classmethod Identity(field: type[Array] | None =
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: type[Array] | None =
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(roots: ArrayLike, ...) 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: type[Array] | None =
None
) Self Constructs the polynomial \(f(x) = 0\) over \(\mathrm{GF}(p^m)\).
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))\).
String representation¶
- __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
) Array - roots(...) tuple[galois._domains._array.Array, numpy.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: int | None =
None
, ...) Array Returns the polynomial coefficients in the order and size specified.
- 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.
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 \mid 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.
-
Poly(coeffs: ArrayLike, field: type[Array] | None =