Commit 4e9b2336 authored by sebastien's avatar sebastien
Browse files

Reorganized the way we deal with functions which exist under only some...

Reorganized the way we deal with functions which exist under only some versions of MATLAB and/or some versions of Octave:
* Created a directory matlab/missing to store them under subdirectories
* Add the needed subdirectories to the path from dynare_config.m
* Moved content of matlab/matlab/ and matlab/octave/ to matlab/missing/*/
* matlab/missing/ordeig/ordeig.m: new name of matlab/my_ordeig
* matlab/missing/ordschur/ordschur.m: fake replacement, displays an error message
* Removed old matlab/matlab/ and matlab/octave/ directories


git-svn-id: https://www.dynare.org/svn/dynare/trunk@2805 ac1d8469-bf42-47a9-8791-bf33cf982152
parent ff548545
......@@ -183,17 +183,9 @@ function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data
kalman_algo = 3;
end
[QT,ST] = schur(T);
if exist('OCTAVE_VERSION') || matlab_ver_less_than('7.0.1')
e1 = abs(my_ordeig(ST)) > 2-options_.qz_criterium;
else
e1 = abs(ordeig(ST)) > 2-options_.qz_criterium;
end
e1 = abs(ordeig(ST)) > 2-options_.qz_criterium;
[QT,ST] = ordschur(QT,ST,e1);
if exist('OCTAVE_VERSION') || matlab_ver_less_than('7.0.1')
k = find(abs(my_ordeig(ST)) > 2-options_.qz_criterium);
else
k = find(abs(ordeig(ST)) > 2-options_.qz_criterium);
end
k = find(abs(ordeig(ST)) > 2-options_.qz_criterium);
nk = length(k);
nk1 = nk+1;
Pinf = zeros(np,np);
......
......@@ -184,17 +184,9 @@ function [fval,llik,cost_flag,ys,trend_coeff,info] = DsgeLikelihood_hh(xparam1,g
kalman_algo = 3;
end
[QT,ST] = schur(T);
if exist('OCTAVE_VERSION') || matlab_ver_less_than('7.0.1')
e1 = abs(my_ordeig(ST)) > 2-options_.qz_criterium;
else
e1 = abs(ordeig(ST)) > 2-options_.qz_criterium;
end
e1 = abs(ordeig(ST)) > 2-options_.qz_criterium;
[QT,ST] = ordschur(QT,ST,e1);
if exist('OCTAVE_VERSION') || matlab_ver_less_than('7.0.1')
k = find(abs(my_ordeig(ST)) > 2-options_.qz_criterium);
else
k = find(abs(ordeig(ST)) > 2-options_.qz_criterium);
end
k = find(abs(ordeig(ST)) > 2-options_.qz_criterium);
nk = length(k);
nk1 = nk+1;
Pinf = zeros(np,np);
......
......@@ -126,17 +126,9 @@ function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK,T,R,P,PK,d,
kalman_algo = 3;
end
[QT,ST] = schur(T);
if exist('OCTAVE_VERSION') || matlab_ver_less_than('7.0.1')
e1 = abs(my_ordeig(ST)) > 2-options_.qz_criterium;
else
e1 = abs(ordeig(ST)) > 2-options_.qz_criterium;
end
e1 = abs(ordeig(ST)) > 2-options_.qz_criterium;
[QT,ST] = ordschur(QT,ST,e1);
if exist('OCTAVE_VERSION') || matlab_ver_less_than('7.0.1')
k = find(abs(my_ordeig(ST)) > 2-options_.qz_criterium);
else
k = find(abs(ordeig(ST)) > 2-options_.qz_criterium);
end
k = find(abs(ordeig(ST)) > 2-options_.qz_criterium);
nk = length(k);
nk1 = nk+1;
Pinf = zeros(np,np);
......
......@@ -183,17 +183,9 @@ function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data
kalman_algo = 3;
end
[QT,ST] = schur(T);
if exist('OCTAVE_VERSION') || matlab_ver_less_than('7.0.1')
e1 = abs(my_ordeig(ST)) > 2-options_.qz_criterium;
else
e1 = abs(ordeig(ST)) > 2-options_.qz_criterium;
end
e1 = abs(ordeig(ST)) > 2-options_.qz_criterium;
[QT,ST] = ordschur(QT,ST,e1);
if exist('OCTAVE_VERSION') || matlab_ver_less_than('7.0.1')
k = find(abs(my_ordeig(ST)) > 2-options_.qz_criterium);
else
k = find(abs(ordeig(ST)) > 2-options_.qz_criterium);
end
k = find(abs(ordeig(ST)) > 2-options_.qz_criterium);
nk = length(k);
nk1 = nk+1;
Pinf = zeros(np,np);
......
......@@ -42,20 +42,34 @@ addpath([dynareroot '/kalman/'])
addpath([dynareroot '/kalman/likelihood'])
addpath([dynareroot '/AIM/'])
% For functions that exist under Octave and not under Matlab, or vice-versa,
% we provide some replacement functions
if exist('OCTAVE_VERSION')
% Functions missing under Octave
addpath([dynareroot '/octave/'])
else
% Functions missing under Matlab
addpath([dynareroot '/matlab/'])
% For functions that exist only under some Octave versions
% or some MATLAB versions, and for which we provide some replacement functions
if ~exist('OCTAVE_VERSION')
% Replacements for rows() and columns() (inexistent under MATLAB)
addpath([dynareroot '/missing/rows_columns'])
if isempty(ver('stats'))
% Replacements for functions of the stats toolbox
addpath([dynareroot '/matlab/stats/'])
addpath([dynareroot '/missing/stats/'])
end
end
% ordeig() was introducted in MATLAB 7.0.1, and doesn't exist in Octave
if exist('OCTAVE_VERSION') || matlab_ver_less_than('7.0.1')
addpath([dynareroot '/missing/ordeig'])
end
% rcond() was introduced in Octave 3.2.0
if exist('OCTAVE_VERSION') && octave_ver_less_than('3.2.0')
addpath([dynareroot '/missing/rcond'])
end
% orschur() is missing in Octave; we don't have a real replacement;
% the one we provide just exits with an error message
if exist('OCTAVE_VERSION')
addpath([dynareroot '/missing/ordschur'])
end
% Add path to MEX files
if exist('OCTAVE_VERSION')
path_to_mex_files = [dynareroot '../mex/octave/'] ;
......
......@@ -20,7 +20,7 @@ function [x,u] = lyapunov_symm(a,b,qz_criterium,lyapunov_complex_threshold,metho
% Uses reordered Schur decomposition
%
% SPECIAL REQUIREMENTS
% needs Matlab >= 7.0.1 for ordeig function (otherwise uses my_ordeig)
% None
% Copyright (C) 2006-2009 Dynare Team
%
......@@ -38,12 +38,6 @@ function [x,u] = lyapunov_symm(a,b,qz_criterium,lyapunov_complex_threshold,metho
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
persistent test1 test2
if isempty(test1)
test1 = exist('OCTAVE_VERSION') || matlab_ver_less_than('7.0.1') ;
test2 = exist('ordschur','builtin');
end
if nargin<5
method = 0;
......@@ -65,21 +59,13 @@ function [x,u] = lyapunov_symm(a,b,qz_criterium,lyapunov_complex_threshold,metho
if method<2
[U,T] = schur(a);
if test1
e1 = abs(my_ordeig(T)) > 2-qz_criterium;
else
e1 = abs(ordeig(T)) > 2-qz_criterium;
end
e1 = abs(ordeig(T)) > 2-qz_criterium;
k = sum(e1); % Number of unit roots.
n = length(e1)-k; % Number of stationary variables.
if test2
if k > 0
% Selects stable roots
[U,T] = ordschur(U,T,e1);
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'])
end
end
......
function eigs = my_ordeig(t)
% function eval = my_ordeig(t)
function eigs = ordeig(t)
% function eval = ordeig(t)
% Computes the eigenvalues of a quasi-triangular matrix
%
% INPUTS
......
## Copyright (C) 2009 Dynare Team
##
## This file is part of Dynare.
##
## Dynare is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## Dynare is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Dynare. If not, see <http://www.gnu.org/licenses/>.
function [US,TS] = ordschur(U,T,SELECT)
error("The ordschur() function is missing under Octave. For this reason, Dynare can't estimate models with unit roots with Octave.")
endfunction
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment