Update of, not yet complete algorithm for unpacking g_2 into ghxx/xu/uu; added logic for 2nd order derivative symmetry and some other improvements but still not finished yet

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2623 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
george 2009-04-24 01:20:21 +00:00
parent d7b8c64d8b
commit 2053243f78
1 changed files with 31 additions and 13 deletions

View File

@ -138,24 +138,40 @@ function [dr,info,M_,options_,oo_] = dr1(dr,task,M_,options_,oo_)
else % 2nd order
[ysteady, ghx_u, g_2]=k_order_perturbation(dr,task,M_,options_, oo_ , ['.' mexext]);
%Here is pseud code for recovering ghxx ghxu ghxx ghs2
%Here is code for recovering ghxx ghxu ghxx ghs2
s0 = 0;
s1 = 0;%0
g_2cols=size(g_2,2);
g_2rows=size(g_2,1);
nExog=M_.exo_nbr;
nspred=dr.nspred;
%ghxx=zeros(g_2rows);
for i=1:g_2cols
ghxx=zeros(g_2rows, nspred^2);
ghxu=zeros(g_2rows, nspred*nExog);
ghuu=zeros(g_2rows, nExog^2);
ghs2=zeros(g_2rows, 1);
% for i=1:g_2cols
i=0;
while i<g_2cols
i=i+1
if s0 < nspred & s1 < nspred%+1
for j=1:g_2rows
ghxx(j,s0*nspred+s1+1) = 2*g_2(j,i);
if s1 < s0
ghxx(:,s0*nspred+s1+1) = ghxx(:,(s0+1)+(nspred+1)*s1);
i=i-1;
else
for j=1:g_2rows % j is the row jumber
ghxx(j,s0*nspred+s1+1) = 2*g_2(j,i);
end
end
elseif s0 < nspred & s1 < nspred+nExog %+1
for j=1:g_2rows
ghxu(j,(s0*nspred+s1-nspred+1)) = 2*g_2(j,i);
end
elseif s0 < nspred+nExog & s1 < nspred+nExog%+1
% if s1 < s0+nspred
% ghxu(:,s0*nExog+s1-nspred+1) = ghxu(:,(s0+1)+(nExog+1)*(s1-nspred));
% i=i-1;
% else
for j=1:g_2rows
ghxu(j,(s0*nExog+s1-nspred+1)) = 2*g_2(j,i);
end
% end
elseif s0 < nspred+nExog & s1 < nExog% nspred+nExog%+1
for j=1:g_2rows
ghuu(j,(s0-nspred)*nExog+s1-nExog+1) = 2*g_2(j,i);
end
@ -164,14 +180,16 @@ function [dr,info,M_,options_,oo_] = dr1(dr,task,M_,options_,oo_)
ghs2(j,1) = 2*g_2(j,i);
end
end
% Note: j is the row jumber
s1=s1+1;
if s1 == nspred+nExog+1
if s1 == nspred+nExog%+1
s0=s0+1;
s1 =s0;
s1 =0 %s0;
end
end % for loop
dr.ghxx = ghxx;
dr.ghxu = ghxu;
dr.ghuu = ghuu;
dr.ghs2 = ghs2;
end
% load(M_.fname);