3 v4: chnaged lyapunov_symm.m to work with 6.5 except with unit roots

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@740 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
michel 2006-05-08 14:51:06 +00:00
parent 01754a4446
commit dcc7c7e1f0
1 changed files with 15 additions and 4 deletions

View File

@ -14,10 +14,21 @@ function [x,ns_var]=lyapunov_symm(a,b)
e1 = abs(my_ordeig(t)) > 2-options_.qz_criterium;
end
k = sum(e1);
[u,t] = ordschur(u,t,e1);
n = length(e1)-k;
b=u(:,k+1:end)'*b*u(:,k+1:end);
t = t(k+1:end,k+1:end);
if exist('ordschur','builtin')
% selects stable roots
[u,t] = ordschur(u,t,e1);
n = length(e1)-k;
b=u(:,k+1:end)'*b*u(:,k+1:end);
t = t(k+1:end,k+1:end);
elseif k > 0
% problem for Matlab version that don't have ordschur
error(['lyapunov_sym: you need a Matlab version > 6.5 to handle models' ...
' with unit roots'])
else
% no unit root
n = length(e1);
b=u'*b*u;
end
x=zeros(n,n);
for i=n:-1:2
if t(i,i-1) == 0