clear

h=1:7;
n=[-1 -1 -1  1 -1 1 1];
Dnn=corr(n,n);
y=myconv(h,n);
Dny=corr(y,n)
myconv(Dnn,h)

nn=fliplr(Dnn.');
MDnn=nn;
for(k=1:length(nn)-1)
    nn=[nn(end) nn(1:end-1) ];
    MDnn= [MDnn;nn];
end;

nn=n;
N=nn;
for(k=1:length(nn)-1)
    nn=[nn(end) nn(1:end-1) ];
    N= [N;nn];
end;

N*y
H=hadamard(8);
G=H(2:end,2:end);

Ns=(1-N)/2;
sP1=(Ns(1:3,:).')*(2.^(0:2)).';
[ff,sP1]=sort(sP1);
P1=zeros(7,7);
P1(((0:6)*7).'+sP1)=1;
P1=P1.';

bla=Ns*P1.';
bla=N *P1.';

P2=(G*inv(bla)).';
S1=[zeros(1,7) ;eye(7)];
S2=S1.';

hr=inv(MDnn)*P2*S2*H*S1*P1*y

return


function [spx]=corr(c1,c2);
c1=c1(:);
c2=c2(:);
spx=(real(ifft(fft(c1).*conj(fft(c2)))));

function [erg] = myconv(x,y);

x=x(:);
y=y(:);
if(length(x) ~= length(y)) 
disp('myconv: Vectoren unterschiedlich lang'); 
return; 
end;

erg=corr(x,flipud(y));
return