Commit 58f96e10 authored by Houtan Bastani's avatar Houtan Bastani

remove ndat member, #4

parent befdf3f6
......@@ -9,7 +9,7 @@ function o = append(o, d) % --*-- Unitary tests --*--
% OUTPUTS
% - o [dates] dates object containing dates defined in o and d.
% Copyright (C) 2012-2014 Dynare Team
% Copyright (C) 2012-2015 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
......@@ -39,7 +39,6 @@ if ~isequal(o.freq, d.freq)
error('dates:append:ArgCheck','dates must have common frequency!')
end
o.ndat = o.ndat+1;
o.time = [o.time; d.time];
%@test:1
......@@ -53,7 +52,6 @@ o.time = [o.time; d.time];
%$ % Define expected results.
%$ e.time = [1945 3; 1950 1; 1950 2; 1953 4; 2009 2];
%$ e.freq = 4;
%$ e.ndat = 5;
%$
%$ % Call the tested routine.
%$ d = dates(B4,B3,B2,B1);
......@@ -62,7 +60,6 @@ o.time = [o.time; d.time];
%$ % Check the results.
%$ t(1) = dassert(d.time,e.time);
%$ t(2) = dassert(d.freq,e.freq);
%$ t(3) = dassert(d.ndat,e.ndat);
%$ T = all(t);
%@eof:1
......@@ -77,7 +74,6 @@ o.time = [o.time; d.time];
%$ % Define expected results.
%$ e.time = [1945 3; 1950 1; 1950 2; 1953 4; 2009 2];
%$ e.freq = 4;
%$ e.ndat = 5;
%$
%$ % Call the tested routine.
%$ d = dates(B4,B3,B2,B1);
......@@ -86,6 +82,5 @@ o.time = [o.time; d.time];
%$ % Check the results.
%$ t(1) = dassert(d.time,e.time);
%$ t(2) = dassert(d.freq,e.freq);
%$ t(3) = dassert(d.ndat,e.ndat);
%$ T = all(t);
%@eof:2
\ No newline at end of file
%@eof:2
......@@ -14,7 +14,7 @@ function q = colon(varargin) % --*-- Unitary tests --*--
% 1. p must be greater than o if d>0.
% 2. p and q are dates objects with one element.
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 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
......@@ -78,7 +78,6 @@ q.freq = o.freq;
if isequal(q.freq, 1)
% Yearly
q.ndat = m;
q.time = NaN(m,2);
q.time(:,1) = o.time(1)+transpose(0:d:n-1);
q.time(:,2) = 1;
......@@ -106,9 +105,6 @@ else
end
if d>1
q.time = q.time(1:d:n,:);
q.ndat = m;
else
q.ndat = n;
end
end
......@@ -193,4 +189,4 @@ end
%$ t(1) = dassert(d.time,e.time);
%$ t(2) = dassert(d.freq,e.freq);
%$ T = all(t);
%$ @eof:4
\ No newline at end of file
%$ @eof:4
......@@ -8,7 +8,7 @@ function p = copy(o)
% OUTPUTS
% - p [dates]
% Copyright (C) 2014 Dynare Team
% Copyright (C) 2014-2015 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
......@@ -25,5 +25,4 @@ function p = copy(o)
p = dates();
p.freq = o.freq;
p.ndat = o.ndat;
p.time = o.time;
\ No newline at end of file
p.time = o.time;
......@@ -16,16 +16,14 @@ classdef dates<handle
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
properties
ndat = []; % Number of dates (integer scalar)
freq = []; % Frequency (integer scalar)
time = []; % Array (ndat rows and two columns)
time = []; % Array (one row for every date. first column is the year, second is the period)
end
methods
function o = dates(varargin)
if ~nargin
% Returns empty dates object.
o.ndat = 0;
o.freq = NaN(0);
o.time = NaN(0,2);
return
......@@ -43,8 +41,7 @@ classdef dates<handle
else
error('dates:ArgCheck', 'All dates passed as inputs must have the same frequency!')
end
o.ndat = length(tmp);
o.time = transpose(reshape([tmp.time],2,o.ndat));
o.time = transpose(reshape([tmp.time], 2, length(tmp)));
return
end
if isequal(nargin,1) && isfreq(varargin{1})
......@@ -68,7 +65,6 @@ classdef dates<handle
if isnumeric(varargin{3}) && isvector(varargin{3}) && all(isint(varargin{3}))
if all(varargin{3}>=1) && all(varargin{3}<=o.freq)
o.time = [varargin{2}(:), varargin{3}(:)];
o.ndat = size(o.time,1);
else
error('dates:ArgCheck','Third input must contain integers between 1 and %i.', o.freq)
end
......@@ -90,7 +86,6 @@ classdef dates<handle
if isequal(o.freq, 1)
if (isnumeric(varargin{2}) && isvector(varargin{2}) && all(isint(varargin{2})))
o.time = [varargin{2}, ones(length(varargin{2}),1)];
o.ndat = size(o.time,1);
return
else
error('dates:ArgCheck','Second input must be a vector of integers.')
......@@ -100,7 +95,6 @@ classdef dates<handle
if all(isint(varargin{2}(:,1))) && all(isint(varargin{2}(:,1)))
if all(varargin{2}(:,2)>=1) && all(varargin{2}(:,2)<=o.freq)
o.time = [varargin{2}(:,1), varargin{2}(:,2)];
o.ndat = size(o.time,1);
else
error('dates:ArgCheck','Second column of the last input must contain integers between 1 and %i.',o.freq)
end
......@@ -129,7 +123,6 @@ end % classdef
%$ % Define expected results.
%$ e.time = [1945 3; 1950 2; 1950 1; 1953 4];
%$ e.freq = 4;
%$ e.ndat = 4;
%$
%$ % Call the tested routine.
%$ d = dates(B1,B2,B3,B4);
......@@ -137,7 +130,7 @@ end % classdef
%$ % Check the results.
%$ t(1) = dassert(d.time,e.time);
%$ t(2) = dassert(d.freq,e.freq);
%$ t(3) = dassert(d.ndat,e.ndat);
%$ t(3) = dassert(d.ndat(),e.ndat());
%$ T = all(t);
%@eof:1
......@@ -151,7 +144,6 @@ end % classdef
%$ % Define expected results.
%$ e.time = [1945 3; 1950 2; 1950 10; 1953 12];
%$ e.freq = 12;
%$ e.ndat = 4;
%$
%$ % Call the tested routine.
%$ d = dates(B1,B2,B3,B4);
......@@ -159,7 +151,7 @@ end % classdef
%$ % Check the results.
%$ t(1) = dassert(d.time,e.time);
%$ t(2) = dassert(d.freq,e.freq);
%$ t(3) = dassert(d.ndat,e.ndat);
%$ t(3) = dassert(d.ndat(),e.ndat());
%$ T = all(t);
%@eof:2
......@@ -173,7 +165,6 @@ end % classdef
%$ % Define expected results.
%$ e.time = [1945 1; 1950 1; 1950 1; 1953 1];
%$ e.freq = 1;
%$ e.ndat = 4;
%$
%$ % Call the tested routine.
%$ d = dates(B1,B2,B3,B4);
......@@ -181,7 +172,7 @@ end % classdef
%$ % Check the results.
%$ t(1) = dassert(d.time,e.time);
%$ t(2) = dassert(d.freq,e.freq);
%$ t(3) = dassert(d.ndat,e.ndat);
%$ t(3) = dassert(d.ndat(),e.ndat());
%$ T = all(t);
%@eof:3
......
......@@ -10,7 +10,7 @@ function lastIndex = end(o, k, n)
% OUTPUTS
% lastIndex [integer] last dates index
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 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
......@@ -26,4 +26,4 @@ function lastIndex = end(o, k, n)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert(k==1 && n==1, 'dates:end:ArgCheck', 'dates only has one dimension');
lastIndex = o.ndat;
\ No newline at end of file
lastIndex = o.ndat();
......@@ -9,7 +9,7 @@ function l = eq(varargin) % --*-- Unitary tests --*--
% OUTPUTS
% - l [logical] column vector of max(n,1) elements (zeros or ones).
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 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
......@@ -26,7 +26,7 @@ function l = eq(varargin) % --*-- Unitary tests --*--
[o, p] = comparison_arg_checks(varargin{:});
if isequal(o.ndat, p.ndat)
if isequal(o.ndat(), p.ndat())
l = logical(transpose(all(transpose(eq(o.time,p.time)))));
else
l = logical(transpose(all(transpose(bsxfun(@eq,o.time,p.time)))));
......
......@@ -9,7 +9,7 @@ function l = ge(varargin) % --*-- Unitary tests --*--
% OUTPUTS
% - l [logical] column vector of max(n,1) elements (zeros or ones).
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 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
......@@ -26,21 +26,21 @@ function l = ge(varargin) % --*-- Unitary tests --*--
[o, p] = comparison_arg_checks(varargin{:});
if isequal(o.ndat, p.ndat)
if isequal(o.ndat(), p.ndat())
l = (o==p);
idx = find(l==false);
for i=1:length(idx)
l(idx(i)) = greaterorequal(o.time(idx(i),:), p.time(idx(i),:));
end
else
if isequal(o.ndat,1)
l = false(p.ndat,1);
for i=1:p.ndat
if isequal(o.ndat(),1)
l = false(p.ndat(),1);
for i=1:p.ndat()
l(i) = greaterorequal(o.time, p.time(i,:));
end
else
l = false(o.ndat,1);
for i=1:o.ndat
l = false(o.ndat(),1);
for i=1:o.ndat()
l(i) = greaterorequal(o.time(i,:), p.time);
end
end
......@@ -92,4 +92,4 @@ end
%$ t(5) = dassert(dates(B5)>=dd,true(4,1));
%$ t(6) = dassert(dates(B1)>=dd,[true; false(3,1)]);
%$ T = all(t);
%@eof:2
\ No newline at end of file
%@eof:2
......@@ -9,7 +9,7 @@ function l = gt(varargin) % --*-- Unitary tests --*--
% OUTPUTS
% - l [logical] column vector of max(n,1) elements (zeros or ones).
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 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
......@@ -26,20 +26,20 @@ function l = gt(varargin) % --*-- Unitary tests --*--
[o, p] = comparison_arg_checks(varargin{:});
if isequal(o.ndat, p.ndat)
l = false(o.ndat,1);
for i=1:o.ndat
if isequal(o.ndat(), p.ndat())
l = false(o.ndat(),1);
for i=1:o.ndat()
l(i) = greaterthan(o.time(i,:), p.time(i,:));
end
else
if isequal(o.ndat,1)
l = false(p.ndat,1);
for i=1:p.ndat
if isequal(o.ndat(),1)
l = false(p.ndat(),1);
for i=1:p.ndat()
l(i) = greaterthan(o.time, p.time(i,:));
end
else
l = false(o.ndat,1);
for i=1:o.ndat
l = false(o.ndat(),1);
for i=1:o.ndat()
l(i) = greaterthan(o.time(i,:), p.time);
end
end
......@@ -89,4 +89,4 @@ end
%$ t(5) = dassert(dates(B5)>dd,true(4,1));
%$ t(6) = dassert(dates(B1)>dd,false(4,1));
%$ T = all(t);
%@eof:2
\ No newline at end of file
%@eof:2
......@@ -8,7 +8,7 @@ function o = horzcat(varargin) % --*-- Unitary tests --*--
% OUTPUTS
% - o [dates] object containing dates defined in varargin{:}
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 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
......@@ -38,7 +38,6 @@ for i=2:n
p = varargin{i};
if isequal(o.freq,p.freq)
if ~isempty(p)
o.ndat = o.ndat + p.ndat;
o.time = [o.time; p.time];
end
else
......@@ -57,7 +56,6 @@ end
%$ % Define expected results.
%$ e.time = [1945 3; 1950 1; 1950 2; 1953 4; 2009 2];
%$ e.freq = 4;
%$ e.ndat = 5;
%$
%$ % Call the tested routine.
%$ d = dates(B4,B3,B2,B1);
......@@ -66,7 +64,7 @@ end
%$ % Check the results.
%$ t(1) = dassert(d.time,e.time);
%$ t(2) = dassert(d.freq,e.freq);
%$ t(3) = dassert(d.ndat,e.ndat);
%$ t(3) = size(e.time,1)==d.ndat();
%$ T = all(t);
%@eof:1
......@@ -81,7 +79,6 @@ end
%$ % Define expected results.
%$ e.time = [1945 3; 1950 1; 1950 2; 1953 4; 2009 2];
%$ e.freq = 4;
%$ e.ndat = 5;
%$
%$ % Call the tested routine.
%$ d = dates(B4,B3,B2);
......@@ -90,7 +87,7 @@ end
%$ % Check the results.
%$ t(1) = dassert(d.time,e.time);
%$ t(2) = dassert(d.freq,e.freq);
%$ t(3) = dassert(d.ndat,e.ndat);
%$ t(3) = size(e.time,1)==d.ndat();
%$ T = all(t);
%@eof:2
......@@ -105,7 +102,6 @@ end
%$ % Define expected results.
%$ e.time = [1945 3; 1950 1; 1950 2; 1953 4; 2009 2];
%$ e.freq = 4;
%$ e.ndat = 5;
%$
%$ % Call the tested routine.
%$ d = dates(B4,B3,B2);
......@@ -114,7 +110,7 @@ end
%$ % Check the results.
%$ t(1) = dassert(d.time,e.time);
%$ t(2) = dassert(d.freq,e.freq);
%$ t(3) = dassert(d.ndat,e.ndat);
%$ t(3) = size(e.time,1)==d.ndat();
%$ T = all(t);
%@eof:3
......@@ -129,7 +125,6 @@ end
%$ % Define expected results.
%$ e.time = [1945 3; 1950 1; 1950 2; 1953 4; 2009 2];
%$ e.freq = 4;
%$ e.ndat = 5;
%$
%$ % Call the tested routine.
%$ d = dates(B4,B3,B2);
......@@ -138,6 +133,6 @@ end
%$ % Check the results.
%$ t(1) = dassert(d.time,e.time);
%$ t(2) = dassert(d.freq,e.freq);
%$ t(3) = dassert(d.ndat,e.ndat);
%$ t(3) = size(e.time,1)==d.ndat();
%$ T = all(t);
%@eof:4
\ No newline at end of file
%@eof:4
......@@ -9,7 +9,7 @@ function q = intersect(o, p) % --*-- Unitary tests --*--
% OUTPUTS
% - q [dates] All the common elements in o and p.
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 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
......@@ -51,7 +51,6 @@ end
q.freq = o.freq;
q.time = time;
q.ndat = rows(time);
%@test:1
%$ % Define some dates objects
......@@ -67,4 +66,4 @@ q.ndat = rows(time);
%$ t(1) = dassert(c1,d2);
%$ t(2) = dassert(isempty(c2),true);
%$ T = all(t);
%@eof:1
\ No newline at end of file
%@eof:1
......@@ -8,7 +8,7 @@ function l = isempty(o) % --*-- Unitary tests --*--
% OUTPUTS
% - l [logical]
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 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
......@@ -22,8 +22,8 @@ function l = isempty(o) % --*-- Unitary tests --*--
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
l = isequal(o.ndat,0);
l = isequal(o.ndat(),0);
%@test:1
%$ % Instantiate an empty dates object
......@@ -39,4 +39,4 @@ l = isequal(o.ndat,0);
%$ % Test if this object is empty
%$ t(1) = ~isempty(d);
%$ T = all(t);
%@eof:2
\ No newline at end of file
%@eof:2
......@@ -9,7 +9,7 @@ function l = isequal(o, p, fake)
% OUTPUTS
% - l [logical]
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 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
......@@ -33,7 +33,7 @@ if ~isequal(o.freq, p.freq)
return
end
if ~isequal(o.ndat, p.ndat)
if ~isequal(o.ndat(), p.ndat())
l = false;
return
end
......
......@@ -9,7 +9,7 @@ function l = le(varargin) % --*-- Unitary tests --*--
% OUTPUTS
% - l [logical] column vector of max(n,1) elements (zeros or ones).
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 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
......@@ -26,21 +26,21 @@ function l = le(varargin) % --*-- Unitary tests --*--
[o, p] = comparison_arg_checks(varargin{:});
if isequal(o.ndat, p.ndat)
if isequal(o.ndat(), p.ndat())
l = (o==p);
idx = find(l==0);
for i=1:length(idx)
l(idx(i)) = lessorequal(o.time(idx(i),:), p.time(idx(i),:));
end
else
if isequal(o.ndat,1)
l = false(p.ndat,1);
for i=1:p.ndat
if isequal(o.ndat(),1)
l = false(p.ndat(),1);
for i=1:p.ndat()
l(i) = lessorequal(o.time, p.time(i,:));
end
else
l = false(o.ndat,1);
for i=1:o.ndat
l = false(o.ndat(),1);
for i=1:o.ndat()
l(i) = lessorequal(o.time(i,:), p.time);
end
end
......@@ -92,4 +92,4 @@ end
%$ t(5) = dassert(dates(B5)<=dd,false(4,1));
%$ t(6) = dassert(dates(B1)<=dd,true(4,1));
%$ T = all(t);
%@eof:2
\ No newline at end of file
%@eof:2
......@@ -8,7 +8,7 @@ function n = length(o)
% OUTPUTS
% - n [integer] Number of elements in o.
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 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
......@@ -23,7 +23,7 @@ function n = length(o)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
n = o.ndat;
n = o.ndat();
%@test:1
%$ d = dates('1938Q1');
......@@ -44,4 +44,4 @@ n = o.ndat;
%$ % Test if this object is empty
%$ t(1) = isequal(d.length(),3);
%$ T = all(t);
%@eof:3
\ No newline at end of file
%@eof:3
......@@ -9,7 +9,7 @@ function l = lt(varargin) % --*-- Unitary tests --*--
% OUTPUTS
% - l [logical] column vector of max(n,1) elements (zeros or ones).
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 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
......@@ -26,20 +26,20 @@ function l = lt(varargin) % --*-- Unitary tests --*--
[o, p] = comparison_arg_checks(varargin{:});
if isequal(o.ndat, p.ndat)
l = false(o.ndat,1);
for i=1:o.ndat
if isequal(o.ndat(), p.ndat())
l = false(o.ndat(),1);
for i=1:o.ndat()
l(i) = lessthan(o.time(i,:),p.time(i,:));
end
else
if isequal(o.ndat,1)
l = false(p.ndat,1);
for i=1:p.ndat
if isequal(o.ndat(),1)
l = false(p.ndat(),1);
for i=1:p.ndat()
l(i) = lessthan(o.time,p.time(i,:));
end
else
l = false(o.ndat,1);
for i=1:o.ndat
l = false(o.ndat(),1);
for i=1:o.ndat()
l(i) = lessthan(o.time(i,:),p.time);
end
end
......@@ -89,4 +89,4 @@ end
%$ t(5) = dassert(dates(B5)<dd,false(4,1));
%$ t(6) = dassert(dates(B1)<dd,[false; true(3,1)]);
%$ T = all(t);
%@eof:2
\ No newline at end of file
%@eof:2
......@@ -8,7 +8,7 @@ function q = max(varargin) % --*-- Unitary tests --*--
% OUTPUTS
% - q [dates]
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 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
......@@ -32,8 +32,7 @@ switch nargin
sorted_time_member = sortrows(varargin{1}.time);
q = dates();
q.freq = varargin{1}.freq;
q.ndat = 1;
q.time = sorted_time_member(varargin{1}.ndat,:);
q.time = sorted_time_member(varargin{1}.ndat(),:);
otherwise
q = max(horzcat(varargin{:}));
end
......@@ -84,4 +83,4 @@ end
%$ % Check the results.
%$ t(1) = dassert(i,true);
%$ T = all(t);
%@eof:4
\ No newline at end of file
%@eof:4
......@@ -8,7 +8,7 @@ function q = min(varargin) % --*-- Unitary tests --*--
% OUTPUTS
% - q [dates]
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 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
......@@ -32,7 +32,6 @@ switch nargin
sorted_time_member = sortrows(varargin{1}.time);
q = dates();
q.freq = varargin{1}.freq;
q.ndat = 1;
q.time = sorted_time_member(1,:);
otherwise
q = min(horzcat(varargin{:}));
......@@ -84,4 +83,4 @@ end
%$ % Check the results.
%$ t(1) = dassert(i,true);
%$ T = all(t);
%@eof:4
\ No newline at end of file
%@eof:4
......@@ -18,7 +18,7 @@ function q = minus(o,p) % --*-- Unitary tests --*--
% p periods backward.
% 3. If o is not a dates object, an error is returned.
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 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
......@@ -44,11 +44,9 @@ if isa(o,'dates') && isa(p,'dates')
v = copy(p);
if ~isequal(u.length(),v.length())
if isequal(u.length(),1)
u.time = repmat(u.time,v.ndat,1);
u.ndat = v.ndat;
u.time = repmat(u.time,v.ndat(),1);
elseif isequal(v.length(),1)
v.time = repmat(v.time,u.ndat,1);
v.ndat = u.ndat;
v.time = repmat(v.time,u.ndat(),1);
else
error('dates:minus:ArgCheck','Input arguments lengths are not consistent!')
end
......@@ -59,11 +57,10 @@ if isa(o,'dates') && isa(p,'dates')
q(id) = u.time(id,2)-v.time(id,2) + (u.time(id,1)-v.time(id,1))*v.freq;
end
elseif isa(o,'dates') && ~isa(p,'dates')
if (isvector(p) && isequal(length(p),o.ndat) && all(isint(p))) || (isscalar(p) && isint(p)) || (isequal(o.length(),1) && isvector(p) && all(isint(p)))
if (isvector(p) && isequal(length(p),o.ndat()) && all(isint(p))) || (isscalar(p) && isint(p)) || (isequal(o.length(),1) && isvector(p) && all(isint(p)))
q = dates();
q.freq = o.freq;
q.time = add_periods_to_array_of_dates(o.time, o.freq, -p(:));
q.ndat = rows(q.time);
else
error('dates:minus:ArgCheck','Second argument has to be a vector of integers or scalar integer. You should read the manual.')
end
......@@ -169,4 +166,4 @@ end
%$ t(2) = dassert(e1,f1);
%$ end
%$ T = all(t);
%@eof:5
\ No newline at end of file
%@eof:5
......@@ -12,7 +12,7 @@ function p = mtimes(o,n) % --*-- Unitary tests --*--
% 1. If A = dates('2000Q1'), then B=A*3 is a dates object equal to dates('2000Q1','2000Q1','2000Q1')
% 2. If A = dates('2003Q1','2009Q2'), then B=A*2 is a dates object equal to dates('2003Q1','2009Q2','2003Q1','2009Q2')
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 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
......@@ -33,7 +33,6 @@ end
p = copy(o);
p.time = repmat(p.time, n, 1);
p.ndat = o.ndat*n;
%@test:1
%$ % Define some dates
......
function s = ndat(o)
% Given a one element dates object, returns a string with the formatted date.
%
% INPUTS
% - o [dates]
%
% OUTPUTS
% - s [integer]
% Copyright (C) 2015 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/>.
s = size(o.time, 1);
......@@ -9,7 +9,7 @@ function l = ne(varargin) % --*-- Unitary tests --*--
% OUTPUTS
% - l [logical] column vector of max(n,1) elements (zeros or ones).
% Copyright (C) 2013-2014 Dynare Team