#HW8 Nuray Kutlu #Old code from class #MinD(C): The minimal (Hamming) distance of the code C MinD:=proc(C) local i,j: min( seq(seq(HD(C[i],C[j]),j=i+1..nops(C)), i=1..nops(C))): end: #HD(u,v): The Hamming distance between two words (of the same length) HD:=proc(u,v) local i,co: co:=0: for i from 1 to nops(u) do if u[i]<>v[i] then co:=co+1: fi: od: co: end: #LtoC(q,M): inputs a list of basis vectors for our linear code over GF(q) #outputs all the codewords (the actual subset of GF(q)^n with q^k elements LtoC:=proc(q,M) local n,k,C,c,i,M1: option remember: k:=nops(M): n:=nops(M[1]): if k=1 then RETURN({seq(i*M[1] mod q,i=0..q-1) }): fi: M1:=M[1..k-1]: C:=LtoC(q,M1): {seq(seq(c+i*M[k] mod q,i=0..q-1),c in C)}: end: #End of old code from class #WtEnumerator(q,M,t) #that inputs a generating matrix M (with k rows say, so so it is an [n,k,d] code for some d ) #for a linear code over GF(q) (q prime) and outputs the Sum(t^wt(v), v in C) #So basically it sums all WtEnumerator:=proc(q,M,t) local v, n, k, d, sum, C,w: sum:=0: k:=nops(M): n:=nops(M[1]): d:= MinD(M): C:= LtoC(q,M): for v in C do: w := HD(c,[0$n]): sum:= sum + t^w: od: sum: end: