diff --git a/src/group_operations/multiplication_operation.jl b/src/group_operations/multiplication_operation.jl index b9f376b..7966543 100644 --- a/src/group_operations/multiplication_operation.jl +++ b/src/group_operations/multiplication_operation.jl @@ -15,8 +15,12 @@ A group operation that is realised by a matrix multiplication. struct MatrixMultiplicationGroupOperation <: AbstractMultiplicationGroupOperation end Base.:*(e::Identity{<:AbstractMultiplicationGroupOperation}) = e -Base.:*(::Identity{MatrixMultiplicationGroupOperation}, p::AbstractMatrix) = p -Base.:*(p::AbstractMatrix, ::Identity{MatrixMultiplicationGroupOperation}) = p +Base.:*(::Identity{MatrixMultiplicationGroupOperation}, p::Union{AbstractMatrix,Number}) = p +function Base.:*( + p::Union{AbstractMatrix,Number}, ::Identity{MatrixMultiplicationGroupOperation} +) + return p +end function Base.:*( e::Identity{<:AbstractMultiplicationGroupOperation}, ::Identity{<:AbstractMultiplicationGroupOperation}, diff --git a/test/operations/test_multiplication_operation.jl b/test/operations/test_multiplication_operation.jl new file mode 100644 index 0000000..04f2fc7 --- /dev/null +++ b/test/operations/test_multiplication_operation.jl @@ -0,0 +1,19 @@ +using LieGroups, Test + +@testset "Addition Operation" begin + @testset "Base.:+ and Base.:- with the Identity" begin + e = Identity(MatrixMultiplicationGroupOperation()) + @test (e * e) === e + g = 2 + @test (g * e) == g + @test (e * g) == g + @test (g / e) == g + @test (e \ g) == g + @test (e / g) == 1 / g + @test (g \ e) == 1 / g + @test (e / e) === e + @test (e \ e) === e + @test inv(e) === e + @test det(e) + end +end diff --git a/test/runtests.jl b/test/runtests.jl index 0eaeaba..bd02722 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -15,6 +15,7 @@ end end @testset "Generic Group Operations" begin include_test("operations/test_addidion_operation.jl") + include_test("operations/test_multiplication_operation.jl") end @testset "Generic Group Actions" begin include_test("actions/test_action_interface.jl")