From 22f63e085a7727798a5855f434af8fc77555bf95 Mon Sep 17 00:00:00 2001 From: Sebastian Spindler <153911337+S17A05@users.noreply.github.com> Date: Thu, 18 Jan 2024 17:36:43 +0100 Subject: [PATCH] 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. --- src/sage/algebras/quatalg/quaternion_algebra.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/sage/algebras/quatalg/quaternion_algebra.py b/src/sage/algebras/quatalg/quaternion_algebra.py index 5a615b43978..81343bd7451 100644 --- a/src/sage/algebras/quatalg/quaternion_algebra.py +++ b/src/sage/algebras/quatalg/quaternion_algebra.py @@ -2295,6 +2295,20 @@ def __repr__(self): """ 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. = 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): """ Return the order for which this ideal is a left or right