1function b = isequal(o, p, tol)
2
3% Overloads the isequal Matlab/Octave's function.
4%
5% INPUTS
6% - o      [dseries]  T periods, N variables.
7% - p      [dseries]  T periods, N variables.
8% - tol    [double]   tolerance parameter.
9%
10% OUTPUTS
11%  o b     [logical]
12
13% Copyright (C) 2013-2017 Dynare Team
14%
15% This file is part of Dynare.
16%
17% Dynare is free software: you can redistribute it and/or modify
18% it under the terms of the GNU General Public License as published by
19% the Free Software Foundation, either version 3 of the License, or
20% (at your option) any later version.
21%
22% Dynare is distributed in the hope that it will be useful,
23% but WITHOUT ANY WARRANTY; without even the implied warranty of
24% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25% GNU General Public License for more details.
26%
27% You should have received a copy of the GNU General Public License
28% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
29
30if nargin~=2
31    error('dseries::isequal: I need exactly two input arguments!')
32end
33
34if ~isdseries(p)
35    error('dseries::isequal: Both input arguments must be dseries objects!')
36end
37
38if ~isequal(nobs(o), nobs(p))
39    b = 0;
40    return
41end
42
43if ~isequal(vobs(o), vobs(p))
44    b = 0;
45    return
46end
47
48if ~isequal(frequency(o), frequency(p))
49    b = 0;
50    return
51end
52
53if ~isequal(o.dates, p.dates)
54    b = 0;
55    return
56end
57
58if ~isequal(o.name, p.name)
59    warning off backtrace
60    warning('dseries::isequal: Both input arguments do not have the same variables!')
61    warning on backtrace
62end
63
64if ~isequal(o.tex, p.tex)
65    warning off backtrace
66    warning('dseries::isequal: Both input arguments do not have the same tex names!')
67    warning on backtrace
68end
69
70if ~isequal(o.ops, p.ops)
71    warning off backtrace
72    warning('dseries::isequal: Both input arguments received different treatments!')
73    warning on backtrace
74end
75
76if ~isequal(o.tags, p.tags)
77    warning off backtrace
78    warning('dseries::isequal: Both input arguments have different tags!')
79    warning on backtrace
80end
81
82
83if nargin<3
84    b = isequal(o.data, p.data);
85else
86    b = ~(max(abs(o.data(:)-p.data(:)))>tol);
87end