Skip to content

Commit

Permalink
Fix Rotations(1) (#636)
Browse files Browse the repository at this point in the history
* Fix `Rotations(1)`

* fix for Julia 1.6

* bump version
  • Loading branch information
mateuszbaran authored Jun 26, 2023
1 parent 20fe351 commit e714d9d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
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.8.71"
version = "0.8.72"

[deps]
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Expand Down
17 changes: 16 additions & 1 deletion src/manifolds/GeneralUnitaryMatrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -342,17 +342,22 @@ function get_coordinates_orthogonal(M::GeneralUnitaryMatrices{n,ℝ}, p, X, N) w
return get_coordinates_orthogonal!(M, Y, p, X, N)
end

function get_coordinates_orthogonal!(::GeneralUnitaryMatrices{1,ℝ}, Xⁱ, p, X, ::RealNumbers)
return Xⁱ
end
function get_coordinates_orthogonal!(::GeneralUnitaryMatrices{2,ℝ}, Xⁱ, p, X, ::RealNumbers)
Xⁱ[1] = X[2]
return Xⁱ
end
function get_coordinates_orthogonal!(
::GeneralUnitaryMatrices{n,ℝ},
M::GeneralUnitaryMatrices{n,ℝ},
Xⁱ,
p,
X,
::RealNumbers,
) where {n}
@assert length(Xⁱ) == manifold_dimension(M)
@assert size(X) == (n, n)
@inbounds begin
Xⁱ[1] = X[3, 2]
Xⁱ[2] = X[1, 3]
Expand Down Expand Up @@ -414,6 +419,9 @@ function get_vector_orthogonal(::GeneralUnitaryMatrices{2,ℝ}, p::SMatrix, Xⁱ
return @SMatrix [0 -Xⁱ[]; Xⁱ[] 0]
end

function get_vector_orthogonal!(::GeneralUnitaryMatrices{1,ℝ}, X, p, Xⁱ, N::RealNumbers)
return X .= 0
end
function get_vector_orthogonal!(M::GeneralUnitaryMatrices{2,ℝ}, X, p, Xⁱ, N::RealNumbers)
return get_vector_orthogonal!(M, X, p, Xⁱ[1], N)
end
Expand Down Expand Up @@ -526,6 +534,7 @@ Return the radius of injectivity on the [`Rotations`](@ref) manifold `M`, which
> For a derivation of the injectivity radius, see [sethaxen.com/blog/2023/02/the-injectivity-radii-of-the-unitary-groups/](https://sethaxen.com/blog/2023/02/the-injectivity-radii-of-the-unitary-groups/).
"""
injectivity_radius(::GeneralUnitaryMatrices{n,ℝ}) where {n} = π * sqrt(2.0)
injectivity_radius(::GeneralUnitaryMatrices{1,ℝ}) = 0.0

# Resolve ambiguity on Rotations and Orthogonal
function _injectivity_radius(
Expand All @@ -537,6 +546,12 @@ end
function _injectivity_radius(::GeneralUnitaryMatrices{n,ℝ}, ::PolarRetraction) where {n}
return π / sqrt(2.0)
end
function _injectivity_radius(::GeneralUnitaryMatrices{1,ℝ}, ::ExponentialRetraction)
return 0.0
end
function _injectivity_radius(::GeneralUnitaryMatrices{1,ℝ}, ::PolarRetraction)
return 0.0
end

inner(::GeneralUnitaryMatrices, p, X, Y) = dot(X, Y)

Expand Down
18 changes: 18 additions & 0 deletions test/manifolds/rotations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,22 @@ include("../utils.jl")
PolarInverseRetraction(),
)
end

@testset "Rotations(1)" begin
M = Rotations(1)
p = fill(1.0, 1, 1)
X = get_vector(M, p, Float64[], DefaultOrthonormalBasis())
@test X isa Matrix{Float64}
@test X == fill(0.0, 1, 1)
Xc = get_coordinates(M, p, X, DefaultOrthonormalBasis())
@test length(Xc) == 0
@test Xc isa Vector{Float64}

@test injectivity_radius(M) == 0.0
@test injectivity_radius(M, p) == 0.0
@test injectivity_radius(M, ExponentialRetraction()) == 0.0
@test injectivity_radius(M, p, ExponentialRetraction()) == 0.0
@test injectivity_radius(M, PolarRetraction()) == 0.0
@test injectivity_radius(M, p, PolarRetraction()) == 0.0
end
end

2 comments on commit e714d9d

@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
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/86281

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.8.72 -m "<description of version>" e714d9d97e274ba8dd27d51095696064206054d4
git push origin v0.8.72

Please sign in to comment.