Home > matlab > dynare_solve_block_or_bytecode.m

dynare_solve_block_or_bytecode

PURPOSE ^

Copyright (C) 2010-2011 Dynare Team

SYNOPSIS ^

function [x,info] = dynare_solve_block_or_bytecode(y, exo, params, options, M)

DESCRIPTION ^

 Copyright (C) 2010-2011 Dynare Team

 This file is part of Dynare.

 Dynare is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 Dynare is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with Dynare.  If not, see <http://www.gnu.org/licenses/>.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [x,info] = dynare_solve_block_or_bytecode(y, exo, params, options, M)
0002 % Copyright (C) 2010-2011 Dynare Team
0003 %
0004 % This file is part of Dynare.
0005 %
0006 % Dynare is free software: you can redistribute it and/or modify
0007 % it under the terms of the GNU General Public License as published by
0008 % the Free Software Foundation, either version 3 of the License, or
0009 % (at your option) any later version.
0010 %
0011 % Dynare is distributed in the hope that it will be useful,
0012 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014 % GNU General Public License for more details.
0015 %
0016 % You should have received a copy of the GNU General Public License
0017 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0018 
0019 info = 0;
0020 x = y;
0021 if options.block && ~options.bytecode
0022     for b = 1:size(M.blocksMFS,1)
0023         n = size(M.blocksMFS{b}, 1);
0024         ss = x;
0025         if n ~= 0
0026             if options.solve_algo <= 4
0027                 [y, check] = dynare_solve('block_mfs_steadystate', ...
0028                                           ss(M.blocksMFS{b}), ...
0029                                           options.jacobian_flag, b, ss, exo, params, M);
0030                 if check ~= 0
0031                     %                    error(['STEADY: convergence
0032                     %                    problems in block ' int2str(b)])
0033                     info = 1;
0034                     return
0035                 end
0036                 ss(M.blocksMFS{b}) = y;
0037             else
0038                 [ss, check] = solve_one_boundary([M.fname '_static_' int2str(b)], ss, exo, ...
0039                                                  params, [], M.blocksMFS{b}, n, 1, 0, b, 0, options.maxit_, ...
0040                                                  options.solve_tolf, ...
0041                                                  options.slowc, 0, options.solve_algo, 1, 0, 0,M,options);
0042                 if check
0043                     info = 1;
0044                     return
0045                 end
0046             end
0047         end
0048         [r, g1, x] = feval([M.fname '_static'], b, ss, ...
0049                            exo, params);
0050     end
0051 elseif options.bytecode
0052     if options.solve_algo > 4
0053         [check, x] = bytecode('static', x, exo, params);
0054         %        mexErrCheck('bytecode', check);
0055         if check
0056             info = 1;
0057             return
0058         end
0059     elseif options.block
0060         for b = 1:size(M.blocksMFS,1)
0061             n = size(M.blocksMFS{b}, 1);
0062             if n ~= 0
0063                 [y, check] = dynare_solve('block_bytecode_mfs_steadystate', ...
0064                                           x(M.blocksMFS{b}), ...
0065                                           options.jacobian_flag, b, x, exo, params, M);
0066                 if check
0067                     %                    error(['STEADY: convergence
0068                     %                    problems in block ' int2str(b)])
0069                     info = 1;
0070                     return
0071                 end
0072                 x(M.blocksMFS{b}) = y;
0073             else
0074                 [chk, nulldev, nulldev1, x] = bytecode( x, exo, params, ...
0075                                                         x, 1, x, 'evaluate', 'static', ['block = ' int2str(b)]);
0076                 if chk
0077                     info = 1;
0078                     return
0079                 end
0080             end;
0081         end
0082     else
0083         [x, check] = dynare_solve('bytecode_steadystate', ...
0084                                   y, ...
0085                                   options.jacobian_flag, exo, params);
0086         if check
0087             %            error('STEADY: convergence problems')
0088             info = 1;
0089             return
0090         end
0091     end
0092 end

Generated on Mon 21-May-2012 02:42:43 by m2html © 2005