1function b = eq(o, p) % --*-- Unitary tests --*-- 2 3% Overloads eq (==) operator. 4% 5% INPUTS 6% o A dseries object (T periods, N variables). 7% o B dseries object (T periods, N variables). 8% 9% OUTPUTS 10% o C T*N matrix of zeros and ones. Element C(t,n) is nonzero iff observation t of variable n in A and B are equal. 11% 12% REMARKS 13% If the number of variables, the number of observations or the frequencies are different in A and B, the function returns a zero scalar. 14 15% Copyright (C) 2013-2017 Dynare Team 16% 17% This file is part of Dynare. 18% 19% Dynare is free software: you can redistribute it and/or modify 20% it under the terms of the GNU General Public License as published by 21% the Free Software Foundation, either version 3 of the License, or 22% (at your option) any later version. 23% 24% Dynare is distributed in the hope that it will be useful, 25% but WITHOUT ANY WARRANTY; without even the implied warranty of 26% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27% GNU General Public License for more details. 28% 29% You should have received a copy of the GNU General Public License 30% along with Dynare. If not, see <http://www.gnu.org/licenses/>. 31 32if nargin~=2 33 error('dseries::eq: I need exactly two input arguments!') 34end 35 36if ~(isdseries(o) && isdseries(p)) 37 error('dseries::eq: Both input arguments must be dseries objects!') 38end 39 40if ~isequal(nobs(o), nobs(p)) 41 warning('dseries::eq: Both input arguments should have the same number of observations!') 42 b = 0; 43 return 44end 45 46if ~isequal(vobs(o), vobs(p)) 47 warning('dseries::eq: Both input arguments should have the same number of observations!') 48 b = 0; 49 return 50end 51 52if ~isequal(frequency(o),frequency(p)) 53 warning('dseries::eq: Both input arguments should have the same frequencies!') 54 b = 0; 55 return 56end 57 58if ~isequal(firstdate(o),firstdate(p)) 59 warning('dseries::eq: Both input arguments should have the same initial period!') 60 b = 0; 61 return 62end 63 64b = eq(o.data, p.data); 65 66%@test:1 67%$ % Define a datasets. 68%$ A = rand(10,3); 69%$ 70%$ % Define names 71%$ A_name = {'A1';'A2';'A3'}; 72%$ 73%$ t = zeros(2,1); 74%$ 75%$ % Instantiate a time series object. 76%$ try 77%$ ts1 = dseries(A,[],A_name,[]); 78%$ ts2 = ts1; 79%$ a = eq(ts1,ts2); 80%$ t(1) = 1; 81%$ catch 82%$ t = 0; 83%$ end 84%$ 85%$ if length(t)>1 86%$ t(2) = dassert(a,logical(ones(10,3))); 87%$ end 88%$ T = all(t); 89%@eof:1