Added initialization script and missing routines (if Dynare is not in the path). Fixes #1.

parent 56133950
% Get the path to the dates/src folder.
dates_src_root = strrep(which('initialize_dates_toolbox'),'initialize_dates_toolbox.m','');
% Add some subfolders to the path.
addpath([dates_src_root '/utilities/is'])
addpath([dates_src_root '/utilities/op'])
addpath([dates_src_root '/utilities/convert'])
% Add empty dates object in the base workspace
dates('initialize');
% Add missing routines if dynare is not in the path
if ~exist('isint','file')
addpath([dates_src_root '/utilities/missing/isint'])
end
if ~exist('rows','file') || ~exist('columns','file')
addpath([dates_src_root '/utilities/missing/dims'])
end
if ~exist('isoctave','file')
addpath([dates_src_root '/utilities/missing/isoctave'])
end
if ~exist('shiftS','file')
addpath([dates_src_root '/utilities/missing/shiftS'])
end
if ~exist('matlab_ver_less_than','file')
addpath([dates_src_root '/utilities/missing/matlab_ver_less_than'])
end
\ No newline at end of file
function c = columns(M)
% Computes the number of columns of a matrix
% Copyright (C) 2005-2014 Dynare Team
%
% 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 dates 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/>.
c = size(M,2);
\ No newline at end of file
function r = rows(x)
% Computes the number of rows of a matrix
% Copyright (C) 2005-2014 Dynare Team
%
% 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 dates 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/>.
r = size(x,1);
function [l,c,d] = isint(a)
% This function tests if the input argument is an integer.
%
% INPUT
% - a [double] m*n matrix.
%
% OUTPUT
% - l [logical] m*n matrix of true and false (1 and 0). l(i,j)=true if a(i,j) is an integer.
% - c [integer] p*1 vector of indices pointing to the integer elements of a.
% - d [integer] q*1 vector of indices pointing to the non integer elements of a.
%
% REMARKS
% p+q is equal to the product of m by n.
% Copyright (C) 2009-2014 Dynare Team
%
% 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 dates 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/>.
if ~isnumeric(a)
b = false;
if nargout>1
c = [];
d = [];
end
return
end
l = abs(fix(a)-a)<1e-15;
if nargout>1
c = find(b==1);
d = find(b==0);
end
\ No newline at end of file
function l = isoctave()
% Tests if Octave is used.
% Copyright (C) 2013-2014 Dynare Team
%
% 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 dates 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/>.
l = exist('OCTAVE_VERSION');
\ No newline at end of file
function r = matlab_ver_less_than(verstr)
% Returns 1 if current Matlab version is strictly older than the one given in argument.
%
% INPUTS
% - verstr [string] Matlab's version as 'x.y' or 'x.y.z'
%
% OUTPUTS
% - r [logical] true or false (0 or 1)
%
% REMARKS
% 1. This function will fail under Octave.
% Copyright (C) 2008-2014 Dynare Team
%
% 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 dates 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/>.
r = verLessThan('matlab', verstr);
\ No newline at end of file
function S = shiftS(S,n)
% Removes the first n elements of a one dimensional cell array.
% Copyright (C) 2009-2014 Dynare Team
%
% 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 dates 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/>.
if length(S) >= n+1
S = S(n+1:end);
else
S = {};
end
\ No newline at end of file
Markdown is supported
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