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

Commit 246be18

Browse files
committed
fixed allocations and tests pass
1 parent b359a9d commit 246be18

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/halley.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function SciMLBase.__solve(prob::NonlinearProblem,
4242
maxiters = 1000, kwargs...)
4343
f = Base.Fix2(prob.f, prob.p)
4444
x = float(prob.u0)
45+
fx = f(x)
4546
if isa(x, AbstractArray)
4647
n = length(x)
4748
end
@@ -70,7 +71,7 @@ function SciMLBase.__solve(prob::NonlinearProblem,
7071
else
7172
fx = f(x)
7273
dfx = ForwardDiff.jacobian(f, x)
73-
d2fx = ForwardDiff.jacobian(x -> ForwardDiff.jacobian(f, x), x) # n^2 by n matrix
74+
d2fx = ForwardDiff.jacobian(x -> ForwardDiff.jacobian(f, x), x)
7475
ai = -(dfx \ fx)
7576
A = reshape(d2fx * ai, (n, n))
7677
bi = (dfx) \ (A * ai)

0 commit comments

Comments
 (0)