Skip to content

Commit

Permalink
u eltype cast for TrustRegion
Browse files Browse the repository at this point in the history
  • Loading branch information
daviehh committed Jan 23, 2023
1 parent c62e922 commit fd8c37e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/trustRegion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,16 @@ function SciMLBase.__init(prob::NonlinearProblem{uType, iip}, alg::TrustRegion,
uf, linsolve, J, u_tmp, jac_config = jacobian_caches(alg, f, u, p, Val(iip))

# Set default trust region radius if not specified
max_trust_radius = alg.max_trust_radius
initial_trust_radius = alg.initial_trust_radius
if max_trust_radius == 0.0
u_elType = uType <: Number ? uType : eltype(u)
max_trust_radius = u_elType(alg.max_trust_radius)
initial_trust_radius = u_elType(alg.initial_trust_radius)
if iszero(max_trust_radius)
max_trust_radius = max(norm(fu), maximum(u) - minimum(u))
end
if initial_trust_radius == 0.0
if iszero(initial_trust_radius)
initial_trust_radius = max_trust_radius / 11
end

H = ArrayInterfaceCore.undefmatrix(u)

return TrustRegionCache{iip}(f, alg, u, fu, p, uf, linsolve, J, jac_config,
Expand Down

0 comments on commit fd8c37e

Please sign in to comment.