-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
86 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
struct Noaccel end | ||
|
||
function update!(_::Noaccel, _, _) end | ||
|
||
import Base: * | ||
|
||
function (*)(L::Noaccel, v) | ||
w = similar(v) | ||
mul!(w, L, v) | ||
end | ||
|
||
import LinearAlgebra: mul! | ||
|
||
mul!(d::T, _::Noaccel, v::T) where {T} = copyto!(d, v) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using LinearAlgebra | ||
using Test | ||
|
||
using ProximalAlgorithms | ||
|
||
@testset "Noaccel" begin | ||
L = ProximalAlgorithms.Noaccel() | ||
|
||
x = randn(10) | ||
y = L*x | ||
|
||
@test y == x | ||
|
||
mul!(y, L, x) | ||
|
||
@test y == x | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using LinearAlgebra | ||
using Test | ||
|
||
using ProximalOperators | ||
using ProximalAlgorithms | ||
|
||
@testset "DRS/DRLS equivalence ($T)" for T in [Float32, Float64] | ||
A = T[ | ||
1.0 -2.0 3.0 -4.0 5.0 | ||
2.0 -1.0 0.0 -1.0 3.0 | ||
-1.0 0.0 4.0 -3.0 2.0 | ||
-1.0 -1.0 -1.0 1.0 3.0 | ||
] | ||
b = T[1.0, 2.0, 3.0, 4.0] | ||
|
||
m, n = size(A) | ||
|
||
R = real(T) | ||
|
||
lam = R(0.1) * norm(A' * b, Inf) | ||
|
||
f = LeastSquares(A, b) | ||
g = NormL1(lam) | ||
|
||
x0 = zeros(R, n) | ||
|
||
drs_iter = ProximalAlgorithms.DRS_iterable(f, g, x0, R(10) / opnorm(A)^2) | ||
drls_iter = ProximalAlgorithms.DRLS_iterable(f, g, x0, R(10) / opnorm(A)^2, R(1), -R(Inf), 1, ProximalAlgorithms.Noaccel()) | ||
|
||
for (state_drs, state_drls) in Iterators.take(zip(drs_iter, drls_iter), 10) | ||
@test isapprox(state_drs.x, state_drls.xbar) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters