1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| # Polynomials on the finite field with 2 elements for the indeterminate 'X'
R.<X>=GF(2)[]
P=X^2+X^4+X^5+X^8
PP1=P*X; print PP1
PP2=P*(X+1); print PP2
> X^9 + X^6 + X^5 + X^3\nX^9 + X^8 + X^6 + X^4 + X^3 + X^2
def pol2binary(poly):
lst=list(poly)
#for x in range(0,len(lst)):
# print lst[x]
lst.reverse()
return lst
pol2binary(PP1)
> [1, 0, 0, 1, 1, 0, 1, 0, 0, 0]
def interleaving(lst1,lst2):
y=0
lst = []
for x in range(0,len(lst1)):
lst.append(lst1[x])
lst.append(lst2[y])
if y<=len(lst2):
y=y+1
print lst
interleaving(pol2binary(PP1),pol2binary(PP2))
> [1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0]
|