Skip to content

Commit a9fc4b8

Browse files
committed
Non allocating for scalars
1 parent 5e7bafc commit a9fc4b8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ad.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function scalar_nlsolve_ad(prob, alg, args...; kwargs...)
1313
z_arr = -inv(f_x) * f_p
1414

1515
pp = prob.p
16-
sumfun = ((z, p),) -> [zᵢ * ForwardDiff.partials(p) for zᵢ in z]
16+
sumfun = ((z, p),) -> map(zᵢ -> zᵢ * ForwardDiff.partials(p), z)
1717
if uu isa Number
1818
partials = sum(sumfun, zip(z_arr, pp))
1919
else
@@ -52,7 +52,7 @@ end
5252

5353
function scalar_nlsolve_dual_soln(u::Number, partials,
5454
::Union{<:AbstractArray{<:Dual{T, V, P}}, Dual{T, V, P}}) where {T, V, P}
55-
return Dual{T, V, P}(u, partials[1])
55+
return Dual{T, V, P}(u, partials)
5656
end
5757

5858
function scalar_nlsolve_dual_soln(u::AbstractArray, partials,

0 commit comments

Comments
 (0)