diff --git a/src/ADMM.jl b/src/ADMM.jl index 0fea0360..00a4852d 100644 --- a/src/ADMM.jl +++ b/src/ADMM.jl @@ -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) @@ -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) diff --git a/src/SplitBregman.jl b/src/SplitBregman.jl index 9f7655df..03d9d2b6 100644 --- a/src/SplitBregman.jl +++ b/src/SplitBregman.jl @@ -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) @@ -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 @@ -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)