From dcc7c7e1f0209179eda7a355c82b3bdb3da485e2 Mon Sep 17 00:00:00 2001 From: michel Date: Mon, 8 May 2006 14:51:06 +0000 Subject: [PATCH] 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 --- matlab/lyapunov_symm.m | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/matlab/lyapunov_symm.m b/matlab/lyapunov_symm.m index 1c1be1e16..dbcacf89c 100644 --- a/matlab/lyapunov_symm.m +++ b/matlab/lyapunov_symm.m @@ -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