add_vector:=function(L,n,d)
#adds smallest binary vector of length n
#which is at least distance d from any other
L0:=[]:
for i from 0 to 2^n-1 do
LL:=binary representation of i;
L0:={LL} union L0:
end for;
L1:=sort L0 lexicographically;
for v in L1 do
L2:=[];
for y in L1 do
if y<>v then L2:=[op(L3),y]; fi;
end for;
m:=minimum of all Hamming weights of v-w, w in L
if m >= d then
RETURN(L union v);
end if;
end for;
RETURN(L);
end function;
Next, we need a function which iterates this add_vector
procedure over and over.
lexicode_binary:=function(M,n,d) #M is the number of elements, n is the length, #d is the min distance L:=[]; for i from 1 to M do L:=add_vector(L,n,d): end for; RETURN(L); end function;For example,
L:=lexicode_binary(16,7,3); returns
| [1, 0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0], |
| [0, 0, 1, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1], |
| [0, 1, 0, 0, 1, 0, 1], [1, 0, 0, 0, 0, 1, 1], |
| [0, 1, 1, 1, 1, 0, 0], [1, 0, 1, 1, 0, 1, 0], |
| [1, 1, 0, 0, 1, 1, 0], [1, 1, 0, 1, 0, 0, 1], |
| [1, 0, 1, 0, 1, 0, 1], [0, 1, 1, 0, 0, 1, 1], |
| [0, 0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1] |
L:=lexicode_binary(16,8,3); return?
(Go through every step.)
L:=lexicode_binary(16,8,3); return?
(Go through every step.)