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

Commit

Permalink
Fix trailing whitespaces in hadamard_matrix.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoCati committed Jan 22, 2023
1 parent 29a6d86 commit 2116084
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/sage/combinat/matrices/hadamard_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,8 +1101,8 @@ def turyn_type_hadamard_matrix_smallcases(n, existence=False, check=True):
def hadamard_matrix_spence_construction(n, existence=False, check=True):
r"""Create an Hadamard matrix of order `n` using Spence construction.
This construction (detailed in [Spe1975]_), uses supplementary difference sets implemented in
:func:`sage.combinat.designs.difference_family.supplementary_difference_set` to create the
This construction (detailed in [Spe1975]_), uses supplementary difference sets implemented in
:func:`sage.combinat.designs.difference_family.supplementary_difference_set` to create the
desired matrix.
INPUT:
Expand Down Expand Up @@ -1154,10 +1154,10 @@ def hadamard_matrix_spence_construction(n, existence=False, check=True):
assert n%4 == 0 and n > 0

q = n//4
if existence:

if existence:
return supplementary_difference_set(q, existence=True)

if not supplementary_difference_set(q, existence=True):
raise ValueError(f'The order {n} is not covered by Spence construction.')

Expand All @@ -1167,7 +1167,7 @@ def hadamard_matrix_spence_construction(n, existence=False, check=True):
A2 = matrix.circulant([1 if j in S4 else -1 for j in range(q-1)])
A3 = matrix.circulant([1 if j in S3 else -1 for j in range(q-1)])
A4 = matrix.circulant([1 if j in S2 else -1 for j in range(q-1)])

P = matrix(ZZ, [[1 if (i + j)%(q-1) == 0 else 0 for i in range(1, q)] for j in range(1, q)])

e = matrix([1]*(q-1))
Expand Down Expand Up @@ -2020,8 +2020,8 @@ def GS_skew_hadamard_smallcases(n, existence=False, check=True):
* `n=236`: [FKS2004]_
* `n=276`: [Djo2023]_
Additional data is obtained from skew supplementary difference sets contained in
:func:`sage.combinat.designs.difference_family.skew_supplementary_difference_set`, using the
Additional data is obtained from skew supplementary difference sets contained in
:func:`sage.combinat.designs.difference_family.skew_supplementary_difference_set`, using the
construction described in [Djo1992a]_.
INPUT:
Expand Down Expand Up @@ -2097,12 +2097,12 @@ def skew_hadamard_matrix_whiteman_construction(n, existence=False, check=True):
- ``existence`` -- boolean (default False). If True, only return whether the Hadamard matrix can be constructed.
- ``check`` -- boolean: if True (default), check the the result is a skew Hadamard matrix
- ``check`` -- boolean: if True (default), check the the result is a skew Hadamard matrix
before returning it.
OUTPUT:
If ``existence`` is false, returns the skew Hadamard matrix of order `n`. It raises an error if `n` does
If ``existence`` is false, returns the skew Hadamard matrix of order `n`. It raises an error if `n` does
not satisfy the required conditions.
If ``existence`` is true, returns a boolean representing whether the matrix can be constructed or not.
Expand All @@ -2112,8 +2112,8 @@ def skew_hadamard_matrix_whiteman_construction(n, existence=False, check=True):
sage: skew_hadamard_matrix_whiteman_construction(52)
52 x 52 dense matrix over Integer Ring...
sage: skew_hadamard_matrix_whiteman_construction(52, existence=True)
True
True
TESTS::
sage: from sage.combinat.matrices.hadamard_matrix import is_hadamard_matrix
Expand All @@ -2132,14 +2132,14 @@ def skew_hadamard_matrix_whiteman_construction(n, existence=False, check=True):
sage: skew_hadamard_matrix_whiteman_construction(100, existence=True)
False
"""

q = n // 2 - 1
p, t = is_prime_power(q, get_data=True)

is_order_valid = n % 4 == 0 and t > 0 and p % 8 == 5 and t % 4 == 2
if existence:
return is_order_valid

if not is_order_valid:
raise ValueError(f'The order {n} is not covered by the Whiteman construction.')

Expand Down Expand Up @@ -2175,7 +2175,7 @@ def skew_hadamard_matrix_whiteman_construction(n, existence=False, check=True):
if check:
assert is_hadamard_matrix(H, skew=True)
return H


def skew_hadamard_matrix_324():
r"""
Expand Down Expand Up @@ -2407,10 +2407,10 @@ def pm_to_good_matrix(s, sign=1):

if existence:
return l in E_sequences

if l not in E_sequences:
raise ValueError("The Good matrices of order %s are not yet implemented." % m)
raise ValueError("The Good matrices of order %s are not yet implemented." % m)

e1, e2, e3, e4 = E_sequences[l]
a = pm_to_good_matrix(e1, sign=-1)
b = pm_to_good_matrix(e2)
Expand Down Expand Up @@ -2539,11 +2539,11 @@ def true():
return true()
M = hadamard_matrix_paleyI(n, normalize=False)
elif is_prime_power(n//2 -1) and (n//2 -1)%8 == 5:
if existence:
if existence:
return true()
M = skew_hadamard_matrix_spence_construction(n, check=False)
elif skew_hadamard_matrix_whiteman_construction(n, existence=True):
if existence:
if existence:
return true()
M = skew_hadamard_matrix_whiteman_construction(n, check=False)
elif n % 8 == 0:
Expand Down

0 comments on commit 2116084

Please sign in to comment.