Skip to content

Commit

Permalink
Introduce proxes.
Browse files Browse the repository at this point in the history
  • Loading branch information
kellertuer committed Nov 28, 2023
1 parent 7fb4aa7 commit 537b194
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/proximal_maps.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@doc raw"""
y = prox_distance(M,λ,f,x [, p=2])
prox_distance!(M, y, λ, f, x [, p=2])
compute the proximal map ``\operatorname{prox}_{λ\varphi}`` with
parameter λ of ``φ(x) = \frac{1}{p}d_{\mathcal M}^p(f,x)``.
For the mutating variant the computation is done in place of `y`.
# Input
* `M` – a manifold `M`
* `λ` – the prox parameter
* `f` – a point ``f ∈ \mathcal M`` (the data)
* `x` – the argument of the proximal map
# Optional argument
* `p` – (`2`) exponent of the distance.
# Output
* `y` – the result of the proximal map of ``φ``
"""
function prox_distance(M::AbstractManifold, λ, f, x, p::Int = 2)
d = distance(M, f, x)
if p == 2
t = λ / (1 + λ)
elseif p == 1
t =< d) ? λ / d : 1.0

Check warning on line 26 in src/proximal_maps.jl

View check run for this annotation

Codecov / codecov/patch

src/proximal_maps.jl#L21-L26

Added lines #L21 - L26 were not covered by tests
else
throw(

Check warning on line 28 in src/proximal_maps.jl

View check run for this annotation

Codecov / codecov/patch

src/proximal_maps.jl#L28

Added line #L28 was not covered by tests
ErrorException(
"Proximal Map of distance(M,f,x) not implemented for p=$(p) (requires p=1 or 2)",
),
)
end
return exp(M, x, log(M, x, f), t)

Check warning on line 34 in src/proximal_maps.jl

View check run for this annotation

Codecov / codecov/patch

src/proximal_maps.jl#L34

Added line #L34 was not covered by tests
end
function prox_distance!(M::AbstractManifold, y, λ, f, x, p::Int = 2)
d = distance(M, f, x)
if p == 2
t = λ / (1 + λ)
elseif p == 1
t =< d) ? λ / d : 1.0

Check warning on line 41 in src/proximal_maps.jl

View check run for this annotation

Codecov / codecov/patch

src/proximal_maps.jl#L36-L41

Added lines #L36 - L41 were not covered by tests
else
throw(

Check warning on line 43 in src/proximal_maps.jl

View check run for this annotation

Codecov / codecov/patch

src/proximal_maps.jl#L43

Added line #L43 was not covered by tests
ErrorException(
"Proximal Map of distance(M,f,x) not implemented for p=$(p) (requires p=1 or 2)",
),
)
end
return exp!(M, y, x, log(M, x, f), t)

Check warning on line 49 in src/proximal_maps.jl

View check run for this annotation

Codecov / codecov/patch

src/proximal_maps.jl#L49

Added line #L49 was not covered by tests
end

0 comments on commit 537b194

Please sign in to comment.