1function [A,B,ys,info,Model,DynareOptions,DynareResults] = dynare_resolve(Model,DynareOptions,DynareResults,mode)
2% Computes the linear approximation and the matrices A and B of the transition equation.
3
4%@info:
5%! @deftypefn {Function File} {[@var{A},@var{B},@var{ys},@var{info},@var{Model},@var{DynareOptions},@var{DynareResults}] =} resol (@var{Model},@var{DynareOptions},@var{DynareResults})
6%! @anchor{dynare_resolve}
7%! @sp 1
8%! Computes the linear approximation and the matrices A and B of the transition equation.
9%! @sp 2
10%! @strong{Inputs}
11%! @sp 1
12%! @table @ @var
13%! @item Model
14%! Matlab's structure describing the model (initialized by dynare, see @ref{M_}).
15%! @item DynareOptions
16%! Matlab's structure describing the options (initialized by dynare, see @ref{options_}).
17%! @item DynareResults
18%! Matlab's structure gathering the results (initialized by dynare, see @ref{oo_}).
19%! @item mode
20%! Passed argument if restricted state-space is required, not passed otherwise
21%! @end table
22%! @sp 2
23%! @strong{Outputs}
24%! @sp 1
25%! @table @ @var
26%! @item A
27%! Matrix of doubles, transition matrix of the state equation.
28%! @item B
29%! Matrix of doubles, matrix relating the endogenous variables to the innovations in the state equation.
30%! @item ys
31%! Vector of doubles, steady state level of the endogenous variables in declaration order
32%! @item info
33%! Integer scalar, error code as given by @ref{resol}.
34%! @item Model
35%! Matlab's structure describing the model (initialized by dynare, see @ref{M_}).
36%! @item DynareOptions
37%! Matlab's structure describing the options (initialized by dynare, see @ref{options_}).
38%! @item DynareResults
39%! Matlab's structure gathering the results (initialized by dynare, see @ref{oo_}).
40%! @end table
41%! @sp 2
42%! @strong{This function is called by:}
43%! @sp 1
44%! @ref{dsge_likelihood}, @ref{DsgeLikelihood_hh}, @ref{DsgeVarLikelihood}, @ref{dsge_posterior_kernel}, @ref{DsgeSmoother}, @ref{dynare_sensitivity}, @ref{gsa/thet2tau}, @ref{gsa/stab_map}, @ref{identification_analysis}, @ref{imcforecast}, @ref{thet2tau}
45%! @sp 2
46%! @strong{This function calls:}
47%! @sp 1
48%! @ref{resol}, @ref{kalman_transition_matrix}
49%! @end deftypefn
50%@eod:
51
52% Copyright (C) 2001-2020 Dynare Team
53%
54% This file is part of Dynare.
55%
56% Dynare is free software: you can redistribute it and/or modify
57% it under the terms of the GNU General Public License as published by
58% the Free Software Foundation, either version 3 of the License, or
59% (at your option) any later version.
60%
61% Dynare is distributed in the hope that it will be useful,
62% but WITHOUT ANY WARRANTY; without even the implied warranty of
63% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
64% GNU General Public License for more details.
65%
66% You should have received a copy of the GNU General Public License
67% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
68
69[dr,info,Model,DynareOptions,DynareResults] =compute_decision_rules(Model,DynareOptions,DynareResults);
70
71if info(1) > 0
72    A = [];
73    if nargout>1
74        B = [];
75        if nargout>2
76            ys = [];
77        end
78    end
79    return
80end
81
82switch nargin
83  case 3
84    endo_nbr = Model.endo_nbr;
85    nstatic = Model.nstatic;
86    nspred = Model.nspred;
87    iv = (1:endo_nbr)';
88    if ~DynareOptions.block
89        ic = [ nstatic+(1:nspred) endo_nbr+(1:size(DynareResults.dr.ghx,2)-nspred) ]';
90    else
91        ic = DynareResults.dr.restrict_columns;
92    end
93  case 4
94    iv = DynareResults.dr.restrict_var_list;
95    ic = DynareResults.dr.restrict_columns;
96  otherwise
97    error('dynare_resolve:: Error in the calling sequence!')
98end
99
100if nargout==1
101    A = kalman_transition_matrix(DynareResults.dr,iv,ic,Model.exo_nbr);
102    return
103end
104
105[A,B] = kalman_transition_matrix(DynareResults.dr,iv,ic,Model.exo_nbr);
106ys = DynareResults.dr.ys;
107