Open
Description
SimpleHalley
is type unstable when used with StaticArrays
using SimpleNonlinearSolve, StaticArrays, Test
julia> f_SA(u, p) = SA[u[1] * u[1] - p, u[2] * u[2] - p]
julia> prob = NonlinearProblem(f_SA, SA[1.0, 1.0], 2.0)
julia> @inferred solve(prob, SimpleHalley())
ERROR: return type SciMLBase.NonlinearSolution{Float64, 1, SVector{2, Float64}, SVector{2, Float64}, NonlinearSolveBase.ImmutableNonlinearProblem{SVector{2, Float64}, false, Float64, NonlinearFunction{false, SciMLBase.FullSpecialize, typeof(f_SA), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, @NamedTuple{}}, SciMLBase.StandardNonlinearProblem}, SimpleHalley{AutoForwardDiff{nothing, Nothing}}, Nothing, Nothing, Nothing, Nothing} does not match inferred return type SciMLBase.NonlinearSolution{_A, _B, _C, _D, NonlinearSolveBase.ImmutableNonlinearProblem{SVector{2, Float64}, false, Float64, NonlinearFunction{false, SciMLBase.FullSpecialize, typeof(f_SA), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, @NamedTuple{}}, SciMLBase.StandardNonlinearProblem}, SimpleHalley{AutoForwardDiff{nothing, Nothing}}, Nothing, Nothing, Nothing, Nothing} where {_A, _B, _C, _D}
which is caused by instability in the hessian computation
julia> @inferred SimpleNonlinearSolve.Utils.compute_jacobian_and_hessian(alg.autodiff, prob, prob.f(prob.u0, prob.p), prob.u0)
ERROR: return type Tuple{SVector{2, Float64}, SMatrix{2, 2, Float64, 4}, SMatrix{4, 2, Float64, 8}} does not match inferred return type Tuple{SVector{2, Float64}, SMatrix{2, 2, Float64, 4}, Any}