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

schur_ord(A,B,xi)
function [U,V,TA,TB,n,eigenvalues] = schur_ord(A,B,xi)
%  PURPOSE: performs generalized Schur decomposition, eigenvalues lambda, 
%           such that |lambda|< xi are selected first
%
%           following relations hold:
%               U TA V' = A
%               U TB V' = B
%
% ---------------------------------------------------
%  USAGE: [U,V,TA,TB,eigenvalues] = schur_ord(A,B,xi);
%  where: 
%         A,B                       quadratic matrices
%         xi                        selects eigenavlues lambda, such that
%                                   |lambda|<xi
%
%         U,V                       orthogonal matrices
%         TA,TB                     quasi upper-triangular matrices
%         n                         number of selected eigenvalues
%         eigenvalues               eigenvalues of the matrix A
%
%   COMMENTS:
%
% Copyright  (c) Pawel Kowal (2006)
% All rights reserved
% LREM_SOLVE toolbox is available free for noncommercial academic use only.
% pkowal3@sgh.waw.pl

COND                                =[-1 -1 xi 0 0 0 0]';
[U,V,TA,TB,WR,WI,BETA,n]            =gschur(A,B,COND);

ALPHA                               = abs(WR+i*WI);
tol                                 = 10*max([max(ALPHA);max(BETA)])*size(A,1)*eps;
I                                   = find(BETA<tol);
I                                   = ALPHA(I);
I                                   = find(ALPHA<tol);
if length(I)>0
    error('Matrix pair is not regular');
end

eigenvalues                         =((WR+i*WI).^-1).*BETA;

Contact us at files@mathworks.com