all repos — delsarte-bound @ 52e28601c5c745fe8e194d73c449d1dca9434b1a

first commit
Bi-Rabittoh andronacomarco@gmail.com
Wed, 18 Jan 2023 22:02:35 +0100
commit

52e28601c5c745fe8e194d73c449d1dca9434b1a

4 files changed, 57 insertions(+), 0 deletions(-)

jump to
A README.md

@@ -0,0 +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. + +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$.
A comb.m

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

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

@@ -0,0 +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); +end
A k.m

@@ -0,0 +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 +end