Skip to content

Commit e126b0e

Browse files
committed
Implemented reviewer recommendations
- Slightly modified description of `.discriminant()` to be more accurate - Cached the method `.ramified_primes()` - Removed optional parameter `sorted` in `.ramified_primes()`, sorting the primes by default instead. - Removed `set()` functions in `.is_isomorphic` since the lists can be compared directly, as they are always sorted according to the above change. - Made description of `.is_isomorphic` slightly more explicit.
1 parent 8af280b commit e126b0e

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

src/sage/algebras/quatalg/quaternion_algebra.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,8 @@ def inner_product_matrix(self):
10311031
@cached_method
10321032
def discriminant(self):
10331033
"""
1034-
Return the discriminant of this quaternion algebra, i.e. the product of the ramified primes in it.
1034+
Return the discriminant of this quaternion algebra, i.e. the product of the finite
1035+
primes it ramifies at.
10351036
10361037
EXAMPLES::
10371038
@@ -1058,46 +1059,34 @@ def discriminant(self):
10581059
else:
10591060
return prod(self.ramified_primes())
10601061

1061-
def ramified_primes(self, sorted=False):
1062+
@cached_method
1063+
def ramified_primes(self):
10621064
"""
10631065
Return the (finite) primes that ramify in this rational quaternion algebra.
10641066
1065-
INPUT:
1066-
1067-
- ``sorted`` -- (default: ``False``)
1068-
10691067
OUTPUT:
10701068
10711069
The list of prime numbers at which ``self`` ramifies (given as integers), sorted by their
1072-
magnitude (small to large) if ``sorted`` is set to ``True``.
1070+
magnitude (small to large).
10731071
10741072
EXAMPLES::
10751073
10761074
sage: QuaternionAlgebra(QQ, -1, -1).ramified_primes()
10771075
[2]
10781076
10791077
sage: QuaternionAlgebra(QQ, -58, -69).ramified_primes()
1080-
[3, 29, 23]
1081-
1082-
sage: QuaternionAlgebra(QQ, -58, -69).ramified_primes(sorted=True)
10831078
[3, 23, 29]
10841079
"""
10851080
if not is_RationalField(self.base_ring()):
10861081
raise ValueError("base field must be the rational numbers")
10871082

1088-
if not sorted:
1089-
return [p for p in set([2]).union(prime_divisors(self._a.numerator()),
1090-
prime_divisors(self._a.denominator()), prime_divisors(self._b.numerator()),
1091-
prime_divisors(self._b.denominator())) if hilbert_symbol(self._a, self._b, p) == -1]
1092-
1093-
else:
1094-
return sorted([p for p in set([2]).union(prime_divisors(self._a.numerator()),
1083+
return sorted([p for p in set([2]).union(prime_divisors(self._a.numerator()),
10951084
prime_divisors(self._a.denominator()), prime_divisors(self._b.numerator()),
10961085
prime_divisors(self._b.denominator())) if hilbert_symbol(self._a, self._b, p) == -1])
10971086

10981087
def is_isomorphic(self, A) -> bool:
10991088
"""
1100-
Return ``True`` if ``self`` and ``A`` are isomorphic quaternion algebras over Q.
1089+
Return ``True`` if (and only if) ``self`` and ``A`` are isomorphic quaternion algebras over Q.
11011090
11021091
INPUT:
11031092
@@ -1118,7 +1107,7 @@ def is_isomorphic(self, A) -> bool:
11181107
if self.base_ring() != QQ or A.base_ring() != QQ:
11191108
raise NotImplementedError("isomorphism check only implemented for rational quaternion algebras")
11201109

1121-
return set(self.ramified_primes()) == set(A.ramified_primes())
1110+
return self.ramified_primes() == A.ramified_primes()
11221111

11231112
def _magma_init_(self, magma):
11241113
"""

0 commit comments

Comments
 (0)