Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

capitalize ITP #71

Merged
merged 2 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SimpleNonlinearSolve"
uuid = "727e6d20-b764-4bd8-a329-72de5adea6c7"
authors = ["SciML"]
version = "0.1.17"
version = "0.1.18"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
4 changes: 2 additions & 2 deletions src/SimpleNonlinearSolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ PrecompileTools.@compile_workload begin
prob_brack = IntervalNonlinearProblem{false}((u, p) -> u * u - p,
T.((0.0, 2.0)),
T(2))
for alg in (Bisection, Falsi, Ridder, Brent, Alefeld, Itp)
for alg in (Bisection, Falsi, Ridder, Brent, Alefeld, ITP)
solve(prob_brack, alg(), abstol = T(1e-2))
end
end
end

# DiffEq styled algorithms
export Bisection, Brent, Broyden, LBroyden, SimpleDFSane, Falsi, Halley, Klement,
Ridder, SimpleNewtonRaphson, SimpleTrustRegion, Alefeld, Itp
Ridder, SimpleNewtonRaphson, SimpleTrustRegion, Alefeld, ITP
export BatchedBroyden, BatchedSimpleNewtonRaphson, BatchedSimpleDFSane

end # module
8 changes: 4 additions & 4 deletions src/itp.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
```julia
Itp(; k1::Real = 0.007, k2::Real = 1.5, n0::Int = 10)
ITP(; k1::Real = 0.007, k2::Real = 1.5, n0::Int = 10)
```

ITP (Interpolate Truncate & Project)
Expand Down Expand Up @@ -39,11 +39,11 @@ n½ + `n₀` iterations, where n½ is the number of iterations using bisection
If `f` is twice differentiable and the root is simple,
then with `n₀` > 0 the convergence rate is √`κ₂`.
"""
struct Itp{T} <: AbstractBracketingAlgorithm
struct ITP{T} <: AbstractBracketingAlgorithm
k1::T
k2::T
n0::Int
function Itp(; k1::Real = 0.007, k2::Real = 1.5, n0::Int = 10)
function ITP(; k1::Real = 0.007, k2::Real = 1.5, n0::Int = 10)
if k1 < 0
error("Hyper-parameter κ₁ should not be negative")
end
Expand All @@ -58,7 +58,7 @@ struct Itp{T} <: AbstractBracketingAlgorithm
end
end

function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Itp,
function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::ITP,
args...; abstol = 1.0e-15,
maxiters = 1000, kwargs...)
f = Base.Fix2(prob.f, prob.p)
Expand Down
12 changes: 6 additions & 6 deletions test/basictests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ end
# ITP
g = function (p)
probN = IntervalNonlinearProblem{false}(f, typeof(p).(tspan), p)
sol = solve(probN, Itp())
sol = solve(probN, ITP())
return sol.u
end

Expand Down Expand Up @@ -258,7 +258,7 @@ end
f, tspan = (u, p) -> p[1] * u * u - p[2], (1.0, 100.0)
t = (p) -> [sqrt(p[2] / p[1])]
p = [0.9, 50.0]
for alg in [Bisection(), Falsi(), Ridder(), Brent(), Itp()]
for alg in [Bisection(), Falsi(), Ridder(), Brent(), ITP()]
global g, p
g = function (p)
probN = IntervalNonlinearProblem{false}(f, tspan, p)
Expand Down Expand Up @@ -361,16 +361,16 @@ probB = IntervalNonlinearProblem(f, tspan)
sol = solve(probB, Alefeld())
@test sol.u ≈ sqrt(2.0)

# Itp
sol = solve(probB, Itp())
# ITP
sol = solve(probB, ITP())
@test sol.u ≈ sqrt(2.0)
tspan = (sqrt(2.0), 10.0)
probB = IntervalNonlinearProblem(f, tspan)
sol = solve(probB, Itp())
sol = solve(probB, ITP())
@test sol.u ≈ sqrt(2.0)
tspan = (0.0, sqrt(2.0))
probB = IntervalNonlinearProblem(f, tspan)
sol = solve(probB, Itp())
sol = solve(probB, ITP())
@test sol.u ≈ sqrt(2.0)

# Garuntee Tests for Bisection
Expand Down