Ticket #12418: update.diff

File update.diff, 2.8 KB (added by dimpase, 9 years ago)

update of the patch - for reviewing only

  • sage/coding/delsarte_bounds.py

    diff --git a/sage/coding/delsarte_bounds.py b/sage/coding/delsarte_bounds.py
    a b  
    88AUTHORS:
    99
    1010- Dmitrii V. (Dima) Pasechnik (2012-10): initial implementation.
    11 
    12 
    1311"""
    1412#*****************************************************************************
    1513#       Copyright (C) 2012 Dima Pasechnik <dimpase@gmail.com>
     
    2220   """
    2321   Compute ``K^{n,q}_l(i)``, the Krawtchouk polynomial: see
    2422   `en.wikipedia.org/wiki/Kravchuk_polynomials <http://en.wikipedia.org/wiki/Kravchuk_polynomials>`_.
     23   It is given by
    2524
     25   .. math::
     26
     27      K^{n,q}_l(i)=\sum_{j=0}^l (-1)^j(q-1)^{(l-j)}{i \choose j}{n-i \choose l-j}
    2628   """
    2729   from sage.rings.arith import binomial
     30   # Use the expression in equation (55) of MacWilliams & Sloane, pg 151
     31   # We write jth term = some_factor * (j-1)th term
     32   kraw = jth_term = (q-1)**l * binomial(n, l) # j=0
     33   for j in range(1,l+1):
     34      jth_term *= -q*(l-j+1)*(i-j+1)/((q-1)*j*(n-j+1))
     35      kraw += jth_term
     36   return kraw
    2837
    29    return sum([((-1)**j)*((q-1)**(l-j))*binomial(i,j)*binomial(n-i,l-j)
    30                               for j in range(l+1)])
    3138
    3239def delsarte_bound_hamming_space(n, d, q, \
    3340                    isinteger=False, return_data=False, solver="PPL"):
     
    4754   - ``isinteger`` -- if ``True``, uses an integer programming solver (ILP), rather
    4855     that an LP solver. Can be very slow if set to ``True``.
    4956
    50    - ``return_data`` -- if ``True``, return a weights vector, which actually need not
    51      be a proper weight enumerator, or even have integer entries, and the LP.
     57   - ``return_data`` -- if ``True``, return a triple (W,LP,bound), where W is
     58     a weights vector. W need not be a weight distribution of a code, or,
     59     if ``isinteger==False``, even have integer entries, and the Delsarte bound LP.
    5260
    5361   - ``solver`` -- the LP/ILP solved to be used. Defaults to ``PPL``. It is arbitrary
    5462     precision, thus there will be no rounding errors. With other solvers, you are on
     
    138146   - ``isinteger`` -- if ``True``, uses an integer programming solver (ILP), rather
    139147     that an LP solver. Can be very slow if set to ``True``.
    140148
    141    - ``return_data`` -- if ``True``, return a weights vector, which actually need not
    142      be a proper weight enumerator, or even have integer entries, and the LP.
     149   - ``return_data`` -- if ``True``, return a triple (W,LP,bound), where W is
     150     a weights vector. W need not be a weight distribution of a code, or,
     151     if ``isinteger==False``, even have integer entries, and the Delsarte bound LP.
    143152
    144153   - ``solver`` -- the LP/ILP solved to be used. Defaults to ``PPL``. It is arbitrary
    145154     precision, thus there will be no rounding errors. With other solvers, you are on