Open piever opened 5 years ago
I tried to design this packages to be agnostic to a coefficient types. Mainly, simplicies and chains can have any coefficient types which support: zero
,one
, +
, -
, *
. I'll try to cook up an example with GaloisFields.jl.
So after some hacking I got the following:
julia> using ComputationalHomology
julia> cplx = SimplicialComplex(Simplex(1,2,3)) SimplicialComplex((3, 3, 1))
julia> cells(cplx, 0) # all 0-simplexes 3-element Array{Simplex{Int64},1}: "σ1[2]" "σ2[3]" "σ3[1]"
julia> cplx[2,1] # second 1-simplex in the complex "σ2[2, 1]"
- Define PID
```julia
julia> using GaloisFields
julia> F = @GaloisField 29
𝔽₂₉
julia> boundary(cplx, 2, 1, F) # calculated with coefs from 𝔽₂₉
1[3] + 28[1]
julia> boundary(cplx, 2, 1, Int) 1[3] + -1[1]
Calculation of homology group is a bit tricky. I hacked some additional functions in order to Smith decomposition to work
```julia
# a quotient function needed, for Smith decomposition (division does not work well with integers)
Base.div(a::F, b::F) where F <: GaloisFields.AbstractGaloisField = a/b
# comparison
Base.isless(a::F, b::F) where F <: GaloisFields.AbstractGaloisField = a.n < b.n
# and maxumum type value
Base.typemax(::Type{F}) where F <: GaloisFields.AbstractGaloisField = char(F)-1
after that
julia> h = homology(cplx, F)
Homology(𝔽₂₉)[SimplicialComplex((3, 3, 1))]
julia> group(h,0)[1] # β₀
1
Thanks for this nice package! I wanted to ask whether there are plans to support coefficients in a finite field (using for example https://github.com/tkluck/GaloisFields.jl). Otherwise it would be helpful to know what interface a number type needs to respect for things to just work.