Skip to content

Commit 3b9d676

Browse files
author
Release Manager
committed
gh-35643: Avoid redundant computations in finite field .conjugate() method ### 📚 Description The previous implementation was factoring the order (characteristic^degree) to obtain the field degree. The methods `cardinality()` and `order()` are really defined as `return self.characteristic()**self.degree()`. Sage 10rc3 ``` sage: p = next_prime(2**160) sage: K = GF((p,2)) sage: x = K.random_element() sage: %timeit x.conjugate() 13.2 ms ± 77.8 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) ``` After patch: ``` sage: %timeit x.conjugate() 5.01 µs ± 15.5 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each) ``` ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies None URL: #35643 Reported by: Rémy Oudompheng Reviewer(s): Lorenz Panny
2 parents 9a0d0ab + 8d09044 commit 3b9d676

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/sage/rings/finite_rings/element_base.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ cdef class FinitePolyExtElement(FiniteRingElement):
10071007
sage: G32(m1) == g1
10081008
True
10091009
"""
1010-
[(p, k2)] = list(self.parent().cardinality().factor())
1010+
k2 = self.parent().degree()
10111011
if k2 % 2:
10121012
raise TypeError("cardinality of the field must be a square number")
10131013
k = k2 / 2

0 commit comments

Comments
 (0)