function delta=elim_bloc(A,B,C,r,N)
%se rezolva sistemul prin metoda eliminarii blocurilor
%parametrul returnat delta reprezinta solutia sistemului
dd(:,:,1)=A(:,:,1);
w(:,1)=r(:,1);
for i=2:N
   gamma(:,:,i)=B(:,:,i)*inv(dd(:,:,i-1));
   w(:,i)=r(:,i)-gamma(:,:,i)*w(:,i-1);
   dd(:,:,i)=A(:,:,i)-gamma(:,:,i)*C(:,:,i-1);
end
delta(:,N)=inv(dd(:,:,N))*w(:,N);
for i=N-1:-1:1
   delta(:,i)=inv(dd(:,:,i))*(w(:,i)-C(:,:,i)*delta(:,i+1));
end