Skip to content

Commit 0392455

Browse files
committed
fix: return type inference
1 parent d539ac2 commit 0392455

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/SimpleNonlinearSolve/src/lbroyden.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,11 @@ end
6262

6363
# For scalar problems / if the threshold is larger than problem size just use Broyden
6464
if x isa Number || length(x) η
65-
return SciMLBase.__solve(
65+
sol = SciMLBase.__solve(
6666
prob, SimpleBroyden(; alg.linesearch), args...;
6767
abstol, reltol, maxiters, termination_condition, kwargs...
6868
)
69+
return Utils.nonlinear_solution_new_alg(sol, alg)
6970
end
7071

7172
fx = NLBUtils.evaluate_f(prob, x)

lib/SimpleNonlinearSolve/src/utils.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,13 @@ function compute_hvvp(prob, autodiff, fx, x, dir)
174174
return only(DI.pushforward(jvp_fn, autodiff, x, (dir,), Constant(prob.p)))
175175
end
176176

177+
function nonlinear_solution_new_alg(
178+
sol::SciMLBase.NonlinearSolution{T, N, uType, R, P, A, O, uType2, S, Tr}, alg
179+
) where {T, N, uType, R, P, A, O, uType2, S, Tr}
180+
return SciMLBase.NonlinearSolution{T, N, uType, R, P, typeof(alg), O, uType2, S, Tr}(
181+
sol.u, sol.resid, sol.prob, alg, sol.retcode, sol.original, sol.left, sol.right,
182+
sol.stats, sol.trace
183+
)
184+
end
185+
177186
end

0 commit comments

Comments
 (0)