No BSD License  

Highlights from
Solution to Linear Rational Expectations Models

from Solution to Linear Rational Expectations Models by Pawel Kowal
Solves linear rational expectation models, delivers derivatives of solutions

rank2(A,tol)
function n = rank2(A,tol)
%  PURPOSE: estimates matrix rank of an triangular matrix
%
% ---------------------------------------------------
%  USAGE: n = rank2(A,tol)
%  where: 
%         A                         a matrix
%         tol                       uses the tolerance tol in estimating
%                                   matrix rank
%
%         n                         an estimate of matrix A rank
%
%   COMMENTS:
%       This routine gives fast estimation of matrix rank but less accurate
%       than Mathlab's rank. This routine is unable to distinguish very small
%       singular values from zero.
%
% Copyright  (c) Pawel Kowal (2006)
% All rights reserved
% LREM_SOLVE toolbox is available free for noncommercial academic use only.
% pkowal3@sgh.waw.pl


[n,m]           = size(A);
if n==0 ||m==0
    n           = 0;
    return;
end    
if n==1 || m==1
    s           = abs(A(1,1));
else
s               = abs(diag(A));
end

n               = sum(s>tol);

Contact us at files@mathworks.com