Skip to content

Commit 6d1c5f7

Browse files
committed
adding line breaks ad suggested
1 parent 3240723 commit 6d1c5f7

File tree

1 file changed

+41
-27
lines changed

1 file changed

+41
-27
lines changed

src/sage/coding/delsarte_bounds.py

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ def _delsarte_LP_building(n, d, d_star, q, isinteger, solver, maxc=0):
217217
for i in range(1, d):
218218
p.add_constraint(A[i] == 0)
219219
for j in range(1, n + 1):
220-
rhs = sum([krawtchouk(n, q, j, r, check=False)*A[r] for r in range(n+1)])
220+
rhs = sum([krawtchouk(n, q, j, r, check=False) * A[r]
221+
for r in range(n + 1)])
221222
p.add_constraint(0 <= rhs)
222223
if j >= d_star:
223224
p.add_constraint(0 <= rhs)
@@ -281,12 +282,14 @@ def _q(k, i):
281282
return mu_i*eberlein(n, w, i, k)/v_i
282283

283284
for k in range(1, w+1):
284-
p.add_constraint(sum([A[2*i]*_q(k, i) for i in range(d//2, w+1)]), min=-1)
285+
p.add_constraint(sum([A[2*i]*_q(k, i) for i in range(d//2, w+1)]),
286+
min=-1)
285287

286288
return A, p
287289

288290

289-
def delsarte_bound_constant_weight_code(n, d, w, return_data=False, solver="PPL", isinteger=False):
291+
def delsarte_bound_constant_weight_code(n, d, w, return_data=False,
292+
solver="PPL", isinteger=False):
290293
r"""
291294
Find the Delsarte bound on a constant weight code.
292295
@@ -335,10 +338,12 @@ def delsarte_bound_constant_weight_code(n, d, w, return_data=False, solver="PPL"
335338
from sage.numerical.mip import MIPSolverException
336339

337340
if d < 4:
338-
raise ValueError("Violated constraint d>=4 for Binary Constant Weight Codes")
341+
raise ValueError("Violated constraint d>=4 for "
342+
"Binary Constant Weight Codes")
339343

340344
if d >= 2*w or 2*w > n:
341-
raise ValueError("Violated constraint d<2w<=n for Binary Constant Weight Codes")
345+
raise ValueError("Violated constraint d<2w<=n for "
346+
"Binary Constant Weight Codes")
342347

343348
# minimum distance is even => if there is an odd lower bound on d we can
344349
# increase it by 1
@@ -355,12 +360,13 @@ def delsarte_bound_constant_weight_code(n, d, w, return_data=False, solver="PPL"
355360
return (A, p, bd) if return_data else int(bd)
356361

357362

358-
def delsarte_bound_hamming_space(n, d, q, return_data=False, solver="PPL", isinteger=False):
363+
def delsarte_bound_hamming_space(n, d, q, return_data=False,
364+
solver="PPL", isinteger=False):
359365
r"""
360366
Find the Delsarte bound on codes in ``H_q^n`` of minimal distance ``d``
361367
362-
Find the Delsarte bound [De1973]_ on the size of codes in the Hamming space ``H_q^n``
363-
of minimal distance ``d``.
368+
Find the Delsarte bound [De1973]_ on the size of codes in
369+
the Hamming space ``H_q^n`` of minimal distance ``d``.
364370
365371
INPUT:
366372
@@ -438,14 +444,16 @@ def delsarte_bound_hamming_space(n, d, q, return_data=False, solver="PPL", isint
438444
return (A, p, bd) if return_data else bd
439445

440446

441-
def delsarte_bound_additive_hamming_space(n, d, q, d_star=1, q_base=0, return_data=False, solver="PPL", isinteger=False):
447+
def delsarte_bound_additive_hamming_space(n, d, q, d_star=1, q_base=0, return_data=False,
448+
solver="PPL", isinteger=False):
442449
r"""
443-
Find a modified Delsarte bound on additive codes in Hamming space `H_q^n` of minimal distance `d`
450+
Find a modified Delsarte bound on additive codes in Hamming space `H_q^n` of minimal distance `d`.
444451
445-
Find the Delsarte LP bound on ``F_{q_base}``-dimension of additive codes in
446-
Hamming space `H_q^n` of minimal distance ``d`` with minimal distance of the dual
447-
code at least ``d_star``. If ``q_base`` is set to
448-
non-zero, then ``q`` is a power of ``q_base``, and the code is, formally, linear over
452+
Find the Delsarte LP bound on ``F_{q_base}``-dimension of additive
453+
codes in Hamming space `H_q^n` of minimal distance ``d`` with
454+
minimal distance of the dual code at least ``d_star``. If
455+
``q_base`` is set to non-zero, then ``q`` is a power of
456+
``q_base``, and the code is, formally, linear over
449457
``F_{q_base}``. Otherwise it is assumed that ``q_base==q``.
450458
451459
INPUT:
@@ -462,17 +470,19 @@ def delsarte_bound_additive_hamming_space(n, d, q, d_star=1, q_base=0, return_da
462470
- ``q_base`` -- if ``0``, the code is assumed to be linear. Otherwise,
463471
``q=q_base^m`` and the code is linear over ``F_{q_base}``.
464472
465-
- ``return_data`` -- if ``True``, return a triple ``(W,LP,bound)``, where ``W`` is
466-
a weights vector, and ``LP`` the Delsarte bound LP; both of them are Sage LP
467-
data. ``W`` need not be a weight distribution of a code, or,
468-
if ``isinteger==False``, even have integer entries.
473+
- ``return_data`` -- if ``True``, return a triple ``(W,LP,bound)``,
474+
where ``W`` is a weights vector, and ``LP`` the Delsarte bound
475+
LP; both of them are Sage LP data. ``W`` need not be a weight
476+
distribution of a code, or, if ``isinteger==False``, even have
477+
integer entries.
469478
470-
- ``solver`` -- the LP/ILP solver to be used. Defaults to ``'PPL'``. It is arbitrary
471-
precision, thus there will be no rounding errors. With other solvers
472-
(see :class:`MixedIntegerLinearProgram` for the list), you are on your own!
479+
- ``solver`` -- the LP/ILP solver to be used. Defaults to ``'PPL'``. It is
480+
arbitrary precision, thus there will be no rounding errors. With
481+
other solvers (see :class:`MixedIntegerLinearProgram` for the
482+
list), you are on your own!
473483
474-
- ``isinteger`` -- if ``True``, uses an integer programming solver (ILP), rather
475-
that an LP solver. Can be very slow if set to ``True``.
484+
- ``isinteger`` -- if ``True``, uses an integer programming solver (ILP),
485+
rather that an LP solver. Can be very slow if set to ``True``.
476486
477487
EXAMPLES:
478488
@@ -532,11 +542,13 @@ def delsarte_bound_additive_hamming_space(n, d, q, d_star=1, q_base=0, return_da
532542
m = kk*n # this is to emulate repeat/until block
533543
bd = q**n+1
534544

535-
while q_base**m < bd: # need to solve the LP repeatedly, as this is a new constraint!
545+
while q_base**m < bd:
546+
# need to solve the LP repeatedly, as this is a new constraint!
536547
# we might become infeasible. More precisely, after rounding down
537548
# to the closest value of q_base^m, the LP, with the constraint that
538549
# the objective function is at most q_base^m,
539-
A, p = _delsarte_LP_building(n, d, d_star, q, isinteger, solver, q_base**m)
550+
A, p = _delsarte_LP_building(n, d, d_star, q, isinteger,
551+
solver, q_base**m)
540552
try:
541553
bd = p.solve()
542554
except MIPSolverException as exc:
@@ -626,7 +638,8 @@ def _delsarte_Q_LP_building(q, d, solver, isinteger):
626638
return A, p
627639

628640

629-
def delsarte_bound_Q_matrix(q, d, return_data=False, solver="PPL", isinteger=False):
641+
def delsarte_bound_Q_matrix(q, d, return_data=False,
642+
solver="PPL", isinteger=False):
630643
r"""
631644
Delsarte bound on a code with Q matrix ``q`` and lower bound on min. dist. ``d``.
632645
@@ -683,7 +696,8 @@ def delsarte_bound_Q_matrix(q, d, return_data=False, solver="PPL", isinteger=Fal
683696
from sage.structure.element import is_Matrix
684697

685698
if not is_Matrix(q):
686-
raise ValueError("Input to delsarte_bound_Q_matrix should be a sage Matrix()")
699+
raise ValueError("Input to delsarte_bound_Q_matrix "
700+
"should be a sage Matrix()")
687701

688702
A, p = _delsarte_Q_LP_building(q, d, solver, isinteger)
689703
try:

0 commit comments

Comments
 (0)