Skip to content

Commit

Permalink
Merge pull request #474 from SciML/ap/patch
Browse files Browse the repository at this point in the history
fix: don't use similar on prototype
  • Loading branch information
ChrisRackauckas authored Oct 5, 2024
2 parents d56476c + 834516a commit e7e218b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NonlinearSolve"
uuid = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
authors = ["SciML"]
version = "3.15.0"
version = "3.15.1"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
5 changes: 2 additions & 3 deletions src/internal/helpers.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Evaluate the residual function at a given point
function evaluate_f(prob::AbstractNonlinearProblem{uType, iip}, u) where {uType, iip}
(; f, u0, p) = prob
(; f, p) = prob
if iip
fu = f.resid_prototype === nothing ? zero(u) :
promote_type(eltype(u), eltype(f.resid_prototype)).(f.resid_prototype)
fu = f.resid_prototype === nothing ? zero(u) : similar(f.resid_prototype)
f(fu, u, p)
else
fu = f(u, p)
Expand Down
4 changes: 1 addition & 3 deletions src/internal/jacobian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,11 @@ function JacobianCache(prob, alg, f::F, fu_, u, p; stats, autodiff = nothing,
end
end
else
jac_proto = if eltype(f.jac_prototype) <: Bool
if eltype(f.jac_prototype) <: Bool
similar(f.jac_prototype, promote_type(eltype(fu), eltype(u)))
else
similar(f.jac_prototype)
end
fill!(jac_proto, false)
jac_proto
end
end

Expand Down

0 comments on commit e7e218b

Please sign in to comment.