Skip to content

Commit

Permalink
fixed allocations and tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
yash-rs committed Feb 23, 2023
1 parent 5f531f7 commit 7f54266
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/SimpleNonlinearSolve/src/halley.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function SciMLBase.__solve(prob::NonlinearProblem,
maxiters = 1000, kwargs...)
f = Base.Fix2(prob.f, prob.p)
x = float(prob.u0)
fx = f(x)
if isa(x, AbstractArray)
n = length(x)
end
Expand Down Expand Up @@ -70,7 +71,7 @@ function SciMLBase.__solve(prob::NonlinearProblem,
else
fx = f(x)
dfx = ForwardDiff.jacobian(f, x)
d2fx = ForwardDiff.jacobian(x -> ForwardDiff.jacobian(f, x), x) # n^2 by n matrix
d2fx = ForwardDiff.jacobian(x -> ForwardDiff.jacobian(f, x), x)
ai = -(dfx \ fx)
A = reshape(d2fx * ai, (n, n))
bi = (dfx) \ (A * ai)
Expand Down

0 comments on commit 7f54266

Please sign in to comment.