research/codes: minor fixes/improvements

This commit is contained in:
darkfi
2025-05-01 08:06:45 +02:00
parent 17865fa10e
commit 72b7c4e0da
2 changed files with 23 additions and 17 deletions

View File

@@ -25,16 +25,17 @@ c[1] = 0
table = []
count = 0
total = 0
for (i0, i1) in itertools.permutations(range(n), int(2)):
g = R.lagrange_polynomial([(α^i0, c[i0]), (α^i1, c[i1])])
table.append([
(i0, i1),
g,
"*" if f == g else None
])
if f == g:
count += 1
total += 1
for i0 in range(n):
for i1 in range(i0+1, n):
g = R.lagrange_polynomial([(α^i0, c[i0]), (α^i1, c[i1])])
table.append([
(i0, i1),
g,
"*" if f == g else None
])
if f == g:
count += 1
total += 1
print(tabulate(table))
print(f"{count} / {total}")

View File

@@ -1,3 +1,4 @@
from tabulate import tabulate
q = 11
k = 3
d0 = q - k + 1
@@ -11,19 +12,23 @@ K = GF(q)
F.<z> = K[]
V = VectorSpace(K, n)
C = V.subspace([
M = V.subspace([
[1, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0],
])
for c in C:
f = c[0] + c[1]*z + c[2]*z^2
table = []
for m in M:
f = m[0] + m[1]*z + m[2]*z^2
w = vector(f(β) for β in list(K)[:n])
assert len(w) == n
c = vector(f(β) for β in list(K)[:n])
assert len(c) == n
if w.is_zero():
if c.is_zero():
continue
assert d <= w.hamming_weight()
table.append((c, c.hamming_weight()))
assert d <= c.hamming_weight()
print(tabulate(table))
print(d)