From 1a02d4e9a4c37b39d49dd27146b5c77f4d48e5de Mon Sep 17 00:00:00 2001 From: Mateusz Baran Date: Wed, 25 Oct 2023 18:24:14 +0200 Subject: [PATCH] Fix #665 --- NEWS.md | 6 ++++++ src/groups/GroupManifold.jl | 2 +- src/groups/general_unitary_groups.jl | 5 ++++- src/groups/translation_group.jl | 4 ++++ test/groups/general_unitary_groups.jl | 3 +++ test/groups/special_euclidean.jl | 2 ++ test/groups/translation_group.jl | 4 ++++ 7 files changed, 24 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 84ca00e2f7..e9038e17d4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,12 @@ 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.2] - 2023-10-26 + +### Added + +- `rand(G; vector_at=Identity(G))` now works for translation, special orthogonal and special Euclidean groups `G`. + ## [0.9.1] - 2023-10-25 ### Added diff --git a/src/groups/GroupManifold.jl b/src/groups/GroupManifold.jl index c8983731be..2698bc48e6 100644 --- a/src/groups/GroupManifold.jl +++ b/src/groups/GroupManifold.jl @@ -102,7 +102,7 @@ function is_vector( return false end end - return is_vector(G.manifold, identity_element(G), X, false, te; kwargs...) + return is_vector(G.manifold, identity_element(G), X, false; error=error, kwargs...) end Base.show(io::IO, G::GroupManifold) = print(io, "GroupManifold($(G.manifold), $(G.op))") diff --git a/src/groups/general_unitary_groups.jl b/src/groups/general_unitary_groups.jl index 40c56a179d..39faa74d03 100644 --- a/src/groups/general_unitary_groups.jl +++ b/src/groups/general_unitary_groups.jl @@ -34,13 +34,16 @@ function allocate_result( return allocate(X) end function allocate_result( - ::GeneralUnitaryMultiplicationGroup, + M::GeneralUnitaryMultiplicationGroup, ::typeof(log), ::Identity{MultiplicationOperation}, q, ) return allocate(q) end +function allocate_result(M::Rotations, ::typeof(rand), ::Identity{MultiplicationOperation}) + return similar(Matrix{Float64}, representation_size(M)...) +end decorated_manifold(G::GeneralUnitaryMultiplicationGroup) = G.manifold diff --git a/src/groups/translation_group.jl b/src/groups/translation_group.jl index cbc752acab..a52f9a1731 100644 --- a/src/groups/translation_group.jl +++ b/src/groups/translation_group.jl @@ -33,6 +33,10 @@ end end end +function allocate_result(M::Euclidean, ::typeof(rand), ::Identity{AdditionOperation}) + return similar(Array{Float64}, representation_size(M)...) +end + exp!(::TranslationGroup, q, ::Identity{AdditionOperation}, X) = copyto!(q, X) has_biinvariant_metric(::TranslationGroup) = true diff --git a/test/groups/general_unitary_groups.jl b/test/groups/general_unitary_groups.jl index a3829e2990..d393c07819 100644 --- a/test/groups/general_unitary_groups.jl +++ b/test/groups/general_unitary_groups.jl @@ -74,6 +74,9 @@ include("group_utils.jl") 0.4070678736115306 0.10586374034761421 -0.43156436122007846 0.0 ] @test volume_density(M, p, X) ≈ 0.710713830700454 + + # random Lie algebra element + @test is_vector(M, Identity(M), rand(M; vector_at=Identity(M))) end @testset "Unitary Group" begin diff --git a/test/groups/special_euclidean.jl b/test/groups/special_euclidean.jl index c4cd336dc0..0030a38b72 100644 --- a/test/groups/special_euclidean.jl +++ b/test/groups/special_euclidean.jl @@ -100,6 +100,8 @@ using Manifolds: @test w2mat ≈ affine_matrix(G, pts[1]) * screw_matrix(G, X_pts[1]) @test screw_matrix(G, w2mat) === w2mat + @test is_vector(G, Identity(G), rand(G; vector_at=Identity(G))) + test_group( G, pts, diff --git a/test/groups/translation_group.jl b/test/groups/translation_group.jl index 5c1b43d75c..e88704ff72 100644 --- a/test/groups/translation_group.jl +++ b/test/groups/translation_group.jl @@ -1,6 +1,8 @@ include("../utils.jl") include("group_utils.jl") +using Manifolds: LeftForwardAction, RightBackwardAction + @testset "Translation group" begin @testset "real" begin G = TranslationGroup(2, 3) @@ -42,6 +44,8 @@ include("group_utils.jl") test_vee_hat_from_identity=true, ) end + + @test is_vector(G, Identity(G), rand(G; vector_at=Identity(G))) end @testset "complex" begin