Skip to content

Commit f1d8f72

Browse files
committed
adjusts converted input if Oscar input generators contain zero elements
1 parent a8a4e59 commit f1d8f72

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/algorithms/groebner-bases.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ function _core_groebner_basis(
147147
error("At the moment we only supports finite fields.")
148148
end
149149

150-
lens, cfs, exps = _convert_to_msolve(F)
150+
# nr_gens might change if F contains zero polynomials
151+
lens, cfs, exps, nr_gens = _convert_to_msolve(F)
151152

152153
gb_ld = Ref(Cint(0))
153154
gb_len = Ref(Ptr{Cint}(0))

src/interfaces/nemo.jl

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ function _convert_to_msolve(
2121
if field_char > 2^31 || degree(base_ring(R)) != 1
2222
error("At the moment we only support prime fields up to prime characteristic < 2^31.")
2323
end
24+
25+
lens = Int32[]
2426
# get coefficients
2527
if field_char == 0
2628
cfs = BigInt[]
@@ -29,15 +31,21 @@ function _convert_to_msolve(
2931
end
3032
if field_char == 0
3133
for i in 1:nr_gens
32-
for cf in coefficients(F[i])
33-
push!(cfs, BigInt(numerator(cf)))
34-
push!(cfs, BigInt(denominator(cf)))
34+
if F[i] != R(0)
35+
for cf in coefficients(F[i])
36+
push!(cfs, BigInt(numerator(cf)))
37+
push!(cfs, BigInt(denominator(cf)))
38+
end
39+
push!(lens, length(F[i]))
3540
end
3641
end
3742
else
3843
for i in 1:nr_gens
39-
for cf in coefficients(F[i])
40-
push!(cfs, Int32(lift(Nemo.ZZ, cf)))
44+
if F[i] != R(0)
45+
for cf in coefficients(F[i])
46+
push!(cfs, Int32(lift(Nemo.ZZ, cf)))
47+
end
48+
push!(lens, length(F[i]))
4149
end
4250
end
4351
end
@@ -50,7 +58,7 @@ function _convert_to_msolve(
5058
end
5159
end
5260

53-
return lens, cfs, exps
61+
return lens, cfs, exps, length(lens)
5462
end
5563

5664
@doc Markdown.doc"""

0 commit comments

Comments
 (0)