Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions src/Combinatorics/SimplicialComplexes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,10 @@ julia> h_vector(torus())
h_vector(K::SimplicialComplex) = Vector{Int}(pm_object(K).H_VECTOR)

@doc raw"""
betti_numbers(K::SimplicialComplex)
betti_numbers([p::Int=0,] K::SimplicialComplex)

Return the reduced rational Betti numbers of the abstract simplicial complex `K`.
Return the reduced Betti numbers of the abstract simplicial complex `K`.
Defaults to rational Betti numbers, otherwise computes the Betti numbers over a field of characteristic `p`.
Comment thread
antonydellavecchia marked this conversation as resolved.
Outdated

# Examples
```jldoctest
Expand All @@ -194,10 +195,31 @@ julia> betti_numbers(klein_bottle())
0
1
0

julia> betti_numbers(2, klein_bottle())
3-element Vector{Int64}:
0
2
1
```
"""
betti_numbers(K::SimplicialComplex) = Vector{Int}(Polymake.topaz.betti_numbers(pm_object(K)))

function betti_numbers(p::Int, K::SimplicialComplex)
iszero(p) && return betti_numbers(K)
b = Int[]
L = fpField(UInt(p))
boundary_m = matrix(L, Polymake.topaz.boundary_matrix(Oscar.pm_object(K), 0))
for k = 1:dim(K) + 1
ker_dim = rank(kernel(boundary_m; side=:left))
boundary_m = matrix(L, Polymake.topaz.boundary_matrix(Oscar.pm_object(K), k))
im_dim = rank(boundary_m)
Comment thread
antonydellavecchia marked this conversation as resolved.
Outdated

push!(b, ker_dim - im_dim)
end
return b
end

@doc raw"""
euler_characteristic(K::SimplicialComplex)

Expand Down
1 change: 1 addition & 0 deletions test/Combinatorics/SimplicialComplexes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@test f_vector(sphere) == [4, 6, 4]
@test h_vector(sphere) == [1, 1, 1, 1]
@test betti_numbers(sphere) == [0, 0, 1]
@test betti_numbers(2, real_projective_plane()) == [0, 1, 1]
@test euler_characteristic(sphere) == 1
@test minimal_nonfaces(sphere) == [Set{Int}([1, 2, 3, 4])]
R, _ = polynomial_ring(ZZ, [:a, :x, :i_7, :n])
Expand Down
Loading