From 1e6dad6f299d0df61c03dbcfe1926abf8c2d59f6 Mon Sep 17 00:00:00 2001 From: Ronny Bergmann Date: Wed, 30 Oct 2024 18:36:24 +0100 Subject: [PATCH] fix a few bugs and increase test cov. --- .../multiplication_operation.jl | 11 ++------ .../test_multiplication_operation.jl | 26 +++++++++++++++---- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/group_operations/multiplication_operation.jl b/src/group_operations/multiplication_operation.jl index 402b430..b73130c 100644 --- a/src/group_operations/multiplication_operation.jl +++ b/src/group_operations/multiplication_operation.jl @@ -100,7 +100,7 @@ function diff_conjugate!( ) where {𝔽} inv_right_compose!(G, Y, X, g) # Y = Xg^{-1} compose!(G, Y, g, Y) # Y = gY - return copyto!(LieAlgebra(G), Y, X) + return Y end _doc_diff_inv_mult = """ @@ -324,19 +324,12 @@ function LinearAlgebra.mul!( return copyto!(q, p) end function LinearAlgebra.mul!( - q::Union{AbstractMatrix,Number}, + q::Union{AbstractMatrix}, ::Identity{<:AbstractMultiplicationGroupOperation}, ::Identity{<:AbstractMultiplicationGroupOperation}, ) return copyto!(q, I) end -function LinearAlgebra.mul!( - q, - ::Identity{<:AbstractMultiplicationGroupOperation}, - ::Identity{<:AbstractMultiplicationGroupOperation}, -) - return copyto!(q, one(q)) -end function LinearAlgebra.mul!( q::Identity{<:AbstractMultiplicationGroupOperation}, ::Identity{<:AbstractMultiplicationGroupOperation}, diff --git a/test/operations/test_multiplication_operation.jl b/test/operations/test_multiplication_operation.jl index 703d717..2c01bd9 100644 --- a/test/operations/test_multiplication_operation.jl +++ b/test/operations/test_multiplication_operation.jl @@ -1,4 +1,4 @@ -using LieGroups, Test +using LieGroups, LinearAlgebra, Test s = joinpath(@__DIR__, "..", "LieGroupsTestSuite.jl") !(s in LOAD_PATH) && (push!(LOAD_PATH, s)) @@ -23,12 +23,28 @@ using LieGroupsTestSuite ea = Identity(AdditionGroupOperation) @test ea * e === e @test e * ea === e - # Zero array - g2 = fill(2.0, ()) - # Array - g3 = [2.0 0.0; 0.0 2.0] M = LieGroupsTestSuite.DummyManifold() G = LieGroup(M, MatrixMultiplicationGroupOperation()) + # Zero-dimensional array + g2 = fill(2.0, ()) + X2 = fill(1.0, ()) + @test diff_inv(G, g2, X2) == fill(-1.0, ()) + # Array + g3 = [2.0 0.0; 1.0 2.0] @test inv(G, e) === e + h3 = zero(g3) + X3 = [1.0 0.0; 0.0 2.0] + @test diff_conjugate(G, g3, g3, X3) = g3 * X3 * inv(g3) + # inplace-multiplication with e + h3 = zero(g3) + mul!(h3, e, g3) + @test h3 == g3 + h3 = zero(g3) + mul!(h3, g3, e) + @test h3 == g3 + mul!(h3, e, e) + @test h3 == I + @test mul!(e, e, e) === e + @test one(e) === e end end