convert to unix line-endings, add download link
Marco Andronaco andronacomarco@gmail.com
Wed, 18 Jan 2023 22:22:57 +0100
4 files changed,
59 insertions(+),
57 deletions(-)
M
README.md
→
README.md
@@ -1,5 +1,7 @@
-# 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 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$. + +Click [here](https://github.com/BiRabittoh/delsarte-bound/archive/refs/heads/master.zip) to download the code.
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); -end+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