From 4912e4feb353df8d8073c659a8ce243f652d404a Mon Sep 17 00:00:00 2001 From: Ronny Bergmann Date: Sun, 12 Sep 2021 20:09:11 +0200 Subject: [PATCH] Adress points from code review. --- src/manifolds/CenteredMatrices.jl | 2 +- src/manifolds/HyperbolicPoincareBall.jl | 8 ++------ src/manifolds/MetricManifold.jl | 8 +++----- src/manifolds/PositiveNumbers.jl | 4 ++-- src/manifolds/PowerManifold.jl | 2 +- src/manifolds/SymmetricPositiveDefiniteLinearAffine.jl | 4 ++-- 6 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/manifolds/CenteredMatrices.jl b/src/manifolds/CenteredMatrices.jl index b387a31162..33d922b727 100644 --- a/src/manifolds/CenteredMatrices.jl +++ b/src/manifolds/CenteredMatrices.jl @@ -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) diff --git a/src/manifolds/HyperbolicPoincareBall.jl b/src/manifolds/HyperbolicPoincareBall.jl index a226dc6fa2..ce8849cf03 100644 --- a/src/manifolds/HyperbolicPoincareBall.jl +++ b/src/manifolds/HyperbolicPoincareBall.jl @@ -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""" @@ -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} diff --git a/src/manifolds/MetricManifold.jl b/src/manifolds/MetricManifold.jl index 8673f0be45..22efb6b881 100644 --- a/src/manifolds/MetricManifold.jl +++ b/src/manifolds/MetricManifold.jl @@ -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 @@ -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, @@ -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}}``, @@ -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. diff --git a/src/manifolds/PositiveNumbers.jl b/src/manifolds/PositiveNumbers.jl index 3d6d56cb7e..0a41d21ec6 100644 --- a/src/manifolds/PositiveNumbers.jl +++ b/src/manifolds/PositiveNumbers.jl @@ -58,7 +58,7 @@ 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 @@ -66,7 +66,7 @@ change_gradient(::PositiveNumbers, ::EuclideanMetric, p, X) = p .* X .* p 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 diff --git a/src/manifolds/PowerManifold.jl b/src/manifolds/PowerManifold.jl index ba745087df..5e67b36cf6 100644 --- a/src/manifolds/PowerManifold.jl +++ b/src/manifolds/PowerManifold.jl @@ -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...]) diff --git a/src/manifolds/SymmetricPositiveDefiniteLinearAffine.jl b/src/manifolds/SymmetricPositiveDefiniteLinearAffine.jl index dfffbb8982..443a79e86e 100644 --- a/src/manifolds/SymmetricPositiveDefiniteLinearAffine.jl +++ b/src/manifolds/SymmetricPositiveDefiniteLinearAffine.jl @@ -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 @@ -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