Skip to content

Commit b2ed091

Browse files
update previous Jacobian on shift!
1 parent 4d91640 commit b2ed091

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

src/ShiftedProximalOperators.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ function shift!(ψ::ShiftedProximableFunction, shift::AbstractVector{R}) where {
7979
end
8080

8181
function shift!::ShiftedCompositeProximableFunction, shift::AbstractVector{R}) where {R <: Real}
82+
!isnothing.A_prev) &&.A_prev.vals .= ψ.A.vals) # Update previous Jacobian if necessary
8283
ψ.c!.b, shift)
8384
ψ.J!.A, shift)
8485
return ψ

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ for (op, composite_op, shifted_op) ∈
8989
@test all(ϕ_store_prev.A_prev .== SparseMatrixCOO([4.0 0.0 0.0 -1.0; 0.0 1.0 1.0 0.0]))
9090
@test all(ϕ_store_prev.A .== SparseMatrixCOO([8.0 0.0 0.0 -1.0; 0.0 1.0 1.0 0.0]))
9191

92+
# test reshifting
93+
xk = [0.5, 0.0, 0.0, 0.0]
94+
shift!(ϕ_store_prev, xk)
95+
@test all(ϕ_store_prev.A_prev .== SparseMatrixCOO([8.0 0.0 0.0 -1.0; 0.0 1.0 1.0 0.0]))
96+
@test all(ϕ_store_prev.A .== SparseMatrixCOO([2.0 0.0 0.0 -1.0; 0.0 1.0 1.0 0.0]))
97+
9298

9399
# test different types
94100
h = Op(Float32(λ))

0 commit comments

Comments
 (0)