Skip to content

Commit

Permalink
Fixed random_element() for rational quaternionic fractional ideals
Browse files Browse the repository at this point in the history
Added QuaternionFractionalIdeal_rational.random_element() to overwrite the ideal.random_element()-method, which doesn't work for fractional ideals.
  • Loading branch information
S17A05 committed Jan 18, 2024
1 parent 439065e commit acdf2c2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/sage/algebras/quatalg/quaternion_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -2294,6 +2294,20 @@ def __repr__(self):
'Fractional ideal (2 + 6*j + 4*k, 2*i + 4*j + 2*k, 8*j, 8*k)'
"""
return 'Fractional ideal %s' % (self.gens(),)

def random_element(self, *args, **kwds):
"""
Return a random element in the rational fractional ideal ``self``.
EXAMPLES::
sage: B.<i,j,k> = QuaternionAlgebra(211)
sage: I = B.ideal([1, 1/4*j, 20*(i+k), 2/3*i])
sage: x = I.random_element() # random
sage: x in I
True
"""
return sum(ZZ.random_element(*args, **kwds) * g for g in self.gens())

def quaternion_order(self):
"""
Expand Down

0 comments on commit acdf2c2

Please sign in to comment.