Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trac 16948: adopted changes proposed by nsirolli.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmasdeu committed Feb 23, 2017
1 parent 355c58d commit fcf1a69
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
19 changes: 9 additions & 10 deletions src/sage/algebras/quatalg/quaternion_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ def quaternion_algebra_invariants_from_ramification(F, I, S=None):
INPUT:
- ``F`` -- a number field
- ``I`` -- an ideal in ``F``
- ``I`` -- a list of prime ideals in ``F``
- ``S`` -- (default: ``None``) a list of real embeddings or real places
of ``F``
Expand All @@ -599,7 +599,7 @@ def quaternion_algebra_invariants_from_ramification(F, I, S=None):
sage: F.<r> = QuadraticField(5)
sage: from sage.algebras.quatalg.quaternion_algebra import quaternion_algebra_invariants_from_ramification
sage: quaternion_algebra_invariants_from_ramification(F,F.ideal(11),[]) # random
sage: quaternion_algebra_invariants_from_ramification(F,[(F.ideal(11))],[]) # random
(22, -22*r - 31)
sage: F.<r> = NumberField(x^2 - x - 24)
sage: D = F.ideal(106*r + 469)
Expand Down Expand Up @@ -630,12 +630,11 @@ def quaternion_algebra_invariants_from_ramification(F, I, S=None):
from sage.misc.misc_c import prod
if S is None:
S = []
I = F.ideal(I)
P = I.factor()
if (len(P) + len(S)) % 2:
I = list(set(I)) # Remove repetitions
if (len(I) + len(S)) % 2:
raise ValueError('Number of ramified places must be even')
if any([ri > 1 for _, ri in P]):
raise ValueError('All exponents in the discriminant factorization must be odd')
if any((not p.is_prime() for p in I)):
raise ValueError('I must be a list of distinct prime ideals')
Foo = F.real_places(prec=infinity)
T = F.real_places(prec=infinity)
Sold, S = S, []
Expand All @@ -647,11 +646,11 @@ def quaternion_algebra_invariants_from_ramification(F, I, S=None):
break
if len(S) != len(Sold):
raise ValueError('Please specify more precision for the places.')
a = F.weak_approximation(I, J=None, S=S, T=[v for v in Foo if v not in S])
if len(P) == 0 and all([F.hilbert_symbol(-F.one(),a,pp) == 1 for pp,_ in F.ideal(2*a).factor()]):
a = F.weak_approximation([(p,1) for p in I], J=None, S=S, T=[v for v in Foo if v not in S])
if len(I) == 0 and all([F.hilbert_symbol(-F.one(),a,pp) == 1 for pp,_ in F.ideal(2*a).factor()]):
return -F.one(), a
Ps = []
for p, _ in P:
for p in I:
if F.ideal(2).valuation(p) == 0:
Ps.append((p, 1, False))
else:
Expand Down
12 changes: 8 additions & 4 deletions src/sage/rings/number_field/number_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -1812,9 +1812,9 @@ def weak_approximation(self, I=None, S=None, J=None, T=None):
INPUT:
- ``I`` -- a fractional ideal (trivial by default) of ``self``
- ``I`` -- a list of (primes,exponents) or a fractional ideal (trivial by default) of ``self``
- ``S`` -- a list (empty by default) of real places of ``self``
- ``J`` -- a fractional ideal (trivial by default) of ``self``
- ``J`` -- a list of (primes,exponents) or a fractional ideal (trivial by default) of ``self``
- ``T`` -- a list (empty by default) of real places of ``self``
OUTPUT:
Expand Down Expand Up @@ -1862,11 +1862,15 @@ def weak_approximation(self, I=None, S=None, J=None, T=None):
n = 0
entrylist = []
if I is not None:
for p, e in I.factor():
if not isinstance(I,list):
I = I.factor()
for p, e in I:
entrylist.extend([p.pari_prime(), e])
n += 1
if J is not None:
for p, _ in J.factor():
if not isinstance(J,list):
J = J.factor()
for p, _ in J:
entrylist.extend([p.pari_prime(), 0])
n += 1
if n > 0:
Expand Down

0 comments on commit fcf1a69

Please sign in to comment.