Docsity

Error Correction with Hamming Codes - Prof. Julie M. Clark, Study notes of Mathematics

Toggle sidebar
bg1
Math350:Codes&Ciphers March3,2009
1
Adding Vectors - mod 2
>restart:
>with(linalg):
We can define row vectors using transpose:
>v1:=transpose(<<1,0,1,0,1,0,1>>);
v2:=transpose(<<0,1,1,1,0,0,0>>);
:= v1 []1010101
:= v2 []0111000
>v:=map(modp,matadd(v1,v2),2);
:=
Or, we can define the vectors as matrices:
>v3:=matrix(1,7,[1,0,1,0,1,0,1]);
v4:=matrix(1,7,[1,1,1,1,1,0,1]);
>v:=map(modp,matadd(v3,v4),2);
GeneratorMatrixfortheHamming‐(7,4)code:
1110000
1001100
0101010
1101001
H
G
⎡⎤
⎢⎥
⎢⎥
=⎢⎥
⎢⎥
⎣⎦
v
[]1101101
:= v3 []1010101
:= v4 []1111101
:= v[]0101000
pf3
pf4
pf5

Partial preview of the text

Download Error Correction with Hamming Codes - Prof. Julie M. Clark and more Study notes Mathematics in PDF only on Docsity!

Adding Vectors - mod 2

> restart:

> with(linalg):

We can define row vectors using transpose:

> v1:=transpose(<<1,0,1,0,1,0,1>>);

v2:=transpose(<<0,1,1,1,0,0,0>>);

v1 :=[ 1 0 1 0 1 0 1 ]

v2 :=[ 0 1 1 1 0 0 0 ]

> v:=map(modp,matadd(v1,v2),2);

Or, we can define the vectors as matrices:

> v3:=matrix(1,7,[1,0,1,0,1,0,1]);

v4:=matrix(1,7,[1,1,1,1,1,0,1]);

> v:=map(modp,matadd(v3,v4),2);

Generator Matrix for the Hamming‐(7,4) code:

1 1 1 0 0 0 0

1 0 0 1 1 0 0

0 1 0 1 0 1 0

1 1 0 1 0 0 1

H

G

⎡ ⎤

⎢ ⎥

⎢ ⎥

⎢ ⎥

⎢ ⎥

⎣ ⎦

v [ 1 1 0 1 1 0 1 ]

v3 :=[ 1 0 1 0 1 0 1 ]

v4 :=[ 1 1 1 1 1 0 1 ]

v :=[ 0 1 0 1 0 0 0 ]

Using Maple to Encode with the Hamming-(7, 4)-Code

> restart:

> with(linalg): with(LinearAlgebra):

>G :=matrix(4,7,[1,1,1,0,0,0,0,1,0,0,1,1,0,0,0,1,0,1,0,

,0,1,1,0,1,0,0,1]);

G :=

> a:= matrix(1,4,[0,1,1,0]);

> b:= map(modp,multiply(a,G),2);

Now ‐ suppose we want to add an 8th parity check digit:

> I7:= IdentityMatrix(7):

> C1:= matrix(7,1,[1,1,1,1,1,1,1]);

> CM:=concat(I7,C1);

> cw:=map(modp,multiply(b,CM),2);

a :=[ 0 1 1 0 ]

b :=[ 1 1 0 0 1 1 0 ]

C1 :=

CM :=

cw :=[ 1 1 0 0 1 1 0 0 ]

Error-Correcting with the Hamming-(8,4) Code

> restart:

> with(linalg): with(LinearAlgebra):

P:=transpose(<<0,0,1>|<0,1,0>|<0,1,1>|<1,0,0>|<1,0,1>|<1,1,0>|<

P :=

And now, we input a (length 8) received vector that we want to decode:

> rv:=matrix(1,8,[1,0,1,0,1,0,0,0]);

> parity:=map(modp,sum(rv[1,j],j=1..8),2);

> chckword:=map(modp,multiply(delcols(rv,8..8),P),2);

> if parity = 1 then #one error in word or 8th digit

We compute the location of the error (if any) and correct the error in our word.

> if chckword[1,1]+chckword[1,2]+chckword[1,3] > 0 then

digiterror:=chckword[1,3]+2chckword[1,2]+4chckword[1,1];**

> rv[1,digiterror]:=(rv[1,digiterror]+1)mod 2;

> print("Single Error Corrected in position",

digiterror);

> u[1]:=rv[1,3]:u[2]:=rv[1,5]:u[3]:=rv[1,6]:u[4]:=rv[1,7]:

> print(u[t] $t=1..4);

> else

> print("Error in Check Digit Only");

u[1]:=rv[1,3]:u[2]:=rv[1,5]:u[3]:=rv[1,6]:u[4]:=rv[1,7]:

> print(u[t] $t=1..4);

> end if

rv :=[ 1 0 1 0 1 0 0 0 ]

parity := 1

chckword := [ 1 1 1 ]

> elif chckword[1,1]+chckword[1,2]+chckword[1,3] = 0 then

> print("No error");

u[1]:=rv[1,3]:u[2]:=rv[1,5]:u[3]:=rv[1,6]:u[4]:=rv[1,7]:

> print(u[t] $t=1..4);

> else print("Double Error Detected")

> end if:

"Single Error Corrected in position" , 7

  1. Use Maple and the Hamming‐(15,11) code to encode the following information digits:

a) 1011 0110 101 b) 1101 1011 011 c) 0000 1111 000

  1. Add an over‐all parity check digit to your codewords from #5. (You may simply list the parity

check digit.)

  1. a) How many parity checks will the Hamming‐(31, 26) code have?

b) What are the parity checks for this code?

c) What are the check positions for words in this code?

d) How many codewords are there in this code?

e) What is the size (dimension) of the generator matrix G for this code?

f) Find the generator matrix for this code. (Use graph paper or Excel to write it – it’s not

necessary to use Maple.)

  1. Use Maple to determine and correct any errors in the following Hamming‐(8,4) received words,

then determine the correct 4 information digits in each word. Indicate the position of any errors

(if there are any). If there are double‐errors indicate that you cannot correctly decode.

a) r 1 = [00001000] b) r 2 = [01011011]

c) r 3 = [01111001] d) r 4 = [01100110]

e) r 5 = [10010000] f) r 6 =01010111]

g) r 7 = [01111111]

  1. Use Maple to find and correct any errors in the following Hamming‐(15, 11) received words, and

then report the correct 11 information digits in each word. Indicate the position of any errors (if

there are any). If there are double‐errors indicate that you cannot correctly decode.

a) r 1 = [0011 0111 0001 1110]

b) r 2 = [0111 1111 1000 0001]

c) r 3 = [1011 0100 1010 1010]

d) r 4 = [1100 1000 1001 0000]

e) r 5 =^ [0111^0010 1111 1111]