initialize_dseries_class.m 3.31 KB
Newer Older
1
function initialize_dseries_class()
2

3
% Copyright (C) 2015-2019 Dynare Team
Stéphane Adjemian's avatar
Stéphane Adjemian committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17
%
% This code 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 dseries submodule 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/>.

18
% Get the path to the dseries toolbox.
19
dseries_src_root = strrep(which('initialize_dseries_class'),'initialize_dseries_class.m','');
20

21
% Set the subfolders to be added in the path.
22 23 24 25 26 27 28 29 30 31 32
p = {'read'; ...
     'utilities/is'; ...
     'utilities/op'; ...
     'utilities/convert'; ...
     'utilities/str'; ...
     'utilities/insert'; ...
     'utilities/file'; ...
     'utilities/from'; ...
     'utilities/print'; ...
     'utilities/variables'; ...
     'utilities/cumulate'; ...
33 34
     'utilities/struct'; ...
     'utilities/x13'};
35

36
% Add missing routines if dynare is not in the path
37 38 39 40 41
if ~exist('isint','file')
    p{end+1} = 'utilities/missing/isint';
end

if ~exist('isoctave','file')
42
    p{end+1} = 'utilities/missing/isoctave';
43 44 45 46 47 48 49 50 51 52
end

if ~exist('shiftS','file')
    p{end+1} = 'utilities/missing/shiftS';
end

if ~exist('matlab_ver_less_than','file')
    p{end+1} = 'utilities/missing/matlab_ver_less_than';
end

53
if ~exist('demean','file')
54
    p{end+1} = 'utilities/missing/demean';
55 56 57
end

if ~exist('ndim','file')
58 59 60
    p{end+1} = 'utilities/missing/ndim';
end

61
if ~exist('OCTAVE_VERSION') && (~exist('rows','file') || ~exist('columns','file'))
62
    p{end+1} = 'utilities/missing/dims';
63 64 65
end

if ~exist('sample_hp_filter','file')
66
    p{end+1} = 'utilities/missing/sample_hp_filter';
Stéphane Adjemian's avatar
Stéphane Adjemian committed
67 68
end

Stéphane Adjemian's avatar
Stéphane Adjemian committed
69
if ~exist('get_file_extension','file')
70
    p{end+1} = 'utilities/missing/get_file_extension';
Stéphane Adjemian's avatar
Stéphane Adjemian committed
71 72
end

73
if exist('OCTAVE_VERSION') && ~exist('user_has_octave_forge_package','file')
74
    p{end+1} = 'utilities/missing/user_has_octave_forge_package';
75
end
76 77

if ~exist('get_cells_id','file')
78
    p{end+1} = 'utilities/missing/get_cells_id';
79 80
end

81
if ~exist('randomstring','file')
82
    p{end+1} = 'utilities/missing/randomstring';
83 84
end

85
if ~exist('one_sided_hp_filter','file')
86
    p{end+1} = 'utilities/missing/one_sided_hp_filter';
87 88
end

89
if ~exist('OCTAVE_VERSION') && ~exist('ismatrix','builtin')
90 91 92
    p{end+1} = 'utilities/missing/ismatrix';
end

93
if ~exist('OCTAVE_VERSION') && ~exist('isrow','builtin')
94 95 96
    p{end+1} = 'utilities/missing/isrow';
end

97
if ~exist('OCTAVE_VERSION') && ~exist('iscolumn','builtin')
98 99 100
    p{end+1} = 'utilities/missing/iscolumn';
end

101 102 103 104 105 106 107 108
if ~exist('OCTAVE_VERSION') && ~exist('strsplit','file')
    p{end+1} = 'utilities/missing/strsplit';
end

if ~exist('OCTAVE_VERSION') && ~exist('strjoin','file')
    p{end+1} = 'utilities/missing/strjoin';
end

109
% Set path
110
P = cellfun(@(c)[dseries_src_root c], p, 'uni', false);
111 112
addpath(P{:});

113 114 115 116 117 118
% If x13 binary is not available, display a warning, and remove the x13
% subdirectory from the path
if isempty(select_x13_binary(true));
    rmpath([dseries_src_root 'utilities/x13']);
end

119
assignin('caller', 'dseries_src_root', dseries_src_root);