44
44
45
45
function linearsolve_forwarddiff_solve (cache:: DualLinearCache , alg, args... ; kwargs... )
46
46
sol = solve! (cache. linear_cache, alg, args... ; kwargs... )
47
+ primal_b = copy (cache. linear_cache. b)
47
48
uu = sol. u
48
49
49
50
primal_sol = deepcopy (sol)
@@ -57,11 +58,15 @@ function linearsolve_forwarddiff_solve(cache::DualLinearCache, alg, args...; kwa
57
58
58
59
partial_cache = cache. linear_cache
59
60
partial_cache. u = dual_u0
61
+
60
62
for i in eachindex (rhs_list)
61
63
partial_cache. b = rhs_list[i]
62
- rhs_list[i] = copy (solve! (partial_cache, alg). u)
64
+ rhs_list[i] = copy (solve! (partial_cache, alg, args ... ; kwargs ... ). u)
63
65
end
64
66
67
+ # Reset to the original `b`, users will expect that `b` doesn't change if they don't tell it to
68
+ partial_cache. b = primal_b
69
+
65
70
partial_sols = rhs_list
66
71
67
72
primal_sol, partial_sols
173
178
# If setting A or b for DualLinearCache, also set it for the underlying LinearCache
174
179
function Base. setproperty! (dc:: DualLinearCache , sym:: Symbol , val)
175
180
# If the property is A or b, also update it in the LinearCache
176
- if sym === :A || sym === :b
181
+ if sym === :A || sym === :b || sym === :u
177
182
if hasproperty (dc, :linear_cache )
178
183
setproperty! (dc. linear_cache, sym, nodual_value (val))
179
184
end
0 commit comments