Skip to content

Commit 726de34

Browse files
committed
Fix bug in Gröbner basis caching
1 parent 2171d26 commit 726de34

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/algorithms/groebner-bases.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,12 @@ function groebner_basis(
128128
worker_pool::Union{Nothing,AbstractWorkerPool}=nothing,
129129
info_level::Int=0
130130
)
131-
return get!(I.gb, eliminate) do
131+
key = if intersect && complete_reduction && !normalize && truncate_lifting == 0
132+
eliminate
133+
else
134+
reinterpret(Int64, hash((eliminate, intersect, complete_reduction, normalize, truncate_lifting)) | 0x8000000000000000)
135+
end
136+
return get!(I.gb, key) do
132137
_core_groebner_basis(I, initial_hts = initial_hts, nr_thrds = nr_thrds,
133138
max_nr_pairs = max_nr_pairs, la_option = la_option,
134139
eliminate = eliminate, intersect = intersect,

test/algorithms/groebner-bases.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using Distributed
44
R, (x,y,z) = polynomial_ring(GF(101),["x","y","z"], internal_ordering=:degrevlex)
55
I = Ideal([x+2*y+2*z-1, x^2+2*y^2+2*z^2-x, 2*x*y+2*y*z-y])
66
G = groebner_basis(I)
7-
H = MPolyRingElem[
7+
H = FqMPolyRingElem[
88
x + 2*y + 2*z + 100
99
y*z + 82*z^2 + 10*y + 40*z
1010
y^2 + 60*z^2 + 20*y + 81*z
@@ -14,14 +14,14 @@ using Distributed
1414
@test I.gb[0] == H
1515

1616
G = groebner_basis(I, eliminate=2)
17-
H = MPolyRingElem[
17+
H = FqMPolyRingElem[
1818
z^4 + 38*z^3 + 95*z^2 + 95*z
1919
]
2020
@test G == H
2121

2222
I = Ideal([x+2*y+2*z-1, x^2+2*y^2+2*z^2-x, 2*x*y+2*y*z-y])
2323
G = groebner_basis(I, eliminate=2, intersect=false)
24-
H = MPolyRingElem[
24+
H = FqMPolyRingElem[
2525
z^4 + 38*z^3 + 95*z^2 + 95*z
2626
30*z^3 + 32*z^2 + y + 87*z
2727
41*z^3 + 37*z^2 + x + 30*z + 100
@@ -30,6 +30,9 @@ using Distributed
3030

3131
@test_throws ErrorException eliminate(I,0)
3232
L = eliminate(I,2)
33+
H = FqMPolyRingElem[
34+
z^4 + 38*z^3 + 95*z^2 + 95*z
35+
]
3336
@test L == H
3437
@test I.gb[2] == H
3538

0 commit comments

Comments
 (0)