1function [Da1,DP1,D2a,D2P] = univariate_computeDstate(k,a,P,T,Da,DP,DT,DOm,notsteady,D2a,D2P,D2T,D2Om) 2 3% Copyright (C) 2012-2017 Dynare Team 4% 5% This file is part of Dynare. 6% 7% Dynare is free software: you can redistribute it and/or modify 8% it under the terms of the GNU General Public License as published by 9% the Free Software Foundation, either version 3 of the License, or 10% (at your option) any later version. 11% 12% Dynare is distributed in the hope that it will be useful, 13% but WITHOUT ANY WARRANTY; without even the implied warranty of 14% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15% GNU General Public License for more details. 16% 17% You should have received a copy of the GNU General Public License 18% along with Dynare. If not, see <http://www.gnu.org/licenses/>. 19 20% AUTHOR(S) marco.ratto@jrc.ec.europa.eu 21 22 23DP1=DP*0; 24Da1=Da*0; 25for j=1:k 26 Da1(:,j) = T*Da(:,j) + DT(:,:,j)*a; 27 if notsteady 28 DP1(:,:,j) = T*DP(:,:,j)*T'+DT(:,:,j)*P*T'+T*P*DT(:,:,j)'; 29 else 30 DP1=DP; 31 end 32end 33if notsteady 34 DP1 = DP1 + DOm; 35end 36if nargout>2 37 jcount=0; 38 for j=1:k 39 for i=1:j 40 jcount=jcount+1; 41 D2a(:,j,i) = DT(:,:,i)*Da(:,j) + DT(:,:,j)*Da(:,i) + T*D2a(:,j,i)+ reshape(D2T(:,jcount),size(T))*a; 42 D2a(:,i,j) = D2a(:,j,i); 43 if notsteady 44 tmp = dyn_unvech(D2P(:,jcount)); 45 tmp = T*tmp*T' +DT(:,:,i)*DP(:,:,j)*T'+T*DP(:,:,j)*DT(:,:,i)' + ... 46 DT(:,:,j)*DP(:,:,i)*T'+T*DP(:,:,i)*DT(:,:,j)' + ... 47 DT(:,:,j)*P*DT(:,:,i)'+DT(:,:,i)*P*DT(:,:,j)'+ ... 48 reshape(D2T(:,jcount),size(T))*P*T'+T*P*reshape(D2T(:,jcount),size(T))' + ... 49 dyn_unvech(D2Om(:,jcount)); 50 D2P(:,jcount) = dyn_vech(tmp); 51 % D2P(:,:,i,j) = D2P(:,:,j,i); 52 end 53 end 54 end 55 56end 57