Commit 01bfd371 authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Changed name of dynDates class to dynDate. dynDates will be used latter for...

Changed name of dynDates class to dynDate. dynDates will be used latter for irregular and unsorted sequence of dates.
parent ead128ee
......@@ -2,17 +2,17 @@ function sp = colon(a,b)
%@info:
%! @deftypefn {Function File} {@var{sp} =} colon (@var{a},@var{b})
%! @anchor{@dynDates/colon}
%! @anchor{@dynDate/colon}
%! @sp 1
%! Overloads the colon operator for the Dynare Dates class (@ref{dynDates}). Creates a @ref{dynTime} object.
%! Overloads the colon operator for the Dynare Dates class (@ref{dynDate}). Creates a @ref{dynTime} object.
%! @sp 2
%! @strong{Inputs}
%! @sp 1
%! @table @ @var
%! @item a
%! Dynare date object instantiated by @ref{dynDates}, initial date.
%! Dynare date object instantiated by @ref{dynDate}, initial date.
%! @item b
%! Dynare date object instantiated by @ref{dynDates}, last date.
%! Dynare date object instantiated by @ref{dynDate}, last date.
%! @end table
%! @sp 1
%! @strong{Outputs}
......@@ -52,8 +52,8 @@ if nargin~=2
error('dynTime::colon: I need exactly two input arguments!')
end
if ~( isa(a,'dynDates') && isa(b,'dynDates'))
error(['dynTime::colon: Input arguments ' inputname(1) 'and ' inputname(2) ' have to be a dynDates objects!'])
if ~( isa(a,'dynDate') && isa(b,'dynDate'))
error(['dynTime::colon: Input arguments ' inputname(1) 'and ' inputname(2) ' have to be a dynDate objects!'])
end
if a.freq~=b.freq
......@@ -93,8 +93,8 @@ end
%$ e.time = [1950 2; 1950 3; 1950 4; 1951 1; 1951 2; 1951 3; 1951 4];
%$
%$ % Call the tested routine.
%$ d1 = dynDates(date_1);
%$ d2 = dynDates(date_2);
%$ d1 = dynDate(date_1);
%$ d2 = dynDate(date_2);
%$ d3 = d1:d2;
%$
%$ % Check the results.
......
function date = dynDates(a)
function date = dynDate(a)
%@info:
%! @deftypefn {Function File} {@var{date} =} dynDate (@var{a})
%! @anchor{dynDates}
%! @anchor{dynDate}
%! @sp 1
%! Constructor for the Dynare dates class.
%! @sp 2
......@@ -11,8 +11,8 @@ function date = dynDates(a)
%! @table @ @var
%! @item a
%! Date. For Quaterly, Monthly or Weekly data, a must be a string. For yearly data or if the frequence is not
%! defined must be an integer. If @var{a} is a dynDates object, then date will be a copy of this object. If
%! the constructor is called without input argument, it will return an empty dynDates object.
%! defined must be an integer. If @var{a} is a dynDate object, then date will be a copy of this object. If
%! the constructor is called without input argument, it will return an empty dynDate object.
%! @end table
%! @sp 1
%! @strong{Outputs}
......@@ -66,7 +66,7 @@ date = struct;
date.freq = NaN;
date.time = NaN(1,2);
date = class(date,'dynDates');
date = class(date,'dynDate');
switch nargin
case 0
......@@ -93,7 +93,7 @@ switch nargin
end
if isempty(quaterly) && isempty(monthly) && isempty(weekly)
if any(isletter(a))
error('dynDates:: Using a string as an input argument, I can only handle weekly (W), monthly (M) or quaterly (Q) data!');
error('dynDate:: Using a string as an input argument, I can only handle weekly (W), monthly (M) or quaterly (Q) data!');
else
% Yearly data declared with a string
date.freq = 1;
......@@ -101,7 +101,7 @@ switch nargin
date.time(2) = 1;
end
end
elseif isa(a,'dynDates') % If input argument is a dynDates object then do a copy.
elseif isa(a,'dynDate') % If input argument is a dynDate object then do a copy.
date = a;
else% If b is not a string then yearly data are assumed.
date.freq = 1;
......@@ -109,7 +109,7 @@ switch nargin
date.time(2) = 1;
end
otherwise
error('dynDates:: Can''t instantiate the class, wrong calling sequence!')
error('dynDate:: Can''t instantiate the class, wrong calling sequence!')
end
%@test:1
......@@ -135,11 +135,11 @@ end
%$ e_freq_5 = 1;
%$
%$ % Call the tested routine.
%$ d1 = dynDates(date_1);
%$ d2 = dynDates(date_2);
%$ d3 = dynDates(date_3);
%$ d4 = dynDates(date_4);
%$ d5 = dynDates(date_5);
%$ d1 = dynDate(date_1);
%$ d2 = dynDate(date_2);
%$ d3 = dynDate(date_3);
%$ d4 = dynDate(date_4);
%$ d5 = dynDate(date_5);
%$
%$ % Check the results.
%$ t(1) = dyn_assert(d1.time,e_date_1);
......
......@@ -2,17 +2,17 @@ function c = eq(a,b)
%@info:
%! @deftypefn {Function File} {@var{c} =} eq (@var{a},@var{b})
%! @anchor{@dynDates/eq}
%! @anchor{@dynDate/eq}
%! @sp 1
%! Overloads the eq (equal) operator for the Dynare dates class (@ref{dynDates}).
%! Overloads the eq (equal) operator for the Dynare dates class (@ref{dynDate}).
%! @sp 2
%! @strong{Inputs}
%! @sp 1
%! @table @ @var
%! @item a
%! Dynare date object instantiated by @ref{dynDates}.
%! Dynare date object instantiated by @ref{dynDate}.
%! @item b
%! Dynare date object instantiated by @ref{dynDates}.
%! Dynare date object instantiated by @ref{dynDate}.
%! @end table
%! @sp 1
%! @strong{Outputs}
......@@ -50,15 +50,15 @@ function c = eq(a,b)
verbose = 0;
if nargin~=2
error('dynDates::eq: I need exactly two input arguments!')
error('dynDate::eq: I need exactly two input arguments!')
end
if ~( isa(a,'dynDates') && isa(b,'dynDates'))
error(['dynDates::eq: Input arguments ' inputname(1) 'and ' inputname(2) ' have to be a dynDates objects!'])
if ~( isa(a,'dynDate') && isa(b,'dynDate'))
error(['dynDate::eq: Input arguments ' inputname(1) 'and ' inputname(2) ' have to be a dynDate objects!'])
end
if verbose && a.freq~=b.freq
disp(['dynDates::eq: Input arguments ' inputname(1) 'and ' inputname(2) ' have no common frequencies!'])
disp(['dynDate::eq: Input arguments ' inputname(1) 'and ' inputname(2) ' have no common frequencies!'])
c = 0;
end
......@@ -75,11 +75,11 @@ c = isequal(a.time,b.time);
%$ date_5 = '1950W32';
%$
%$ % Call the tested routine.
%$ d1 = dynDates(date_1);
%$ d2 = dynDates(date_2);
%$ d3 = dynDates(date_3);
%$ d4 = dynDates(date_4);
%$ d5 = dynDates(date_5);
%$ d1 = dynDate(date_1);
%$ d2 = dynDate(date_2);
%$ d3 = dynDate(date_3);
%$ d4 = dynDate(date_4);
%$ d5 = dynDate(date_5);
%$ i1 = (d1==d2);
%$ i2 = (d2==d2);
%$ i3 = (d4==d5);
......
......@@ -2,15 +2,15 @@ function p = format(date)
%@info:
%! @deftypefn {Function File} {@var{p} =} format (@var{date})
%! @anchor{@dynDates/format}
%! @anchor{@dynDate/format}
%! @sp 1
%! Produces a formatted date from a Dynare date object instantiated by @ref{dynDates}.
%! Produces a formatted date from a Dynare date object instantiated by @ref{dynDate}.
%! @sp 2
%! @strong{Inputs}
%! @sp 1
%! @table @ @var
%! @item date
%! Dynare date object, instantiated by @ref{dynDates}.
%! Dynare date object, instantiated by @ref{dynDate}.
%! @end table
%! @sp 1
%! @strong{Outputs}
......@@ -47,11 +47,11 @@ function p = format(date)
if nargin~=1
error('dynDates::format: I need exactly one input argument!')
error('dynDate::format: I need exactly one input argument!')
end
if ~isa(date,'dynDates')
error(['dynDates::format: Input argument ' inputname(1) ' has to be a dynDates object!'])
if ~isa(date,'dynDate')
error(['dynDate::format: Input argument ' inputname(1) ' has to be a dynDate object!'])
end
switch date.freq
......@@ -64,7 +64,7 @@ switch date.freq
case 52
p = [num2str(date.time(1)) 'W' num2str(date.time(2))];
otherwise
error('dynDates::format: Unkonwn frequency!')
error('dynDate::format: Unkonwn frequency!')
end
%@test:1
......@@ -77,10 +77,10 @@ end
%$ date_4 = '1950W50';
%$
%$ % Call the tested routine.
%$ d1 = dynDates(date_1); DATE_1 = format(d1);
%$ d2 = dynDates(date_2); DATE_2 = format(d2);
%$ d3 = dynDates(date_3); DATE_3 = format(d3);
%$ d4 = dynDates(date_4); DATE_4 = format(d4);
%$ d1 = dynDate(date_1); DATE_1 = format(d1);
%$ d2 = dynDate(date_2); DATE_2 = format(d2);
%$ d3 = dynDate(date_3); DATE_3 = format(d3);
%$ d4 = dynDate(date_4); DATE_4 = format(d4);
%$
%$ % Check the results.
%$ t(1) = dyn_assert(num2str(date_1),DATE_1);
......
......@@ -2,17 +2,17 @@ function c = ge(a,b)
%@info:
%! @deftypefn {Function File} {@var{c} =} ge (@var{a},@var{b})
%! @anchor{@dynDates/ge}
%! @anchor{@dynDate/ge}
%! @sp 1
%! Overloads the ge (greater or equal) operator for the Dynare dates class (@ref{dynDates}).
%! Overloads the ge (greater or equal) operator for the Dynare dates class (@ref{dynDate}).
%! @sp 2
%! @strong{Inputs}
%! @sp 1
%! @table @ @var
%! @item a
%! Dynare date object instantiated by @ref{dynDates}.
%! Dynare date object instantiated by @ref{dynDate}.
%! @item b
%! Dynare date object instantiated by @ref{dynDates}.
%! Dynare date object instantiated by @ref{dynDate}.
%! @end table
%! @sp 1
%! @strong{Outputs}
......@@ -25,7 +25,7 @@ function c = ge(a,b)
%! @strong{This function is called by:}
%! @sp 2
%! @strong{This function calls:}
%! @ref{@@dynDates/gt}, @ref{@@dynDates/eq}
%! @ref{@@dynDate/gt}, @ref{@@dynDate/eq}
%!
%! @end deftypefn
%@eod:
......@@ -68,10 +68,10 @@ end
%$ date_4 = '1949Q2';
%$
%$ % Call the tested routine.
%$ d1 = dynDates(date_1);
%$ d2 = dynDates(date_2);
%$ d3 = dynDates(date_3);
%$ d4 = dynDates(date_4);
%$ d1 = dynDate(date_1);
%$ d2 = dynDate(date_2);
%$ d3 = dynDate(date_3);
%$ d4 = dynDate(date_4);
%$ i1 = (d1>=d2);
%$ i2 = (d3>=d4);
%$ i3 = (d4>=d2);
......
......@@ -2,17 +2,17 @@ function c = gt(a,b)
%@info:
%! @deftypefn {Function File} {@var{c} =} gt (@var{a},@var{b})
%! @anchor{@dynDates/gt}
%! @anchor{@dynDate/gt}
%! @sp 1
%! Overloads the gt (greater than) operator for the Dynare dates class (@ref{dynDates}).
%! Overloads the gt (greater than) operator for the Dynare dates class (@ref{dynDate}).
%! @sp 2
%! @strong{Inputs}
%! @sp 1
%! @table @ @var
%! @item a
%! Dynare date object instantiated by @ref{dynDates}.
%! Dynare date object instantiated by @ref{dynDate}.
%! @item b
%! Dynare date object instantiated by @ref{dynDates}.
%! Dynare date object instantiated by @ref{dynDate}.
%! @end table
%! @sp 1
%! @strong{Outputs}
......@@ -50,15 +50,15 @@ function c = gt(a,b)
verbose = 0;
if nargin~=2
error('dynDates::eq: I need exactly two input arguments!')
error('dynDate::eq: I need exactly two input arguments!')
end
if ~( isa(a,'dynDates') && isa(b,'dynDates'))
error(['dynDates::eq: Input arguments ' inputname(1) 'and ' inputname(2) ' have to be a dynDates objects!'])
if ~( isa(a,'dynDate') && isa(b,'dynDate'))
error(['dynDate::eq: Input arguments ' inputname(1) 'and ' inputname(2) ' have to be a dynDate objects!'])
end
if verbose && a.freq~=b.freq
error(['dynDates::eq: Input arguments ' inputname(1) 'and ' inputname(2) ' have no common frequencies!'])
error(['dynDate::eq: Input arguments ' inputname(1) 'and ' inputname(2) ' have no common frequencies!'])
end
if a.time(1)>b.time(1)
......@@ -84,11 +84,11 @@ end
%$ date_5 = '1949Q2';
%$
%$ % Call the tested routine.
%$ d1 = dynDates(date_1);
%$ d2 = dynDates(date_2);
%$ d3 = dynDates(date_3);
%$ d4 = dynDates(date_4);
%$ d5 = dynDates(date_5);
%$ d1 = dynDate(date_1);
%$ d2 = dynDate(date_2);
%$ d3 = dynDate(date_3);
%$ d4 = dynDate(date_4);
%$ d5 = dynDate(date_5);
%$ i1 = (d2>d3);
%$ i2 = (d3>d4);
%$ i3 = (d4>d2);
......
......@@ -2,17 +2,17 @@ function c = le(a,b)
%@info:
%! @deftypefn {Function File} {@var{c} =} le (@var{a},@var{b})
%! @anchor{@dynDates/le}
%! @anchor{@dynDate/le}
%! @sp 1
%! Overloads the le (less or equal) operator for the Dynare dates class (@ref{dynDates}).
%! Overloads the le (less or equal) operator for the Dynare dates class (@ref{dynDate}).
%! @sp 2
%! @strong{Inputs}
%! @sp 1
%! @table @ @var
%! @item a
%! Dynare date object instantiated by @ref{dynDates}.
%! Dynare date object instantiated by @ref{dynDate}.
%! @item b
%! Dynare date object instantiated by @ref{dynDates}.
%! Dynare date object instantiated by @ref{dynDate}.
%! @end table
%! @sp 1
%! @strong{Outputs}
......@@ -25,7 +25,7 @@ function c = le(a,b)
%! @strong{This function is called by:}
%! @sp 2
%! @strong{This function calls:}
%! @ref{@@dynDates/lt}, @ref{@@dynDates/eq}
%! @ref{@@dynDate/lt}, @ref{@@dynDate/eq}
%!
%! @end deftypefn
%@eod:
......@@ -68,10 +68,10 @@ end
%$ date_4 = '1949Q2';
%$
%$ % Call the tested routine.
%$ d1 = dynDates(date_1);
%$ d2 = dynDates(date_2);
%$ d3 = dynDates(date_3);
%$ d4 = dynDates(date_4);
%$ d1 = dynDate(date_1);
%$ d2 = dynDate(date_2);
%$ d3 = dynDate(date_3);
%$ d4 = dynDate(date_4);
%$ i1 = (d1<=d2);
%$ i2 = (d3<=d4);
%$ i3 = (d4<=d2);
......
......@@ -2,17 +2,17 @@ function c = lt(a,b)
%@info:
%! @deftypefn {Function File} {@var{c} =} lt (@var{a},@var{b})
%! @anchor{@dynDates/lt}
%! @anchor{@dynDate/lt}
%! @sp 1
%! Overloads the lt (less than) operator for the Dynare dates class (@ref{dynDates}).
%! Overloads the lt (less than) operator for the Dynare dates class (@ref{dynDate}).
%! @sp 2
%! @strong{Inputs}
%! @sp 1
%! @table @ @var
%! @item a
%! Dynare date object instantiated by @ref{dynDates}.
%! Dynare date object instantiated by @ref{dynDate}.
%! @item b
%! Dynare date object instantiated by @ref{dynDates}.
%! Dynare date object instantiated by @ref{dynDate}.
%! @end table
%! @sp 1
%! @strong{Outputs}
......@@ -50,15 +50,15 @@ function c = lt(a,b)
verbose = 0;
if nargin~=2
error('dynDates::eq: I need exactly two input arguments!')
error('dynDate::eq: I need exactly two input arguments!')
end
if ~( isa(a,'dynDates') && isa(b,'dynDates'))
error(['dynDates::eq: Input arguments ' inputname(1) 'and ' inputname(2) ' have to be a dynDates objects!'])
if ~( isa(a,'dynDate') && isa(b,'dynDate'))
error(['dynDate::eq: Input arguments ' inputname(1) 'and ' inputname(2) ' have to be a dynDate objects!'])
end
if verbose && a.freq~=b.freq
error(['dynDates::eq: Input arguments ' inputname(1) 'and ' inputname(2) ' have no common frequencies!'])
error(['dynDate::eq: Input arguments ' inputname(1) 'and ' inputname(2) ' have no common frequencies!'])
end
if a.time(1)<b.time(1)
......@@ -84,11 +84,11 @@ end
%$ date_5 = '1949Q2';
%$
%$ % Call the tested routine.
%$ d1 = dynDates(date_1);
%$ d2 = dynDates(date_2);
%$ d3 = dynDates(date_3);
%$ d4 = dynDates(date_4);
%$ d5 = dynDates(date_5);
%$ d1 = dynDate(date_1);
%$ d2 = dynDate(date_2);
%$ d3 = dynDate(date_3);
%$ d4 = dynDate(date_4);
%$ d5 = dynDate(date_5);
%$ i1 = (d2<d3);
%$ i2 = (d3<d4);
%$ i3 = (d4<d2);
......
......@@ -2,24 +2,24 @@ function c = max(a,b)
%@info:
%! @deftypefn {Function File} {@var{c} =} max (@var{a},@var{b})
%! @anchor{@dynDates/gt}
%! @anchor{@dynDate/gt}
%! @sp 1
%! Overloads the max function for the Dynare dates class @ref{dynDates}.
%! Overloads the max function for the Dynare dates class @ref{dynDate}.
%! @sp 2
%! @strong{Inputs}
%! @sp 1
%! @table @ @var
%! @item a
%! Dynare date object instantiated by @ref{dynDates}.
%! Dynare date object instantiated by @ref{dynDate}.
%! @item b
%! Dynare date object instantiated by @ref{dynDates}.
%! Dynare date object instantiated by @ref{dynDate}.
%! @end table
%! @sp 1
%! @strong{Outputs}
%! @sp 1
%! @table @ @var
%! @item c
%! Dynare date object instantiated by @ref{dynDates}. @var{c} is a copy of @var{a} if @var{a}>=@var{b}, a copy of @var{b} otherwise.
%! Dynare date object instantiated by @ref{dynDate}. @var{c} is a copy of @var{a} if @var{a}>=@var{b}, a copy of @var{b} otherwise.
%! @end table
%! @sp 2
%! @strong{This function is called by:}
......@@ -50,15 +50,15 @@ function c = max(a,b)
verbose = 0;
if nargin~=2
error('dynDates::min: I need exactly two input arguments!')
error('dynDate::min: I need exactly two input arguments!')
end
if ~( isa(a,'dynDates') && isa(b,'dynDates'))
error(['dynDates::min: Input arguments ' inputname(1) 'and ' inputname(2) ' have to be a dynDates objects!'])
if ~( isa(a,'dynDate') && isa(b,'dynDate'))
error(['dynDate::min: Input arguments ' inputname(1) 'and ' inputname(2) ' have to be a dynDate objects!'])
end
if verbose && a.freq~=b.freq
error(['dynDates::min: Input arguments ' inputname(1) 'and ' inputname(2) ' have no common frequencies!'])
error(['dynDate::min: Input arguments ' inputname(1) 'and ' inputname(2) ' have no common frequencies!'])
end
if a>=b
......@@ -79,12 +79,12 @@ end
%$ date_6 = '1948M6';
%$
%$ % Call the tested routine.
%$ d1 = dynDates(date_1);
%$ d2 = dynDates(date_2);
%$ d3 = dynDates(date_3);
%$ d4 = dynDates(date_4);
%$ d5 = dynDates(date_5);
%$ d6 = dynDates(date_6);
%$ d1 = dynDate(date_1);
%$ d2 = dynDate(date_2);
%$ d3 = dynDate(date_3);
%$ d4 = dynDate(date_4);
%$ d5 = dynDate(date_5);
%$ d6 = dynDate(date_6);
%$ m1 = max(d1,d2);
%$ i1 = (m1==d2);
%$ m2 = max(d3,d4);
......
......@@ -2,24 +2,24 @@ function c = min(a,b)
%@info:
%! @deftypefn {Function File} {@var{c} =} min (@var{a},@var{b})
%! @anchor{@dynDates/gt}
%! @anchor{@dynDate/gt}
%! @sp 1
%! Overloads the min function for the Dynare dates class (@ref{dynDates}).
%! Overloads the min function for the Dynare dates class (@ref{dynDate}).
%! @sp 2
%! @strong{Inputs}
%! @sp 1
%! @table @ @var
%! @item a
%! Dynare date object instantiated by @ref{dynDates}.
%! Dynare date object instantiated by @ref{dynDate}.
%! @item b
%! Dynare date object instantiated by @ref{dynDates}.
%! Dynare date object instantiated by @ref{dynDate}.
%! @end table
%! @sp 1
%! @strong{Outputs}
%! @sp 1
%! @table @ @var
%! @item c
%! Dynare date object instantiated by @ref{dynDates}. @var{c} is a copy of @var{a} if @var{a}<=@var{b}, a copy of @var{b} otherwise.
%! Dynare date object instantiated by @ref{dynDate}. @var{c} is a copy of @var{a} if @var{a}<=@var{b}, a copy of @var{b} otherwise.
%! @end table
%! @sp 2
%! @strong{This function is called by:}
......@@ -50,15 +50,15 @@ function c = min(a,b)
verbose = 0;
if nargin~=2
error('dynDates::min: I need exactly two input arguments!')
error('dynDate::min: I need exactly two input arguments!')
end
if ~( isa(a,'dynDates') && isa(b,'dynDates'))
error(['dynDates::min: Input arguments ' inputname(1) 'and ' inputname(2) ' have to be a dynDates objects!'])
if ~( isa(a,'dynDate') && isa(b,'dynDate'))
error(['dynDate::min: Input arguments ' inputname(1) 'and ' inputname(2) ' have to be a dynDate objects!'])
end
if verbose && a.freq~=b.freq
error(['dynDates::min: Input arguments ' inputname(1) 'and ' inputname(2) ' have no common frequencies!'])
error(['dynDate::min: Input arguments ' inputname(1) 'and ' inputname(2) ' have no common frequencies!'])
end
if a<=b
......@@ -79,12 +79,12 @@ end
%$ date_6 = '1948M6';
%$
%$ % Call the tested routine.
%$ d1 = dynDates(date_1);
%$ d2 = dynDates(date_2);
%$ d3 = dynDates(date_3);
%$ d4 = dynDates(date_4);
%$ d5 = dynDates(date_5);
%$ d6 = dynDates(date_6);
%$ d1 = dynDate(date_1);
%$ d2 = dynDate(date_2);
%$ d3 = dynDate(date_3);
%$ d4 = dynDate(date_4);
%$ d5 = dynDate(date_5);
%$ d6 = dynDate(date_6);
%$ m1 = min(d1,d2);
%$ i1 = (m1==d1);
%$ m2 = min(d3,d4);
......
......@@ -2,18 +2,18 @@ function c = minus(a,b)
%@info:
%! @deftypefn {Function File} {@var{c} =} minus (@var{a},@var{b})