- class property galois.FieldArray.squares : FieldArray
All squares in the finite field.
An element \(x\) in \(\mathrm{GF}(p^m)\) is a square if there exists a \(y\) such that \(y^2 = x\) in the field.
See also
Examples¶
In fields with characteristic 2, every element is a square (with two identical square roots).
In [1]: GF = galois.GF(2**3, display="poly") In [2]: x = GF.squares; x Out[2]: GF([ 0, 1, α, α + 1, α^2, α^2 + 1, α^2 + α, α^2 + α + 1], order=2^3) In [3]: y1 = np.sqrt(x); y1 Out[3]: GF([ 0, 1, α^2 + α, α^2 + α + 1, α, α + 1, α^2, α^2 + 1], order=2^3) In [4]: y2 = -y1; y2 Out[4]: GF([ 0, 1, α^2 + α, α^2 + α + 1, α, α + 1, α^2, α^2 + 1], order=2^3) In [5]: np.array_equal(y1 ** 2, x) Out[5]: True In [6]: np.array_equal(y2 ** 2, x) Out[6]: True
In fields with characteristic greater than 2, exactly half of the nonzero elements are squares (with two unique square roots).
In [7]: GF = galois.GF(11) In [8]: x = GF.squares; x Out[8]: GF([0, 1, 3, 4, 5, 9], order=11) In [9]: y1 = np.sqrt(x); y1 Out[9]: GF([0, 1, 5, 2, 4, 3], order=11) In [10]: y2 = -y1; y2 Out[10]: GF([ 0, 10, 6, 9, 7, 8], order=11) In [11]: np.array_equal(y1 ** 2, x) Out[11]: True In [12]: np.array_equal(y2 ** 2, x) Out[12]: True