|
1 |
| -function SciMLBase.solve(prob::NonlinearProblem{<:Number}, alg::NewtonRaphson, args...; xatol = nothing, xrtol = nothing, maxiters = 1000, kwargs...) |
| 1 | +function SciMLBase.solve(prob::NonlinearProblem{<:Union{Number,SVector}}, alg::NewtonRaphson, args...; xatol = nothing, xrtol = nothing, maxiters = 1000, kwargs...) |
2 | 2 | f = Base.Fix2(prob.f, prob.p)
|
3 | 3 | x = float(prob.u0)
|
4 | 4 | fx = float(prob.u0)
|
5 | 5 | T = typeof(x)
|
6 |
| - atol = xatol !== nothing ? xatol : oneunit(T) * (eps(one(T)))^(4//5) |
7 |
| - rtol = xrtol !== nothing ? xrtol : eps(one(T))^(4//5) |
| 6 | + atol = xatol !== nothing ? xatol : oneunit(eltype(T)) * (eps(one(eltype(T))))^(4//5) |
| 7 | + rtol = xrtol !== nothing ? xrtol : eps(one(eltype(T)))^(4//5) |
| 8 | + |
| 9 | + if typeof(x) <: Number |
| 10 | + xo = oftype(one(eltype(x)), Inf) |
| 11 | + else |
| 12 | + xo = map(x->oftype(one(eltype(x)), Inf),x) |
| 13 | + end |
8 | 14 |
|
9 |
| - xo = oftype(x, Inf) |
10 | 15 | for i in 1:maxiters
|
11 | 16 | if alg_autodiff(alg)
|
12 | 17 | fx, dfx = value_derivative(f, x)
|
|
52 | 57 | function SciMLBase.solve(prob::NonlinearProblem{<:Number, iip, <:Dual{T,V,P}}, alg::NewtonRaphson, args...; kwargs...) where {iip, T, V, P}
|
53 | 58 | sol, partials = scalar_nlsolve_ad(prob, alg, args...; kwargs...)
|
54 | 59 | return SciMLBase.build_solution(prob, alg, Dual{T,V,P}(sol.u, partials), sol.resid; retcode=sol.retcode)
|
55 |
| - |
| 60 | + |
56 | 61 | end
|
57 | 62 | function SciMLBase.solve(prob::NonlinearProblem{<:Number, iip, <:AbstractArray{<:Dual{T,V,P}}}, alg::NewtonRaphson, args...; kwargs...) where {iip, T, V, P}
|
58 | 63 | sol, partials = scalar_nlsolve_ad(prob, alg, args...; kwargs...)
|
|
0 commit comments