From e83c5f865b4f5f807321a99ac2b5ce0b93b4ff36 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 26 Sep 2023 12:25:30 +0200 Subject: [PATCH] Rename rank(A::GrpAbFinGen) to torsion_free_rank Unfortunately the notion of 'rank' for groups clashes with that for abelian groups. The latter is also known as 'torsion free rank'. Hence I propose to rename `rank` for abelian groups here accordingly. --- docs/src/abelian/introduction.md | 1 + src/GrpAb/GrpAbFinGen.jl | 27 +++++++++++++++++++++------ test/GrpAb/GrpAbFinGen.jl | 12 ++++++++---- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/docs/src/abelian/introduction.md b/docs/src/abelian/introduction.md index ad6e1ba1ae..876e56bdd6 100644 --- a/docs/src/abelian/introduction.md +++ b/docs/src/abelian/introduction.md @@ -59,6 +59,7 @@ rels(A::GrpAbFinGen) is_finite(A::GrpAbFinGen) is_infinite(A::GrpAbFinGen) rank(A::GrpAbFinGen) +torsion_free_rank(A::GrpAbFinGen) order(A::GrpAbFinGen) exponent(A::GrpAbFinGen) is_trivial(A::GrpAbFinGen) diff --git a/src/GrpAb/GrpAbFinGen.jl b/src/GrpAb/GrpAbFinGen.jl index 84bbf97170..54a9e1328f 100644 --- a/src/GrpAb/GrpAbFinGen.jl +++ b/src/GrpAb/GrpAbFinGen.jl @@ -33,7 +33,7 @@ ################################################################################ export abelian_group, free_abelian_group, is_snf, ngens, nrels, rels, snf, isfinite, - is_infinite, rank, order, exponent, is_trivial, is_isomorphic, + is_infinite, torsion_free_rank, rank, order, exponent, is_trivial, is_isomorphic, direct_product, is_torsion, torsion_subgroup, sub, quo, is_cyclic, psylow_subgroup, is_subgroup, abelian_groups, flat, tensor_product, dual, chain_complex, is_exact, free_resolution, obj, map, @@ -477,19 +477,23 @@ is_finite_gen(A::GrpAbFinGen) = isfinite(snf(A)[1]) ################################################################################ @doc raw""" - rank(A::GrpAbFinGen) -> Int + torsion_free_rank(A::GrpAbFinGen) -> Int -Return the rank of $A$, that is, the dimension of the +Return the torsion free rank of $A$, that is, the dimension of the $\mathbf{Q}$-vectorspace $A \otimes_{\mathbf Z} \mathbf Q$. + +See also [`rank`](@ref). """ -rank(A::GrpAbFinGen) = is_snf(A) ? rank_snf(A) : rank_gen(A) +torsion_free_rank(A::GrpAbFinGen) = is_snf(A) ? torsion_free_rank_snf(A) : torsion_free_rank_gen(A) -rank_snf(A::GrpAbFinGen) = length(findall(x -> iszero(x), A.snf)) +torsion_free_rank_snf(A::GrpAbFinGen) = length(findall(iszero, A.snf)) -rank_gen(A::GrpAbFinGen) = rank(snf(A)[1]) +torsion_free_rank_gen(A::GrpAbFinGen) = torsion_free_rank(snf(A)[1]) +# TODO: document what this does? rank(A::GrpAbFinGen, p::Union{Int, ZZRingElem}) = is_snf(A) ? rank_snf(A, p) : rank_snf(snf(A)[1], p) +# TODO: document what this does? function rank_snf(A::GrpAbFinGen, p::Union{Int, ZZRingElem}) if isempty(A.snf) return 0 @@ -502,6 +506,17 @@ function rank_snf(A::GrpAbFinGen, p::Union{Int, ZZRingElem}) end +@doc raw""" + rank(A::GrpAbFinGen) -> Int + +Return the rank of $A$, that is, the size of a minimal generating set for $A$. + +See also [`torsion_free_rank`](@ref). +""" +rank(A::GrpAbFinGen) = error("rank(::GrpAbFinGen) has been renamed to torsion_free_rank") +#rank(A::GrpAbFinGen) = is_snf(A) ? length(A.snf) : return rank(snf(A)[1]) + + ################################################################################ # # Order diff --git a/test/GrpAb/GrpAbFinGen.jl b/test/GrpAb/GrpAbFinGen.jl index 54cf7022d3..6bc274c49b 100644 --- a/test/GrpAb/GrpAbFinGen.jl +++ b/test/GrpAb/GrpAbFinGen.jl @@ -130,16 +130,20 @@ @testset "Rank" begin G = abelian_group([3, 15]) - @test @inferred rank(G) == 0 + @test @inferred torsion_free_rank(G) == 0 + #@test @inferred rank(G) == 2 G = abelian_group([3, 5]) - @test @inferred rank(G) == 0 + @test @inferred torsion_free_rank(G) == 0 + #@test @inferred rank(G) == 1 G = abelian_group([3, 15, 0]) - @test @inferred rank(G) == 1 + @test @inferred torsion_free_rank(G) == 1 + #@test @inferred rank(G) == 3 G = abelian_group([3, 5, 0]) - @test @inferred rank(G) == 1 + @test @inferred torsion_free_rank(G) == 1 + #@test @inferred rank(G) == 2 end @testset "Order" begin