Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/sage/algebras/quatalg/quaternion_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ def maximal_order(self, take_shortcuts=True, order_basis=None):
....: (-511, 608), (493, 880), (105, -709), (-213, 530),
....: (97, 745)]
sage: all(QuaternionAlgebra(a, b).maximal_order().is_maximal()
....: for (a, b) in invars)
....: for a, b in invars)
True
"""
if self.base_ring() != QQ:
Expand Down Expand Up @@ -1071,7 +1071,7 @@ def maximal_order(self, take_shortcuts=True, order_basis=None):

e_n = []
x_rows = A.solve_left(matrix([V(vec.coefficient_tuple())
for (vec, val) in f]),
for vec, val in f]),
check=False).rows()
denoms = [x.denominator() for x in x_rows]
for i in range(4):
Expand Down Expand Up @@ -1199,7 +1199,7 @@ def order_with_level(self, level):
fact = M1.factor()
B = O.basis()

for (p, r) in fact:
for p, r in fact:
a = int(-p) // 2
for v in GF(p)**4:
x = sum([int(v[i] + a) * B[i] for i in range(4)])
Expand Down Expand Up @@ -4584,10 +4584,9 @@ def normalize_basis_at_p(e, p, B=QuaternionAlgebraElement_abstract.pair):
sage: e = [A(1), k, j, 1/2 + 1/2*i + 1/2*j + 1/2*k]
sage: e_norm = normalize_basis_at_p(e, 2)
sage: V = QQ**4
sage: V.span([V(x.coefficient_tuple()) for (x,_) in e_norm]).dimension()
sage: V.span([V(x.coefficient_tuple()) for x, _ in e_norm]).dimension()
4
"""

N = len(e)
if N == 0:
return []
Expand Down
48 changes: 23 additions & 25 deletions src/sage/algebras/steenrod/steenrod_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ def _basis_key_iterator(self):
EXAMPLES::

