Skip to content

Commit

Permalink
Adapt to recent vee/hat change in ManifoldsBase (#680)
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszbaran authored Nov 9, 2023
1 parent 2104bef commit 5d267d5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 24 deletions.
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.9.6] - 2023-11-09

### Fixed

- Fixed real coefficient basis for complex circle (an issue exposed by [https://github.com/JuliaManifolds/ManifoldsBase.jl/pull/173](https://github.com/JuliaManifolds/ManifoldsBase.jl/pull/173)).
- Fixed `VeeOrthogonalBasis` test for non-real manifolds.

## [0.9.5] - 2023-11-08

### Changed
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Manifolds"
uuid = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e"
authors = ["Seth Axen <[email protected]>", "Mateusz Baran <[email protected]>", "Ronny Bergmann <[email protected]>", "Antoine Levitt <[email protected]>"]
version = "0.9.5"
version = "0.9.6"

[deps]
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Expand Down
5 changes: 4 additions & 1 deletion ext/ManifoldsTestExt/tests_general.jl
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,10 @@ function test_manifold(
q = pts[2]
X = inverse_retract(M, p, q, default_inverse_retraction_method)
Y = vee(M, p, X)
Test.@test length(Y) == number_of_coordinates(M, ManifoldsBase.VeeOrthogonalBasis())
Test.@test length(Y) == number_of_coordinates(
M,
ManifoldsBase.VeeOrthogonalBasis(number_system(M)),
)
Test.@test isapprox(M, p, X, hat(M, p, Y))
Y2 = allocate(Y)
vee_ret = vee!(M, Y2, p, X)
Expand Down
50 changes: 28 additions & 22 deletions src/manifolds/Circle.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@doc raw"""
Circle{𝔽} <: AbstractManifold{𝔽}
The circle $𝕊^1$ is a manifold here represented by
real-valued points in $[-π,π)$ or complex-valued points $z ∈ ℂ$ of absolute value
$\lvert z\rvert = 1$.
The circle ``𝕊^1`` is a manifold here represented by
real-valued points in ``[-π,π)`` or complex-valued points ``z ∈ ℂ`` of absolute value
``\lvert z\rvert = 1``.
# Constructor
Circle(𝔽=ℝ)
Expand All @@ -24,8 +24,8 @@ end
check_point(M::Circle, p)
Check whether `p` is a point on the [`Circle`](@ref) `M`.
For the real-valued case, `p` is an angle and hence it checks that $p ∈ [-π,π)$.
for the complex-valued case, it is a unit number, $p ∈ ℂ$ with $\lvert p \rvert = 1$.
For the real-valued case, `p` is an angle and hence it checks that ``p ∈ [-π,π)``.
for the complex-valued case, it is a unit number, ``p ∈ ℂ`` with ``\lvert p \rvert = 1``.
"""
check_point(::Circle, ::Any...)

Expand Down Expand Up @@ -142,9 +142,9 @@ Compute the exponential map on the [`Circle`](@ref).
````math
\exp_p X = (p+X)_{2π},
````
where $(\cdot)_{2π}$ is the (symmetric) remainder with respect to division by $2π$, i.e. in $[-π,π)$.
where ``(\cdot)_{2π}`` is the (symmetric) remainder with respect to division by ``2π``, i.e. in ``[-π,π)``.
For the complex-valued case, the same formula as for the [`Sphere`](@ref) $𝕊^1$ is applied to values in the
For the complex-valued case, the same formula as for the [`Sphere`](@ref) ``𝕊^1`` is applied to values in the
complex plane.
"""
exp(::Circle, ::Any...)
Expand Down Expand Up @@ -202,11 +202,17 @@ end
Return tangent vector coordinates in the Lie algebra of the [`Circle`](@ref).
"""
get_coordinates(::Circle{ℂ}, p, X, ::DefaultOrthonormalBasis{<:Any,TangentSpaceType})
function get_coordinates_orthonormal!(M::Circle{ℂ}, Y, p, X, n::RealNumbers)
function get_coordinates_orthonormal!(
M::Circle{ℂ},
Y,
p,
X,
n::Union{RealNumbers,ComplexNumbers},
)
Y[] = get_coordinates_orthonormal(M, p, X, n)[]
return Y
end
function get_coordinates_orthonormal(::Circle{ℂ}, p, X, ::RealNumbers)
function get_coordinates_orthonormal(::Circle{ℂ}, p, X, ::Union{RealNumbers,ComplexNumbers})
X, p = X[1], p[1]
Xⁱ = imag(X) * real(p) - real(X) * imag(p)
return @SVector [Xⁱ]
Expand All @@ -226,18 +232,18 @@ end
Return tangent vector from the coordinates in the Lie algebra of the [`Circle`](@ref).
"""
function get_vector_orthonormal(::Circle{ℂ}, p, c, ::RealNumbers)
function get_vector_orthonormal(::Circle{ℂ}, p, c, ::Union{RealNumbers,ComplexNumbers})
@SArray fill(1im * c[1] * p[1])
end
function get_vector_orthonormal!(::Circle{ℂ}, X, p, c, ::RealNumbers)
function get_vector_orthonormal!(::Circle{ℂ}, X, p, c, ::Union{RealNumbers,ComplexNumbers})
X .= 1im * c[1] * p[1]
return X
end

@doc raw"""
injectivity_radius(M::Circle[, p])
Return the injectivity radius on the [`Circle`](@ref) `M`, i.e. $π$.
Return the injectivity radius on the [`Circle`](@ref) `M`, i.e. ``π``.
"""
injectivity_radius(::Circle) = π

Expand Down Expand Up @@ -287,9 +293,9 @@ Compute the logarithmic map on the [`Circle`](@ref) `M`.
````math
\log_p q = (q-p)_{2π},
````
where $(\cdot)_{2π}$ is the (symmetric) remainder with respect to division by $2π$, i.e. in $[-π,π)$.
where ``(\cdot)_{2π}`` is the (symmetric) remainder with respect to division by ``2π``, i.e. in ``[-π,π)``.
For the complex-valued case, the same formula as for the [`Sphere`](@ref) $𝕊^1$ is applied to values in the
For the complex-valued case, the same formula as for the [`Sphere`](@ref) ``𝕊^1`` is applied to values in the
complex plane.
"""
log(::Circle, ::Any...)
Expand Down Expand Up @@ -327,7 +333,7 @@ end
manifold_dimension(M::Circle)
Return the dimension of the [`Circle`](@ref) `M`,
i.e. $\dim(𝕊^1) = 1$.
i.e. ``\dim(𝕊^1) = 1``.
"""
manifold_dimension(::Circle) = 1

Expand All @@ -342,7 +348,7 @@ manifold_volume(::Circle) = 2 * π
mean(M::Circle{ℝ}, x::AbstractVector[, w::AbstractWeights])
Compute the Riemannian [`mean`](@ref mean(M::AbstractManifold, args...)) of `x` of points on
the [`Circle`](@ref) $𝕊^1$, reprsented by real numbers, i.e. the angular mean
the [`Circle`](@ref) ``𝕊^1``, reprsented by real numbers, i.e. the angular mean
````math
\operatorname{atan}\Bigl( \sum_{i=1}^n w_i\sin(x_i), \sum_{i=1}^n w_i\sin(x_i) \Bigr).
````
Expand All @@ -363,15 +369,15 @@ end
mean(M::Circle{ℂ}, x::AbstractVector[, w::AbstractWeights])
Compute the Riemannian [`mean`](@ref mean(M::AbstractManifold, args...)) of `x` of points on
the [`Circle`](@ref) $𝕊^1$, reprsented by complex numbers, i.e. embedded in the complex plane.
the [`Circle`](@ref) ``𝕊^1``, reprsented by complex numbers, i.e. embedded in the complex plane.
Comuting the sum
````math
s = \sum_{i=1}^n x_i
````
the mean is the angle of the complex number $s$, so represented in the complex plane as
$\frac{s}{\lvert s \rvert}$, whenever $s \neq 0$.
the mean is the angle of the complex number ``s``, so represented in the complex plane as
``\frac{s}{\lvert s \rvert}``, whenever ``s \neq 0``.
If the sum $s=0$, the mean is not unique. For example for opposite points or equally spaced
If the sum ``s=0``, the mean is not unique. For example for opposite points or equally spaced
angles.
"""
mean(::Circle{ℂ}, ::Any)
Expand Down Expand Up @@ -407,7 +413,7 @@ number_of_coordinates(::Circle, ::AbstractBasis) = 1
project(M::Circle, p)
Project a point `p` onto the [`Circle`](@ref) `M`.
For the real-valued case this is the remainder with respect to modulus $2π$.
For the real-valued case this is the remainder with respect to modulus ``2π``.
For the complex-valued case the result is the projection of `p` onto the unit circle in the
complex plane.
"""
Expand Down Expand Up @@ -485,7 +491,7 @@ Base.show(io::IO, ::Circle{𝔽}) where {𝔽} = print(io, "Circle($(𝔽))")
sym_rem(x,[T=π])
Compute symmetric remainder of `x` with respect to the interall 2*`T`, i.e.
`(x+T)%2T`, where the default for `T` is $π$
`(x+T)%2T`, where the default for `T` is ``π``
"""
function sym_rem(x::N, T=π) where {N<:Number}
return (x T ? convert(N, -T) : rem(x, convert(N, 2 * T), RoundNearest))
Expand Down

2 comments on commit 5d267d5

@mateuszbaran
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release notes:

Fixed

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/95093

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.9.6 -m "<description of version>" 5d267d532036399ed9d0e31d19345dee10b64bdb
git push origin v0.9.6

Please sign in to comment.