diff --git a/Project.toml b/Project.toml index 7b2b86f..3e04da3 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Roots" uuid = "f2b01f46-fcfa-551c-844a-d8ac1e96c665" -version = "2.0.17" +version = "2.0.18" [deps] ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" diff --git a/src/Bracketing/alefeld_potra_shi.jl b/src/Bracketing/alefeld_potra_shi.jl index 4df7424..97f787d 100644 --- a/src/Bracketing/alefeld_potra_shi.jl +++ b/src/Bracketing/alefeld_potra_shi.jl @@ -46,8 +46,8 @@ end # set d, ee to a function init_state(::AbstractAlefeldPotraShi, F, x₀, x₁, fx₀, fx₁; c=nothing, fc=nothing) a, b, fa, fb = x₀, x₁, fx₀, fx₁ - iszero(fa) && return AbstractAlefeldPotraShiState(b, a, a, a, fb, fa, fa, fa) - iszero(fb) && return AbstractAlefeldPotraShiState(b, a, a, a, fb, fa, fa, fa) + iszero(fa) && return AbstractAlefeldPotraShiState(promote(b, a, a, a)..., promote(fb, fa, fa, fa)...) + iszero(fb) && return AbstractAlefeldPotraShiState(promote(b, a, a, a)..., promote(fb, fa, fa, fa)...) if a > b a, b, fa, fb = b, a, fb, fa @@ -59,7 +59,7 @@ function init_state(::AbstractAlefeldPotraShi, F, x₀, x₁, fx₀, fx₁; c=no end (iszero(fc) || !isfinite(fc)) && - return AbstractAlefeldPotraShiState(c, a, a, a, fc, fa, fa, fa) + return AbstractAlefeldPotraShiState(promote(c, a, a, a)..., promote(fc, fa, fa, fa)...) a, b, d, fa, fb, fd = bracket(a, b, c, fa, fb, fc) assert_bracket(fa, fb) diff --git a/src/Bracketing/bisection.jl b/src/Bracketing/bisection.jl index 514492f..5b98acd 100644 --- a/src/Bracketing/bisection.jl +++ b/src/Bracketing/bisection.jl @@ -46,7 +46,7 @@ function init_state( end # handle interval if fa*fb ≥ 0 (explicit, but also not needed) - (iszero(fx₀) || iszero(fx₁)) && return UnivariateZeroState(x₁, x₀, fx₁, fx₀) + (iszero(fx₀) || iszero(fx₁)) && return UnivariateZeroState(promote(x₁, x₀)..., promote(fx₁, fx₀)...) assert_bracket(fx₀, fx₁) if sign(fm) * fx₀ < 0 * oneunit(fx₀) a, b, fa, fb = x₀, m, fx₀, fm @@ -57,7 +57,7 @@ function init_state( # handles case where a=-0.0, b=1.0 without error sign(a) * sign(b) < 0 && throw(ArgumentError("_middle error")) - UnivariateZeroState(b, a, fb, fa) + UnivariateZeroState(promote(b, a)..., promote(fb, fa)...) end const FloatNN = Union{Float64,Float32,Float16} diff --git a/src/Bracketing/bracketing.jl b/src/Bracketing/bracketing.jl index 3277a81..3299743 100644 --- a/src/Bracketing/bracketing.jl +++ b/src/Bracketing/bracketing.jl @@ -10,7 +10,7 @@ function init_state(M::AbstractBracketingMethod, F, x₀, x₁, fx₀, fx₁) (iszero(fx₀) || iszero(fx₁)) && return UnivariateZeroState(x₁, x₀, fx₁, fx₀) assert_bracket(fx₀, fx₁) a, b, fa, fb = (x₀ < x₁) ? (x₀, x₁, fx₀, fx₁) : (x₁, x₀, fx₁, fx₀) - UnivariateZeroState(b, a, fb, fa) + UnivariateZeroState(promote(b, a)..., promote(fb, fa)...) end Base.last(state::AbstractUnivariateZeroState, M::AbstractBracketingMethod) = diff --git a/src/Bracketing/brent.jl b/src/Bracketing/brent.jl index 9124f91..91b4e33 100644 --- a/src/Bracketing/brent.jl +++ b/src/Bracketing/brent.jl @@ -29,10 +29,10 @@ function init_state(::Brent, F, x₀, x₁, fx₀, fx₁) end # check if fu*fv ≥ 0 - (iszero(fu) || iszero(fv)) && return BrentState(u, v, v, v, fu, fv, fv, true) + (iszero(fu) || iszero(fv)) && return BrentState(promote(u, v, v, v)..., promote(fu, fv, fv)..., true) assert_bracket(fu, fv) - BrentState(u, v, v, v, fu, fv, fv, true) + BrentState(promote(u, v, v, v)..., promote(fu, fv, fv)..., true) end function update_state( diff --git a/src/Bracketing/chandrapatlu.jl b/src/Bracketing/chandrapatlu.jl index 2e83ed3..a36d4a6 100644 --- a/src/Bracketing/chandrapatlu.jl +++ b/src/Bracketing/chandrapatlu.jl @@ -25,7 +25,7 @@ end function init_state(::Chandrapatla, F, x₀, x₁, fx₀, fx₁) a, b, fa, fb = x₁, x₀, fx₁, fx₀ c, fc = a, fa - ChandrapatlaState(a, b, c, fa, fb, fc) + ChandrapatlaState(promote(a, b, c)..., promote(fa, fb, fc)...) end function update_state( diff --git a/src/Bracketing/itp.jl b/src/Bracketing/itp.jl index 49645dc..b67ce2d 100644 --- a/src/Bracketing/itp.jl +++ b/src/Bracketing/itp.jl @@ -58,12 +58,12 @@ function init_state(M::ITP, F, x₀, x₁, fx₀, fx₁) ϵ2n₁₂ = zero(float(x₁) / x₁) # ϵ*2^(ceil(Int, log2((b-a)/(2*ϵ))) + n₀) # handle interval if fa*fb ≥ 0 (explicit, but also not needed) - (iszero(fx₀) || iszero(fx₁)) && return ITPState(x₁, x₀, fx₁, fx₀, 0, ϵ2n₁₂, x₁) + (iszero(fx₀) || iszero(fx₁)) && return ITPState(promote(x₁, x₀)..., promote(fx₁, fx₀)..., 0, ϵ2n₁₂, x₁) assert_bracket(fx₀, fx₁) a, b, fa, fb = x₀, x₁, fx₀, fx₁ - ITPState(b, a, fb, fa, 0, ϵ2n₁₂, a) + ITPState(promote(b, a)..., promote(fb, fa)..., 0, ϵ2n₁₂, a) end function update_state(M::ITP, F, o::ITPState{T,S,R}, options, l=NullTracks()) where {T,S,R} diff --git a/src/Derivative/halley_like.jl b/src/Derivative/halley_like.jl index 3b7778c..bea0542 100644 --- a/src/Derivative/halley_like.jl +++ b/src/Derivative/halley_like.jl @@ -19,7 +19,7 @@ end function init_state(::AbstractHalleyLikeMethod, F, x₀::T, x₁::T, fx₀, fx₁) where {T} fx₁, (Δ::T, ΔΔ::T) = F(x₁) - HalleyState(x₁, x₀, Δ, ΔΔ, fx₁, fx₀) + HalleyState(promote(x₁, x₀)..., Δ, ΔΔ, promote(fx₁, fx₀)...) end initial_fncalls(M::AbstractHalleyLikeMethod) = 2 * 3 diff --git a/src/Derivative/newton.jl b/src/Derivative/newton.jl index 16afeff..f20a81d 100644 --- a/src/Derivative/newton.jl +++ b/src/Derivative/newton.jl @@ -66,7 +66,7 @@ end # compute fx₁, Δ function init_state(::Newton, F, x₀::T, x₁::T, fx₀, fx₁) where {T} fx₁, Δ::T = F(x₁) - NewtonState(x₁, x₀, Δ, fx₁, fx₀) + NewtonState(promote(x₁, x₀)..., Δ, promote(fx₁, fx₀)...) end initial_fncalls(M::Newton) = 2 diff --git a/src/Derivative/thukralb.jl b/src/Derivative/thukralb.jl index ab8244b..02617e6 100644 --- a/src/Derivative/thukralb.jl +++ b/src/Derivative/thukralb.jl @@ -66,7 +66,7 @@ function init_state( fx₁; Δs=nothing, ) where {T} - ThukralBState(x₁, x₀, NTuple{fn_argout(M) - 1,T}(Δs), fx₁, fx₀) + ThukralBState(promote(x₁, x₀)..., NTuple{fn_argout(M) - 1,T}(Δs), promote(fx₁, fx₀)...) end function update_state( diff --git a/src/DerivativeFree/derivative_free.jl b/src/DerivativeFree/derivative_free.jl index 1960dd6..39107f3 100644 --- a/src/DerivativeFree/derivative_free.jl +++ b/src/DerivativeFree/derivative_free.jl @@ -9,7 +9,7 @@ end # initialize from xs, fxs function init_state(::AbstractSecantMethod, F, x₀, x₁, fx₀, fx₁) - UnivariateZeroState(x₁, x₀, fx₁, fx₀) + UnivariateZeroState(promote(x₁, x₀)..., promote(fx₁, fx₀)...) end initial_fncalls(::AbstractSecantMethod) = 2 diff --git a/src/DerivativeFree/king.jl b/src/DerivativeFree/king.jl index 7e63018..fa7e105 100644 --- a/src/DerivativeFree/king.jl +++ b/src/DerivativeFree/king.jl @@ -28,7 +28,7 @@ end function init_state(::Union{King,Order1B}, F, x₀, x₁, fx₀, fx₁) fₛ₀ = F(x₀ - fx₀ * oneunit(x₀) / oneunit(fx₀)) G₀ = -fx₀^2 / (fₛ₀ - fx₀) - KingState(x₁, x₀, fx₁, fx₀, G₀) + KingState(promote(x₁, x₀)..., promote(fx₁, fx₀, G₀)...) end initial_fncalls(::Union{King,Order1B}) = 3