Skip to content

move conj_sqrt() to method for finite fields #39687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions src/sage/combinat/symmetric_group_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@
and also projective modules)::

sage: SGA = SymmetricGroupAlgebra(QQ, 5)
sage: for la in Partitions(SGA.n):

Check warning on line 1304 in src/sage/combinat/symmetric_group_algebra.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.11)

Warning: slow doctest:

slow doctest:

Check warning on line 1304 in src/sage/combinat/symmetric_group_algebra.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12)

Warning: slow doctest:

slow doctest:

Check warning on line 1304 in src/sage/combinat/symmetric_group_algebra.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, editable)

Warning: slow doctest:

slow doctest:
....: idem = SGA.ladder_idemponent(la)
....: assert idem^2 == idem
....: print(la, SGA.principal_ideal(idem).dimension())
Expand Down Expand Up @@ -2163,7 +2163,6 @@
...
NotImplementedError: not implemented when p|n!; dimension of invariant forms may be greater than one
"""
from sage.matrix.special import diagonal_matrix
F = self.base_ring()
G = self.group()

Expand All @@ -2189,22 +2188,12 @@
raise ValueError("the base ring must be a finite field of square order")
if F.characteristic().divides(G.cardinality()):
raise NotImplementedError("not implemented when p|n!; dimension of invariant forms may be greater than one")
q = F.order().sqrt()

def conj_square_root(u):
if not u:
return F.zero()
z = F.multiplicative_generator()
k = u.log(z)
if k % (q+1) != 0:
raise ValueError(f"unable to factor as {u} is not in base field GF({q})")
return z ** ((k//(q+1)) % (q-1))

dft_matrix = self.dft()
n = dft_matrix.nrows()
for i in range(n):
d = sum(dft_matrix[i, j] * dft_matrix[i, j].conjugate() for j in range(n))
dft_matrix[i] *= ~conj_square_root(d)
dft_matrix[i] *= ~d.conj_sqrt()
return dft_matrix

def _dft_seminormal(self, mult='l2r'):
Expand Down
58 changes: 58 additions & 0 deletions src/sage/rings/finite_rings/element_givaro.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,64 @@ cdef class FiniteField_givaroElement(FinitePolyExtElement):
else:
raise ValueError("must be a perfect square.")

def conj_sqrt(FiniteField_givaroElement self):
r"""
Return a conjugate square root of this finite field element in its
parent, if there is one. Otherwise, raise a :exc:`ValueError`.

ALGORITHM:

``self`` is stored as `a^k` for some generator `a`.
Return `a^{k/(q+1)}` for `k` divisible by `q+1`.

.. WARNING::

This is only implemented for elements whose exponent
is divisible by `q+1` in fields of order `q**2`.

EXAMPLES::

sage: k.<a> = GF(7**2)
sage: k(0).conj_sqrt()
0
sage: z = k(2).conj_sqrt(); z
a + 4
sage: z*z.conjugate()
2
sage: z = k(3).conj_sqrt(); z
a
sage: z*z.conjugate()
3
sage: z = k(4).conj_sqrt(); z
2*a + 6
sage: z*z.conjugate()
4

TESTS::

sage: k.<a> = GF(7**3)
sage: k(3).conj_sqrt()
Traceback (most recent call last):
...
ValueError: the base ring must be a finite field of square order
sage: k.<a> = GF(7**2)
sage: a.conj_sqrt()
Traceback (most recent call last):
...
ValueError: element must be element of base field GF(7)
"""
if not self.parent().order().is_square():
raise ValueError("the base ring must be a finite field of square order")
q = self.parent().order().sqrt()

if self == 0:
return 0
z = self.parent().multiplicative_generator()
k = self.log(z) # Compute discrete log of u to the base z
if k % (q+1) != 0:
raise ValueError(f"element must be element of base field GF({q})")
return z ** (k//(q+1))

cpdef _add_(self, right):
"""
Add two elements.
Expand Down
Loading