#HW 9 Nuray Kutlu #OK to post #Valentine Ages: #Alex Varjebedan: 19 #Aurora Hiveley: 23 #Gloria Liu: 21 #Himanshu Chandra: 22 #Issac Lam: Hard to tell #Joseph Koutsoutis:20 #Kaylee Weatherspoon:22 #Lucy Martinez:25 #Natalya Ter-Saakov:24 #Pablo Blanco:21 #RDB: ... #Ramesh Balaji: 19 #Ryan Badi: 20 #Shaurya Baranwal: 19 #inputs the modolus q, and a parity check matrix in standard form, outputs the corresponding # generating matrix M of a linear code over GF(q) such that #antiPCM(q,PCM(q,M))=M and PCM(q,AntiPCM(q,H))=H antiPCM:=proc(q,H) local nmk, n,k,i,j,M: nmk:= nops(H): n:=nops(H[1]): k:=n-nmk: for i from 1 to k do for j from 1 to k do if j=i then M[i,j] := 1: else M[i,j]:=0: fi: od: for j from k+1 to n do M[i,j] = -H[j-k][i] mod q: od: od: [seq([seq(M[i,j],j=1..n)],i=1..k)]: end: #DecodeLT(q,M) : #that is similar to DecodeT(q,n,C), that inputs a generating matrix M #(note that n=nops(M[1])), and uses the Syndrom Table to construct a table that mays #every vector in Fqn(q,n) to the member of LtoC(q,M) that it is mapped to. DecodeLT:=proc(q,M) local n,k,CT,T, C,FQN,v,w, syn, H,cos: H:= PCM(q, M): C:=LtoC(q,M): n:= nops(M[1]): CT:=SynT(q,M): FQN:=Fqn(q,n): for v in FQN do: syn:= Syn(q,H,v): cos:= SynT[syn]: w := v-cos: T[v]:=w: od: T: end: #Old Code from class #PCM(q,M): inputs the mod. q and a non-empty basis (a list of lists) #n=nops(M[1]) M is k by n matrix and H=PCM(q,M) is an n-k by n matrix #describing the basis of some linear code over GF(q)^n outputs of dimension k=nops(M) #the (n-k) by n PCM:=proc(q,M) local k,n,i,j,H: option remember: k:=nops(M): n:=nops(M[1]): SAah:=proc(q,n,M) local SL,C,A,a,r1,r,j: # copied from class C:=LtoC(q,M): C:=C minus {[0$n]}: # added r1 := [[0$n],op(C)]: SL := [r1]: A:=Fqn(q,n) minus {op(r1)}: # changed from class while A<>{} do # find coset representative of min weight a := minW(A) : # build next row r := []: for j from 1 to nops(r1) do r := [op(r), a + r1[j] mod q]: od: # add new row to array SL := [op(SL), r]; # print(SL); # update available vectors A := A minus {op(SL[-1])}: od: SL; end: if [seq([op(1..k,M[i])],i=1..k)]<>[seq([0$(i-1),1,0$(k-i)],i=1..k)] then print(`Not standard form , please use SFde(q,M) first `): RETURN(FAIL): fi: for i from 1 to n-k do for j from 1 to k do H[i,j]:=-M[j][i+k] mod q: od: for j from k+1 to n do if j-k=i then H[i,j]:=1: else H[i,j]:=0: fi: od: od: [seq([seq(H[i,j],j=1..n)],i=1..n-k)]: end: #Syn(q,H,y): The syndrom of the transmitted vector y if the PCM is H #(a row vector of length n-k) Syn:=proc(q,H,y) local i: [seq(DP(q,y,H[i]),i=1..nops(H))]: end: #Alphabet {0,1,...q-1}, Fqn(q,n): {0,1,...,q-1}^n Fqn:=proc(q,n) local S,a,v: option remember: if n=0 then RETURN({[]}): fi: S:=Fqn(q,n-1): {seq(seq([op(v),a],a=0..q-1), v in S)}: end: