Skip to content

Commit

Permalink
feat: add isomorphism method for abelian groups
Browse files Browse the repository at this point in the history
  • Loading branch information
thofma committed Jan 16, 2025
1 parent d45ee3f commit cbb9b97
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/GrpAb/GrpAbFinGen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,14 @@ function is_isomorphic(G::FinGenAbGroup, H::FinGenAbGroup)
return elementary_divisors(G) == elementary_divisors(H)
end

function isomorphism(G::FinGenAbGroup, H::FinGenAbGroup)
SG, SGtoG = snf(G)
SH, SHtoH = snf(H)
@req SG.snf == SH.snf "Groups are not isomorphic"
h = hom(SG, SH, gens(SH))
return inv(SGtoG) * h * SHtoH
end

################################################################################
#
# Direct products/direct sums/biproducts
Expand Down
8 changes: 8 additions & 0 deletions test/GrpAb/GrpAbFinGen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,18 @@
@testset "Isomorphism" begin
b = @inferred is_isomorphic(abelian_group(Int[]), abelian_group(Int[]))
@test b
h = isomorphism(abelian_group(Int[]), abelian_group(Int[]))
@test is_bijective(h)

G = abelian_group([2, 3, 5])
H = abelian_group([30])
@test @inferred is_isomorphic(G, H)

h = isomorphism(G, H)
@test is_bijective(h)

K = abelian_group([2, 3])
@test_throws ArgumentError isomorphism(G, K)
end

@testset "Direct product" begin
Expand Down

0 comments on commit cbb9b97

Please sign in to comment.