From 3c187780ac07c55b7efeb15de264c29f8af0de9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 4 Jan 2019 09:50:21 +0100 Subject: [PATCH 1/2] py3: some care for Hadamard matrices --- src/sage/combinat/matrices/hadamard_matrix.py | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/sage/combinat/matrices/hadamard_matrix.py b/src/sage/combinat/matrices/hadamard_matrix.py index bec5e98bcda..cbddf7c074d 100644 --- a/src/sage/combinat/matrices/hadamard_matrix.py +++ b/src/sage/combinat/matrices/hadamard_matrix.py @@ -987,7 +987,7 @@ def GS_skew_hadamard_smallcases(n, existence=False, check=True): williamson_goethals_seidel_skew_hadamard_matrix as WGS def pmtoZ(s): - return [1 if x == '+' else -1 for x in s] + return [1 if x == '+' else -1 for x in s] if existence: return n in [36, 52, 92] @@ -1209,6 +1209,7 @@ def symmetric_conference_matrix(n, check=True): assert (C==C.T and C**2==(n-1)*I(n)) return C + def szekeres_difference_set_pair(m, check=True): r""" Construct Szekeres `(2m+1,m,1)`-cyclic difference family @@ -1248,16 +1249,18 @@ def szekeres_difference_set_pair(m, check=True): t = F.multiplicative_generator()**2 G = F.cyclotomic_cosets(t, cosets=[F.one()])[0] sG = set(G) - A = filter(lambda a: a-F.one() in sG, G) - B = filter(lambda b: b+F.one() in sG, G) + A = list(filter(lambda a: a - F.one() in sG, G)) + B = list(filter(lambda b: b + F.one() in sG, G)) if check: from itertools import product, chain - assert(len(list(A)) == len(list(B)) == m) - if m>1: - assert(sG==set([xy[0]/xy[1] for xy in chain(product(A,A), product(B,B))])) - assert(all(F.one()/b+F.one() in sG for b in B)) - assert(not any(F.one()/a-F.one() in sG for a in A)) - return G,A,B + assert(len(A) == len(B) == m) + if m > 1: + assert(sG == set([xy[0] / xy[1] + for xy in chain(product(A, A), product(B, B))])) + assert(all(F.one() / b + F.one() in sG for b in B)) + assert(not any(F.one() / a - F.one() in sG for a in A)) + return G, A, B + def typeI_matrix_difference_set(G,A): r""" From b806b2e9b773121a9e4479bd10da7f5a45b717e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Thu, 10 Jan 2019 16:58:10 +0100 Subject: [PATCH 2/2] reviewer nitpick --- src/sage/combinat/matrices/hadamard_matrix.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/combinat/matrices/hadamard_matrix.py b/src/sage/combinat/matrices/hadamard_matrix.py index cbddf7c074d..c11c1cb479e 100644 --- a/src/sage/combinat/matrices/hadamard_matrix.py +++ b/src/sage/combinat/matrices/hadamard_matrix.py @@ -1249,8 +1249,8 @@ def szekeres_difference_set_pair(m, check=True): t = F.multiplicative_generator()**2 G = F.cyclotomic_cosets(t, cosets=[F.one()])[0] sG = set(G) - A = list(filter(lambda a: a - F.one() in sG, G)) - B = list(filter(lambda b: b + F.one() in sG, G)) + A = [a for a in G if a - F.one() in sG] + B = [b for b in G if b + F.one() in sG] if check: from itertools import product, chain assert(len(A) == len(B) == m)