# lfsr:=function(c,k,n) # c list of coeffs # k initial values # n length of resulting sequence local res,l,i; res:=ShallowCopy(k); l:=Length(c); for i in [1..n-l] do Add(res,res{[i..i+l-1]}*c mod 2); od; return res; end; lfsrlength:=function(v,n) local i,dets,mat; dets:=[]; for i in [2..n] do mat:=List([1..i],x->v{[x..(x-1+i)]}) mod 2; dets[i]:=Determinant(mat) mod 2; od; return dets; end; lfsrsolve:=function(v,n) local mat; mat:=List([1..n],x->v{[x..(x-1+n)]}) mod 2; return (v{[n+1..2*n]}*(TransposedMat(mat)^-1 mod 2)) mod 2; end;