Skip to content
This repository was archived by the owner on Apr 16, 2025. It is now read-only.

Commit 015b9e0

Browse files
committed
Handle Klement
1 parent 009dc15 commit 015b9e0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/nlsolve/klement.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function SciMLBase.__solve(prob::NonlinearProblem, alg::SimpleKlement, args...;
2525
@bb δx² = similar(x)
2626

2727
for _ in 1:maxiters
28-
any(iszero, J) && (J = __init_identity_jacobian!!(J))
28+
any(any(iszero, J)) && (J = __init_identity_jacobian!!(J))
2929

3030
@bb @. δx = fprev / J
3131

src/utils.jl

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ __max_tdir(a, b, x0, x1) = ifelse(x1 > x0, max(a, b), min(a, b))
2222
__standard_tag(::Nothing, f::F, x::AbstractArray{T}) where {F, T} = ForwardDiff.Tag(f, T)
2323
__standard_tag(tag::ForwardDiff.Tag, f::F, x::AbstractArray{T}) where {F, T} = tag
2424
__standard_tag(tag, f::F, x::AbstractArray{T}) where {F, T} = ForwardDiff.Tag(tag, T)
25+
__standard_tag(::Nothing, f::F, x::T) where {F, T <: Number} = ForwardDiff.Tag(f, T)
26+
__standard_tag(tag::ForwardDiff.Tag, f::F, x::T) where {F, T <: Number} = tag
27+
__standard_tag(tag, f::F, x::T) where {F, T <: Number} = ForwardDiff.Tag(tag, T)
2528

2629
__pick_forwarddiff_chunk(x) = ForwardDiff.Chunk(length(x))
2730
function __pick_forwarddiff_chunk(x::StaticArray)
@@ -40,7 +43,7 @@ function __get_jacobian_config(ad::AutoForwardDiff{CS}, f::F, x) where {F, CS}
4043
end
4144
function __get_jacobian_config(ad::AutoForwardDiff{CS}, f!::F, y, x) where {F, CS}
4245
ck = (CS === nothing || CS 0) ? __pick_forwarddiff_chunk(x) : ForwardDiff.Chunk{CS}()
43-
tag = __standard_tag(ad.tag, f, x)
46+
tag = __standard_tag(ad.tag, f!, x)
4447
return ForwardDiff.JacobianConfig(f!, y, x, ck, tag)
4548
end
4649

0 commit comments

Comments
 (0)