galois.Poly.__eq__(other: PolyLike) bool

Determines if two polynomials are equal.

Parameters
other: PolyLike

The polynomial to compare against.

Returns

True if the two polynomials have the same coefficients and are over the same finite field.

Examples

Compare two polynomials over the same field.

In [1]: a = galois.Poly([3, 0, 5], field=galois.GF(7)); a
Out[1]: Poly(3x^2 + 5, GF(7))

In [2]: b = galois.Poly([3, 0, 5], field=galois.GF(7)); b
Out[2]: Poly(3x^2 + 5, GF(7))

In [3]: a == b
Out[3]: True

# They are still two distinct objects, however
In [4]: a is b
Out[4]: False

Compare two polynomials with the same coefficients but over different fields.

In [5]: a = galois.Poly([3, 0, 5], field=galois.GF(7)); a
Out[5]: Poly(3x^2 + 5, GF(7))

In [6]: b = galois.Poly([3, 0, 5], field=galois.GF(7**2)); b
Out[6]: Poly(3x^2 + 5, GF(7^2))

In [7]: a == b
Out[7]: False

Comparison with PolyLike objects is allowed for convenience.

In [8]: GF = galois.GF(7)

In [9]: a = galois.Poly([3, 0, 2], field=GF); a
Out[9]: Poly(3x^2 + 2, GF(7))

In [10]: a == GF([3, 0, 2])
Out[10]: True

In [11]: a == [3, 0, 2]
Out[11]: True

In [12]: a == "3x^2 + 2"
Out[12]: True

In [13]: a == 3*7**2 + 2
Out[13]: True