1function dynareroot = dynare_config(path_to_dynare) 2%function dynareroot = dynare_config(path_to_dynare) 3% 4% This function tests the existence of valid mex files (for qz 5% decomposition, solution to sylvester equation and kronecker 6% products...) and, if needed, add paths to the matlab versions 7% of these routines. 8% Also adds other directories to the path. 9% 10% INPUTS 11% none 12% 13% OUTPUTS 14% none 15% 16% SPECIAL REQUIREMENTS 17% none 18 19% Copyright (C) 2001-2020 Dynare Team 20% 21% This file is part of Dynare. 22% 23% Dynare is free software: you can redistribute it and/or modify 24% it under the terms of the GNU General Public License as published by 25% the Free Software Foundation, either version 3 of the License, or 26% (at your option) any later version. 27% 28% Dynare is distributed in the hope that it will be useful, 29% but WITHOUT ANY WARRANTY; without even the implied warranty of 30% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 31% GNU General Public License for more details. 32% 33% You should have received a copy of the GNU General Public License 34% along with Dynare. If not, see <http://www.gnu.org/licenses/>. 35 36if nargin && ~isempty(path_to_dynare) 37 addpath(path_to_dynare); 38end 39 40dynareroot = strrep(which('dynare'),'dynare.m',''); 41 42origin = pwd(); 43cd([dynareroot '/..']) 44 45p = {'/distributions/' ; ... 46 '/kalman/' ; ... 47 '/kalman/likelihood' ; ... 48 '/AIM/' ; ... 49 '/partial_information/' ; ... 50 '/perfect-foresight-models/' ; ... 51 '/ms-sbvar/' ; ... 52 '/ms-sbvar/identification/' ; ... 53 '/../contrib/ms-sbvar/TZcode/MatlabFiles/' ; ... 54 '/../contrib/jsonlab/' ; ... 55 '/parallel/' ; ... 56 '/particles/src' ; ... 57 '/gsa/' ; ... 58 '/ep/' ; ... 59 '/backward/' ; ... 60 '/convergence_diagnostics/' ; ... 61 '/cli/' ; ... 62 '/lmmcp/' ; ... 63 '/optimization/' ; ... 64 '/discretionary_policy/' ; ... 65 '/accessors/' ; ... 66 '/modules/dseries/src/' ; ... 67 '/utilities/doc/' ; ... 68 '/utilities/tests/src/' ; ... 69 '/utilities/dataset/' ; ... 70 '/utilities/general/' ; ... 71 '/utilities/graphics/' ; ... 72 '/modules/reporting/src/' ; ... 73 '/modules/reporting/macros/'}; 74 75% For functions that exist only under some Octave versions 76% or some MATLAB versions, and for which we provide some replacement functions 77 78% Replacements for rows(), columns(), vec() and issquare() (inexistent under MATLAB) 79if ~isoctave 80 p{end+1} = '/missing/rows_columns'; 81 p{end+1} = '/missing/issquare'; 82 p{end+1} = '/missing/vec'; 83end 84 85% ordeig() doesn't exist in Octave < 5 86if isoctave && octave_ver_less_than('5') 87 p{end+1} = '/missing/ordeig'; 88end 89 90% corrcoef with two outputs is missing in Octave < 4.4 (ticket #796) 91if isoctave && octave_ver_less_than('4.4') && ~user_has_octave_forge_package('nan') 92 p{end+1} = '/missing/corrcoef'; 93end 94 95%% intersect(…, 'stable') doesn't exist in Octave < 6 and in MATLAB < R2013a 96if (isoctave && octave_ver_less_than('6')) || (~isoctave && matlab_ver_less_than('8.1')) 97 p{end+1} = '/missing/intersect_stable'; 98end 99 100% Replacements for functions of the MATLAB statistics toolbox 101if isoctave 102 % These functions were part of Octave < 4.4, they are now in the statistics Forge package 103 if ~octave_ver_less_than('4.4') && ~user_has_octave_forge_package('statistics') 104 % Our replacement functions don't work under Octave (because of gamrnd, see 105 % #1638), hence the statistics toolbox is now a hard requirement 106 error('You must install the "statistics" package from Octave Forge, either with your distribution package manager or with "pkg install -forge io statistics"') 107 end 108else 109 if ~user_has_matlab_license('statistics_toolbox') 110 p{end+1} = '/missing/stats/'; 111 end 112end 113 114% Check if struct2array is available. 115if ~exist('struct2array') 116 p{end+1} = '/missing/struct2array'; 117end 118 119% isfile is missing in Octave < 5 and Matlab < R2017b 120if (isoctave && octave_ver_less_than('5')) || (~isoctave && matlab_ver_less_than('9.3')) 121 p{end+1} = '/missing/isfile'; 122end 123 124% strsplit and strjoin are missing in MATLAB < R2013a 125if ~isoctave && matlab_ver_less_than('8.1') 126 p{end+1} = '/missing/strsplit'; 127 p{end+1} = '/missing/strjoin'; 128end 129 130% contains and splitlines don't exist in Octave and in MATLAB < R2016b 131if isoctave || matlab_ver_less_than('9.1') 132 p{end+1} = '/missing/contains'; 133 p{end+1} = '/missing/splitlines'; 134end 135 136% isrow, iscolumn and ismatrix are missing in Matlab<R2010b 137if ~isoctave && matlab_ver_less_than('7.11') 138 p{end+1} = '/missing/is-row-column-matrix'; 139end 140 141%% isdiag is missing in MATLAB < R2014a 142if ~isoctave && matlab_ver_less_than('8.3') 143 p{end+1} = '/missing/isdiag'; 144end 145 146%% narginchk is missing in MATLAB < R2011b 147if ~isoctave && matlab_ver_less_than('7.13') 148 p{end+1} = '/missing/narginchk'; 149end 150 151P = cellfun(@(c)[dynareroot(1:end-1) c], p, 'uni',false); 152 153% Get mex files folder(s) 154mexpaths = add_path_to_mex_files(dynareroot, false); 155 156% Add mex files folder(s) 157P(end+1:end+length(mexpaths)) = mexpaths; 158 159% Set matlab's path 160addpath(P{:}); 161 162% Initialization of the dates and dseries classes (recursive). 163initialize_dseries_class(); 164 165cd(origin); 166