Commit e8b6a04e authored by stepan's avatar stepan
Browse files

* Cosmetic changes.

* Do not compute B if not needed.



git-svn-id: https://www.dynare.org/svn/dynare/trunk@3167 ac1d8469-bf42-47a9-8791-bf33cf982152
parent a2cef700
function [A,B,ys,info] = dynare_resolve(iv,ic,aux)
% function [A,B,ys,info] = dynare_resolve(iv,ic,aux)
% Computes the linear approximation and the matrices A and B of the
% transition equation
......@@ -46,22 +45,31 @@ function [A,B,ys,info] = dynare_resolve(iv,ic,aux)
[oo_.dr,info] = resol(oo_.steady_state,0);
if info(1) > 0
A = [];
B = [];
ys = [];
return
A = [];
if nargout>1
B = [];
if nargout>2
ys = [];
end
end
return
end
if nargin == 0
endo_nbr = M_.endo_nbr;
nstatic = oo_.dr.nstatic;
npred = oo_.dr.npred;
iv = (1:endo_nbr)';
ic = [ nstatic+(1:npred) endo_nbr+(1:size(oo_.dr.ghx,2)-npred) ]';
aux = oo_.dr.transition_auxiliary_variables;
k = find(aux(:,2) > npred);
aux(:,2) = aux(:,2) + nstatic;
aux(k,2) = aux(k,2) + oo_.dr.nfwrd;
endo_nbr = M_.endo_nbr;
nstatic = oo_.dr.nstatic;
npred = oo_.dr.npred;
iv = (1:endo_nbr)';
ic = [ nstatic+(1:npred) endo_nbr+(1:size(oo_.dr.ghx,2)-npred) ]';
aux = oo_.dr.transition_auxiliary_variables;
k = find(aux(:,2) > npred);
aux(:,2) = aux(:,2) + nstatic;
aux(k,2) = aux(k,2) + oo_.dr.nfwrd;
end
if nargout==1
A = kalman_transition_matrix(oo_.dr,iv,ic,aux,M_.exo_nbr);
return
end
[A,B] = kalman_transition_matrix(oo_.dr,iv,ic,aux,M_.exo_nbr);
......
......@@ -37,16 +37,17 @@ function [A,B] = kalman_transition_matrix(dr,iv,ic,aux,exo_nbr)
nr = n_iv + n_ir1;
A = zeros(nr,nr);
B = zeros(nr,exo_nbr);
i_n_iv = 1:n_iv;
A(i_n_iv,ic) = dr.ghx(iv,:);
if n_ir1 > 0
A(n_iv+1:end,:) = sparse(aux(:,1),aux(:,2),ones(n_ir1,1),n_ir1,nr);
end
B(i_n_iv,:) = dr.ghu(iv,:);
if nargout>1
B = zeros(nr,exo_nbr);
B(i_n_iv,:) = dr.ghu(iv,:);
end
% $$$ function [A,B] = kalman_transition_matrix(dr)
% $$$ global M_
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment