isequal.m 2.09 KB
Newer Older
1
function b = isequal(o, p, tol)
2 3 4

% Overloads the isequal Matlab/Octave's function.
%
Stéphane Adjemian's avatar
Stéphane Adjemian committed
5
% INPUTS
6 7 8
% - o      [dseries]  T periods, N variables.
% - p      [dseries]  T periods, N variables.
% - tol    [double]   tolerance parameter.
9
%
Stéphane Adjemian's avatar
Stéphane Adjemian committed
10
% OUTPUTS
11
%  o b     [logical]
12

13
% Copyright (C) 2013-2017 Dynare Team
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
%
% This file is part of Dynare.
%
% Dynare 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,
% 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/>.

if nargin~=2
    error('dseries::isequal: I need exactly two input arguments!')
end

34
if ~isdseries(p)
35 36 37
    error('dseries::isequal: Both input arguments must be dseries objects!')
end

38 39
if ~isequal(nobs(o), nobs(p))
    b = 0;
40 41 42
    return
end

43 44
if ~isequal(vobs(o), vobs(p))
    b = 0;
45 46 47
    return
end

48 49
if ~isequal(frequency(o), frequency(p))
    b = 0;
50 51 52
    return
end

53 54
if ~isequal(o.dates, p.dates)
    b = 0;
55 56 57
    return
end

58
if ~isequal(o.name, p.name)
Stéphane Adjemian's avatar
Stéphane Adjemian committed
59
    warning off backtrace
60
    warning('dseries::isequal: Both input arguments do not have the same variables!')
Stéphane Adjemian's avatar
Stéphane Adjemian committed
61
    warning on backtrace
62 63
end

64
if ~isequal(o.tex, p.tex)
Stéphane Adjemian's avatar
Stéphane Adjemian committed
65
    warning off backtrace
66
    warning('dseries::isequal: Both input arguments do not have the same tex names!')
Stéphane Adjemian's avatar
Stéphane Adjemian committed
67 68 69 70 71 72 73
    warning on backtrace
end

if ~isequal(o.ops, p.ops)
    warning off backtrace
    warning('dseries::isequal: Both input arguments received different treatments!')
    warning on backtrace
74 75
end

76 77 78 79 80 81 82
if ~isequal(o.tags, p.tags)
    warning off backtrace
    warning('dseries::isequal: Both input arguments have different tags!')
    warning on backtrace
end


83
if nargin<3
84
    b = isequal(o.data, p.data);
85
else
86
    b = ~(max(abs(o.data(:)-p.data(:)))>tol);
87
end