From abd16ec7d0663f903019e18271b3b6e44eded806 Mon Sep 17 00:00:00 2001 From: Rafael Mohr Date: Thu, 10 Oct 2024 15:04:37 +0200 Subject: [PATCH 1/2] fix dimension --- src/algorithms/dimension.jl | 19 ++++++++++++++----- test/algorithms/dimension.jl | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/algorithms/dimension.jl b/src/algorithms/dimension.jl index 05ff7a4..c104e7f 100644 --- a/src/algorithms/dimension.jl +++ b/src/algorithms/dimension.jl @@ -19,17 +19,16 @@ julia> dimension(I) """ function dimension(I::Ideal{T}) where T <: MPolyRingElem - gb = isempty(values(I.gb)) ? groebner_basis(I) : first(values(I.gb)) + gb = get(I.gb, 0, groebner_basis(I, complete_reduction = true)) R = parent(first(gb)) res = [trues(ngens(R))] - lms = (Nemo.leading_monomial).(gb) - for lm in lms + lead_exps = (_drl_lead_exp).(gb) + for lexp in lead_exps to_del = Int[] new_miss = BitVector[] for (i, mis) in enumerate(res) - nz_exps_inds = findall(e -> !iszero(e), - first(Nemo.exponent_vectors(lm))) + nz_exps_inds = findall(e -> !iszero(e), lexp) ind_var_inds = findall(mis) if issubset(nz_exps_inds, ind_var_inds) for j in nz_exps_inds @@ -48,3 +47,13 @@ function dimension(I::Ideal{T}) where T <: MPolyRingElem max_length = maximum(mis -> length(findall(mis)), res) return max_length end + +function _drl_exp_vector(u::Vector{Int}) + return [sum(u), -reverse(u)...] +end + +function _drl_lead_exp(p::MPolyRingElem) + exps = collect(Nemo.exponent_vectors(p)) + _, i = findmax((u -> _drl_exp_vector(u)).(exps)) + return exps[i] +end diff --git a/test/algorithms/dimension.jl b/test/algorithms/dimension.jl index 265d576..d8cab64 100644 --- a/test/algorithms/dimension.jl +++ b/test/algorithms/dimension.jl @@ -5,5 +5,5 @@ R, (x,y,z) = polynomial_ring(GF(101),["x","y","z"]) I = Ideal([x+2*y+2*z-1, x^2+2*y^2+2*z^2-x, 2*x*y+2*y*z-y]) - @test isone(dimension(I)) + @test iszero(dimension(I)) end From 4d24cf1acb4bdc64edf90df79bf0b25ffcf61fe1 Mon Sep 17 00:00:00 2001 From: ederc Date: Thu, 10 Oct 2024 15:33:24 +0200 Subject: [PATCH 2/2] Update Project.toml v0.7.2 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 1e6976a..9178f6e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "AlgebraicSolving" uuid = "66b61cbe-0446-4d5d-9090-1ff510639f9d" authors = ["ederc ", "Mohab Safey El Din "] -version = "0.7.1" +version = "0.7.2" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"