2019-09-03 11:19:46 +02:00
function dynareroot = dynare_config ( path_to_dynare)
%function dynareroot = dynare_config(path_to_dynare)
%
2008-05-16 10:18:37 +02:00
% This function tests the existence of valid mex files (for qz
% decomposition, solution to sylvester equation and kronecker
% products...) and, if needed, add paths to the matlab versions
% of these routines.
2008-08-04 15:33:57 +02:00
% Also adds other directories to the path.
2008-05-16 10:18:37 +02:00
%
% INPUTS
% none
2011-08-11 15:10:57 +02:00
%
2008-05-16 10:18:37 +02:00
% OUTPUTS
% none
2011-08-11 15:10:57 +02:00
%
2008-05-16 10:18:37 +02:00
% SPECIAL REQUIREMENTS
% none
2008-08-01 14:40:33 +02:00
2023-09-27 13:24:14 +02:00
% Copyright © 2001-2023 Dynare Team
2008-08-01 14:40:33 +02:00
%
% 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
2021-06-09 17:33:48 +02:00
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
2008-08-01 14:40:33 +02:00
2011-07-26 11:07:27 +02:00
if nargin && ~ isempty ( path_to_dynare )
2008-05-16 10:18:37 +02:00
addpath ( path_to_dynare ) ;
end
2015-03-30 14:54:14 +02:00
2009-07-03 12:36:11 +02:00
dynareroot = strrep ( which ( ' dynare' ) , ' dynare.m' , ' ' ) ;
2008-06-24 20:20:48 +02:00
2011-12-21 18:31:29 +01:00
origin = pwd ( ) ;
cd ( [ dynareroot ' /..' ] )
2023-11-30 16:52:02 +01:00
p = { ' /../contrib/ms-sbvar/TZcode/MatlabFiles/' ; ...
2023-09-06 15:11:06 +02:00
' /accessors/' ; ...
' /AIM/' ; ...
' /backward/' ; ...
' /cli/' ; ...
' /convergence_diagnostics/' ; ...
' /discretionary_policy/' ; ...
' /distributions/' ; ...
' /ep/' ; ...
2023-04-10 20:59:05 +02:00
' /estimation/' ; ...
' /estimation/smc/' ; ...
' /estimation/resampler/' ; ...
2016-06-16 23:55:07 +02:00
' /kalman/' ; ...
' /kalman/likelihood' ; ...
2023-12-08 10:06:00 +01:00
' /latex/' ; ...
2023-09-06 15:11:06 +02:00
' /lmmcp/' ; ...
2023-12-16 22:30:12 +01:00
' /dseries/src/' ; ...
2023-11-17 11:56:42 +01:00
' /reporting/' ; ...
2023-12-08 10:06:00 +01:00
' /matrix_solver/' ; ...
2023-09-07 08:01:18 +02:00
' /moments/' ; ...
2016-06-16 23:55:07 +02:00
' /ms-sbvar/' ; ...
' /ms-sbvar/identification/' ; ...
2023-07-12 13:53:52 +02:00
' /nonlinear-filters/' ; ...
2020-09-17 14:53:32 +02:00
' /ols/' ; ...
2023-12-08 10:06:00 +01:00
' /optimal_policy/' ; ...
2023-09-06 15:11:06 +02:00
' /optimization/' ; ...
2020-09-17 14:53:32 +02:00
' /pac-tools/' ; ...
2023-09-06 15:11:06 +02:00
' /parallel/' ; ...
' /partial_information/' ; ...
' /perfect-foresight-models/' ; ...
2023-12-08 10:06:00 +01:00
' /shock_decomposition/' ; ...
' /stochastic_solver/' ; ...
2016-06-16 23:55:07 +02:00
' /utilities/dataset/' ; ...
2023-09-06 15:11:06 +02:00
' /utilities/doc/' ; ...
' /utilities/estimation/' ; ...
2016-06-16 23:55:07 +02:00
' /utilities/general/' ; ...
2017-01-06 11:09:04 +01:00
' /utilities/graphics/' ; ...
2023-09-06 15:11:06 +02:00
' /utilities/tests/src/' ; ...
' /utilities/version/' } ;
2008-10-13 20:54:42 +02:00
2009-07-03 12:20:42 +02:00
% For functions that exist only under some Octave versions
% or some MATLAB versions, and for which we provide some replacement functions
2018-06-05 19:46:09 +02:00
% Replacements for rows(), columns(), vec() and issquare() (inexistent under MATLAB)
2013-11-04 10:54:45 +01:00
if ~ isoctave
2016-06-16 23:55:07 +02:00
p { end + 1 } = ' /missing/rows_columns' ;
p { end + 1 } = ' /missing/issquare' ;
p { end + 1 } = ' /missing/vec' ;
2008-07-28 11:46:07 +02:00
end
2018-06-05 19:46:09 +02:00
% Replacements for functions of the MATLAB statistics toolbox
2019-02-18 17:33:52 +01:00
if isoctave
2020-01-06 14:32:22 +01:00
% Under Octave, these functions are in the statistics Forge package.
% Our replacement functions don't work under Octave (because of gamrnd, see
% #1638), hence the statistics toolbox is now a hard requirement
if ~ user_has_octave_forge_package ( ' statistics' )
2021-02-19 14:23:58 +01:00
error ( ' You must install the "statistics" package from Octave Forge, either with your distribution package manager or with "pkg install -forge io statistics"' )
2019-02-18 17:33:52 +01:00
end
else
if ~ user_has_matlab_license ( ' statistics_toolbox' )
p { end + 1 } = ' /missing/stats/' ;
2018-06-06 13:02:42 +02:00
end
2018-06-05 19:46:09 +02:00
end
2017-03-22 15:20:13 +01:00
% Check if struct2array is available.
if ~ exist ( ' struct2array' )
p { end + 1 } = ' /missing/struct2array' ;
end
2023-11-22 13:24:52 +01:00
% contains and splitlines don't exist in Octave
if isoctave
2019-11-13 11:43:27 +01:00
p { end + 1 } = ' /missing/contains' ;
p { end + 1 } = ' /missing/splitlines' ;
end
2023-11-22 13:24:52 +01:00
% datetime doesn't exist in Octave
if isoctave
2021-01-15 17:41:35 +01:00
p { end + 1 } = ' /missing/datetime' ;
end
2023-10-08 18:18:43 +02:00
% intersect with 'stable' flag is broken before Octave 8.4, bug #60347
if isoctave && octave_ver_less_than ( ' 8.4' )
p { end + 1 } = ' /missing/intersect_stable' ;
end
2016-06-17 21:59:29 +02:00
P = cellfun ( @ ( c ) [ dynareroot ( 1 : end - 1 ) c ] , p , ' uni' , false ) ;
2016-06-16 23:55:07 +02:00
2016-06-17 21:59:29 +02:00
% Get mex files folder(s)
2023-09-27 13:24:14 +02:00
mexpaths = get_path_to_mex_files ( dynareroot ) ;
2016-06-16 23:55:07 +02:00
2016-06-17 21:59:29 +02:00
% Add mex files folder(s)
P ( end + 1 : end + length ( mexpaths ) ) = mexpaths ;
% Set matlab's path
2016-06-16 23:55:07 +02:00
addpath ( P { : } ) ;
2009-03-11 15:57:34 +01:00
2015-06-24 19:02:42 +02:00
% Initialization of the dates and dseries classes (recursive).
2019-02-10 00:02:05 +01:00
initialize_dseries_class ( ) ;
2014-05-14 12:36:06 +02:00
2018-03-12 21:24:38 +01:00
cd ( origin ) ;