| 1 |
function [fval, fjac] = rosenbrock(x) |
| 2 |
|
| 3 |
% Copyright © 2021-2022 Dynare Team |
| 4 |
% |
| 5 |
% This file is part of Dynare. |
| 6 |
% |
| 7 |
% Dynare is free software: you can redistribute it and/or modify |
| 8 |
% it under the terms of the GNU General Public License as published by |
| 9 |
% the Free Software Foundation, either version 3 of the License, or |
| 10 |
% (at your option) any later version. |
| 11 |
% |
| 12 |
% Dynare is distributed in the hope that it will be useful, |
| 13 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
% GNU General Public License for more details. |
| 16 |
% |
| 17 |
% You should have received a copy of the GNU General Public License |
| 18 |
% along with Dynare. If not, see <https://www.gnu.org/licenses/>. |
| 19 |
|
| 20 |
if nargin==1 |
| 21 |
fval = zeros(2, 1); |
| 22 |
fval(1) = 1.0-x(1); |
| 23 |
fval(2) = 10.0*(x(2)-x(1)*x(1)); |
| 24 |
if nargout>1 |
| 25 |
fjac = zeros(2); |
| 26 |
fjac(1,1) = -1; |
| 27 |
fjac(1,2) = 0; |
| 28 |
fjac(2,1) = -20*x(1); |
| 29 |
fjac(2,2) = 10; |
| 30 |
end |
| 31 |
elseif ~nargin |
| 32 |
if nargout==1 |
| 33 |
fval = [10000; 1]; |
| 34 |
else |
| 35 |
error('One output is required for initialization mode.') |
| 36 |
end |
| 37 |
else |
| 38 |
error('Wrong number of input arguments.') |
| 39 |
end |