Skip to content

Commit

Permalink
Adress points from code review.
Browse files Browse the repository at this point in the history
  • Loading branch information
kellertuer committed Sep 12, 2021
1 parent 9769a1a commit 4912e4f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/manifolds/CenteredMatrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ where $c_i = \frac{1}{m}\sum_{j=1}^m x_{j,i}$ for $i = 1, \dots, n$.
"""
project(::CenteredMatrices, ::Any, ::Any)

project!(::CenteredMatrices, Y, p::Any, X) = (Y .= X .- mean(X, dims=1))
project!(::CenteredMatrices, Y, p, X) = (Y .= X .- mean(X, dims=1))

@generated representation_size(::CenteredMatrices{m,n,𝔽}) where {m,n,𝔽} = (m, n)

Expand Down
8 changes: 2 additions & 6 deletions src/manifolds/HyperbolicPoincareBall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ function change_gradient(
X::PoincareBallTVector,
)
α = 2 / (1 - norm(p.value)^2)
Y = copy(M, p, X)
Y.value ./= α^2
return Y
return PoincareBallTVector(X.value ./ α^2)
end

@doc raw"""
Expand All @@ -29,9 +27,7 @@ function change_metric(
X::PoincareBallTVector,
)
α = 2 / (1 - norm(p.value)^2)
Y = copy(M, p, X)
Y.value ./= α
return Y
return PoincareBallTVector(X.value ./ α)
end

function check_point(M::Hyperbolic{N}, p::PoincareBallPoint; kwargs...) where {N}
Expand Down
8 changes: 3 additions & 5 deletions src/manifolds/MetricManifold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Here, the default metric in `\mathcal P(3)` is the [`LinearAffineMetric`](@ref)
"""
change_gradient(::AbstractManifold, ::AbstractMetric, ::Any, ::Any)

function change_tangent(M::AbstractManifold, G::AbstractMetric, p, X)
function change_gradient(M::AbstractManifold, G::AbstractMetric, p, X)
if is_default_metric(M, G)
return X
end
Expand All @@ -108,7 +108,7 @@ function change_tangent(M::AbstractManifold, G::AbstractMetric, p, X)
return get_vector(M, p, z, B)
end

function change_metric(
function change_gradient(
::MetricManifold{𝔽,M,G},
::G,
p,
Expand All @@ -128,8 +128,6 @@ sense that it returns the tangent vector ``Z=BX`` such that the linear map ``B``
g_2(Y_1,Y_2) = g_1(BY_1,BY_2) \quad \text{for all } Y_1, Y_2 ∈ T_p\mathcal M.
````
holds.
If both metrics are given in their [`local_metric`](@ref) (symmetric positive defintie) matrix
representations ``G_1 = C_1C_1^{\mathrm{H}}`` and ``G_2 = C_2C_2^{\mathrm{H}}``, where ``C_1,C_2`` denote their
Cholesky factor, then solving ``C_2C_2^{\mathrm{H}} = G_2 = B^{\mathrm{H}}G_1B = B^{\mathrm{H}}C_1C_1^{\mathrm{H}}B`` yields ``B = (C_1 \backslash C_2)^{\mathrm{H}}``,
Expand Down Expand Up @@ -234,7 +232,7 @@ Return the [`LeviCivitaConnection`](@ref) for a metric manifold.
connection(::MetricManifold) = LeviCivitaConnection()

@doc raw"""
det_local_metric(M::AbstractManifold, p, B::AbstractBasis=DefaultOrthogonalBasis)
det_local_metric(M::AbstractManifold, p, B::AbstractBasis)
Return the determinant of local matrix representation of the metric tensor ``g``, i.e. of the
matrix ``G(p)`` representing the metric in the tangent space at ``p`` with as a matrix.
Expand Down
4 changes: 2 additions & 2 deletions src/manifolds/PositiveNumbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ end
Given a tangent vector ``X ∈ T_p\mathcal M``representing a gradient with respect to the [`EuclideanMetric`](@ref) `g_E`,
this function changes into the positivity metric representation of
[`PositiveNumbers`](lref) `M` for the same gradient.
[`PositiveNumbers`](@ref) `M` for the same gradient.
"""
change_gradient(::PositiveNumbers, ::EuclideanMetric, p, X) = p .* X .* p

@doc raw"""
change_metric(M::SymmetricPOsitiveDefinite, E::EuclideanMetric, p, X)
Given a tangent vector ``X ∈ T_p\mathcal M`` with respect to the [`EuclideanMetric`](@ref) `g_E`,
this function changes into the positivity metric of [`PositiveNumbers`](lref) `M` for the same gradient.
this function changes into the positivity metric of [`PositiveNumbers`](@ref) `M` for the same gradient.
"""
change_metric(::PositiveNumbers, ::EuclideanMetric, p, X) = p .* X

Expand Down
2 changes: 1 addition & 1 deletion src/manifolds/PowerManifold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ end
Since the metric on a power manifold decouples, the change of a representer can be done elementwise
"""
function change_gradient(::AbstractPowerManifold, M::AbstractMetric, p, X)
function change_metric(::AbstractPowerManifold, M::AbstractMetric, p, X)
Z = copy(M, p, X)
for i in get_iterator(M)
Z[i...] = change_gradient(M.manifold, G, p[i...], X[i...])
Expand Down
4 changes: 2 additions & 2 deletions src/manifolds/SymmetricPositiveDefiniteLinearAffine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct LinearAffineMetric <: RiemannianMetric end
Given a tangent vector ``X ∈ T_p\mathcal M``representing a gradient with respect to the [`EuclideanMetric`](@ref) `g_E`,
this function changes into the [`LinearAffine`](@ref) (default) metric representation of
[`SymmetricPOsitiveDefinite`](lref) `M` for the same gradient.
[`SymmetricPOsitiveDefinite`](@ref) `M` for the same gradient.
"""
change_gradient(::SymmetricPositiveDefinite, ::EuclideanMetric, p, X) = p * X * p

Expand All @@ -20,7 +20,7 @@ change_gradient(::SymmetricPositiveDefinite, ::EuclideanMetric, p, X) = p * X *
Given a tangent vector ``X ∈ T_p\mathcal M`` with respect to the [`EuclideanMetric`](@ref) `g_E`,
this function changes into the [`LinearAffine`](@ref) (default) metric on the
[`SymmetricPOsitiveDefinite`](lref) `M`.
[`SymmetricPOsitiveDefinite`](@ref) `M`.
"""
change_metric(::SymmetricPositiveDefinite, ::EuclideanMetric, p, X) = p * X

Expand Down

0 comments on commit 4912e4f

Please sign in to comment.