Skip to content

Commit 60dd540

Browse files
continues with NaN jacobian
1 parent 73a802d commit 60dd540

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/rootfinders/newton.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ function newton_solver(device, _y, _x, batchdim)
315315
if isnothing(batchdim)
316316
let lx=_lx, ly=_ly
317317
return (dx, jac, y)->begin
318-
if ArrayInterface.issingular(jac)
318+
if ArrayInterface.issingular(jac) || any(isnan, jac) || any(isinf, jac)
319319
dx .= NaN32
320320
else
321321
reshape(dx, lx) .= -jac \ reshape(y, ly)
@@ -333,7 +333,7 @@ function newton_solver(device, _y, _x, batchdim)
333333
curjac = reshape(view(jac.nzval, (jac_offset+1):(jac_offset+jacsize)), (n_rows, n_cols))
334334
dx_offset = (i-1)*n_cols
335335
y_offset = (i-1)*n_rows
336-
if ArrayInterface.issingular(curjac)
336+
if ArrayInterface.issingular(curjac) || any(isnan, curjac) || any(isinf, curjac)
337337
view(dx, (dx_offset+1):(dx_offset+n_cols)) .= NaN32
338338
else
339339
view(dx, (dx_offset+1):(dx_offset+n_cols)) .= -curjac \ view(y, (y_offset+1):(y_offset+n_rows))
@@ -348,7 +348,7 @@ function newton_solver(device, _y, _x, batchdim)
348348
return (dx, jac::SparseMatrixCSC, y)->begin
349349
for i in 1:batchsize
350350
curjac = view(reshape(jac.nzval, n_rows, :), :, i:batchsize:xlen)
351-
if ArrayInterface.issingular(curjac)
351+
if ArrayInterface.issingular(curjac) || any(isnan, curjac) || any(isinf, curjac)
352352
view(dx, i:batchsize:xlen) .= NaN32
353353
else
354354
view(dx, i:batchsize:xlen) .= -curjac \ view(y, i:batchsize:ylen)

0 commit comments

Comments
 (0)