Skip to content

Commit

Permalink
enable dimension over rings (ZZ)
Browse files Browse the repository at this point in the history
  • Loading branch information
tthsqe12 authored and fingolfin committed Jun 17, 2021
1 parent 0c729e0 commit 3173b1c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Nemo = "0.23.0"
RandomExtensions = "0.4.2"
Singular_jll = "~402.000.102"
julia = "1.3"
libsingular_julia_jll = "~0.12.0"
libsingular_julia_jll = "~0.13.0"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
9 changes: 5 additions & 4 deletions src/ideal/ideal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,18 @@ $R/I$ is zero, where $R$ is the polynomial ring over which $I$ is an ideal..
iszerodim(I::sideal) = Bool(libSingular.id_IsZeroDim(I.ptr, base_ring(I).ptr))

@doc Markdown.doc"""
dimension(I::sideal{S}) where S <: Union{spoly{T}, spoly{n_unknown{U}}} where {T <: Singular.FieldElem, U <: Nemo.FieldElem}
dimension(I::sideal{S}) where S <: Union{spoly{T}, spoly{n_unknown{U}}} where {T <: Singular.RingElem, U <: Nemo.RingElem}
Given an ideal $I$ this function computes the Krull dimension
of the ring $R/I$, where $R$ is the polynomial ring over
which $I$ is an ideal. The ideal must be over a polynomial ring
over a field, and a Groebner basis.
and a Groebner basis.
"""
function dimension(I::sideal{S}) where S <: Union{spoly{T}, spoly{n_unknown{U}}} where {T <: Singular.FieldElem, U <: Nemo.FieldElem}
function dimension(I::sideal{S}) where S <: Union{spoly{T}, spoly{n_unknown{U}}} where {T <: Singular.RingElem, U <: Nemo.RingElem}
I.isGB == false && error("I needs to be a Gröbner basis.")
R = base_ring(I)
GC.@preserve I R return Int(libSingular.scDimInt(I.ptr, R.ptr))
# scDimIntRing does both fields and non-fields
GC.@preserve I R return Int(libSingular.scDimIntRing(I.ptr, R.ptr))
end

@doc Markdown.doc"""
Expand Down
9 changes: 9 additions & 0 deletions test/ideal/sideal-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ end
@test isvar_generated(Ideal(R, x, y))
@test !isvar_generated(Ideal(R, R(1)))
@test !isvar_generated(Ideal(R, x + y))

R, (x, y) = PolynomialRing(ZZ, ["x", "y"])
@test -1 == dimension(std(Ideal(R, R(-1))))
@test -1 == dimension(std(Ideal(R, x, R(1))))
@test 0 == dimension(std(Ideal(R, x, y, R(3))))
@test 1 == dimension(std(Ideal(R, x, R(3))))
@test 1 == dimension(std(Ideal(R, x - y, R(2))))
@test 2 == dimension(std(Ideal(R, R(5))))
@test 2 == dimension(std(Ideal(R, R(35))))
end

@testset "sideal.binary_ops" begin
Expand Down

0 comments on commit 3173b1c

Please sign in to comment.