@@ -33,6 +33,7 @@ mutable struct ShiftedCompositeNormL2{
3333 c!:: F0
3434 J!:: F1
3535 A:: M
36+ A_prev:: Union{Nothing, M} # (Optional) can be used to store the previous Jacobian, useful for quasi-Newton approximations
3637 shifted_spmat:: qrm_shifted_spmat{T}
3738 spfct:: qrm_spfct{T}
3839 b:: V
@@ -41,12 +42,14 @@ mutable struct ShiftedCompositeNormL2{
4142 dq:: V # Preallocated vector to refine the q solution.
4243 p:: V # Preallocated vector used to compute s(α)ᵀ∇s(α) for the secular equation.
4344 dp:: V # Preallocated vector used to refine the p vector.
45+ full_row_rank:: Bool # Boolean that tells whether A has full row rank or not. Is updated on each call to `prox!`
4446 function ShiftedCompositeNormL2 (
4547 λ:: T ,
4648 c!:: Function ,
4749 J!:: Function ,
4850 A:: AbstractMatrix{T} ,
49- b:: AbstractVector{T} ,
51+ b:: AbstractVector{T} ;
52+ store_previous_jacobian:: Bool = false
5053 ) where {T <: Real }
5154 p = similar (b, A. n + A. m)
5255 dp = similar (b, A. n + A. m)
@@ -59,6 +62,8 @@ mutable struct ShiftedCompositeNormL2{
5962 )
6063 end
6164
65+ A_prev = store_previous_jacobian ? copy (A) : nothing
66+
6267 spmat = qrm_spmat_init (A; sym = false )
6368 shifted_spmat = qrm_shift_spmat (spmat)
6469 spfct = qrm_spfct_init (spmat)
@@ -68,6 +73,7 @@ mutable struct ShiftedCompositeNormL2{
6873 c!,
6974 J!,
7075 A,
76+ A_prev,
7177 shifted_spmat,
7278 spfct,
7379 b,
@@ -76,6 +82,7 @@ mutable struct ShiftedCompositeNormL2{
7682 dq,
7783 p,
7884 dp,
85+ false
7986 )
8087 end
8188end
@@ -94,7 +101,7 @@ shifted(
94101 ψ. c! (b, xk)
95102 A = similar (ψ. A)
96103 ψ. J! (A, xk)
97- ShiftedCompositeNormL2 (ψ. h. lambda, ψ. c!, ψ. J!, A, b)
104+ ShiftedCompositeNormL2 (ψ. h. lambda, ψ. c!, ψ. J!, A, b, store_previous_jacobian = ψ . store_previous_jacobian )
98105end
99106
100107fun_name (ψ:: ShiftedCompositeNormL2 ) = " shifted `ℓ₂` norm"
@@ -110,6 +117,7 @@ function prox!(
110117 atol = eps (T)^ 0.3 ,
111118 max_time = 180.0 ,
112119) where {T <: Real , F0 <: Function , F1 <: Function , M <: AbstractMatrix{T} , V <: AbstractVector{T} }
120+ @assert ν > zero (T)
113121 start_time = time ()
114122 θ = T (0.8 )
115123 α = zero (T)
@@ -134,8 +142,8 @@ function prox!(
134142 _obj_dot_grad! (spmat, spfct, ψ. p, ψ. q, ψ. g, ψ. dq)
135143
136144 # Check full-rankness
137- full_row_rank = (qrm_get (spfct, " qrm_rd_num" ) == 0 )
138- if ! full_row_rank
145+ ψ . full_row_rank = (qrm_get (spfct, " qrm_rd_num" ) == 0 )
146+ if ! ψ . full_row_rank
139147 # QRMumps cannot factorize rank-deficient matrices; use the Golub-Riley iteration instead
140148 α = αmin
141149 qrm_golub_riley! (
0 commit comments