Skip to content

Commit 22f63e0

Browse files
committed
Fixed random_element() for rational quaternionic fractional ideals
Added QuaternionFractionalIdeal_rational.random_element() to overwrite the ideal.random_element()-method, which doesn't work for fractional ideals; fixed whitespace detected by Lint checks.
1 parent 439065e commit 22f63e0

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)