galois.Poly¶
-
class
galois.
Poly
(coeffs, field=<class 'galois.gf2.GF2'>)[source]¶ Bases:
object
asdf
Examples
Create polynomials over GF(2)
# Construct a polynominal over GF(2) In [20]: a = galois.Poly([1,0,1,1]); a Out[20]: Poly(x^3 + x + 1 , GF2) # Construct the same polynomial by only specifying its non-zero coefficients In [21]: b = galois.Poly.NonZero([1,1,1], [3,1,0]); b Out[21]: Poly(x^3 + x + 1 , GF2)
Create polynomials over GF(7)
# Construct the GF(7) field In [22]: GF = galois.GF_factory(7, 1) # Construct a polynominal over GF(7) In [23]: a = galois.Poly([4,0,3,0,0,2], field=GF); a Out[23]: Poly(4x^5 + 3x^3 + 2 , GF7) # Construct the same polynomial by only specifying its non-zero coefficients In [24]: b = galois.Poly.NonZero([4,3,2], [5,3,0], field=GF); b Out[24]: Poly(4x^5 + 3x^3 + 2 , GF7)
Polynomial arithmetic
In [25]: a = galois.Poly([1,0,6,3], field=GF); a Out[25]: Poly(x^3 + 6x + 3 , GF7) In [26]: b = galois.Poly([2,0,2], field=GF); b Out[26]: Poly(2x^2 + 2 , GF7) In [27]: a + b Out[27]: Poly(x^3 + 2x^2 + 6x + 5 , GF7) In [28]: a - b Out[28]: Poly(x^3 + 5x^2 + 6x + 1 , GF7) # Compute the quotient of the polynomial division In [29]: a / b Out[29]: Poly(4x , GF7) # True division and floor division are equivalent In [30]: a / b == a // b Out[30]: True # Compute the remainder of the polynomial division In [31]: a % b Out[31]: Poly(5x + 3 , GF7)
-
__init__
(coeffs, field=<class 'galois.gf2.GF2'>)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
NonZero
(coeffs, degrees[, field])Examples
__init__
(coeffs[, field])Initialize self.
divmod
(dividend, divisor)Attributes
The degree of the polynomial, i.e. the highest degree with non-zero coefficient.
The finite field to which the coefficients belong.
-
classmethod
NonZero
(coeffs, degrees, field=<class 'galois.gf2.GF2'>)[source]¶ Examples
# Construct a polynomial over GF2 only specifying the non-zero terms In [32]: a = galois.Poly.NonZero([1,1,1], [3,1,0]); a Out[32]: Poly(x^3 + x + 1 , GF2)
-
property
coeffs
¶
-
property
degree
¶ The degree of the polynomial, i.e. the highest degree with non-zero coefficient.
- Type
int
-
property
field
¶ The finite field to which the coefficients belong.
- Type
-
property
str
¶
-