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]: assert a == b

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

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]: assert a != b

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]: assert a == GF([3, 0, 2])

In [11]: assert a == [3, 0, 2]

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

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