Hi everybody,
I managed to create a simple program calculating the weight spectra of non-binary linear block codes (using the old GF package):
<< GaloisField`GaloisField`
DeclareGaloisField[GF8]
pp = 2^ExtensionDegree[GF8];
nd = 12; (* code word length *)
kd = 5; (* the length of information vector *)
pmat = {{GF8[1], GF8[1], GF8[1], GF8[1], GF8[1], GF8[1], GF8[1]},
{GF8[5], GF8[7], GF8[6], GF8[3], GF8[4], GF8[2], GF8[1]},
{GF8[7], GF8[3], GF8[2], GF8[5], GF8[6], GF8[4], GF8[1]},
{GF8[1], GF8[1], GF8[1], GF8[1], GF8[1], GF8[1], GF8[1]},
{GF8[1], GF8[1], GF8[1], GF8[1], GF8[1], GF8[1], GF8[1]}}; (* parity part of generator matrix *)
vysl = Array[w, nd, 0];
Do[w[i] = 0, {i, 0, nd}];
Do[
Do[
Do[
Do[
Do[
info = {GF8[n], GF8[m], GF8[l], GF8[j], GF8[i]};
r = kd - Count[info, GF8[0]];
s = (nd - kd) - Count[info.pmat, 0];
t = r + s;
++w[t],
{j, 0, pp - 1}],
{i, 0, pp - 1}],
{l, 0, pp - 1}],
{m, 0, pp - 1}],
{n, 0, pp - 1}];
Do[Print["code word weight ", p, " = ", w[p]], {p, 0, nd}]
Note: the above assumes a systematic form of generator matrix.
My question is how to make this nested “Do” structure dynamic, so I do not have to input it manually and it will be created automatically based on the input parameters: “nd” and “kd”?
I tried to use Nest[] but I wasn’t successful (I am not a good programmer).
Many thanks for your help,
Martin