1function o = exp_(o) % --*-- Unitary tests --*-- 2 3% Apply the exponential to all the variables in a dseries object (in place modification). 4% 5% INPUTS 6% - o [dseries] 7% 8% OUTPUTS 9% - o [dseries] 10 11% Copyright (C) 2015-2018 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 = exp(o.data); 29 30for i=1:vobs(o) 31 if isempty(o.ops{i}) 32 o.ops(i) = {['exp(' o.name{i} ')']}; 33 else 34 o.ops(i) = {['exp(' o.ops{i} ')']}; 35 end 36end 37 38%@test:1 39%$ % Define a dates object 40%$ data = zeros(10,2); 41%$ o = dseries(data); 42%$ q = o; 43%$ r = copy(o); 44%$ 45%$ % Call the tested routine. 46%$ try 47%$ o.exp_(); 48%$ t(1) = true; 49%$ catch 50%$ t(1) = false; 51%$ end 52%$ 53%$ if t(1) 54%$ t(2) = dassert(o.data, ones(10,2)); 55%$ t(3) = dassert(q.data, ones(10,2)); 56%$ t(4) = dassert(r.data, zeros(10, 2)); 57%$ end 58%$ 59%$ T = all(t); 60%@eof:1 61 62%@test:2 63%$ % Define a dates object 64%$ data = zeros(10,2); 65%$ o = dseries(data); 66%$ q = o; 67%$ r = copy(o); 68%$ 69%$ % Call the tested routine. 70%$ try 71%$ o.exp_(); 72%$ t(1) = true; 73%$ catch 74%$ t(1) = false; 75%$ end 76%$ 77%$ if t(1) 78%$ t(2) = dassert(length(o.name), 2); 79%$ t(3) = dassert(o.name{1},'Variable_1'); 80%$ t(4) = dassert(o.name{2},'Variable_2'); 81%$ t(5) = dassert(q.name{1},'Variable_1'); 82%$ t(6) = dassert(q.name{2},'Variable_2'); 83%$ t(7) = dassert(o.ops{1},'exp(Variable_1)'); 84%$ t(8) = dassert(o.ops{2},'exp(Variable_2)'); 85%$ t(9) = dassert(q.ops{1},'exp(Variable_1)'); 86%$ t(10) = dassert(q.ops{2},'exp(Variable_2)'); 87%$ t(11) = dassert(r.name{1},'Variable_1'); 88%$ t(12) = dassert(r.name{2},'Variable_2'); 89%$ t(13) = isempty(r.ops{1}); 90%$ t(14) = isempty(r.ops{2}); 91%$ end 92%$ 93%$ T = all(t); 94%@eof:2