Code covered by the BSD License  

Highlights from
UD Factorization & Kalman Filtering

UD Factorization & Kalman Filtering

by

 

15 Aug 2011 (Updated )

UD and LD factorization of nonnegative matrices and associated Kalman filter implementations.

[lti,r]=ltinv(lt,tolp,toln)
% LTINV : inverse of lower triangular ut
%
%         function [lti,r]=ltinv(lt,tolp,toln)
%
%         lt  : L'DL factorization
%         tolp: tolerance for positiveness
%               default 1e-12, see also toln
%         toln: error generation if diagonal part < toln,  default: tolp
%               if toln < 0 all the diagonal parts < max(0,tolp) are set to zero
%
%         lti : inv(lt)
%         r   : rank(di)
%
%         Used to compute : inv(p)=inv(l)'*inv(l)
%         [lti]=ltinv(lt) computes inv(l)
%         Then: inv(p)=ltt2sym(ltinv(sym2ld(p)))
%
%         See also ltt2sym, lt2sym, sym2lt
%
%         References: Factorization methods for discrete sequential estimation
%                     1977, Gerald J. Bierman
%
% L.G. van Willigenburg, W.L. de Koning, Update August 2011

  function [lti,r]=ltinv(lt,tolp,toln)

  if nargin > 3; error('  one, two or three input arguments required'); end;
  if nargin==1; tolp=1e-12; toln=tolp;
  elseif nargin==2; toln=tolp; end; tolp=max(0,tolp); 
  if (toln>tolp); error('  toln > tolp'); end;

  [n,m]=size(lt);
  if n~=m; error(' lt must be square'); end;
  if n==0; error(' Compatible but empty inputs'); end;

  r=n;
  for i=n:-1:1
    if lt(i,i)<toln; error('  toln violated');
    elseif lt(i,i)<=tolp; lti(i,i)=0; r=r-1;
    else lti(i,i)=1/lt(i,i); end
  end;

  for j=n-1:-1:1
    jp1=j+1;
    for k=n:-1:jp1
      sum=0;
      for i=jp1:k
        sum=sum-lti(k,i)*lt(i,j);
      end
      lti(k,j)=sum*lti(j,j);
    end
  end

Contact us