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

Commit e4193de

Browse files
Merge pull request #5 from SciML/deps
Dramatically reduce dependencies
2 parents c6c858e + 769737e commit e4193de

File tree

3 files changed

+36
-19
lines changed

3 files changed

+36
-19
lines changed

Project.toml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,33 @@
11
name = "SimpleNonlinearSolve"
22
uuid = "727e6d20-b764-4bd8-a329-72de5adea6c7"
33
authors = ["SciML"]
4-
version = "0.1.0"
4+
version = "0.1.1"
55

66
[deps]
77
ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2"
88
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
99
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
10-
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
11-
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
1210
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1311
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
14-
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
15-
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
16-
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
12+
SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c"
13+
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
1714

1815
[compat]
1916
ArrayInterfaceCore = "0.1.1"
2017
FiniteDiff = "2"
2118
ForwardDiff = "0.10.3"
22-
RecursiveArrayTools = "2"
2319
Reexport = "0.2, 1"
2420
SciMLBase = "1.73"
25-
Setfield = "0.7, 0.8, 1"
26-
StaticArrays = "0.12,1.0"
27-
UnPack = "1.0"
21+
SnoopPrecompile = "1"
22+
StaticArraysCore = "1.4"
2823
julia = "1.6"
2924

3025
[extras]
3126
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
32-
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
3327
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
3428
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
29+
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
3530
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3631

3732
[targets]
38-
test = ["BenchmarkTools", "SafeTestsets", "Pkg", "Test", "ForwardDiff"]
33+
test = ["BenchmarkTools", "SafeTestsets", "Pkg", "Test", "StaticArrays"]

src/SimpleNonlinearSolve.jl

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
module SimpleNonlinearSolve
22

33
using Reexport
4-
using UnPack: @unpack
54
using FiniteDiff, ForwardDiff
65
using ForwardDiff: Dual
7-
using Setfield
8-
using StaticArrays
9-
using RecursiveArrayTools
10-
using LinearAlgebra
6+
using StaticArraysCore
117
import ArrayInterfaceCore
128

139
@reexport using SciMLBase
@@ -23,6 +19,30 @@ include("falsi.jl")
2319
include("raphson.jl")
2420
include("ad.jl")
2521

22+
import SnoopPrecompile
23+
24+
SnoopPrecompile.@precompile_all_calls begin for T in (Float32, Float64)
25+
prob_no_brack = NonlinearProblem{false}((u, p) -> u .* u .- p, T(0.1), T(2))
26+
for alg in (SimpleNewtonRaphson,)
27+
solve(prob_no_brack, alg(), tol = T(1e-2))
28+
end
29+
30+
#=
31+
for alg in (SimpleNewtonRaphson,)
32+
for u0 in ([1., 1.], StaticArraysCore.SA[1.0, 1.0])
33+
u0 = T.(.1)
34+
probN = NonlinearProblem{false}((u,p) -> u .* u .- p, u0, T(2))
35+
solve(probN, alg(), tol = T(1e-2))
36+
end
37+
end
38+
=#
39+
40+
prob_brack = IntervalNonlinearProblem{false}((u, p) -> u * u - p, T.((0.0, 2.0)), T(2))
41+
for alg in (Bisection, Falsi)
42+
solve(prob_brack, alg(), tol = T(1e-2))
43+
end
44+
end end
45+
2646
# DiffEq styled algorithms
2747
export Bisection, Falsi, SimpleNewtonRaphson
2848

src/ad.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@ function scalar_nlsolve_ad(prob, alg, args...; kwargs...)
2828
return sol, partials
2929
end
3030

31-
function SciMLBase.solve(prob::NonlinearProblem{<:Union{Number, SVector}, iip,
31+
function SciMLBase.solve(prob::NonlinearProblem{<:Union{Number, StaticArraysCore.SVector},
32+
iip,
3233
<:Dual{T, V, P}}, alg::SimpleNewtonRaphson,
3334
args...; kwargs...) where {iip, T, V, P}
3435
sol, partials = scalar_nlsolve_ad(prob, alg, args...; kwargs...)
3536
return SciMLBase.build_solution(prob, alg, Dual{T, V, P}(sol.u, partials), sol.resid;
3637
retcode = sol.retcode)
3738
end
38-
function SciMLBase.solve(prob::NonlinearProblem{<:Union{Number, SVector}, iip,
39+
function SciMLBase.solve(prob::NonlinearProblem{<:Union{Number, StaticArraysCore.SVector},
40+
iip,
3941
<:AbstractArray{<:Dual{T, V, P}}},
4042
alg::SimpleNewtonRaphson, args...; kwargs...) where {iip, T, V, P}
4143
sol, partials = scalar_nlsolve_ad(prob, alg, args...; kwargs...)

0 commit comments

Comments
 (0)