Skip to content

Commit 345f8f4

Browse files
Review Changes
- Changed order mod 2 call to characteristic equal in is_square() - Capitalization in docstrings - Correct chapter in docstring for sqrt - Co-authored-by: Vincent Macri <vincent.macri@ucalgary.ca>
1 parent 688d2d5 commit 345f8f4

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/sage/categories/finite_fields.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def quadratic_non_residue(self):
270270
"""
271271
# if the order is an even power of two
272272
# then every element is a square
273-
if self.order() % 2 == 0:
273+
if self.characteristic() == 2:
274274
raise ValueError("There are no non-squares in finite fields of even order")
275275
# uniformly randomly select elements for a non-square
276276
# with probability 1/2 for a non-square
@@ -302,8 +302,7 @@ def is_square(self) -> bool:
302302
"""
303303
if self.is_zero():
304304
return True
305-
char = self.parent().characteristic()
306-
if char == 2:
305+
if self.parent().characteristic() == 2:
307306
return True
308307
q = self.parent().order()
309308
character = self**((q-1)//2)
@@ -313,7 +312,7 @@ def is_square(self) -> bool:
313312
def _tonelli(self):
314313
r"""
315314
Returns a square root of the element if it exists
316-
using tonelli's algorithm
315+
using Tonelli's algorithm
317316
318317
OUTPUT:
319318
@@ -351,7 +350,7 @@ def _tonelli(self):
351350
def _cipolla(self):
352351
r"""
353352
Returns a square root of the element if it exists
354-
using cipolla's algorithm, more suited if order - 1
353+
using Cipolla's algorithm, more suited if order - 1
355354
is highly divisible by 2
356355
357356
OUTPUT:
@@ -437,7 +436,7 @@ def sqrt(self, all: bool = False, algorithm: str = 'tonelli'):
437436
438437
ALGORITHM:
439438
440-
The algorithms used come from chapter 6 of [BS1996]_.
439+
The algorithms used come from chapter 7 of [BS1996]_.
441440
Let `q = p^n` be the order of the finite field, let `a` be the finite field element
442441
that we wish to find the square root of.
443442

0 commit comments

Comments
 (0)