v4 matlab:

* added a function matlab_ver_less_than() for testing Matlab version
* updated dynare_config.m and build_matlab.m accordingly
* removed tests to check whether we are older than Matlab 6.5 (R13), since we don't support those old versions anymore
* removed a few unnecessary uses of eval()


git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1936 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
sebastien 2008-07-07 17:08:55 +00:00
parent 27886047cf
commit ddaaf9e1e3
7 changed files with 49 additions and 40 deletions

View File

@ -25,10 +25,8 @@ GridSize = length(omega);
exo_names_orig_ord = M_.exo_names_orig_ord;
if exist('OCTAVE_VERSION')
warning('off', 'Octave:divide-by-zero')
elseif sscanf(version('-release'),'%d') < 13
warning off
else
eval('warning off MATLAB:dividebyzero')
warning off MATLAB:dividebyzero
end
if nargin<2
var_list = [];
@ -150,10 +148,8 @@ end
if exist('OCTAVE_VERSION')
warning('on', 'Octave:divide-by-zero')
elseif sscanf(version('-release'),'%d') < 13
warning_config
else
eval('warning on MATLAB:dividebyzero')
warning on MATLAB:dividebyzero
end
if pltinfo

View File

@ -24,14 +24,7 @@ dynareroot = strrep(which('dynare.m'),'dynare.m','');
if exist('OCTAVE_VERSION')
addpath([dynareroot '../mex/octave/'])
else
MATLAB = ver('matlab');
%% FIXME:
%% It's not satisfactory to convert string versions into numbers, and to
%% compare these numbers:
%% - conversion will fail if version = 1.2.3
%% - it will give 7.10 < 7.9
VERSION = str2num(MATLAB.Version);
if (VERSION <= 7.4)
if matlab_ver_less_than('7.5')
addpath([dynareroot '../mex/2007a/'])
else
addpath([dynareroot '../mex/2007b/'])

View File

@ -26,7 +26,7 @@ function [x,info] = dynare_solve(func,x,jacobian_flag,varargin)
options_ = set_default_option(options_,'solve_algo',2);
info = 0;
if options_.solve_algo == 0
if ~isempty(which('fsolve')) & sscanf(version('-release'),'%d') >= 13;
if ~isempty(which('fsolve'))
options=optimset('fsolve');
options.MaxFunEvals = 50000;
options.MaxIter = 2000;

View File

@ -0,0 +1,35 @@
function r = matlab_ver_less_than(verstr)
% function r = matlab_ver_less_than(verstr)
%
% Returns 1 if current Matlab version is strictly older than
% the one given in argument.
%
% It basically does the same job than verLessThan(), which is
% only available since Matlab 7.4.
%
% Note that this function will fail under Octave.
%
% INPUTS
% verstr: a string of the format 'x.y' or 'x.y.z'
%
% OUTPUTS
% r: 0 or 1
%
% SPECIAL REQUIREMENTS
% none
%
% part of DYNARE, copyright Dynare Team (2008)
% Gnu Public License.
ver_struct = ver('matlab');
cur_verstr = ver_struct.Version;
r = get_ver_numeric(cur_verstr) < get_ver_numeric(verstr);
function x = get_ver_numeric(verstr)
nums = sscanf(verstr, '%d.%d.%d')';
if length(nums) < 3
nums(3) = 0;
end
x = nums * [1; 0.01; 0.0001 ];

View File

@ -18,11 +18,7 @@ function options=set_default_option(options,field,default)
% Gnu Public License.
if ~isfield(options,field)
if ~exist('OCTAVE_VERSION') && sscanf(version('-release'),'%d') < 13
options = setfield(options,field,default);
else
eval('options.(field) = default;');
end
options.(field) = default;
end
% 06/07/03 MJ added ; to eval expression

View File

@ -22,10 +22,8 @@ function [Gamma_y,ivar]=th_autocovariances(dr,ivar,M_,options_)
exo_names_orig_ord = M_.exo_names_orig_ord;
if exist('OCTAVE_VERSION')
warning('off', 'Octave:divide-by-zero')
elseif sscanf(version('-release'),'%d') < 13
warning off
else
eval('warning off MATLAB:dividebyzero')
warning off MATLAB:dividebyzero
end
nar = options_.ar;
Gamma_y = cell(nar+1,1);
@ -202,9 +200,7 @@ function [Gamma_y,ivar]=th_autocovariances(dr,ivar,M_,options_)
end
if exist('OCTAVE_VERSION')
warning('on', 'Octave:divide-by-zero')
elseif sscanf(version('-release'),'%d') < 13
warning_config
else
eval('warning on MATLAB:dividebyzero')
warning on MATLAB:dividebyzero
end

View File

@ -2,14 +2,7 @@
% Copyright Dynare Team (2007-2008)
% GNU Public License
% Get Matlab version number in numeric format
% FIXME:
% It's not satisfactory to convert string versions into numbers, and to
% compare these numbers:
% - conversion will fail if version = 1.2.3
% - it will give 7.10 < 7.9
MATLAB = ver('matlab');
VERSION = str2num(MATLAB.Version);
addpath '../../matlab'; % For matlab_ver_less_than
MATLAB_PATH = matlabroot;
@ -19,7 +12,7 @@ if strcmpi('GLNX86', computer) || strcmpi('GLNXA64', computer) ...
|| strcmpi('MACI', computer) || strcmpi('MAC', computer)
% GNU/Linux (x86-32 or x86-64) or MacOS (Intel or PPC)
LAPACK_PATH = '-lmwlapack';
if VERSION <= 7.4
if matlab_ver_less_than('7.5')
BLAS_PATH = LAPACK_PATH; % On <= 7.4, BLAS in included in LAPACK
else
BLAS_PATH = '-lmwblas';
@ -28,7 +21,7 @@ elseif strcmpi('PCWIN', computer)
% Windows (x86-32) with Microsoft or gcc compiler
LIBRARY_PATH = [MATLAB_PATH '/extern/lib/win32/microsoft/'];
LAPACK_PATH = ['"' LIBRARY_PATH 'libmwlapack.lib"'];
if VERSION <= 7.4
if matlab_ver_less_than('7.5')
BLAS_PATH = LAPACK_PATH; % On <= 7.4, BLAS in included in LAPACK
else
BLAS_PATH = ['"' LIBRARY_PATH 'libmwblas.lib"'];
@ -38,21 +31,21 @@ else
end
% mwSize and mwIndex appeared in Matlab 7.3
if VERSION < 7.3
if matlab_ver_less_than('7.3')
COMPILE_OPTIONS = [ COMPILE_OPTIONS ' -DMWTYPES_NOT_DEFINED' ];
end
% Large array dims for 64 bits platforms appeared in Matlab 7.3
if strcmpi('GLNXA64', computer) && VERSION >= 7.3
if strcmpi('GLNXA64', computer) && ~matlab_ver_less_than('7.3')
COMPILE_OPTIONS = [ COMPILE_OPTIONS ' -largeArrayDims' ];
end
% blas.h and lapack.h appeared in Matlab 7.5
if VERSION < 7.5
if matlab_ver_less_than('7.5')
COMPILE_OPTIONS = [ COMPILE_OPTIONS ' -DNO_BLAS_H -DNO_LAPACK_H' ];
end
if VERSION <= 7.4
if matlab_ver_less_than('7.5')
OUTPUT_DIR = '../2007a';
else
OUTPUT_DIR = '../2007b';