Skip to content

Commit 6968981

Browse files
committed
Add test for MatrixGroupElem
1 parent bbbfc66 commit 6968981

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Groups/types.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ mutable struct MatrixGroupElem{RE<:RingElem, T<:MatElem{RE}} <: AbstractMatrixGr
446446
end
447447

448448
function Base.hash(x::MatrixGroupElem, h::UInt)
449-
return hash(matrix(x), hash(parent(x), h))
449+
return hash(matrix(x), hash(base_ring(parent(x)), h))
450450
end
451451

452452
################################################################################

test/Groups/matrixgroups.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,3 +824,16 @@ end
824824
@test h * v == mat * v
825825
end
826826
end
827+
828+
@testset "hashing matrix elements" begin
829+
matrices = [matrix(ZZ, [0 -1; 1 -1]), matrix(ZZ, [0 1; 1 0])]
830+
G = matrix_group(matrices)
831+
A = matrix(ZZ, [1 -1; 0 -1])
832+
B = matrix(ZZ, [-1 0; -1 1])
833+
C = G([1 0; 0 1])
834+
835+
@test hash(C) == hash(one(G))
836+
@test hash(G(A)) != hash(one(G))
837+
@test hash(G(A)) == hash(G(A))
838+
@test hash(G(A)) != hash(G(B))
839+
end

0 commit comments

Comments
 (0)