Skip to content

Commit

Permalink
fix hilbert_series_data for 0 entries (#803)
Browse files Browse the repository at this point in the history
  • Loading branch information
hannes14 committed Apr 30, 2024
1 parent 3aeaa66 commit f9aa64c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/ideal/ideal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,12 @@ The coefficients are of type `BigInt`.
function hilbert_series_data(I::sideal{spoly{T}}) where T <: Nemo.FieldElem
Qt,(t,) = polynomial_ring(ZZ, ["t"])
h = hilbert_series(I,Qt)
v = [convert(BigInt,c) for c in coefficients(h)]
d=total_degree(h)+1
v = zeros(BigInt, d)
for (c,m) in zip(coefficients(h), monomials(h))
e = leading_exponent_vector(m)[1]
v[d-e] = convert(BigInt,c)
end
return v
end

Expand All @@ -1511,7 +1516,11 @@ The coefficients are of type `BigInt`.
function hilbert_series_data(I::sideal{spoly{T}}, w::Vector{<:Integer}) where T <: Nemo.FieldElem
Qt,(t,) = polynomial_ring(ZZ, ["t"])
h = hilbert_series(I,w,Qt)
v = [convert(BigInt,c) for c in coefficients(h)]
v = zeros(BigInt, total_degree(h)+1)
for (c,m) in zip(coefficients(h), monomials(h))
e = leading_exponent_vector(m)[1]
v[e+1] = convert(BigInt,c)
end
return v
end

Expand Down
4 changes: 4 additions & 0 deletions test/ideal/sideal-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,10 @@ end
I=Ideal(R,[x,y,z])
I=std(I)
@test hilbert_series(I,Qt) == -t^3+3*t^2-3*t+1
@test hilbert_series_data(I) == BigInt[-1,3,-3,1]
I=Ideal(R,[x^3])
I=std(I)
@test hilbert_series_data(I) == BigInt[-1,0,0,1]
A,x = polynomial_ring(QQ,["x$i" for i in 1:37])
I = Ideal(A,[2*x[11] - 2*x[17] - 2*x[24] + 2*x[32] - 111916*x[37], 2*x[4] - 2*x[8] - 2*x[26] + 2*x[34] - 41216*x[37], 2*x[2] - 2*x[9] - 2*x[20] + 2*x[35] + 37974*x[37], x[28] - x[36], x[21] - x[36], x[27] - x[28] + x[33] + x[36], x[26] - x[27] - x[33] + x[34], x[20] - x[21] + x[35] + x[36], x[15] - x[21] - x[28] + x[36], x[10] - x[36], x[25] - x[28] + x[31] + x[36], x[24] - x[25] - x[26] + x[27] - x[31] + x[32] + x[33] - x[34], -x[14] + x[15] + x[18] - x[21] + x[25] - x[28] + x[31] + x[36], x[13] - x[14] + x[18] - x[19] - 2*x[20] + 2*x[21] - x[26] + x[27] + x[33] - x[34] - 2*x[35] - 2*x[36], x[9] - x[10] + x[35] + x[36], x[6] - x[10] - x[28] + x[36], x[19] - x[21] + x[30] + x[36], -x[18] + x[19] + x[23] - x[25] - x[27] + x[28] + x[30] - x[31] - x[33] - x[36], x[17] - x[19] - x[30] + x[32], x[12] - x[14] - x[17] + x[18] - x[27] + x[28] + x[31] - x[32] - x[33] - x[36], x[8] - x[10] + x[34] + x[36], x[5] - x[6] - x[8] + x[10] - x[27] + x[28] - x[34] - x[36], x[3] - x[10] - x[21] + x[36], -x[18] + x[19] + x[20] - x[21] + x[29] + x[30] + x[35] + x[36], x[22] + x[23] + x[24] - x[25] - x[29] - x[30] - x[31] + x[32], x[16] + x[17] + x[18] - x[19] - x[22] - x[23] - x[24] + x[25], x[11] + x[12] + x[13] - x[14] - x[16] - x[17] - x[18] + x[19] + x[22] + x[23] + x[24] - x[25] + x[29] + x[30] + x[31] - x[32], x[7] + x[8] + x[9] - x[10] - x[33] + x[34] + x[35] + x[36], x[4] + x[5] + x[9] - x[10] + x[26] - x[27] + x[35] + x[36], x[2] + x[3] + x[9] - x[10] + x[20] - x[21] + x[35] + x[36], x[1] - x[3] - x[6] + x[10] - x[15] + x[21] + x[28] - x[36], -x[27]*x[36] + x[34]*x[35], -x[25]*x[36] + x[32]*x[35], x[14]*x[36] + x[19]*x[35] + x[25]*x[36] + x[27]*x[36] - x[32]*x[35] - x[34]*x[35], -x[19]*x[36] - x[25]*x[36] + x[32]*x[34] + x[32]*x[35], -x[19]*x[35] - x[19]*x[36] + x[25]*x[34] - x[25]*x[36] + x[32]*x[34] + x[32]*x[35], x[14]*x[36] - x[19]*x[35] + x[25]*x[34] + x[27]*x[32], x[14]*x[35] - x[14]*x[36] + x[19]*x[35] - x[19]*x[36] + x[25]*x[27] - x[25]*x[34] - x[27]*x[32] + x[32]*x[34], x[14]*x[34] + x[19]*x[27] - 2*x[19]*x[35] + 2*x[25]*x[34] - x[25]*x[36] + x[32]*x[35], x[14]*x[32] - 2*x[14]*x[36] + x[19]*x[25] - 2*x[19]*x[35] - x[27]*x[36] + x[34]*x[35]])
I=std(I)
Expand Down

0 comments on commit f9aa64c

Please sign in to comment.