all repos — delsarte-bound @ 9e52421604671795607f4fce1882cf4be914a52b

first commit
Marco Andronaco andronacomarco@gmail.com
Wed, 18 Jan 2023 22:10:10 +0100
commit

9e52421604671795607f4fce1882cf4be914a52b

parent

52e28601c5c745fe8e194d73c449d1dca9434b1a

4 files changed, 53 insertions(+), 53 deletions(-)

jump to
M README.mdREADME.md

@@ -1,5 +1,5 @@

-# A Delsarte Bound calculator in MATLAB - -The `delsarte(n, d)` function returns an upper bound for $A_2(n, d)$: the maximum number of binary code-words of length $n$ and having Hamming distance $d$ between each other. - +# A Delsarte Bound calculator in MATLAB + +The `delsarte(n, d)` function returns an upper bound for $A_2(n, d)$: the maximum number of binary code-words of length $n$ and having Hamming distance $d$ between each other. + The obtained bound can often be improved (see [this table](https://www.win.tue.nl/~aeb/codes/binary-1.html)), with further observations and only for special cases, but this function can compute a valid bound for any value of $n$ and $d$.
M comb.mcomb.m

@@ -1,3 +1,3 @@

-function r = comb(n, k) - r = gamma(n + 1) / (gamma(k + 1) * gamma(n - k + 1)); +function r = comb(n, k) + r = gamma(n + 1) / (gamma(k + 1) * gamma(n - k + 1)); end
M delsarte.mdelsarte.m

@@ -1,43 +1,43 @@

-function r = delsarte(n, d) - % https://www.win.tue.nl/~aeb/codes/binary-1.html - - if d > n - r = 1; - return - end - - if 1.5 * d > n - r = 2; - return - end - - m = n - d + 1; - - % populate the objective function - c = -ones(1, m); - - A = zeros(n, m); - b = zeros(1, n); - for t = 1:n - % populate the A matrix - for j = 1:m - i = n - m + j; - A(t, j) = - k(t, n, i); - end - % populate the b vector - b(1, t) = k(t, n, 0); - end - - % populate non-negativity constraints - lb = zeros(1, m); - - % fill other parameters - Aeq = []; - beq = []; - - % find an optimal solution - s = sym(linprog(c, A, b, Aeq, beq, lb)); - - % add the value of x_0 and round the result - r = fix(sum(s) + 1); +function r = delsarte(n, d) + % https://www.win.tue.nl/~aeb/codes/binary-1.html + + if d > n + r = 1; + return + end + + if 1.5 * d > n + r = 2; + return + end + + m = n - d + 1; + + % populate the objective function + c = -ones(1, m); + + A = zeros(n, m); + b = zeros(1, n); + for t = 1:n + % populate the A matrix + for j = 1:m + i = n - m + j; + A(t, j) = - k(t, n, i); + end + % populate the b vector + b(1, t) = k(t, n, 0); + end + + % populate non-negativity constraints + lb = zeros(1, m); + + % fill other parameters + Aeq = []; + beq = []; + + % find an optimal solution + s = sym(linprog(c, A, b, Aeq, beq, lb)); + + % add the value of x_0 and round the result + r = fix(sum(s) + 1); end
M k.mk.m

@@ -1,6 +1,6 @@

-function r = k(t, n, i) - r = 0; - for j = 0:min(i, t) - r = r + ((-1)^j * comb(i, j) * comb(n - i, t - j)); - end +function r = k(t, n, i) + r = 0; + for j = 0:min(i, t) + r = r + ((-1)^j * comb(i, j) * comb(n - i, t - j)); + end end