1function b = isreal(o) % --*-- Unitary tests --*-- 2 3% Returns true if no elements of the dseries have imaginary parts. 4% Returns false otherwise 5% 6% INPUTS 7% - o [dseries] with N variables and T periods. 8% 9% OUTPUTS 10% - b [logical] true iff all elements are real; false otherwise. 11 12 13% Copyright (C) 2019 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 30b = isreal(o.data); 31 32%@test:1 33%$ try 34%$ data = randn(100, 10); 35%$ cnan = randi(10, 50, 1); 36%$ rnan = randi(100, 50, 1); 37%$ for i=1:50, data(rnan(i),cnan(i)) = sqrt(-1); end 38%$ ireal = isreal(data); 39%$ ts = dseries(data); 40%$ dd = ts.isreal(); 41%$ t(1) = true; 42%$ catch 43%$ t(1) = false; 44%$ end 45%$ 46%$ if t(1) 47%$ t(2) = isequal(dd, ireal); 48%$ end 49%$ 50%$ T = all(t); 51%@eof:1 52