From 5781ff5266934eb2821e4abb568e58e17964d242 Mon Sep 17 00:00:00 2001 From: Remi Prebet Date: Mon, 16 Sep 2024 13:37:17 +0200 Subject: [PATCH] Handle zero ideal cases --- src/algorithms/groebner-bases.jl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/algorithms/groebner-bases.jl b/src/algorithms/groebner-bases.jl index a9e2eb3..78e4b3b 100644 --- a/src/algorithms/groebner-bases.jl +++ b/src/algorithms/groebner-bases.jl @@ -150,12 +150,13 @@ function _core_groebner_basis( ) F = I.gens - R = first(F).parent - if F == repeat([R(0)], length(F)) - I.gb[eliminate] = F - return F + if iszero(F) + I.gb[eliminate] = QQMPolyRingElem[] + return I.gb[eliminate] end + + R = first(F).parent nr_vars = nvars(R) nr_gens = length(F) field_char = Int(characteristic(R)) @@ -214,7 +215,7 @@ function _core_groebner_basis( # coefficient handling depending on field characteristic if field_char == 0 ptr = reinterpret(Ptr{BigInt}, gb_cf[]) - jl_cf = [QQFieldElem(unsafe_load(ptr, i)) for i in 1:nr_terms] + jl_cf = QQFieldElem[QQFieldElem(unsafe_load(ptr, i)) for i in 1:nr_terms] else ptr = reinterpret(Ptr{Int32}, gb_cf[]) jl_cf = Base.unsafe_wrap(Array, ptr, nr_terms)