sage: A = SteenrodAlgebra(3,basis='adem')
sage: for (idx,key) in zip((1,..,10),A._basis_key_iterator()):
sage: for idx, key in zip((1,..,10),A._basis_key_iterator()):
....: print("> %2d %-20s %s" % (idx,key,A.monomial(key)))
> 1 () 1
> 2 (1,) beta
Expand Down Expand Up @@ -767,17 +767,15 @@ def _repr_(self) -> str:
sage: SteenrodAlgebra(p=5, profile=(lambda n: 4, lambda n: 1))
sub-Hopf algebra of mod 5 Steenrod algebra, milnor basis, profile function ([4, 4, 4, ..., 4, 4, +Infinity, +Infinity, +Infinity, ...], [1, 1, 1, ..., 1, 1, 2, 2, ...])
"""
def abridge_list(l):
def abridge_list(li):
"""
String rep for list ``l`` if ``l`` is short enough;
String rep for list ``li`` if ``li`` is short enough;
otherwise print the first few terms and the last few
terms, with an ellipsis in between.
"""
if len(l) < 8:
l_str = str(l)
else:
l_str = str(l[:3]).rstrip("]") + ", ..., " + str(l[-2:]).lstrip("[")
return l_str
if len(li) < 8:
return str(li)
return str(li[:3]).rstrip("]") + ", ..., " + str(li[-2:]).lstrip("[")

from sage.rings.infinity import Infinity
profile = self._profile
Expand Down Expand Up @@ -1345,8 +1343,8 @@ def coprod_list(t):
right_q = sorted(all_q - a)
sign = Permutation(convert_perm(left_q + right_q)).signature()
tens_q[(tuple(left_q), tuple(right_q))] = sign
tens = {((q[0], l), (q[1], r)): tq
for l, r in zip(left_p, right_p)
tens = {((q[0], lp), (q[1], rp)): tq
for lp, rp in zip(left_p, right_p)
for q, tq in tens_q.items()}
return self.tensor_square()._from_dict(tens, coerce=True)
elif basis == 'serre-cartan':
Expand Down Expand Up @@ -1642,14 +1640,14 @@ def _milnor_on_basis(self, t):
elif basis == 'woody' or basis == 'woodz':
# each entry in t is a pair (m,k), corresponding to w(m,k), defined by
# `w(m,k) = \text{Sq}^{2^m (2^{k+1}-1)}`.
for (m, k) in t:
for m, k in t:
ans = ans * A.Sq(2**m * (2**(k+1) - 1))

# wall[_long]
elif basis.find('wall') >= 0:
# each entry in t is a pair (m,k), corresponding to Q^m_k, defined by
# `Q^m_k = Sq(2^k) Sq(2^{k+1}) ... Sq(2^m)`.
for (m, k) in t:
for m, k in t:
exponent = 2**k
ans = ans * A.Sq(exponent)
for i in range(m-k):
Expand All @@ -1660,22 +1658,22 @@ def _milnor_on_basis(self, t):
elif basis.find('pst') >= 0:
if not self._generic:
# each entry in t is a pair (i,j), corresponding to P^i_j
for (i, j) in t:
for i, j in t:
ans = ans * A.pst(i, j)
else:
# t = (Q, P) where Q is the tuple of Q_i's, and P is a
# tuple with entries of the form ((i,j), n),
# corresponding to (P^i_j)^n
if t[0]:
ans = ans * A.Q(*t[0])
for ((i, j), n) in t[1]:
for (i, j), n in t[1]:
ans = ans * (A.pst(i, j))**n

# arnona[_long]
elif basis.find('arnona') >= 0:
# each entry in t is a pair (m,k), corresponding to X^m_k, defined by
# `X^m_k = Sq(2^m) ... Sq(2^{k+1}) Sq(2^k)`
for (m, k) in t:
for m, k in t:
exponent = 2**k
X = A.Sq(exponent)
for i in range(m-k):
Expand All @@ -1689,7 +1687,7 @@ def _milnor_on_basis(self, t):
# each entry in t is a pair (i,j), corresponding to
# c_{i,j}, the iterated commutator defined by c_{i,1}
# = Sq(2^i) and c_{i,j} = [c_{i,j-1}, Sq(2^{i+j-1})].
for (i, j) in t:
for i, j in t:
comm = A.Sq(2**i)
for k in range(2, j+1):
y = A.Sq(2**(i+k-1))
Expand All @@ -1703,7 +1701,7 @@ def _milnor_on_basis(self, t):
# c_{i,j} = [P(p^{i+j-1}), c_{i,j-1}].
if t[0]:
ans = ans * A.Q(*t[0])
for ((i, j), n) in t[1]:
for (i, j), n in t[1]:
comm = A.P(p**i)
for k in range(2, j+1):
y = A.P(p**(i+k-1))
Expand Down Expand Up @@ -1947,7 +1945,7 @@ def q_degree(m, prime=3):
if basis == 'woody' or basis == 'woodz':
# each entry in t is a pair (m,k), corresponding to w(m,k), defined by
# `w(m,k) = \text{Sq}^{2^m (2^{k+1}-1)}`.
return sum(2**m * (2**(k+1)-1) for (m, k) in t)
return sum(2**m * (2**(k+1)-1) for m, k in t)

# wall, arnon_a
if basis.find('wall') >= 0 or basis.find('arnona') >= 0:
Expand All @@ -1958,7 +1956,7 @@ def q_degree(m, prime=3):
# Arnon A: each entry in t is a pair (m,k), corresponding
# to X^m_k, defined by `X^m_k = Sq(2^m) ... Sq(2^{k+1})
# Sq(2^k)`
return sum(2**k * (2**(m-k+1)-1) for (m, k) in t)
return sum(2**k * (2**(m-k+1)-1) for m, k in t)

# pst, comm
if basis.find('pst') >= 0 or basis.find('comm') >= 0:
Expand All @@ -1969,7 +1967,7 @@ def q_degree(m, prime=3):
# to c_{i,j}, the iterated commutator defined by
# c_{i,1} = Sq(2^i) and c_{i,j} = [c_{i,j-1},
# Sq(2^{i+j-1})].
return sum(2**m * (2**k - 1) for (m, k) in t)
return sum(2**m * (2**k - 1) for m, k in t)
# p odd:
#
# Pst: have pair (Q, P) where Q is a tuple of Q's, as in
Expand All @@ -1982,7 +1980,7 @@ def q_degree(m, prime=3):
# iterated commutator defined by c_{s,1} = P(p^s) and
# c_{s,t} = [P(p^{s+t-1}), c_{s,t-1}].
q_deg = q_degree(t[0], prime=p)
p_deg = sum(2 * n * p**s * (p**t - 1) for ((s, t), n) in t[1])
p_deg = sum(2 * n * p**s * (p**t - 1) for (s, t), n in t[1])
return q_deg + p_deg

# coercion methods:
Expand Down Expand Up @@ -2236,7 +2234,7 @@ def basis(self, d=None):
Lazy family (Term map from basis key family of mod 7 Steenrod algebra, milnor basis
to mod 7 Steenrod algebra, milnor basis(i))_{i in basis key family
of mod 7 Steenrod algebra, milnor basis}
sage: for (idx,a) in zip((1,..,9),A7.basis()):
sage: for idx, a in zip((1,..,9),A7.basis()):
....: print("{} {}".format(idx, a))
1 1
2 Q_0
Expand Down Expand Up @@ -3435,7 +3433,7 @@ def coproduct(self, algorithm='milnor'):
1
sage: Sq(*supp[0][1])
Sq(2)
sage: [(Sq(*x), Sq(*y)) for (x,y) in supp]
sage: [(Sq(*x), Sq(*y)) for x, y in supp]
[(1, Sq(2)), (Sq(1), Sq(1)), (Sq(2), 1)]

The ``support`` of an element does not include the
Expand All @@ -3453,7 +3451,7 @@ def coproduct(self, algorithm='milnor'):
(((), (1,)), ((), (1,))): 2,
(((), (2,)), ((), ())): 2}
sage: mc = b.monomial_coefficients()
sage: sorted([(A3.monomial(x), A3.monomial(y), mc[x,y]) for (x,y) in mc])
sage: sorted([(A3.monomial(x), A3.monomial(y), mc[x,y]) for x, y in mc])
[(1, P(2), 2), (P(1), P(1), 2), (P(2), 1, 2)]
"""
A = self.parent()
Expand Down Expand Up @@ -3627,7 +3625,7 @@ def may_weight(self):
return wt
else: # p odd
wt = Infinity
for (mono1, mono2) in self.milnor().support():
for mono1, mono2 in self.milnor().support():
P_wt = 0
index = 1
for n in mono2:
Expand Down
58 changes: 32 additions & 26 deletions src/sage/algebras/steenrod/steenrod_algebra_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,13 @@ def steenrod_algebra_basis(n, basis='milnor', p=2, **kwds):
return serre_cartan_basis(n, p, **kwds)
# Atomic bases, p odd:
elif generic and (basis_name.find('pst') >= 0
or basis_name.find('comm') >= 0):
or basis_name.find('comm') >= 0):
return atomic_basis_odd(n, basis_name, p, **kwds)
# Atomic bases, p=2
elif not generic and (basis_name == 'woody' or basis_name == 'woodz'
or basis_name == 'wall' or basis_name == 'arnona'
or basis_name.find('pst') >= 0
or basis_name.find('comm') >= 0):
or basis_name == 'wall' or basis_name == 'arnona'
or basis_name.find('pst') >= 0
or basis_name.find('comm') >= 0):
return atomic_basis(n, basis_name, **kwds)
# Arnon 'C' basis
elif not generic and basis == 'arnonc':
Expand Down Expand Up @@ -726,7 +726,7 @@ def serre_cartan_basis(n, p=2, bound=1, **kwds):
for vec in serre_cartan_basis(n - last, bound=2 * last):
new = vec + (last,)
result.append(new)
else: # p odd
else: # p odd
if n % (2 * (p-1)) == 0 and n//(2 * (p-1)) >= bound:
result = [(0, int(n//(2 * (p-1))), 0)]
elif n == 1:
Expand All @@ -739,7 +739,7 @@ def serre_cartan_basis(n, p=2, bound=1, **kwds):
if n - 2*(p-1)*last > 0:
for vec in serre_cartan_basis(n - 2*(p-1)*last,
p, p*last, generic=generic):
result.append(vec + (last,0))
result.append(vec + (last, 0))
# case 2: append P^{last} beta
if bound == 1:
bound = 0
Expand Down Expand Up @@ -849,7 +849,7 @@ def degree_dictionary(n, basis):
m = 0
deg = 2**m * (2**(k+1) - 1)
while deg <= n:
dict[deg] = (m,k)
dict[deg] = (m, k)
if m > 0:
m = m - 1
k = k + 1
Expand All @@ -862,7 +862,7 @@ def degree_dictionary(n, basis):
m = 0
deg = 2**k * (2**(m-k+1) - 1)
while deg <= n:
dict[deg] = (m,k)
dict[deg] = (m, k)
if k == 0:
m = m + 1
k = m
Expand All @@ -875,9 +875,9 @@ def degree_dictionary(n, basis):
deg = 2**s * (2**t - 1)
while deg <= n:
if basis.find('pst') >= 0:
dict[deg] = (s,t)
dict[deg] = (s, t)
else: # comm
dict[deg] = (s,t)
dict[deg] = (s, t)
if s == 0:
s = t
t = 1
Expand All @@ -889,18 +889,18 @@ def degree_dictionary(n, basis):

def sorting_pair(s, t, basis): # pair used for sorting the basis
if basis.find('wood') >= 0 and basis.find('z') >= 0:
return (-s-t,-s)
return (-s-t, -s)
elif basis.find('wood') >= 0 or basis.find('wall') >= 0 or \
basis.find('arnon') >= 0:
return (-s,-t)
return (-s, -t)
elif basis.find('rlex') >= 0:
return (t,s)
return (t, s)
elif basis.find('llex') >= 0:
return (s,t)
return (s, t)
elif basis.find('deg') >= 0:
return (s+t,t)
return (s+t, t)
elif basis.find('revz') >= 0:
return (s+t,s)
return (s+t, s)

from sage.rings.infinity import Infinity
profile = kwds.get("profile", None)
Expand All @@ -926,7 +926,7 @@ def sorting_pair(s, t, basis): # pair used for sorting the basis
okay = True
if basis.find('pst') >= 0:
if profile is not None and len(profile) > 0:
for (s,t) in big_list:
for s, t in big_list:
if ((len(profile) > t-1 and profile[t-1] <= s)
or (len(profile) <= t-1 and trunc < Infinity)):
okay = False
Expand Down Expand Up @@ -1087,7 +1087,7 @@ def sorting_pair(s, t, basis): # pair used for sorting the basis
okay = False
break

for ((s, t), _) in p_mono:
for (s, t), _ in p_mono:
if ((len(profile[0]) > t-1 and profile[0][t-1] <= s)
or (len(profile[0]) <= t-1 and trunc < Infinity)):
okay = False
Expand Down Expand Up @@ -1135,7 +1135,7 @@ def steenrod_basis_error_check(dim, p, **kwds):
generic = kwds.get('generic', p != 2)

if not generic:
bases = ('adem','woody', 'woodz', 'wall', 'arnona', 'arnonc',
bases = ('adem', 'woody', 'woodz', 'wall', 'arnona', 'arnonc',
'pst_rlex', 'pst_llex', 'pst_deg', 'pst_revz',
'comm_rlex', 'comm_llex', 'comm_deg', 'comm_revz')
else:
Expand All @@ -1146,29 +1146,35 @@ def steenrod_basis_error_check(dim, p, **kwds):
for i in range(dim):
if i % 5 == 0:
verbose("up to dimension %s" % i)
milnor_dim = len(steenrod_algebra_basis.f(i,'milnor',p=p,generic=generic))
milnor_dim = len(steenrod_algebra_basis.f(i, 'milnor', p=p,
generic=generic))
for B in bases:
if milnor_dim != len(steenrod_algebra_basis.f(i,B,p,generic=generic)):
if milnor_dim != len(steenrod_algebra_basis.f(i, B, p,
generic=generic)):
print("problem with milnor/{} in dimension {}".format(B, i))
mat = convert_to_milnor_matrix.f(i,B,p,generic=generic)
mat = convert_to_milnor_matrix.f(i, B, p, generic=generic)
if mat.nrows() != 0 and not mat.is_invertible():
print("%s invertibility problem in dim %s at p=%s" % (B, i, p))

verbose("done checking, no profiles")

bases = ('pst_rlex', 'pst_llex', 'pst_deg', 'pst_revz')
if not generic:
profiles = [(4,3,2,1), (2,2,3,1,1), (0,0,0,2)]
profiles = [(4, 3, 2, 1), (2, 2, 3, 1, 1), (0, 0, 0, 2)]
else:
profiles = [((3,2,1), ()), ((), (2,1,2)), ((3,2,1), (2,2,2,2))]
profiles = [((3, 2, 1), ()), ((), (2, 1, 2)), ((3, 2, 1), (2, 2, 2, 2))]

for i in range(dim):
if i % 5 == 0:
verbose("up to dimension %s" % i)
for pro in profiles:
milnor_dim = len(steenrod_algebra_basis.f(i,'milnor',p=p,profile=pro,generic=generic))
milnor_dim = len(steenrod_algebra_basis.f(i, 'milnor', p=p,
profile=pro,
generic=generic))
for B in bases:
if milnor_dim != len(steenrod_algebra_basis.f(i,B,p,profile=pro,generic=generic)):
if milnor_dim != len(steenrod_algebra_basis.f(i, B, p,
profile=pro,
generic=generic)):
print("problem with milnor/%s in dimension %s with profile %s" % (B, i, pro))

verbose("done checking with profiles")
Loading
Loading