Skip to content

Commit 0a5027c

Browse files
committed
Set up partition table for Hilbert algorithm w/ at least 1 variable
Even when our ring doesn't have any variables, we still represent the monomial 1 using a dummy variable raised to the 0th power. Previously, when calling "poincaire ideal 1_R" when R had no variables, we segfaulted in partition_table::partition() when calling "reset(I->topvar() + 1)", since "I->topvar()" returned 0 (for the dummy variable) and reset tries writing in the "dad" and "occurs" arrays, but they were initialized as length 0. To fix this, we initialize these arrays to have length 1 even when the ring has no variables.
1 parent 0fc397b commit 0a5027c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

M2/Macaulay2/e/hilb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ hilb_comp::hilb_comp(const PolynomialRing *RR, const Matrix *m)
350350
this_comp(0),
351351
n_components(m->n_rows()),
352352
current(nullptr),
353-
part_table(S->n_vars(), mi_stash)
353+
part_table(std::max(1, S->n_vars()), mi_stash)
354354
{
355355
assert(D == R->getMonoid());
356356
one = R->getCoefficientRing()->from_long(1);

M2/Macaulay2/tests/normal/hilbert.m2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,7 @@ assert(truncateSeries(5, {1,1}, Divide{1_R,Product{Power{1-x,1}}}) == x^4+x^3+x^
8282
assert(truncateSeries(5, {1,1}, Divide{1_R,Product{Power{1+x,1}}}) == x^4-x^3+x^2-x+1)
8383
assert(truncateSeries(5, {1,1}, Divide{1_R,Product{Power{1+x,1},Power{1-x,1}}}) == x^4+x^2+1)
8484
assert(truncateSeries(3, {1,1}, Divide{1_R,Product{Power{1+x,1},Power{1-y,1}}}) == x^2-x*y+y^2-x+y+1)
85+
86+
-- used to crash M2 (#4100)
87+
R = QQ[]
88+
assert(zero poincare ideal 1_R)

0 commit comments

Comments
 (0)