Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelDavidMohr committed Oct 10, 2024
2 parents 23e6687 + 007ab3b commit d0f1687
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "AlgebraicSolving"
uuid = "66b61cbe-0446-4d5d-9090-1ff510639f9d"
authors = ["ederc <[email protected]>", "Mohab Safey El Din <[email protected]", "Rafael Mohr <[email protected]>"]
version = "0.7.1"
version = "0.7.2"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
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 d0f1687

Please sign in to comment.