Skip to content

Commit

Permalink
Rename rank(A::GrpAbFinGen) to torsion_free_rank (#1224)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fingolfin authored Feb 29, 2024
1 parent a116eb9 commit 80bb0ee
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/src/abelian/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ nrels(G::FinGenAbGroup)
rels(A::FinGenAbGroup)
is_finite(A::FinGenAbGroup)
is_infinite(A::FinGenAbGroup)
rank(A::FinGenAbGroup)
torsion_free_rank(A::FinGenAbGroup)
order(A::FinGenAbGroup)
exponent(A::FinGenAbGroup)
is_trivial(A::FinGenAbGroup)
Expand Down
38 changes: 28 additions & 10 deletions src/GrpAb/GrpAbFinGen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -533,20 +533,27 @@ is_finite_gen(A::FinGenAbGroup) = isfinite(snf(A)[1])
################################################################################

@doc raw"""
rank(A::FinGenAbGroup) -> Int
torsion_free_rank(A::FinGenAbGroup) -> 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$.
"""
rank(A::FinGenAbGroup) = is_snf(A) ? rank_snf(A) : rank_gen(A)

rank_snf(A::FinGenAbGroup) = length(findall(x -> iszero(x), A.snf))

rank_gen(A::FinGenAbGroup) = rank(snf(A)[1])
rank(A::FinGenAbGroup, p::Union{Int, ZZRingElem}) = is_snf(A) ? rank_snf(A, p) : rank_snf(snf(A)[1], p)
See also [`rank`](@ref).
"""
function torsion_free_rank(A::FinGenAbGroup)
if !is_snf(A)
A = snf(A)[1]
end
return length(findall(iszero, A.snf))
end

function rank_snf(A::FinGenAbGroup, p::Union{Int, ZZRingElem})
# return the p-rank of A, which is the dimension of the elementary abelian
# group A/pA, or in other words, the rank (=size of minimal generating set) of
# the maximal p-quotient of A
function rank(A::FinGenAbGroup, p::Union{Int, ZZRingElem})
if !is_snf(A)
A = snf(A)[1]
end
if isempty(A.snf)
return 0
end
Expand All @@ -558,6 +565,17 @@ function rank_snf(A::FinGenAbGroup, p::Union{Int, ZZRingElem})
end


@doc raw"""
rank(A::FinGenAbGroup) -> 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::FinGenAbGroup) = error("rank(::FinGenAbGroup) has been renamed to torsion_free_rank")
#rank(A::FinGenAbGroup) = is_snf(A) ? length(A.snf) : return rank(snf(A)[1])


################################################################################
#
# Order
Expand Down
1 change: 1 addition & 0 deletions src/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ export tensor_product
export theta
export tidy_model
export torsion_bound
export torsion_free_rank
export torsion_points
export torsion_points_division_poly
export torsion_points_lutz_nagell
Expand Down
12 changes: 8 additions & 4 deletions test/GrpAb/GrpAbFinGen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 80bb0ee

Please sign in to comment.