1function o = diff_(o) % --*-- Unitary tests --*--
2
3% Computes differences, independently of the frequency.
4%
5% INPUTS
6% - o   [dseries]
7%
8% OUTPUTS
9% - o   [dseries]
10
11% Copyright (C) 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.data(2:end,:) = o.data(2:end,:)-o.data(1:end-1,:);
29o.data(1,:) = NaN;
30
31for i = 1:vobs(o)
32    if isempty(o.ops{i})
33        o.ops(i) = {['diff(' o.name{i} ')']};
34    else
35        o.ops(i) = {['diff(' o.ops{i} ')']};
36    end
37end
38
39%@test:1
40%$ try
41%$     data = transpose(0:1:50);
42%$     ts = dseries(data,'1950Q1');
43%$     ts.diff_;
44%$     t(1) = 1;
45%$ catch
46%$     t(1) = 0;
47%$ end
48%$
49%$ if t(1)
50%$     DATA = NaN(1,ts.vobs);
51%$     DATA = [DATA; ones(ts.nobs-1,ts.vobs)];
52%$     t(2) = dassert(ts.data,DATA,1e-15);
53%$ end
54%$
55%$ T = all(t);
56%@eof:1