Chapter16 : Error correcting codes

Page no 732 Example no 16.1

In [35]:
from numpy import mat,shape

#here generator matrix is given
G=mat([[1, 0, 0, 1 ,0 ,1],[0, 1, 0, 0, 1, 1],[0, 0, 1, 1, 1, 0]])
d1=mat([[1, 1, 1]])
d2=mat([[1, 1, 0]])
d3=mat([[1, 0, 1]])
d4=mat([[1, 0, 0]])
d5=mat([[0, 1, 1]])
d6=mat([[0, 1, 0]])
d7=mat([[0, 0, 1]])
d8=mat([[0, 0 ,0]])
c1=d1*G

for i in range(0,6):
    if c1[0,i]==2:
        c1[0,i]=0
    

c2=d2*G#
for i in range(0,6):
    if c2[0,i]==2:
        c2[0,i]=0
    

c3=d3*G#
for i in range(0,6):
    if c3[0,i]==2:
        c3[0,i]=0
    
   
c4=d4*G#
for i in range(0,6):
    if c4[0,i]==2:
        c4[0,i]=0
    

c5=d5*G#
for i in range(0,6):
    if c5[0,i]==2:
        c5[0,i]=0#
    

c6=d6*G#
for i in range(0,6):
    if c6[0,i]==2:
        c6[0,i]=0#
   

c7=d7*G#
for i in range(0,6):
    if c7[0,i]==2:
        c7[0,i]=0#
   

c8=d8*G#
for i in range(0,6):
    if c8[0,i]==2:
        c8[0,i]=0#
   

print "code words are given as"
print c1
print c2

print c3
print c4
print c5
print c6
print c7
print c8
code words are given as
[[1 1 1 0 0 0]]
[[1 1 0 1 1 0]]
[[1 0 1 0 1 1]]
[[1 0 0 1 0 1]]
[[0 1 1 1 0 1]]
[[0 1 0 0 1 1]]
[[0 0 1 1 1 0]]
[[0 0 0 0 0 0]]