Skip to content

Commit e0f7336

Browse files
feat: use sources (#571)
* feat: use sources * ci: fix scc require base * CI keep the developing scripts --------- Co-authored-by: Christopher Rackauckas <accounts@chrisrackauckas.com>
1 parent d8ae329 commit e0f7336

File tree

11 files changed

+57
-28
lines changed

11 files changed

+57
-28
lines changed

Project.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ SparseMatrixColorings = "0a514795-09f3-496d-8182-132a7b665d35"
3131
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
3232
SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5"
3333

34+
[sources]
35+
BracketingNonlinearSolve = {path = "lib/BracketingNonlinearSolve"}
36+
NonlinearSolveBase = {path = "lib/NonlinearSolveBase"}
37+
NonlinearSolveFirstOrder = {path = "lib/NonlinearSolveFirstOrder"}
38+
NonlinearSolveQuasiNewton = {path = "lib/NonlinearSolveQuasiNewton"}
39+
NonlinearSolveSpectralMethods = {path = "lib/NonlinearSolveSpectralMethods"}
40+
SimpleNonlinearSolve = {path = "lib/SimpleNonlinearSolve"}
41+
3442
[weakdeps]
3543
FastLevenbergMarquardt = "7a0df574-e128-4d35-8cbd-3d84502bf7ce"
3644
FixedPointAcceleration = "817d07cb-a79a-5c30-9a31-890123675176"

lib/BracketingNonlinearSolve/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
1111
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1212
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
1313

14+
[sources]
15+
NonlinearSolveBase = {path = "../NonlinearSolveBase"}
16+
1417
[weakdeps]
1518
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
1619

lib/BracketingNonlinearSolve/src/muller.jl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ initial guesses `(left, middle, right)` for the root.
88
99
### Keyword Arguments
1010
11-
- `middle`: the initial guess for the middle point. If not provided, the
12-
midpoint of the interval `(left, right)` is used.
11+
- `middle`: the initial guess for the middle point. If not provided, the
12+
midpoint of the interval `(left, right)` is used.
1313
"""
1414
struct Muller{T} <: AbstractBracketingAlgorithm
1515
middle::T
@@ -18,7 +18,7 @@ end
1818
Muller() = Muller(nothing)
1919

2020
function CommonSolve.solve(prob::IntervalNonlinearProblem, alg::Muller, args...;
21-
abstol = nothing, maxiters = 1000, kwargs...)
21+
abstol = nothing, maxiters = 1000, kwargs...)
2222
@assert !SciMLBase.isinplace(prob) "`Muller` only supports out-of-place problems."
2323
xᵢ₋₂, xᵢ = prob.tspan
2424
xᵢ₋₁ = isnothing(alg.middle) ? (xᵢ₋₂ + xᵢ) / 2 : alg.middle
@@ -32,35 +32,35 @@ function CommonSolve.solve(prob::IntervalNonlinearProblem, alg::Muller, args...;
3232
abstol = abs(NonlinearSolveBase.get_tolerance(
3333
xᵢ₋₂, abstol, promote_type(eltype(xᵢ₋₂), eltype(xᵢ))))
3434

35-
for _ 1:maxiters
36-
q = (xᵢ - xᵢ₋₁)/(xᵢ₋₁ - xᵢ₋₂)
37-
A = q*fxᵢ - q*(1 + q)*fxᵢ₋₁ + q^2*fxᵢ₋₂
38-
B = (2*q + 1)*fxᵢ - (1 + q)^2*fxᵢ₋₁ + q^2*fxᵢ₋₂
39-
C = (1 + q)*fxᵢ
35+
for _ in 1:maxiters
36+
q = (xᵢ - xᵢ₋₁) / (xᵢ₋₁ - xᵢ₋₂)
37+
A = q * fxᵢ - q * (1 + q) * fxᵢ₋₁ + q^2 * fxᵢ₋₂
38+
B = (2 * q + 1) * fxᵢ - (1 + q)^2 * fxᵢ₋₁ + q^2 * fxᵢ₋₂
39+
C = (1 + q) * fxᵢ
4040

41-
denom₊ = B + (B^2 - 4*A*C)
42-
denom₋ = B - (B^2 - 4*A*C)
41+
denom₊ = B + (B^2 - 4 * A * C)
42+
denom₋ = B - (B^2 - 4 * A * C)
4343

4444
if abs(denom₊) abs(denom₋)
45-
xᵢ₊₁ = xᵢ - (xᵢ - xᵢ₋₁)*2*C/denom₊
45+
xᵢ₊₁ = xᵢ - (xᵢ - xᵢ₋₁) * 2 * C / denom₊
4646
else
47-
xᵢ₊₁ = xᵢ - (xᵢ - xᵢ₋₁)*2*C/denom₋
47+
xᵢ₊₁ = xᵢ - (xᵢ - xᵢ₋₁) * 2 * C / denom₋
4848
end
4949

5050
fxᵢ₊₁ = f(xᵢ₊₁)
5151

5252
# Termination Check
5353
if abstol abs(fxᵢ₊₁)
5454
return SciMLBase.build_solution(prob, alg, xᵢ₊₁, fxᵢ₊₁;
55-
retcode = ReturnCode.Success,
56-
left = xᵢ₊₁, right = xᵢ₊₁)
55+
retcode = ReturnCode.Success,
56+
left = xᵢ₊₁, right = xᵢ₊₁)
5757
end
5858

5959
xᵢ₋₂, xᵢ₋₁, xᵢ = xᵢ₋₁, xᵢ, xᵢ₊₁
6060
fxᵢ₋₂, fxᵢ₋₁, fxᵢ = fxᵢ₋₁, fxᵢ, fxᵢ₊₁
6161
end
6262

6363
return SciMLBase.build_solution(prob, alg, xᵢ₊₁, fxᵢ₊₁;
64-
retcode = ReturnCode.MaxIters,
65-
left = xᵢ₊₁, right = xᵢ₊₁)
64+
retcode = ReturnCode.MaxIters,
65+
left = xᵢ₊₁, right = xᵢ₊₁)
6666
end

lib/BracketingNonlinearSolve/test/muller_tests.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@testitem "Muller" begin
22
f(u, p) = u^2 - p
33
g(u, p) = sin(u)
4-
h(u, p) = exp(-u)*sin(u)
4+
h(u, p) = exp(-u) * sin(u)
55
i(u, p) = u^3 - 1
66

77
@testset "Quadratic function" begin
@@ -30,7 +30,7 @@
3030
prob = IntervalNonlinearProblem{false}(g, tspan)
3131
sol = solve(prob, Muller())
3232

33-
@test sol.u 2*π
33+
@test sol.u 2 * π
3434
end
3535

3636
@testset "Exponential-sine function" begin
@@ -44,7 +44,7 @@
4444
prob = IntervalNonlinearProblem{false}(h, tspan)
4545
sol = solve(prob, Muller())
4646

47-
@test sol.u 0 atol = 1e-15
47+
@test sol.u0 atol=1e-15
4848

4949
tspan = (-1.0, 1.0)
5050
prob = IntervalNonlinearProblem{false}(h, tspan)
@@ -54,17 +54,17 @@
5454
end
5555

5656
@testset "Complex roots" begin
57-
tspan = (-1.0, 1.0*im)
57+
tspan = (-1.0, 1.0 * im)
5858
prob = IntervalNonlinearProblem{false}(i, tspan)
5959
sol = solve(prob, Muller())
6060

61-
@test sol.u (-1 + 3*im)/2
61+
@test sol.u (-1 + 3 * im) / 2
6262

63-
tspan = (-1.0, -1.0*im)
63+
tspan = (-1.0, -1.0 * im)
6464
prob = IntervalNonlinearProblem{false}(i, tspan)
6565
sol = solve(prob, Muller())
6666

67-
@test sol.u (-1 - 3*im)/2
67+
@test sol.u (-1 - 3 * im) / 2
6868
end
6969

7070
@testset "Middle" begin
@@ -87,10 +87,10 @@
8787

8888
@test sol.u -π
8989

90-
tspan = (-1.0, 1.0*im)
90+
tspan = (-1.0, 1.0 * im)
9191
prob = IntervalNonlinearProblem{false}(i, tspan)
9292
sol = solve(prob, Muller(0.0))
9393

94-
@test sol.u (-1 + 3*im)/2
94+
@test sol.u (-1 + 3 * im) / 2
9595
end
9696
end

lib/BracketingNonlinearSolve/test/rootfind_tests.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ end
77
@testitem "Interval Nonlinear Problems" setup=[RootfindingTestSnippet] tags=[:core] begin
88
using ForwardDiff
99

10-
@testset for alg in (Alefeld(), Bisection(), Brent(), Falsi(), ITP(), Muller(), Ridder(), nothing)
10+
@testset for alg in (
11+
Alefeld(), Bisection(), Brent(), Falsi(), ITP(), Muller(), Ridder(), nothing)
1112
tspan = (1.0, 20.0)
1213

1314
function g(p)
@@ -76,7 +77,8 @@ end
7677
end
7778

7879
@testitem "Flipped Signs and Reversed Tspan" setup=[RootfindingTestSnippet] tags=[:core] begin
79-
@testset for alg in (Alefeld(), Bisection(), Brent(), Falsi(), ITP(), Muller(), Ridder(), nothing)
80+
@testset for alg in (
81+
Alefeld(), Bisection(), Brent(), Falsi(), ITP(), Muller(), Ridder(), nothing)
8082
f1(u, p) = u * u - p
8183
f2(u, p) = p - u * u
8284

lib/NonlinearSolveFirstOrder/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ SciMLJacobianOperators = "19f34311-ddf3-4b8b-af20-060888a46c0e"
2323
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
2424
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
2525

26+
[sources]
27+
NonlinearSolveBase = {path = "../NonlinearSolveBase"}
28+
2629
[compat]
2730
ADTypes = "1.9.0"
2831
Aqua = "0.8"

lib/NonlinearSolveHomotopyContinuation/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
1616
SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5"
1717
TaylorDiff = "b36ab563-344f-407b-a36a-4f200bebf99c"
1818

19+
[sources]
20+
NonlinearSolveBase = {path = "../NonlinearSolveBase"}
21+
1922
[compat]
2023
ADTypes = "1.11.0"
2124
Aqua = "0.8"

lib/NonlinearSolveQuasiNewton/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
1818
SciMLOperators = "c0aeaf25-5076-4817-a8d5-81caf7dfa961"
1919
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
2020

21+
[sources]
22+
NonlinearSolveBase = {path = "../NonlinearSolveBase"}
23+
2124
[weakdeps]
2225
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
2326

lib/NonlinearSolveSpectralMethods/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
1414
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1515
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
1616

17+
[sources]
18+
NonlinearSolveBase = {path = "../NonlinearSolveBase"}
19+
1720
[weakdeps]
1821
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
1922

lib/SimpleNonlinearSolve/Project.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
2323
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
2424
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
2525

26+
[sources]
27+
BracketingNonlinearSolve = {path = "../BracketingNonlinearSolve"}
28+
NonlinearSolveBase = {path = "../NonlinearSolveBase"}
29+
2630
[weakdeps]
2731
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
2832
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"

0 commit comments

Comments
 (0)