Skip to content

Commit

Permalink
Merge pull request algebraic-solving#86 from RafaelDavidMohr/rm/dimen…
Browse files Browse the repository at this point in the history
…sion-fix

Fix `dimension`
  • Loading branch information
ederc authored Oct 10, 2024
2 parents f31ae89 + abd16ec commit fa0a51a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
19 changes: 14 additions & 5 deletions src/algorithms/dimension.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion test/algorithms/dimension.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fa0a51a

Please sign in to comment.