first commit
Marco Andronaco andronacomarco@gmail.com
Wed, 18 Jan 2023 22:10:10 +0100
4 files changed,
53 insertions(+),
53 deletions(-)
M
README.md
→
README.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
delsarte.m
→
delsarte.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