1function o = uminus(o) % --*-- Unitary tests --*--
2
3% Overloads the uminus method for dseries objects.
4%
5% INPUTS
6% - o   [dseries]
7%
8% OUTPUTS
9% - o   [dseries]
10
11% Copyright (C) 2012-2017 Dynare Team
12%
13% This file is part of Dynare.
14%
15% Dynare is free software: you can redistribute it and/or modify
16% it under the terms of the GNU General Public License as published by
17% the Free Software Foundation, either version 3 of the License, or
18% (at your option) any later version.
19%
20% Dynare is distributed in the hope that it will be useful,
21% but WITHOUT ANY WARRANTY; without even the implied warranty of
22% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23% GNU General Public License for more details.
24%
25% You should have received a copy of the GNU General Public License
26% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
27
28o = copy(o);
29
30o.data = -(o.data);
31
32for i = 1:vobs(o)
33    if isempty(o.ops{i})
34        o.ops(i) = {sprintf('uminus(%s)', o.name{i})};
35    else
36        o.ops(i) = {sprintf('uminus(%s)', o.ops{i})};
37    end
38end
39
40%@test:1
41%$ % Define a datasets.
42%$ A = rand(10,2);
43%$
44%$ % Define names
45%$ A_name = {'A1';'A2'};
46%$ A_tex = {'A_1';'A_2'};
47%$ t = zeros(6,1);
48%$
49%$ % Instantiate a time series object.
50%$ try
51%$    ts1 = dseries(A,[],A_name,A_tex);
52%$    ts2 = -ts1;
53%$    t(1) = 1;
54%$ catch
55%$    t = 0;
56%$ end
57%$
58%$ if length(t)>1
59%$    t(2) = dassert(ts2.vobs,2);
60%$    t(3) = dassert(ts2.nobs,10);
61%$    t(4) = dassert(ts2.data,-A,1e-15);
62%$    t(5) = dassert(ts2.name,{'A1';'A2'});
63%$    t(6) = dassert(ts2.tex,{'A_1';'A_2'});
64%$    t(7) = dassert(ts2.ops,{'uminus(A1)';'uminus(A2)'});
65%$ end
66%$ T = all(t);
67%@eof:1
68