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

Commit f250799

Browse files
format
1 parent 310f84b commit f250799

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/SimpleNonlinearSolve.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ import SnoopPrecompile
4343

4444
SnoopPrecompile.@precompile_all_calls begin for T in (Float32, Float64)
4545
prob_no_brack = NonlinearProblem{false}((u, p) -> u .* u .- p, T(0.1), T(2))
46-
for alg in (SimpleNewtonRaphson, Halley, Broyden, Klement, SimpleTrustRegion, SimpleDFSane)
46+
for alg in (SimpleNewtonRaphson, Halley, Broyden, Klement, SimpleTrustRegion,
47+
SimpleDFSane)
4748
solve(prob_no_brack, alg(), abstol = T(1e-2))
4849
end
4950

src/halley.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ and static array problems.
3030
"""
3131
struct Halley{CS, AD, FDT} <: AbstractNewtonAlgorithm{CS, AD, FDT}
3232
function Halley(; chunk_size = Val{0}(), autodiff = Val{true}(),
33-
diff_type = Val{:forward})
33+
diff_type = Val{:forward})
3434
new{SciMLBase._unwrap_val(chunk_size), SciMLBase._unwrap_val(autodiff),
3535
SciMLBase._unwrap_val(diff_type)}()
3636
end
@@ -73,12 +73,13 @@ function SciMLBase.__solve(prob::NonlinearProblem,
7373
fx = f(x)
7474
dfx = FiniteDiff.finite_difference_derivative(f, x, diff_type(alg), eltype(x),
7575
fx)
76-
d2fx = FiniteDiff.finite_difference_derivative(x -> FiniteDiff.finite_difference_derivative(f, x),
76+
d2fx = FiniteDiff.finite_difference_derivative(x -> FiniteDiff.finite_difference_derivative(f,
77+
x),
7778
x, diff_type(alg), eltype(x), fx)
7879
end
7980
iszero(fx) &&
8081
return SciMLBase.build_solution(prob, alg, x, fx; retcode = ReturnCode.Success)
81-
Δx = (2*dfx^2 - fx*d2fx) \ (2fx*dfx)
82+
Δx = (2 * dfx^2 - fx * d2fx) \ (2fx * dfx)
8283
x -= Δx
8384
if isapprox(x, xo, atol = atol, rtol = rtol)
8485
return SciMLBase.build_solution(prob, alg, x, fx; retcode = ReturnCode.Success)

test/basictests.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ probN = NonlinearProblem(f, u0)
214214

215215
@test solve(probN, Halley()).u sqrt(2.0)
216216

217-
218217
for u0 in [1.0, [1, 1.0]]
219218
local f, probN, sol
220219
f = (u, p) -> u .* u .- 2.0

0 commit comments

Comments
 (0)