Skip to content

Commit 033f241

Browse files
authored
Merge pull request #35 from ederc/zero-input
Zero input handling
2 parents a6c7a99 + b125ace commit 033f241

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

src/algorithms/groebner-bases.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ function _core_groebner_basis(
131131

132132
F = I.gens
133133
R = first(F).parent
134+
if F == [R(0)]
135+
return F
136+
end
134137
nr_vars = nvars(R)
135138
nr_gens = length(F)
136139
field_char = Int(characteristic(R))

src/algorithms/normal-forms.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,18 @@ function _core_normal_form(
121121

122122
#= first get a degree reverse lexicographical Gröbner basis for I =#
123123
if !haskey(I.gb, 0)
124-
groebner_basis(I, eliminate = 0, la_option = 44, info_level = info_level)
124+
if field_char > 2^17
125+
groebner_basis(I, eliminate = 0, la_option = 44, info_level = info_level)
126+
else
127+
groebner_basis(I, eliminate = 0, la_option = 2, info_level = info_level)
128+
end
125129
end
126130
G = I.gb[0]
127131

132+
if G == [R(0)]
133+
return F
134+
end
135+
128136
tbr_nr_gens = length(F)
129137
bs_nr_gens = length(G)
130138
is_gb = 1

test/algorithms/groebner-bases.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
L = eliminate(I,2)
2626
@test L == H
2727
@test I.gb[2] == H
28+
29+
I = Ideal([R(0)])
30+
G = groebner_basis(I)
31+
@test G == [R(0)]
2832
end
2933

3034
@testset "Algorithms -> Sig Gröbner bases" begin

test/algorithms/normal-forms.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@
1313
I = Ideal([y*x+17-y, x+13*y])
1414
F = [x+13*y, x*y+16]
1515
@test normal_form(F, I) == [0, y + 65520]
16+
I = Ideal([R(0)])
17+
@test normal_form(F, I) == F
1618
end

0 commit comments

Comments
 (0)