commit
5f403e9f62
|
@ -121,7 +121,20 @@ for its = 1:maxit
|
||||||
end
|
end
|
||||||
if rcond_fjac < sqrt(eps)
|
if rcond_fjac < sqrt(eps)
|
||||||
fjac2=fjac'*fjac;
|
fjac2=fjac'*fjac;
|
||||||
p=-(fjac2+sqrt(nn*eps)*max(sum(abs(fjac2)))*eye(nn))\(fjac'*fvec);
|
temp=max(sum(abs(fjac2)));
|
||||||
|
if temp>0
|
||||||
|
p=-(fjac2+sqrt(nn*eps)*temp*eye(nn))\(fjac'*fvec);
|
||||||
|
else
|
||||||
|
errorflag = true;
|
||||||
|
errorcode = 5;
|
||||||
|
if nargout<3
|
||||||
|
skipline()
|
||||||
|
dprintf('SOLVE: Iteration %s', num2str(its))
|
||||||
|
disp('Zero Jacobian.')
|
||||||
|
skipline()
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
else
|
else
|
||||||
p = -fjac\fvec ;
|
p = -fjac\fvec ;
|
||||||
end
|
end
|
||||||
|
|
|
@ -327,5 +327,9 @@ else
|
||||||
end
|
end
|
||||||
% Form the appropriate convex combination of the Gauss-Newton direction and the
|
% Form the appropriate convex combination of the Gauss-Newton direction and the
|
||||||
% scaled gradient direction.
|
% scaled gradient direction.
|
||||||
x = alpha*x + (1.0-alpha)*min(sgnorm, delta)*s;
|
if alpha>0
|
||||||
|
x = alpha*x + (1.0-alpha)*min(sgnorm, delta)*s;
|
||||||
|
else %prevent zero weight on Inf evaluating to NaN
|
||||||
|
x = min(sgnorm, delta)*s;
|
||||||
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue