Skip to content

Commit 5e8ad4a

Browse files
authored
feat: add isomorphism method for abelian groups (#1724)
1 parent 577504b commit 5e8ad4a

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/GrpAb/GrpAbFinGen.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,14 @@ function is_isomorphic(G::FinGenAbGroup, H::FinGenAbGroup)
606606
return elementary_divisors(G) == elementary_divisors(H)
607607
end
608608

609+
function isomorphism(G::FinGenAbGroup, H::FinGenAbGroup)
610+
SG, SGtoG = snf(G)
611+
SH, SHtoH = snf(H)
612+
@req SG.snf == SH.snf "Groups are not isomorphic"
613+
h = hom(SG, SH, gens(SH))
614+
return inv(SGtoG) * h * SHtoH
615+
end
616+
609617
################################################################################
610618
#
611619
# Direct products/direct sums/biproducts

test/GrpAb/GrpAbFinGen.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,18 @@
176176
@testset "Isomorphism" begin
177177
b = @inferred is_isomorphic(abelian_group(Int[]), abelian_group(Int[]))
178178
@test b
179+
h = isomorphism(abelian_group(Int[]), abelian_group(Int[]))
180+
@test is_bijective(h)
179181

180182
G = abelian_group([2, 3, 5])
181183
H = abelian_group([30])
182184
@test @inferred is_isomorphic(G, H)
185+
186+
h = isomorphism(G, H)
187+
@test is_bijective(h)
188+
189+
K = abelian_group([2, 3])
190+
@test_throws ArgumentError isomorphism(G, K)
183191
end
184192

185193
@testset "Direct product" begin

0 commit comments

Comments
 (0)