Skip to content

Commit

Permalink
Add extension for ProximalCore/-Operators adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
nHackel committed Feb 16, 2024
1 parent 8b628f7 commit 3972a76
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
VectorizationBase = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[weakdeps]
ProximalCore = "dc4f5ac2-75d1-4f31-931e-60435d74994b"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand All @@ -30,6 +33,10 @@ VectorizationBase = "0.19, 0.21"
LinearOperatorCollection = "1.0"
LinearOperators = "2.3.3"
FFTW = "1.0"
ProximalCore = "0.1"

[targets]
test = ["Test", "Random", "FFTW"]

[extensions]
RegularizedLeastSquaresProximalCore = "ProximalCore"
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module RegularizedLeastSquaresProximalCore

using RegularizedLeastSquares, ProximalCore

import RegularizedLeastSquares.prox!, RegularizedLeastSquares.ProximalCoreAdapter

struct ProximalCoreAdapterImpl{T, F} <: ProximalCoreAdapter{T, F}
λ::T
op::F
end

RegularizedLeastSquares.ProximalCoreAdapter::T, op::F) where {T, F} = ProximalCoreAdapterImpl(λ, op)

Check warning on line 12 in ext/RegularizedLeastSquaresProximalCore/RegularizedLeastSquaresProximalCore.jl

View check run for this annotation

Codecov / codecov/patch

ext/RegularizedLeastSquaresProximalCore/RegularizedLeastSquaresProximalCore.jl#L12

Added line #L12 was not covered by tests

function prox!(reg::ProximalCoreAdapter, x::AbstractArray{Tc}, λ::T) where {T, Tc <: Union{T, Complex{T}}}
ProximalCore.prox!(x, reg.op, x, λ)
return x

Check warning on line 16 in ext/RegularizedLeastSquaresProximalCore/RegularizedLeastSquaresProximalCore.jl

View check run for this annotation

Codecov / codecov/patch

ext/RegularizedLeastSquaresProximalCore/RegularizedLeastSquaresProximalCore.jl#L14-L16

Added lines #L14 - L16 were not covered by tests
end

end
2 changes: 2 additions & 0 deletions src/Regularization/Regularization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ include("TransformedRegularization.jl")
include("MaskedRegularization.jl")
include("PlugAndPlayRegularization.jl")

export ProximalCoreAdapter
abstract type ProximalCoreAdapter{T, F} <: AbstractParameterizedRegularization{T} where F end

function findfirst(::Type{S}, reg::AbstractRegularization) where S <: AbstractRegularization
regs = collect(reg)
Expand Down

0 comments on commit 3972a76

Please sign in to comment.