diff --git a/src/NonlinearSolve.jl b/src/NonlinearSolve.jl index 944463b51..2d6e13c0e 100644 --- a/src/NonlinearSolve.jl +++ b/src/NonlinearSolve.jl @@ -27,7 +27,6 @@ module NonlinearSolve # DiffEq styled algorithms export Bisection, Falsi, NewtonRaphson - export ScalarBisection, ScalarNewton export reinit! end # module diff --git a/src/scalar.jl b/src/scalar.jl index 691b56313..60bf61466 100644 --- a/src/scalar.jl +++ b/src/scalar.jl @@ -1,11 +1,4 @@ -""" -ScalarNewton - -Fast Newton Raphson for scalar problems. -""" -struct ScalarNewton <: AbstractNonlinearSolveAlgorithm end - -function DiffEqBase.solve(prob::NonlinearProblem{uType, false}, ::ScalarNewton, args...; xatol = nothing, xrtol = nothing, maxiters = 1000, kwargs...) where {uType} +function DiffEqBase.solve(prob::NonlinearProblem{<:Number}, ::NewtonRaphson, args...; xatol = nothing, xrtol = nothing, maxiters = 1000, kwargs...) f = Base.Fix2(prob.f, prob.p) x = float(prob.u0) T = typeof(x) @@ -26,15 +19,7 @@ function DiffEqBase.solve(prob::NonlinearProblem{uType, false}, ::ScalarNewton, return oftype(x, NaN) end -""" - ScalarBisection - -Fast Bisection for scalar problems. Note that it doesn't returns exact solution, but returns -the best left limit of the exact solution. -""" -struct ScalarBisection <: AbstractNonlinearSolveAlgorithm end - -function DiffEqBase.solve(prob::NonlinearProblem{uType, false}, ::ScalarBisection, args...; maxiters = 1000, kwargs...) where {uType} +function DiffEqBase.solve(prob::NonlinearProblem{<:Number}, ::Bisection, args...; maxiters = 1000, kwargs...) f = Base.Fix2(prob.f, prob.p) left, right = prob.u0 fl, fr = f(left), f(right) diff --git a/src/solve.jl b/src/solve.jl index 7870f6fcf..2857dd2e1 100644 --- a/src/solve.jl +++ b/src/solve.jl @@ -12,7 +12,7 @@ function DiffEqBase.init(prob::NonlinearProblem{uType, iip}, alg::AbstractBracke immutable = (prob.u0 isa StaticArray || prob.u0 isa Number), kwargs... ) where {uType, iip} - + if !(prob.u0 isa Tuple) error("You need to pass a tuple of u0 in bracketing algorithms.") end diff --git a/test/runtests.jl b/test/runtests.jl index 52d31cbc8..42ac240eb 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -17,7 +17,7 @@ end function benchmark_scalar(f, u0) probN = NonlinearProblem{false}(f, u0) - sol = (solve(probN, ScalarNewton())) + sol = (solve(probN, NewtonRaphson())) end f, u0 = (u,p) -> u .* u .- 2, @SVector[1.0, 1.0]