Skip to content

Commit

Permalink
Fix type-instability
Browse files Browse the repository at this point in the history
  • Loading branch information
fgittins committed Jun 3, 2024
1 parent 5d5f6ee commit 9bfaee4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/nlsolve/muller.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ function SciMLBase.solve(prob::NonlinearProblem, alg::SimpleMuller, args...;
@assert !isinplace(prob) "`SimpleMuller` only supports OOP problems."
@assert length(prob.u0) == 3 "`SimpleMuller` requires three initial guesses."
xᵢ₋₂, xᵢ₋₁, xᵢ = prob.u0
xᵢ₋₂, xᵢ₋₁, xᵢ = promote(xᵢ₋₂, xᵢ₋₁, xᵢ)
@assert xᵢ₋₂ xᵢ₋₁ xᵢ xᵢ₋₂
f = Base.Fix2(prob.f, prob.p)
fxᵢ₋₂, fxᵢ₋₁, fxᵢ = f(xᵢ₋₂), f(xᵢ₋₁), f(xᵢ)

abstol = __get_tolerance(nothing, abstol,
promote_type(eltype(fxᵢ₋₂), eltype(xᵢ₋₂)))

xᵢ₊₁, fxᵢ₊₁ = xᵢ₋₂, fxᵢ₋₂

for _ 1:maxiters
q = (xᵢ - xᵢ₋₁)/(xᵢ₋₁ - xᵢ₋₂)
A = q*fxᵢ - q*(1 + q)*fxᵢ₋₁ + q^2*fxᵢ₋₂
Expand Down

0 comments on commit 9bfaee4

Please sign in to comment.