Skip to content
Snippets Groups Projects
Commit 399ab297 authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Rewrote unique function.

parent 8c2390a9
Branches
No related tags found
No related merge requests found
function B = unique(A) % --*-- Unitary tests --*--
function o = unique(o) % --*-- Unitary tests --*--
% Overloads the unique function for dates objects.
%
% INPUTS
% o A dates object.
% - o [dates]
%
% OUTPUTS
% o B dates object (a copy of A without repetitions, only the last occurence of a date is kept).
% Copyright (C) 2012-2013 Dynare Team
% OUPUTS
% - o [dates]
%
% This file is part of Dynare.
% REMARKS
% 1. Only the last occurence of a date is kept.
% Copyright (C) 2013-2014 Dynare Team
%
% Dynare is free software: you can redistribute it and/or modify
% 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 is distributed in the hope that it will be useful,
% 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.
......@@ -25,20 +26,18 @@ function B = unique(A) % --*-- 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/>.
if isequal(A.ndat,1)
if o.ndat<=1
return
end
B = A;
if isoctave || matlab_ver_less_than('8.1.0')
[tmp, id, jd] = unique(A.time,'rows');
[tmp, id, jd] = unique(o.time,'rows');
else
[tmp, id, jd] = unique(A.time,'rows','legacy');
[tmp, id, jd] = unique(o.time,'rows','legacy');
end
B.time = A.time(sort(id),:);
B.ndat = size(B.time,1);
o.time = o.time(sort(id),:);
o.ndat = size(o.time,1);
%@test:1
%$ % Define some dates
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment