diff --git a/doc/dynare.texi b/doc/dynare.texi
index e46320884..b7bfeb029 100644
--- a/doc/dynare.texi
+++ b/doc/dynare.texi
@@ -2667,6 +2667,7 @@ command.
@end defvr
@deffn Command model_info ;
+@deffnx Command model_info (@var{OPTIONS}@dots{});
@descriptionhead
@@ -2731,6 +2732,22 @@ to @samp{SIMPLE} if the block has only one equation. If several
equation appears in the block, @var{x} is equal to @samp{COMPLETE}.
@end table
+@optionshead
+
+@table @code
+
+@item 'static'
+Prints out the block decomposition of the static model.
+Without 'static' option model_info displays the block decomposition
+of the dynamic model.
+
+@item 'incidence'
+Displays the gross incidence matrix and the reordered incidence matrix
+of the block decomposed model.
+
+@end table
+
+
@end deffn
@deffn Command print_bytecode_dynamic_model ;
diff --git a/matlab/dyn_ramsey_static.m b/matlab/dyn_ramsey_static.m
index 32616923d..f944afbf1 100644
--- a/matlab/dyn_ramsey_static.m
+++ b/matlab/dyn_ramsey_static.m
@@ -131,9 +131,14 @@ Uyy = reshape(Uyy,endo_nbr,endo_nbr);
% set multipliers and auxiliary variables that
% depends on multipliers to 0 to compute residuals
-[res,fJ] = feval([fname '_static'],xx,[oo.exo_simul oo.exo_det_simul], ...
+if (options_.bytecode)
+ [chck, res, junk] = bytecode('static',xx,[oo.exo_simul oo.exo_det_simul], ...
+ M.params, 'evaluate');
+ fJ = junk.g1;
+else
+ [res,fJ] = feval([fname '_static'],xx,[oo.exo_simul oo.exo_det_simul], ...
M.params);
-
+end
% index of multipliers and corresponding equations
% the auxiliary variables before the Lagrange multipliers are treated
% as ordinary endogenous variables
diff --git a/matlab/model_info.m b/matlab/model_info.m
index e67923b00..d6065b00d 100644
--- a/matlab/model_info.m
+++ b/matlab/model_info.m
@@ -19,39 +19,53 @@ function model_info(varargin);
% along with Dynare. If not, see .
global M_;
-fprintf(' Informations about %s\n',M_.fname);
+if sum(strcmp(varargin,'static')) > 0
+ static = 1;
+else
+ static = 0;
+end;
+if sum(strcmp(varargin,'incidence')) > 0
+ incidence = 1;
+else
+ incidence = 0;
+end;
+if static
+ fprintf(' Informations about %s (static model)\n',M_.fname);
+ block_structre_str = 'block_structure_stat';
+ block_structure = M_.block_structure_stat;
+ nb_leadlag = 1;
+else
+ fprintf(' Informations about %s (dynamic model)\n',M_.fname);
+ block_structre_str = 'block_structure';
+ block_structure = M_.block_structure;
+ nb_leadlag = 3;
+end;
fprintf(strcat(' ===================',char(ones(1,length(M_.fname))*'='),'\n\n'));
-if(isfield(M_,'block_structure'))
- nb_blocks=length(M_.block_structure.block);
+if(isfield(M_,block_structre_str))
+ nb_blocks=length(block_structure.block);
fprintf('The model has %d equations and is decomposed in %d blocks as follow:\n',M_.endo_nbr,nb_blocks);
fprintf('===============================================================================================================\n');
fprintf('| %10s | %10s | %30s | %14s | %31s |\n','Block no','Size','Block Type',' Equation','Dependent variable');
fprintf('|============|============|================================|================|=================================|\n');
for i=1:nb_blocks
- size_block=length(M_.block_structure.block(i).equation);
+ size_block=length(block_structure.block(i).equation);
if(i>1)
fprintf('|------------|------------|--------------------------------|----------------|---------------------------------|\n');
end;
for j=1:size_block
if(j==1)
- fprintf('| %10d | %10d | %30s | %14d | %-6d %24s |\n',i,size_block,Sym_type(M_.block_structure.block(i).Simulation_Type),M_.block_structure.block(i).equation(j),M_.block_structure.block(i).variable(j),M_.endo_names(M_.block_structure.block(i).variable(j),:));
+ fprintf('| %10d | %10d | %30s | %14d | %-6d %24s |\n',i,size_block,Sym_type(block_structure.block(i).Simulation_Type),block_structure.block(i).equation(j),block_structure.block(i).variable(j),M_.endo_names(block_structure.block(i).variable(j),:));
else
- fprintf('| %10s | %10s | %30s | %14d | %-6d %24s |\n','','','',M_.block_structure.block(i).equation(j),M_.block_structure.block(i).variable(j),M_.endo_names(M_.block_structure.block(i).variable(j),:));
+ fprintf('| %10s | %10s | %30s | %14d | %-6d %24s |\n','','','',block_structure.block(i).equation(j),block_structure.block(i).variable(j),M_.endo_names(block_structure.block(i).variable(j),:));
end;
end;
end;
fprintf('===============================================================================================================\n');
fprintf('\n');
- for k=1:M_.maximum_endo_lag+M_.maximum_endo_lead+1
- if(k==M_.maximum_endo_lag+1)
- fprintf('%-30s %s','the variable','is used in equations Contemporaneously');
- elseif(k0)
- IM=sortrows(M_.block_structure.incidence(k).sparse_IM,2);
+ if static
+ fprintf('%-30s %s','the variable','is used in equations Contemporaneously');
+ if(size(block_structure.incidence.sparse_IM,1)>0)
+ IM=sortrows(block_structure.incidence.sparse_IM,2);
else
IM=[];
end;
@@ -65,17 +79,42 @@ if(isfield(M_,'block_structure'))
last=IM(i,2);
end;
fprintf('\n\n');
+ else
+ for k=1:M_.maximum_endo_lag+M_.maximum_endo_lead+1
+ if(k==M_.maximum_endo_lag+1)
+ fprintf('%-30s %s','the variable','is used in equations Contemporaneously');
+ elseif(k0)
+ IM=sortrows(block_structure.incidence(k).sparse_IM,2);
+ else
+ IM=[];
+ end;
+ size_IM=size(IM,1);
+ last=99999999;
+ for i=1:size_IM
+ if(last~=IM(i,2))
+ fprintf('\n%-30s',M_.endo_names(IM(i,2),:));
+ end;
+ fprintf(' %5d',IM(i,1));
+ last=IM(i,2);
+ end;
+ fprintf('\n\n');
+ end;
end;
%printing the gross incidence matrix
IM_star = char([kron(ones(M_.endo_nbr, M_.endo_nbr-1), double(blanks(3))) double(blanks(M_.endo_nbr)')]);
- for i = 1:3
- n = size(M_.block_structure.incidence(i).sparse_IM,1);
+ for i = 1:nb_leadlag
+ n = size(block_structure.incidence(i).sparse_IM,1);
for j = 1:n
- if ismember(M_.block_structure.incidence(i).sparse_IM(j,2), M_.state_var)
- IM_star(M_.block_structure.incidence(i).sparse_IM(j,1), 3 * (M_.block_structure.incidence(i).sparse_IM(j,2) - 1) + 1) = 'X';
+ if ismember(block_structure.incidence(i).sparse_IM(j,2), M_.state_var)
+ IM_star(block_structure.incidence(i).sparse_IM(j,1), 3 * (block_structure.incidence(i).sparse_IM(j,2) - 1) + 1) = 'X';
else
- IM_star(M_.block_structure.incidence(i).sparse_IM(j,1), 3 * (M_.block_structure.incidence(i).sparse_IM(j,2) - 1) + 1) = '1';
+ IM_star(block_structure.incidence(i).sparse_IM(j,1), 3 * (block_structure.incidence(i).sparse_IM(j,2) - 1) + 1) = '1';
end;
end;
end;
@@ -88,7 +127,7 @@ if(isfield(M_,'block_structure'))
var_names = [var_names; blank; M_.endo_names(i,:)];
end;
end;
- if nargin == 1 && strcmp(varargin{1},'incidence')
+ if incidence
topp = [char(kron(double(blanks(ceil(log10(M_.endo_nbr)))),ones(size(M_.endo_names,2),1))) var_names' ];
bott = [int2str(seq') blanks(M_.endo_nbr)' blanks(M_.endo_nbr)' IM_star];
fprintf('\n Gross incidence matrix\n');
@@ -97,42 +136,42 @@ if(isfield(M_,'block_structure'))
%printing the reordered incidence matrix
IM_star_reordered = char([kron(ones(M_.endo_nbr, M_.endo_nbr-1), double(blanks(3))) double(blanks(M_.endo_nbr)')]);
- eq(M_.block_structure.equation_reordered) = seq;
- va(M_.block_structure.variable_reordered) = seq;
+ eq(block_structure.equation_reordered) = seq;
+ va(block_structure.variable_reordered) = seq;
barre_blank = [ barre(size(M_.endo_names,2)); blanks(size(M_.endo_names,2))];
cur_block = 1;
for i = 1:M_.endo_nbr
past_block = cur_block;
- while ismember(M_.block_structure.variable_reordered(i), M_.block_structure.block(cur_block).variable) == 0;
+ while ismember(block_structure.variable_reordered(i), block_structure.block(cur_block).variable) == 0;
cur_block = cur_block + 1;
end;
if i == 1
- var_names = [blank; M_.endo_names(M_.block_structure.variable_reordered(i),:)];
+ var_names = [blank; M_.endo_names(block_structure.variable_reordered(i),:)];
else
if past_block ~= cur_block
- var_names = [var_names; barre_blank; M_.endo_names(M_.block_structure.variable_reordered(i),:)];
+ var_names = [var_names; barre_blank; M_.endo_names(block_structure.variable_reordered(i),:)];
else
- var_names = [var_names; blank; M_.endo_names(M_.block_structure.variable_reordered(i),:)];
+ var_names = [var_names; blank; M_.endo_names(block_structure.variable_reordered(i),:)];
end
end;
end;
topp = [char(kron(double(blanks(ceil(log10(M_.endo_nbr)))),ones(size(M_.endo_names,2),1))) var_names' ];
n_state_var = length(M_.state_var);
IM_state_var = zeros(n_state_var, n_state_var);
- inv_variable_reordered(M_.block_structure.variable_reordered) = 1:M_.endo_nbr;
- state_equation = M_.block_structure.equation_reordered(inv_variable_reordered(M_.state_var));
- for i = 1:3
- n = size(M_.block_structure.incidence(i).sparse_IM,1);
+ inv_variable_reordered(block_structure.variable_reordered) = 1:M_.endo_nbr;
+ state_equation = block_structure.equation_reordered(inv_variable_reordered(M_.state_var));
+ for i = 1:nb_leadlag
+ n = size(block_structure.incidence(i).sparse_IM,1);
for j = 1:n
- [tf, loc] = ismember(M_.block_structure.incidence(i).sparse_IM(j,2), M_.state_var);
+ [tf, loc] = ismember(block_structure.incidence(i).sparse_IM(j,2), M_.state_var);
if tf
- IM_star_reordered(eq(M_.block_structure.incidence(i).sparse_IM(j,1)), 3 * (va(M_.block_structure.incidence(i).sparse_IM(j,2)) - 1) + 1) = 'X';
- [tfi, loci] = ismember(M_.block_structure.incidence(i).sparse_IM(j,1), state_equation);
+ IM_star_reordered(eq(block_structure.incidence(i).sparse_IM(j,1)), 3 * (va(block_structure.incidence(i).sparse_IM(j,2)) - 1) + 1) = 'X';
+ [tfi, loci] = ismember(block_structure.incidence(i).sparse_IM(j,1), state_equation);
if tfi
IM_state_var(loci, loc) = 1;
end;
else
- IM_star_reordered(eq(M_.block_structure.incidence(i).sparse_IM(j,1)), 3 * (va(M_.block_structure.incidence(i).sparse_IM(j,2)) - 1) + 1) = '1';
+ IM_star_reordered(eq(block_structure.incidence(i).sparse_IM(j,1)), 3 * (va(block_structure.incidence(i).sparse_IM(j,2)) - 1) + 1) = '1';
end;
end;
end;
@@ -143,7 +182,7 @@ if(isfield(M_,'block_structure'))
block = {};
for i = 1:n_state_var;
past_block = cur_block;
- while ismember(M_.state_var(i), M_.block_structure.block(cur_block).variable) == 0;
+ while ismember(M_.state_var(i), block_structure.block(cur_block).variable) == 0;
cur_block = cur_block + 1;
end;
if (past_block ~= cur_block) || (past_block == cur_block && i == n_state_var)
@@ -154,7 +193,7 @@ if(isfield(M_,'block_structure'))
cur_block = 1;
for i = 1:M_.endo_nbr
past_block = cur_block;
- while ismember(M_.block_structure.variable_reordered(i), M_.block_structure.block(cur_block).variable) == 0;
+ while ismember(block_structure.variable_reordered(i), block_structure.block(cur_block).variable) == 0;
cur_block = cur_block + 1;
end;
if past_block ~= cur_block
@@ -164,7 +203,7 @@ if(isfield(M_,'block_structure'))
end;
end
- bott = [int2str(M_.block_structure.equation_reordered') blanks(M_.endo_nbr)' blanks(M_.endo_nbr)' IM_star_reordered];
+ bott = [int2str(block_structure.equation_reordered') blanks(M_.endo_nbr)' blanks(M_.endo_nbr)' IM_star_reordered];
fprintf('\n Reordered incidence matrix\n');
fprintf(' ==========================\n');
disp([topp; bott]);
diff --git a/matlab/resol.m b/matlab/resol.m
index a2db2b32d..83544883e 100644
--- a/matlab/resol.m
+++ b/matlab/resol.m
@@ -113,6 +113,7 @@ end
if options.block
[dr,info,M,options,oo] = dr_block(dr,check_flag,M,options,oo);
+ oo.dr = dr;
else
[dr,info] = stochastic_solvers(dr,check_flag,M,options,oo);
oo.dr = dr;
diff --git a/mex/sources/bytecode/SparseMatrix.cc b/mex/sources/bytecode/SparseMatrix.cc
index 10840d15a..77a5425f6 100644
--- a/mex/sources/bytecode/SparseMatrix.cc
+++ b/mex/sources/bytecode/SparseMatrix.cc
@@ -2179,7 +2179,7 @@ SparseMatrix::Singular_display(int block, int Size, bool steady_state, it_code_t
mexCallMATLAB(3, lhs, 1, rhs, "svd");
mxArray* SVD_u = lhs[0];
mxArray* SVD_s = lhs[1];
- mxArray* SVD_v = lhs[2];
+ //mxArray* SVD_v = lhs[2];
double *SVD_ps = mxGetPr(SVD_s);
double *SVD_pu = mxGetPr(SVD_u);
for (int i = 0; i < Size; i++)
diff --git a/mex/sources/bytecode/bytecode.cc b/mex/sources/bytecode/bytecode.cc
index b3ff8c1bb..fde925c5a 100644
--- a/mex/sources/bytecode/bytecode.cc
+++ b/mex/sources/bytecode/bytecode.cc
@@ -439,9 +439,12 @@ main(int nrhs, const char *prhs[])
for (int i = 0; i < nb_blocks; i++)
{
mxSetFieldByNumber(plhs[2], i, jacob_field_number, interprete.get_jacob(i));
- mxSetFieldByNumber(plhs[2], i, jacob_exo_field_number, interprete.get_jacob_exo(i));
- mxSetFieldByNumber(plhs[2], i, jacob_exo_det_field_number, interprete.get_jacob_exo_det(i));
- mxSetFieldByNumber(plhs[2], i, jacob_other_endo_field_number, interprete.get_jacob_other_endo(i));
+ if (!steady_state)
+ {
+ mxSetFieldByNumber(plhs[2], i, jacob_exo_field_number, interprete.get_jacob_exo(i));
+ mxSetFieldByNumber(plhs[2], i, jacob_exo_det_field_number, interprete.get_jacob_exo_det(i));
+ mxSetFieldByNumber(plhs[2], i, jacob_other_endo_field_number, interprete.get_jacob_other_endo(i));
+ }
}
}
}
diff --git a/preprocessor/StaticModel.cc b/preprocessor/StaticModel.cc
index 2c495c2b4..9b8319ca9 100644
--- a/preprocessor/StaticModel.cc
+++ b/preprocessor/StaticModel.cc
@@ -1511,6 +1511,58 @@ StaticModel::writeOutput(ostream &output, bool block) const
output << getBlockEquationID(b, i)+1 << "; ";
output << "];" << endl;
}
+ for (int b = 0; b < (int) nb_blocks; b++)
+ {
+ BlockSimulationType simulation_type = getBlockSimulationType(b);
+ unsigned int block_size = getBlockSize(b);
+ unsigned int block_mfs = getBlockMfs(b);
+ unsigned int block_recursive = block_size - block_mfs;
+ ostringstream tmp_s, tmp_s_eq;
+ tmp_s.str("");
+ tmp_s_eq.str("");
+ for (int i = 0; i < block_size; i++)
+ {
+ tmp_s << " " << getBlockVariableID(b, i)+1;
+ tmp_s_eq << " " << getBlockEquationID(b, i)+1;
+ }
+ output << "block_structure_stat.block(" << b+1 << ").Simulation_Type = " << simulation_type << ";\n";
+ output << "block_structure_stat.block(" << b+1 << ").endo_nbr = " << block_size << ";\n";
+ output << "block_structure_stat.block(" << b+1 << ").mfs = " << getBlockMfs(block) << ";\n";
+ output << "block_structure_stat.block(" << b+1 << ").equation = [" << tmp_s_eq.str() << "];\n";
+ output << "block_structure_stat.block(" << b+1 << ").variable = [" << tmp_s.str() << "];\n";
+ }
+ output << "M_.block_structure_stat.block = block_structure_stat.block;\n";
+ string cst_s;
+ int nb_endo = symbol_table.endo_nbr();
+ output << "M_.block_structure_stat.variable_reordered = [";
+ for (int i = 0; i < nb_endo; i++)
+ output << " " << variable_reordered[i]+1;
+ output << "];\n";
+ output << "M_.block_structure_stat.equation_reordered = [";
+ for (int i = 0; i < nb_endo; i++)
+ output << " " << equation_reordered[i]+1;
+ output << "];\n";
+
+ map, int> row_incidence;
+ for (first_derivatives_t::const_iterator it = first_derivatives.begin();
+ it != first_derivatives.end(); it++)
+ {
+ int deriv_id = it->first.second;
+ if (getTypeByDerivID(deriv_id) == eEndogenous)
+ {
+ int eq = it->first.first;
+ int symb = getSymbIDByDerivID(deriv_id);
+ int var = symbol_table.getTypeSpecificID(symb);
+ //int lag = getLagByDerivID(deriv_id);
+ row_incidence[make_pair(eq, var)] = 1;
+ }
+ }
+ output << "M_.block_structure_stat.incidence.sparse_IM = [";
+ for (map, int>::const_iterator it = row_incidence.begin(); it != row_incidence.end(); it++)
+ {
+ output << it->first.first+1 << " " << it->first.second+1 << ";\n";
+ }
+ output << "];\n";
}
SymbolType