Skip to content

Commit 394725d

Browse files
generalization of iprox for L0 and L1 norm if D is not positive
1 parent 204990a commit 394725d

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

src/shiftedNormL0.jl

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,17 @@ function iprox!(
6767
λ = ψ.h.lambda
6868
for i eachindex(y)
6969
di = d[i]
70-
@assert di > 0
71-
ci = sqrt(2 * λ * di)
72-
xps = ψ.xk[i] + ψ.sj[i]
73-
if abs(di * xps - g[i]) ci
74-
y[i] = -xps
75-
else
76-
y[i] = -g[i] / di
70+
if d[i] 0
71+
y[i] = - 1/eps(R)
72+
continue
73+
else
74+
ci = sqrt(2 * λ * di)
75+
xps = ψ.xk[i] + ψ.sj[i]
76+
if abs(di * xps - g[i]) ci
77+
y[i] = -xps
78+
else
79+
y[i] = -g[i] / di
80+
end
7781
end
7882
end
7983
return y

src/shiftedNormL1.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,12 @@ function iprox!(
6767
@. y = -ψ.xk - ψ.sj
6868

6969
for i eachindex(y)
70-
@assert d[i] > 0
71-
y[i] = min(max(y[i], -g[i] / d[i] - λ / d[i]), -g[i] / d[i] + λ / d[i])
70+
if d[i] < 0
71+
y[i] = - 1/eps(R)
72+
continue
73+
else
74+
y[i] = min(max(y[i], -g[i] / d[i] - λ / d[i]), -g[i] / d[i] + λ / d[i])
75+
end
7276
end
7377

7478
return y

test/partial_prox.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ for op ∈ (:NormL0, :NormL1, :RootNormLhalf)
5858
# tests iprox without bounds
5959
if op == :NormL0 || op == :NormL1
6060
ψ = shifted(h, x)
61-
@test_throws AssertionError iprox(ψ, q, zeros(n))
6261
for d [ones(n), 2 * ones(n)]
6362
y = iprox(ψ, q, d)
6463
σ = d[1]

0 commit comments

Comments
 (0)