Skip to content

Commit 5eb0356

Browse files
committed
branch for nested duals
1 parent c902d61 commit 5eb0356

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ext/LinearSolveForwardDiffExt.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@ function linearsolve_forwarddiff_solve!(cache::DualLinearCache, alg, args...; kw
7979
cache.linear_cache.u .= cache.dual_u0_cache
8080
# We can reuse the linear cache, because the same factorization will work for the partials.
8181
for i in eachindex(rhs_list)
82-
cache.linear_cache.b = copy(rhs_list[i])
82+
if cache.linear_cache isa DualLinearCache
83+
# For nested duals, assign directly to partials_b
84+
cache.linear_cache.b = copy(rhs_list[i])
85+
else
86+
# For regular linear cache, use broadcasting assignment
87+
cache.linear_cache.b .= rhs_list[i]
88+
end
8389
rhs_list[i] .= solve!(cache.linear_cache, alg, args...; kwargs...).u
8490
end
8591

0 commit comments

Comments
 (0)