Skip to content

Commit 507c389

Browse files
author
Release Manager
committed
gh-37098: Fixed random_element() for fractional ideals in rational quaternion algebras Added `QuaternionFractionalIdeal_rational.random_element()` to fix random sampling in fractional ideals of quaternion algebras. The method `.random_element()` of the ideal class refers to the ring over which the ideal is defined, but for fractional ideals Sage often (incorrectly) gives the base field of the algebra as a base ring. To work around this, we implement a new function `QuaternionFractionalIdeal_rational.random_element()` that hardcodes $\mathbb{Z}$ to return a random $\mathbb{Z}$-linear combination of the (lattice) generators of the fractional ideal. Note: The deeper issue of separating ideals and fractional ideals still remains - see #3680. #sd123 URL: #37098 Reported by: Sebastian Spindler Reviewer(s): Peter Bruin
2 parents 6224890 + 22f63e0 commit 507c389

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/sage/algebras/quatalg/quaternion_algebra.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2295,6 +2295,20 @@ def __repr__(self):
22952295
"""
22962296
return 'Fractional ideal %s' % (self.gens(),)
22972297

2298+
def random_element(self, *args, **kwds):
2299+
"""
2300+
Return a random element in the rational fractional ideal ``self``.
2301+
2302+
EXAMPLES::
2303+
2304+
sage: B.<i,j,k> = QuaternionAlgebra(211)
2305+
sage: I = B.ideal([1, 1/4*j, 20*(i+k), 2/3*i])
2306+
sage: x = I.random_element() # random
2307+
sage: x in I
2308+
True
2309+
"""
2310+
return sum(ZZ.random_element(*args, **kwds) * g for g in self.gens())
2311+
22982312
def quaternion_order(self):
22992313
"""
23002314
Return the order for which this ideal is a left or right

0 commit comments

Comments
 (0)