forked from JuliaFirstOrder/ProximalOperators.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_normL1plusL2.jl
58 lines (37 loc) · 946 Bytes
/
test_normL1plusL2.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using Random
using ProximalOperators
using Test
@testset "NormL1plusL2 standard case" begin
f = NormL1(1.0)
g = NormL2(2.0)
fplusg = NormL1plusL2(1.0, 2.0)
x = randn(50)
y1, f1 = prox(f, x)
y2, f2 = prox(g, y1)
y3, f3 = prox(fplusg, x)
@test f3 ≈ f(y3)+g(y3)
@test y3 ≈ y2
end
@testset "NormL1plusL2 norm constructor" begin
f = NormL1(1.0)
g = NormL2(2.0)
fplusg = NormL1plusL2(f, g)
x = randn(50)
y1, f1 = prox(f, x)
y2, f2 = prox(g, y1)
y3, f3 = prox(fplusg, x)
@test f3 ≈ f(y3)+g(y3)
@test y3 ≈ y2
end
@testset "NormL1plusL2 vector case" begin
λ1 = abs.(randn(50))
f = NormL1(λ1)
g = NormL2(2.0)
fplusg = NormL1plusL2(λ1, 2.0)
x = randn(50)
y1, f1 = prox(f, x)
y2, f2 = prox(g, y1)
y3, f3 = prox(fplusg, x)
@test f3 ≈ f(y3)+g(y3)
@test y3 ≈ y2
end