Skip to content

Commit 5bc3cb4

Browse files
committed
some optimizations
1 parent 1b539c5 commit 5bc3cb4

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/algorithms/dimension.jl

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,27 @@ function dimension(I::Ideal{T}) where T <: MPolyRingElem
2222
gb = get(I.gb, 0, groebner_basis(I, complete_reduction = true))
2323
R = parent(first(gb))
2424

25-
res = [trues(ngens(R))]
25+
res = Set([trues(ngens(R))])
2626
lead_exps = (_drl_lead_exp).(gb)
2727
for lexp in lead_exps
28-
to_del = Int[]
29-
new_miss = BitVector[]
30-
nz_exps_inds = findall(!iszero, lexp)
31-
for (i, mis) in enumerate(res)
32-
ind_var_inds = findall(mis)
33-
if issubset(nz_exps_inds, ind_var_inds)
34-
for j in nz_exps_inds
28+
nz_exps = (!iszero).(lexp)
29+
nz_exps_ind = findall(nz_exps)
30+
next_res = Set{BitVector}()
31+
for mis in res
32+
if nz_exps <= mis
33+
@inbounds for j in nz_exps_ind
3534
new_mis = copy(mis)
3635
new_mis[j] = false
37-
push!(new_miss, new_mis)
36+
push!(next_res, new_mis)
3837
end
39-
push!(to_del, i)
38+
else
39+
push!(next_res, mis)
4040
end
4141
end
42-
deleteat!(res, to_del)
43-
append!(res, new_miss)
44-
unique!(res)
42+
res = next_res
4543
end
4644

47-
I.dim = isempty(res) ? -1 : maximum(length findall, res)
45+
I.dim = isempty(res) ? -1 : maximum(sum, res)
4846
return I.dim
4947
end
5048

@@ -56,4 +54,4 @@ function _drl_lead_exp(p::MPolyRingElem)
5654
exps = collect(Nemo.exponent_vectors(p))
5755
_, i = findmax(_drl_exp_vector, exps)
5856
return exps[i]
59-
end
57+
end

0 commit comments

Comments
 (0)