@@ -217,7 +217,8 @@ def _delsarte_LP_building(n, d, d_star, q, isinteger, solver, maxc=0):
217
217
for i in range (1 , d ):
218
218
p .add_constraint (A [i ] == 0 )
219
219
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 )])
221
222
p .add_constraint (0 <= rhs )
222
223
if j >= d_star :
223
224
p .add_constraint (0 <= rhs )
@@ -281,12 +282,14 @@ def _q(k, i):
281
282
return mu_i * eberlein (n , w , i , k )/ v_i
282
283
283
284
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 )
285
287
286
288
return A , p
287
289
288
290
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 ):
290
293
r"""
291
294
Find the Delsarte bound on a constant weight code.
292
295
@@ -335,10 +338,12 @@ def delsarte_bound_constant_weight_code(n, d, w, return_data=False, solver="PPL"
335
338
from sage .numerical .mip import MIPSolverException
336
339
337
340
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" )
339
343
340
344
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" )
342
347
343
348
# minimum distance is even => if there is an odd lower bound on d we can
344
349
# increase it by 1
@@ -355,12 +360,13 @@ def delsarte_bound_constant_weight_code(n, d, w, return_data=False, solver="PPL"
355
360
return (A , p , bd ) if return_data else int (bd )
356
361
357
362
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 ):
359
365
r"""
360
366
Find the Delsarte bound on codes in ``H_q^n`` of minimal distance ``d``
361
367
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``.
364
370
365
371
INPUT:
366
372
@@ -438,14 +444,16 @@ def delsarte_bound_hamming_space(n, d, q, return_data=False, solver="PPL", isint
438
444
return (A , p , bd ) if return_data else bd
439
445
440
446
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 ):
442
449
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`.
444
451
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
449
457
``F_{q_base}``. Otherwise it is assumed that ``q_base==q``.
450
458
451
459
INPUT:
@@ -462,17 +470,19 @@ def delsarte_bound_additive_hamming_space(n, d, q, d_star=1, q_base=0, return_da
462
470
- ``q_base`` -- if ``0``, the code is assumed to be linear. Otherwise,
463
471
``q=q_base^m`` and the code is linear over ``F_{q_base}``.
464
472
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.
469
478
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!
473
483
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``.
476
486
477
487
EXAMPLES:
478
488
@@ -532,11 +542,13 @@ def delsarte_bound_additive_hamming_space(n, d, q, d_star=1, q_base=0, return_da
532
542
m = kk * n # this is to emulate repeat/until block
533
543
bd = q ** n + 1
534
544
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!
536
547
# we might become infeasible. More precisely, after rounding down
537
548
# to the closest value of q_base^m, the LP, with the constraint that
538
549
# 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 )
540
552
try :
541
553
bd = p .solve ()
542
554
except MIPSolverException as exc :
@@ -626,7 +638,8 @@ def _delsarte_Q_LP_building(q, d, solver, isinteger):
626
638
return A , p
627
639
628
640
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 ):
630
643
r"""
631
644
Delsarte bound on a code with Q matrix ``q`` and lower bound on min. dist. ``d``.
632
645
@@ -683,7 +696,8 @@ def delsarte_bound_Q_matrix(q, d, return_data=False, solver="PPL", isinteger=Fal
683
696
from sage .structure .element import is_Matrix
684
697
685
698
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()" )
687
701
688
702
A , p = _delsarte_Q_LP_building (q , d , solver , isinteger )
689
703
try :
0 commit comments