clear all
d=3;N=d^2;
F2=fft(eye(d))/sqrt(d); %Small Fourier for creation of Zak
Z = zeros(N,N);
F=fft(eye(N))/d;
%T=diag(ones(1,N-1),1); %Translation
%T(N,1)=1;
%bl=ones(1,N)/d
%e0=bl*F;
n = 0:d-1;
n=d*n;
for j = 0:d^2-1;
   Z(j+1,n+1+floor(j/d)) = F2(mod(j,d)+1,:); %Zak transform
end;
clf
hold on
for k=0:100;
mm=rand(1,N);
B=exp(2*pi*mm*i)/d; 
plot(Z'*(B'))
end
f=rand(N,1)
jj=[1:N];
kk=[floor(N/2):N];
f=sin(400*jj/pi);
f(kk)=5*cos(50*kk/pi);
f=ones(1,N);
Zf=Z'*f';
ZF=zeros(d,d);
for k=1:d
for m=1:d
ZF(k,m)=Zf((k-1)*d+m);
end;
end;
clf
figure(1)
plot(f);
figure(2)
plot(abs(F*f'))
figure(3)
imagesc(abs(ZF))