From d3173af1bf82b3620d79ecff8a4fd846aca831b2 Mon Sep 17 00:00:00 2001 From: Sebastian Spindler Date: Fri, 19 Jan 2024 15:36:45 +0100 Subject: [PATCH 1/2] Added is_isomorphic Added `QuaternionAlgebra_ab.is_isomorphic()` to conveniently check whether two rational quaternion algebras are isomorphic --- .../algebras/quatalg/quaternion_algebra.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/sage/algebras/quatalg/quaternion_algebra.py b/src/sage/algebras/quatalg/quaternion_algebra.py index 5a615b43978..b8cb5082661 100644 --- a/src/sage/algebras/quatalg/quaternion_algebra.py +++ b/src/sage/algebras/quatalg/quaternion_algebra.py @@ -1074,6 +1074,28 @@ def ramified_primes(self): # TODO: more examples return [f[0] for f in factor(self.discriminant())] + def is_isomorphic(self, A) -> bool: + r""" + Return ``True`` if ``self`` and ``A`` are isomorphic quaternion algebras over Q. + + INPUT: + + - ``A`` -- a quaternion algebra defined over the rationals Q + + EXAMPLES:: + + sage: B = QuaternionAlgebra(-46, -87) + sage: A = QuaternionAlgebra(-58, -69) + sage: B.is_isomorphic(A) + True + sage: A == B + False + """ + if self.base_ring() != QQ or A.base_ring() != QQ: + raise NotImplementedError("isomorphism check only implemented for rational quaternion algebras") + + return self.discriminant() == A.discriminant() + def _magma_init_(self, magma): """ Return Magma version of this quaternion algebra. From e3e69c2de558ad0ebbb65e24efc3e712f5f7e211 Mon Sep 17 00:00:00 2001 From: Sebastian Spindler Date: Sat, 20 Jan 2024 01:27:07 +0100 Subject: [PATCH 2/2] Type check `is_isomorphic` Added a type check to .is_isomorphic to ensure that A is a quaternion algebra of the form (a,b)_K. --- src/sage/algebras/quatalg/quaternion_algebra.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sage/algebras/quatalg/quaternion_algebra.py b/src/sage/algebras/quatalg/quaternion_algebra.py index b8cb5082661..d1904cb74d2 100644 --- a/src/sage/algebras/quatalg/quaternion_algebra.py +++ b/src/sage/algebras/quatalg/quaternion_algebra.py @@ -1091,6 +1091,9 @@ def is_isomorphic(self, A) -> bool: sage: A == B False """ + if not isinstance(A, QuaternionAlgebra_ab): + raise TypeError("A must be a quaternion algebra of the form (a,b)_K") + if self.base_ring() != QQ or A.base_ring() != QQ: raise NotImplementedError("isomorphism check only implemented for rational quaternion algebras")