tic
N=4096*52;
M=N/2+1;
for k=M-100:M+100
for l=M-100:M+100
T=[];
w=[1/2;ones(25,1);1/2];
for p=-1:1
    for q=-1:1
        for r=M-13:M+13
if (k-r+2*p)==0
R1=(-1/2)^abs(p)*N/2;
else 
Num1=1/2*(-1/2)^abs(p)*sin(pi/2*(k-r+2*p))*exp(i*pi/2*(1-1/N)*(k-r+2*p));
Den1=sin(pi/(2*N)*(k-r+2*p));
R1=Num1/Den1;
end
if (l-r+2*q)==0
R2=(-1/2)^abs(q)*N/2;
else 
Num2=1/2*(-1/2)^abs(q)*sin(pi/2*(l-r+2*q))*exp(-i*pi/2*(1-1/N)*(l-r+2*q));
Den2=sin(pi/(2*N)*(l-r+2*q));
R2=Num2/Den2;
end
T=[T w(r-N/2+13)*R1*R2];
        end   
    end
end
SP(l-N/2+100)=sum(T)/N^2;
end
ST(k-N/2+100)=sqrt(sum(SP.*conj(SP)));
end
save('~/data/loops_STC.mat','ST');
toc


    

