function  [OUT,rh,ry,rUn]=RLSt(dsignal,noise,la,order)%#codegen

laiv=1/la;
P=la*eye(order);
ei=zeros(size(dsignal));
h=zeros(order,1);
i=1;
for n=order:length(dsignal)
    % a chunk of noise
    Un=noise(n:-1:n-order+1);
    K=laiv*P*Un/(1+laiv*Un'*P*Un);
    % output or error after filtered by h
    rh(:,i)=h;
    rUn(:,i)=Un;
    ry(:,i)=Un'*h;
    i=i+1;
    ei(n)=dsignal(n)-Un'*h;
    h=h+K*ei(n);
    
    P=laiv*(P-K*Un'*P);   
end
OUT=ei;
% hold on
% plot(OUT)

end

