Download Error Correction with Hamming Codes - Prof. Julie M. Clark and more Study notes Mathematics in PDF only on Docsity! 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 [ ]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 HG ⎡ ⎤ ⎢ ⎥ ⎢ ⎥= ⎢ ⎥ ⎢ ⎥ ⎣ ⎦ 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 Math 350: Codes & Ciphers March 3, 2009 2 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,1 ,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); ⎣ ⎢⎢⎢⎢⎢⎢⎢⎢ ⎤ ⎦ ⎥⎥⎥⎥⎥⎥⎥⎥ 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 := a [ ]0 1 1 0 := b [ ]1 1 0 0 1 1 0 := C1 ⎡ ⎣ ⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢ ⎤ ⎦ ⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥ 1 1 1 1 1 1 1 := CM ⎡ ⎣ ⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢ ⎤ ⎦ ⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥ 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 1 := cw [ ]1 1 0 0 1 1 0 0 Math 350: Codes & Ciphers March 3, 2009 5 > 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: , , ,1 1 0 1 ,"Single Error Corrected in position" 7 Math 350: Codes & Ciphers March 3, 2009 6 Homework Exercises #4: Due 3/10/09 1. Without using Maple, locate the position of any errors, and then correct them, in the following received words from the Hamming‐(7,4) code: a) r1= 0101111 b) r2= 0001101 c) r3= 0100011 d) r4= 0110011 2. Let C be a binary linear code. Prove that the code C*obtained by adding an overall parity check digit to C is linear (closed under the operation of addition). 3. For each of the generator matrices below ‐‐ list all the codewords in the code and find the minimum distance of the code. a) b) 1 1 1 1 1 0 0 0 1 1 1 G ⎡ ⎤ = ⎢ ⎥ ⎣ ⎦ 2 1 0 0 1 1 0 1 0 1 0 1 0 1 1 0 0 1 0 1 1 1 G ⎡ ⎤ ⎢ ⎥= ⎢ ⎥ ⎢ ⎥⎣ ⎦ 4. Use Maple to help you fill in the table below Information Digits H‐ (7,4) codeword H ‐(8,4) parity check digit Information Digits H‐ (7,4) codeword H ‐(8,4) parity check digit 0000 1001 0001 1010 0010 0101 0100 0111 1000 1011 0011 1101 0110 1110 1100 1111 Math 350: Codes & Ciphers March 3, 2009 7 5. 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 6. Add an over‐all parity check digit to your codewords from #5. (You may simply list the parity check digit.) 7. 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.) 8. 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) r1 = [00001000] b) r2 = [01011011] c) r3 = [01111001] d) r4 = [01100110] e) r5 = [10010000] f) r6 =01010111] g) r7 = [01111111] 9. 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) r1 = [0011 0111 0001 1110] b) r2 = [0111 1111 1000 0001] c) r3= [1011 0100 1010 1010] d) r4 = [1100 1000 1001 0000] e) r5 = [0111 0010 1111 1111]