solve1.m: trap zero Jacobian case

mr#2067
Johannes Pfeifer 2022-05-25 14:21:28 +02:00
parent c91e1f895b
commit c9fd266cbb
1 changed files with 14 additions and 1 deletions

View File

@ -121,7 +121,20 @@ for its = 1:maxit
end
if rcond_fjac < sqrt(eps)
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
p = -fjac\fvec ;
end