Skip to content

Commit

Permalink
Enable ADMM and SplitBregman to work with multiple reg terms again wi…
Browse files Browse the repository at this point in the history
…th default rho
  • Loading branch information
nHackel committed Oct 18, 2023
1 parent bbc7139 commit db13951
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
11 changes: 6 additions & 5 deletions src/ADMM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ function ADMM(A::matT, x::Vector{T}=zeros(eltype(A),size(A,2));
# TODO: The constructor is not type stable

# unify Floating types
if typeof(ρ) <: Number
ρ_vec = [real(T).(ρ)]
else
ρ_vec = real(T).(ρ)
end
absTol = real(T)(absTol)
relTol = real(T)(relTol)
tolInner = real(T)(tolInner)
Expand All @@ -102,6 +97,12 @@ function ADMM(A::matT, x::Vector{T}=zeros(eltype(A),size(A,2));
end
end
regTrafo = identity.(regTrafo)

if typeof(ρ) <: Number
ρ_vec = [real(T).(ρ) for i = 1:length(reg)]
else
ρ_vec = real(T).(ρ)
end

xᵒˡᵈ = similar(x)

Expand Down
15 changes: 7 additions & 8 deletions src/SplitBregman.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function SplitBregman(A::matT, x::vecT=zeros(eltype(A),size(A,2)), b=nothing;
, relTol::Float64=eps()
, tolInner::Float64=1.e-6
, normalizeReg::AbstractRegularizationNormalization = NoNormalization()
, kargs...) where {matT, vecT<:AbstractVector}
, kargs...) where {T, matT, vecT<:AbstractVector{T}}

reg = vec(reg)
indices = findsinks(AbstractProjectionRegularization, reg)
Expand All @@ -90,6 +90,12 @@ function SplitBregman(A::matT, x::vecT=zeros(eltype(A),size(A,2)), b=nothing;
end
regTrafo = identity.(regTrafo)

# make sure that ρ is a vector
if typeof(ρ) <: Number
ρ_vec = [real(T).(ρ) for i = 1:length(reg)]
else
ρ_vec = real(T).(ρ)
end


if b==nothing
Expand Down Expand Up @@ -125,13 +131,6 @@ function SplitBregman(A::matT, x::vecT=zeros(eltype(A),size(A,2)), b=nothing;

iter_cnt = 1

# make sure that ρ is a vector
if typeof(ρ) <: Real
ρ_vec = similar(x, real(eltype(x)), 1)
ρ_vec .= ρ
else
ρ_vec = typeof(real.(x))(ρ)
end

# normalization parameters
reg = normalize(SplitBregman, normalizeReg, vec(reg), A, nothing)
Expand Down

0 comments on commit db13951

Please sign in to comment.