4.1: simplication of sorting code for returning ghxx ghxu ghuu and ghs2 to Dynare
git-svn-id: https://www.dynare.org/svn/dynare/trunk@2633 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
parent
af69c4d6a5
commit
90e38a4e8b
|
@ -149,31 +149,23 @@ function [dr,info,M_,options_,oo_] = dr1(dr,task,M_,options_,oo_)
|
||||||
ghxu=zeros(g_2rows, nspred*nExog);
|
ghxu=zeros(g_2rows, nspred*nExog);
|
||||||
ghuu=zeros(g_2rows, nExog^2);
|
ghuu=zeros(g_2rows, nExog^2);
|
||||||
ghs2=zeros(g_2rows, 1);
|
ghs2=zeros(g_2rows, 1);
|
||||||
% for i=1:g_2cols - can not use for loop as i needs to be
|
for i=1:g_2cols
|
||||||
% decremented inside loop when copying symmetric derivatives
|
if s0 < nspred & s1 < nspred
|
||||||
i=0;
|
for j=1:g_2rows
|
||||||
while i<g_2cols
|
ghxx(j,s0*nspred+s1+1) = 2*g_2(j,i);
|
||||||
i=i+1;
|
if s1 > s0
|
||||||
if s0 < nspred & s1 < nspred%+1
|
ghxx(j,s1*nspred+s0+1) = 2*g_2(j,i);
|
||||||
if s1 < s0 % copy symmetric derivatives
|
|
||||||
ghxx(:,s0*nspred+s1+1) = ghxx(:,(s0+1)+(nspred)*s1);
|
|
||||||
i=i-1; % reduce conter
|
|
||||||
else
|
|
||||||
for j=1:g_2rows % j is the row jumber
|
|
||||||
ghxx(j,s0*nspred+s1+1) = 2*g_2(j,i);
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif s0 < nspred & s1 < nspred+nExog
|
elseif s0 < nspred & s1 < nspred+nExog
|
||||||
for j=1:g_2rows
|
for j=1:g_2rows
|
||||||
ghxu(j,(s0*nExog+s1-nspred+1)) = 2*g_2(j,i);
|
ghxu(j,(s0*nExog+s1-nspred+1)) = 2*g_2(j,i);
|
||||||
end
|
end
|
||||||
elseif s0 < nspred+nExog & s1 < nExog% nspred+nExog%+1
|
elseif s0 < nspred+nExog & s1 < nspred+nExog
|
||||||
if s1 < s0-nspred % copy symmetric derivatives
|
for j=1:g_2rows
|
||||||
ghuu(:,(s0-nspred)*nExog+s1+1) = ghuu(:,(s0-nspred+1)+(nExog+1)*(s1));
|
ghuu(j,(s0-nspred)*nExog+s1-nspred +1) = 2*g_2(j,i);
|
||||||
i=i-1;
|
if s1 > s0
|
||||||
else
|
ghuu(j,(s1-nspred)*nExog+s0-nspred+1) = 2*g_2(j,i);
|
||||||
for j=1:g_2rows
|
|
||||||
ghuu(j,(s0-nspred)*nExog+s1+1) = 2*g_2(j,i);
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -182,9 +174,9 @@ function [dr,info,M_,options_,oo_] = dr1(dr,task,M_,options_,oo_)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
s1=s1+1;
|
s1=s1+1;
|
||||||
if (s1 == nspred+nExog & s0<nspred)|(s1 == nExog & s0>=nspred)
|
if s1 == nspred+nExog+1
|
||||||
s0=s0+1;
|
s0=s0+1;
|
||||||
s1 =0;
|
s1 =0;
|
||||||
end
|
end
|
||||||
end % for loop
|
end % for loop
|
||||||
dr.ghxx = ghxx;
|
dr.ghxx = ghxx;
|
||||||
|
|
Loading…
Reference in New Issue