diff --git a/src/Rings/groebner.jl b/src/Rings/groebner.jl index 24a42d84248c..77c4a3a3677a 100644 --- a/src/Rings/groebner.jl +++ b/src/Rings/groebner.jl @@ -158,57 +158,61 @@ function standard_basis(I::MPolyIdeal; ordering::MonomialOrdering = default_orde return I.gb[ordering] end if algorithm == :default && is_f4_applicable(I, ordering) - groebner_basis_f4(I, complete_reduction=true) + # since msolve v0.7.0 is most of the time more efficient + # to compute a reduced GB by default + groebner_basis_f4(I, complete_reduction=true) else - if algorithm == :default - algorithm = :buchberger + if algorithm == :default + algorithm = :buchberger + end + if algorithm == :buchberger + if !haskey(I.gb, ordering) + I.gb[ordering] = _compute_standard_basis(I.gens, ordering, complete_reduction) + elseif complete_reduction == true + I.gb[ordering] = _compute_standard_basis(I.gb[ordering], ordering, complete_reduction) end - if algorithm == :buchberger - if !haskey(I.gb, ordering) - I.gb[ordering] = _compute_standard_basis(I.gens, ordering, complete_reduction) - elseif complete_reduction == true - I.gb[ordering] = _compute_standard_basis(I.gb[ordering], ordering, complete_reduction) - end - elseif algorithm == :fglm - _compute_groebner_basis_using_fglm(I, ordering) - elseif algorithm == :hc - standard_basis_highest_corner(I, ordering=ordering) - elseif algorithm == :hilbert - weights = _find_weights(gens(I)) - if !any(iszero, weights) - J, target_ordering, hn = I, ordering, nothing - else - R = base_ring(I) - K = iszero(characteristic(R)) && !haskey(I.gb, degrevlex(R)) ? _mod_rand_prime(I) : I - S = base_ring(K) - gb = groebner_assure(K, degrevlex(S)) - # 2024-02-09 Next lines "blindly" updated to use new homogenization UI - H = homogenizer(S, "w") - K_hom = H(K) - gb_hom = IdealGens(H.(gens(gb))) - gb_hom.isGB = true - K_hom.gb[degrevlex(S)] = gb_hom - singular_assure(K_hom.gb[degrevlex(S)]) - hn = hilbert_series(quo(base_ring(K_hom), K_hom)[1])[1] - H2 = homogenizer(R, "w") - J = H2(I) - weights = ones(Int, ngens(base_ring(J))) - target_ordering = _extend_mon_order(ordering, base_ring(J)) - end - GB = groebner_basis_hilbert_driven(J, destination_ordering=target_ordering, - complete_reduction=complete_reduction, - weights=weights, - hilbert_numerator=hn) - if base_ring(I) == base_ring(J) - I.gb[ordering] = GB - else - DH2 = dehomogenizer(H2) - GB_dehom_gens = DH2.(gens(GB)) - I.gb[ordering] = IdealGens(GB_dehom_gens, ordering, isGB = true) - end - elseif algorithm == :f4 - groebner_basis_f4(I, complete_reduction=true) + elseif algorithm == :fglm + _compute_groebner_basis_using_fglm(I, ordering) + elseif algorithm == :hc + standard_basis_highest_corner(I, ordering=ordering) + elseif algorithm == :hilbert + weights = _find_weights(gens(I)) + if !any(iszero, weights) + J, target_ordering, hn = I, ordering, nothing + else + R = base_ring(I) + K = iszero(characteristic(R)) && !haskey(I.gb, degrevlex(R)) ? _mod_rand_prime(I) : I + S = base_ring(K) + gb = groebner_assure(K, degrevlex(S)) + # 2024-02-09 Next lines "blindly" updated to use new homogenization UI + H = homogenizer(S, "w") + K_hom = H(K) + gb_hom = IdealGens(H.(gens(gb))) + gb_hom.isGB = true + K_hom.gb[degrevlex(S)] = gb_hom + singular_assure(K_hom.gb[degrevlex(S)]) + hn = hilbert_series(quo(base_ring(K_hom), K_hom)[1])[1] + H2 = homogenizer(R, "w") + J = H2(I) + weights = ones(Int, ngens(base_ring(J))) + target_ordering = _extend_mon_order(ordering, base_ring(J)) + end + GB = groebner_basis_hilbert_driven(J, destination_ordering=target_ordering, + complete_reduction=complete_reduction, + weights=weights, + hilbert_numerator=hn) + if base_ring(I) == base_ring(J) + I.gb[ordering] = GB + else + DH2 = dehomogenizer(H2) + GB_dehom_gens = DH2.(gens(GB)) + I.gb[ordering] = IdealGens(GB_dehom_gens, ordering, isGB = true) end + elseif algorithm == :f4 + # since msolve v0.7.0 is most of the time more efficient + # to compute a reduced GB by default + groebner_basis_f4(I, complete_reduction=true) + end end return I.gb[ordering] end