np.sqrt
- np.sqrt(x)
Computes the square root a Galois field array element-wise.
References
Notes
This function returns the lexicographically-minimal root \(r\) (the root whose integer representation is smallest). In addition to \(r\), \(-r\) is also a root.
Examples
In [1]: GF = galois.GF(31) # Only the "quadratic residues" have square roots In [2]: x = GF.quadratic_residues; x Out[2]: GF([ 0, 1, 2, 4, 5, 7, 8, 9, 10, 14, 16, 18, 19, 20, 25, 28], order=31) In [3]: r = np.sqrt(x) # Both roots in the finite field In [4]: r, -r Out[4]: (GF([ 0, 1, 8, 2, 6, 10, 15, 3, 14, 13, 4, 7, 9, 12, 5, 11], order=31), GF([ 0, 30, 23, 29, 25, 21, 16, 28, 17, 18, 27, 24, 22, 19, 26, 20], order=31)) In [5]: r**2 Out[5]: GF([ 0, 1, 2, 4, 5, 7, 8, 9, 10, 14, 16, 18, 19, 20, 25, 28], order=31) In [6]: (-r)**2 Out[6]: GF([ 0, 1, 2, 4, 5, 7, 8, 9, 10, 14, 16, 18, 19, 20, 25, 28], order=31)