diff --git a/matlab/block_bytecode_mfs_steadystate.m b/matlab/block_bytecode_mfs_steadystate.m index e5104fc69..38c3e5d16 100644 --- a/matlab/block_bytecode_mfs_steadystate.m +++ b/matlab/block_bytecode_mfs_steadystate.m @@ -20,8 +20,7 @@ function [r, g1] = block_bytecode_mfs_steadystate(y, b, y_all) % along with Dynare. If not, see . global M_ oo_ -global temporary_terms; indx = M_.blocksMFS{b}; y_all(indx) = y; x = [oo_.exo_steady_state; oo_.exo_det_steady_state]; -eval(['[chk, r, g1, nulldev, temporary_terms] = bytecode( y_all, x, M_.params, 1, y_all, temporary_terms, ''evaluate'', ''static'', ''block = ' int2str(b) ''', ''global_temporary_terms'');']); +[chk, r, g1] = bytecode( y_all, x, M_.params, 1, y_all, 'evaluate', 'static', ['block = ' int2str(b) ]); diff --git a/matlab/dynare_solve_block_or_bytecode.m b/matlab/dynare_solve_block_or_bytecode.m index cffb992f6..a3219bda5 100644 --- a/matlab/dynare_solve_block_or_bytecode.m +++ b/matlab/dynare_solve_block_or_bytecode.m @@ -59,7 +59,7 @@ elseif options_.bytecode end x(M_.blocksMFS{b}) = y; else - [check, x] = feval('bytecode', x, exo, params, 'static', ['block = ' int2str(b)]); + [chk, nulldev, nulldev1, x] = bytecode( x, exo, params, 1, x, 'evaluate', 'static', ['block = ' int2str(b)]); end; end else diff --git a/mex/sources/bytecode/Interpreter.cc b/mex/sources/bytecode/Interpreter.cc index 78d4b8dac..f13b23399 100644 --- a/mex/sources/bytecode/Interpreter.cc +++ b/mex/sources/bytecode/Interpreter.cc @@ -2546,9 +2546,9 @@ Interpreter::compute_blocks(string file_name, string bin_basename, bool steady_s #ifdef DEBUG mexPrintf("---------------------------------------------------------\n"); if (block < 0) - mexPrintf("FBEGINBLOCK %d\n", Block_Count+1); + mexPrintf("FBEGINBLOCK Block_Count=%d\n", Block_Count+1); else - mexPrintf("FBEGINBLOCK %d\n", block+1); + mexPrintf("FBEGINBLOCK block=%d\n", block+1); #endif //it's a new block { diff --git a/mex/sources/bytecode/bytecode.cc b/mex/sources/bytecode/bytecode.cc index e78a27474..77dbf12a8 100644 --- a/mex/sources/bytecode/bytecode.cc +++ b/mex/sources/bytecode/bytecode.cc @@ -387,48 +387,57 @@ mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) } if (nlhs > 2) { - int jacob_field_number = 0, jacob_exo_field_number = 0, jacob_exo_det_field_number = 0, jacob_other_endo_field_number = 0; - if (!block_structur) + if (evaluate) { - const char *field_names[] = {"g1","g1_x","g1_xd","g1_o"}; - jacob_field_number=0; - jacob_exo_field_number=1; - jacob_exo_det_field_number=2; - jacob_other_endo_field_number=2; - mwSize dims[1] = {nb_blocks }; - plhs[2] = mxCreateStructArray(1, dims, 4, field_names); - } - else if (!mxIsStruct(block_structur)) - { - plhs[2] = interprete.get_jacob(0); - //mexCallMATLAB(0,NULL, 1, &plhs[2], "disp"); - dont_store_a_structure = true; - } - else - { - plhs[2] = block_structur; - jacob_field_number = mxAddField(plhs[2], "g1"); - if (jacob_field_number == -1) - DYN_MEX_FUNC_ERR_MSG_TXT("Fatal error in bytecode: in main, cannot add extra field jacob to the structArray\n"); - jacob_exo_field_number = mxAddField(plhs[2], "g1_x"); - if (jacob_exo_field_number == -1) - DYN_MEX_FUNC_ERR_MSG_TXT("Fatal error in bytecode: in main, cannot add extra field jacob_exo to the structArray\n"); - jacob_exo_det_field_number = mxAddField(plhs[2], "g1_xd"); - if (jacob_exo_det_field_number == -1) - DYN_MEX_FUNC_ERR_MSG_TXT("Fatal error in bytecode: in main, cannot add extra field jacob_exo_det to the structArray\n"); - jacob_other_endo_field_number = mxAddField(plhs[2], "g1_o"); - if (jacob_other_endo_field_number == -1) - DYN_MEX_FUNC_ERR_MSG_TXT("Fatal error in bytecode: in main, cannot add extra field jacob_other_endo to the structArray\n"); - } - if (!dont_store_a_structure) - { - 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)); + int jacob_field_number = 0, jacob_exo_field_number = 0, jacob_exo_det_field_number = 0, jacob_other_endo_field_number = 0; + if (!block_structur) + { + const char *field_names[] = {"g1","g1_x","g1_xd","g1_o"}; + jacob_field_number=0; + jacob_exo_field_number=1; + jacob_exo_det_field_number=2; + jacob_other_endo_field_number=2; + mwSize dims[1] = {nb_blocks }; + plhs[2] = mxCreateStructArray(1, dims, 4, field_names); } + else if (!mxIsStruct(block_structur)) + { + plhs[2] = interprete.get_jacob(0); + //mexCallMATLAB(0,NULL, 1, &plhs[2], "disp"); + dont_store_a_structure = true; + } + else + { + plhs[2] = block_structur; + jacob_field_number = mxAddField(plhs[2], "g1"); + if (jacob_field_number == -1) + DYN_MEX_FUNC_ERR_MSG_TXT("Fatal error in bytecode: in main, cannot add extra field jacob to the structArray\n"); + jacob_exo_field_number = mxAddField(plhs[2], "g1_x"); + if (jacob_exo_field_number == -1) + DYN_MEX_FUNC_ERR_MSG_TXT("Fatal error in bytecode: in main, cannot add extra field jacob_exo to the structArray\n"); + jacob_exo_det_field_number = mxAddField(plhs[2], "g1_xd"); + if (jacob_exo_det_field_number == -1) + DYN_MEX_FUNC_ERR_MSG_TXT("Fatal error in bytecode: in main, cannot add extra field jacob_exo_det to the structArray\n"); + jacob_other_endo_field_number = mxAddField(plhs[2], "g1_o"); + if (jacob_other_endo_field_number == -1) + DYN_MEX_FUNC_ERR_MSG_TXT("Fatal error in bytecode: in main, cannot add extra field jacob_other_endo to the structArray\n"); + } + if (!dont_store_a_structure) + { + 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)); + } + } + } + else + { + plhs[2] = mxCreateDoubleMatrix(1, 1, mxREAL); + pind = mxGetPr(plhs[0]); + pind[0] = NAN; } if (nlhs > 3) {