Create a sparse identifty matrix when it makes sense.

dprior
Stéphane Adjemian (Argos) 2024-02-12 17:48:11 +01:00
parent fd76ce53af
commit 24fbc0d923
Signed by: stepan
GPG Key ID: 295C1FE89E17EB3C
1 changed files with 5 additions and 1 deletions

View File

@ -123,7 +123,11 @@ for its = 1:maxit
fjac2=fjac'*fjac;
temp=max(sum(abs(fjac2)));
if temp>0
p=-(fjac2+sqrt(nn*eps)*temp*eye(nn))\(fjac'*fvec);
if issparse(fjac)
p=-(fjac2+sqrt(nn*eps)*temp*speye(nn))\(fjac'*fvec);
else
p=-(fjac2+sqrt(nn*eps)*temp*eye(nn))\(fjac'*fvec);
end
else
errorflag = true;
errorcode = 5;