Skip to content

Commit

Permalink
gh-37113: Define behaviour of < and > for fractional ideals in a quat…
Browse files Browse the repository at this point in the history
…ernion algebra

    
Previously, comparison of quaternion algebra fractional ideals (in a
quaternion algebra over QQ) was documented only for equality and did
compare the matrices under HNF of bases of the ideals. This gave strange
and undocumented behavior when comparing two ideals with inequalities.

This comparison is now replaced by the comparison of the fractional
ideals as free modules.

Now "smaller than" means "included in".

#sd123
    
URL: #37113
Reported by: syndrakon
Reviewer(s): David Coudert, Lorenz Panny
  • Loading branch information
Release Manager committed Feb 11, 2024
2 parents 138b265 + b47a604 commit 53c3468
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
29 changes: 28 additions & 1 deletion src/sage/algebras/quatalg/quaternion_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -2585,8 +2585,35 @@ def _richcmp_(self, right, op):
sage: I != I # indirect doctest
False
TESTS::
sage: B = QuaternionAlgebra(QQ,-1,-11)
sage: i,j,k = B.gens()
sage: I = B.ideal([1,i,j,i*j])
sage: I == I
True
sage: O = B.ideal([1,i,(i+j)/2,(1+i*j)/2])
sage: I <= O
True
sage: I >= O
False
sage: I != O
True
sage: I == O
False
sage: I != I
False
sage: I < I
False
sage: I < O
True
sage: I <= I
True
sage: O >= O
True
"""
return self.basis_matrix()._richcmp_(right.basis_matrix(), op)
return self.free_module().__richcmp__(right.free_module(), op)

def __hash__(self):
"""
Expand Down
5 changes: 4 additions & 1 deletion src/sage/modular/quatalg/brandt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,10 @@ def right_ideals(self, B=None):
ideals_theta[J_theta] = [J]
verbose("found %s of %s ideals" % (len(ideals), self.dimension()), level=2)
if len(ideals) >= self.dimension():
ideals = tuple(sorted(ideals))
# order by basis matrix (as ideals were previously
# ordered) for backward compatibility and
# deterministic order of the output
ideals = tuple(sorted(ideals, key=lambda x: x.basis_matrix()))
self.__right_ideals = ideals
return ideals
got_something_new = True
Expand Down

0 comments on commit 53c3468

Please sign in to comment.