Skip to content

Commit fa0a51a

Browse files
authored
Merge pull request #86 from RafaelDavidMohr/rm/dimension-fix
Fix `dimension`
2 parents f31ae89 + abd16ec commit fa0a51a

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/algorithms/dimension.jl

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,16 @@ julia> dimension(I)
1919
"""
2020
function dimension(I::Ideal{T}) where T <: MPolyRingElem
2121

22-
gb = isempty(values(I.gb)) ? groebner_basis(I) : first(values(I.gb))
22+
gb = get(I.gb, 0, groebner_basis(I, complete_reduction = true))
2323
R = parent(first(gb))
2424
res = [trues(ngens(R))]
2525

26-
lms = (Nemo.leading_monomial).(gb)
27-
for lm in lms
26+
lead_exps = (_drl_lead_exp).(gb)
27+
for lexp in lead_exps
2828
to_del = Int[]
2929
new_miss = BitVector[]
3030
for (i, mis) in enumerate(res)
31-
nz_exps_inds = findall(e -> !iszero(e),
32-
first(Nemo.exponent_vectors(lm)))
31+
nz_exps_inds = findall(e -> !iszero(e), lexp)
3332
ind_var_inds = findall(mis)
3433
if issubset(nz_exps_inds, ind_var_inds)
3534
for j in nz_exps_inds
@@ -48,3 +47,13 @@ function dimension(I::Ideal{T}) where T <: MPolyRingElem
4847
max_length = maximum(mis -> length(findall(mis)), res)
4948
return max_length
5049
end
50+
51+
function _drl_exp_vector(u::Vector{Int})
52+
return [sum(u), -reverse(u)...]
53+
end
54+
55+
function _drl_lead_exp(p::MPolyRingElem)
56+
exps = collect(Nemo.exponent_vectors(p))
57+
_, i = findmax((u -> _drl_exp_vector(u)).(exps))
58+
return exps[i]
59+
end

test/algorithms/dimension.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55

66
R, (x,y,z) = polynomial_ring(GF(101),["x","y","z"])
77
I = Ideal([x+2*y+2*z-1, x^2+2*y^2+2*z^2-x, 2*x*y+2*y*z-y])
8-
@test isone(dimension(I))
8+
@test iszero(dimension(I))
99
end

0 commit comments

Comments
 (0)