From 72950de0a09bbd854ce7996c41f56cfada0d436e Mon Sep 17 00:00:00 2001 From: Michel Juillard Date: Sun, 11 May 2014 14:44:06 +0200 Subject: [PATCH] solve1: initialize fjac only if it needs to be computed numerically. --- matlab/solve1.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/matlab/solve1.m b/matlab/solve1.m index fd57b2618..17bb0a3ab 100644 --- a/matlab/solve1.m +++ b/matlab/solve1.m @@ -41,7 +41,6 @@ function [x,check] = solve1(func,x,j1,j2,jacobian_flag,gstep,tolf,tolx,maxit,deb % along with Dynare. If not, see . nn = length(j1); -fjac = zeros(nn,nn) ; g = zeros(nn,1) ; tolmin = tolx ; @@ -71,6 +70,9 @@ end stpmax = stpmx*max([sqrt(x'*x);nn]) ; first_time = 1; +if ~jacobian_flag + fjac = zeros(nn,nn) ; +end for its = 1:maxit if jacobian_flag [fvec,fjac] = feval(func,x,varargin{:});