Skip to content

Commit

Permalink
Add FieldClass.quadratic_non_residues
Browse files Browse the repository at this point in the history
  • Loading branch information
mhostetter committed Jan 25, 2022
1 parent ef7f9b7 commit c26143c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions galois/_fields/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,35 @@ def quadratic_residues(cls) -> "FieldArray":
is_quadratic_residue = x.is_quadratic_residue()
return x[is_quadratic_residue]

@property
def quadratic_non_residues(cls) -> "FieldArray":
r"""
galois.FieldArray: All quadratic non-residues in the Galois field.
An element :math:`x` in :math:`\mathrm{GF}(p^m)` is a *quadratic non-residue* if there does not exist a :math:`y` such that
:math:`y^2 = x` in the field.
In fields with characteristic 2, no elements are quadratic non-residues. In fields with characteristic greater than 2,
exactly half of the nonzero elements are quadratic non-residues.
See also :func:`FieldArray.is_quadratic_residue`.
Examples
--------
.. ipython:: python
GF = galois.GF(11)
GF.quadratic_non_residues
.. ipython:: python
GF = galois.GF(2**4)
GF.quadratic_non_residues
"""
x = cls.Elements()
is_quadratic_residue = x.is_quadratic_residue()
return x[~is_quadratic_residue]

@property
def is_prime_field(cls) -> bool:
"""
Expand Down

0 comments on commit c26143c

Please sign in to comment.