Skip to content

Commit

Permalink
Non allocating for scalars
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Sep 11, 2023
1 parent 5e7bafc commit a9fc4b8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ad.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function scalar_nlsolve_ad(prob, alg, args...; kwargs...)
z_arr = -inv(f_x) * f_p

pp = prob.p
sumfun = ((z, p),) -> [zᵢ * ForwardDiff.partials(p) for zᵢ in z]
sumfun = ((z, p),) -> map(zᵢ -> zᵢ * ForwardDiff.partials(p), z)
if uu isa Number
partials = sum(sumfun, zip(z_arr, pp))
else
Expand Down Expand Up @@ -52,7 +52,7 @@ end

function scalar_nlsolve_dual_soln(u::Number, partials,
::Union{<:AbstractArray{<:Dual{T, V, P}}, Dual{T, V, P}}) where {T, V, P}
return Dual{T, V, P}(u, partials[1])
return Dual{T, V, P}(u, partials)
end

function scalar_nlsolve_dual_soln(u::AbstractArray, partials,
Expand Down

0 comments on commit a9fc4b8

Please sign in to comment.