diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index 7c4731868..e193df564 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -713,10 +713,12 @@ void singular_define_ideals(jlcxx::Module & Singular) Singular.method("scHilb", [](ideal I, ring r, jlcxx::ArrayRef a) { const ring origin = currRing; rChangeCurrRing(r); - intvec * v = hFirstSeries(I, NULL, r->qideal); - int * content = v->ivGetVec(); + bigintmat * v = hFirstSeries0b(I, r->qideal, NULL,NULL, r,coeffs_BIGINT); for (int j = 0; j < v->length(); j++) - a.push_back(content[j]); + { + number n=(*v)[j]; + a.push_back(n_Int(n,coeffs_BIGINT)); + } delete v; rChangeCurrRing(origin); }); @@ -725,12 +727,12 @@ void singular_define_ideals(jlcxx::Module & Singular) intvec * w = to_intvec(weights); const ring origin = currRing; rChangeCurrRing(r); - intvec * v = hFirstSeries(I, NULL, r->qideal, w); + bigintmat * v = hFirstSeries0b(I, r->qideal, w, NULL,r,coeffs_BIGINT); delete w; - int * content = v->ivGetVec(); for (int j = 0; j < v->length(); j++) { - a.push_back(content[j]); + number n=(*v)[j]; + a.push_back(n_Int(n,coeffs_BIGINT)); } delete v; rChangeCurrRing(origin); @@ -742,13 +744,13 @@ void singular_define_ideals(jlcxx::Module & Singular) intvec * sh = to_intvec(shifts); const ring origin = currRing; rChangeCurrRing(r); - intvec * v = hFirstSeries(I, sh, r->qideal, w); + bigintmat * v = hFirstSeries0b(I, r->qideal, w, sh,r,coeffs_BIGINT); delete sh; delete w; - int * content = v->ivGetVec(); for (int j = 0; j < v->length(); j++) { - a.push_back(content[j]); + number n=(*v)[j]; + a.push_back(n_Int(n,coeffs_BIGINT)); } delete v; rChangeCurrRing(origin); diff --git a/src/ideal/ideal.jl b/src/ideal/ideal.jl index 267d5c64e..79566807f 100644 --- a/src/ideal/ideal.jl +++ b/src/ideal/ideal.jl @@ -5,7 +5,8 @@ export sideal, IdealSet, syz, lead, normalize!, is_constant, is_zerodim, fglm, intersection, homogenize_ideal, homogenize_ideal_with_weights, quotient, reduce, eliminate, kernel, equal, contains, is_var_generated, saturation, saturation2, satstd, slimgb, std, vdim, interreduce, degree, mult, - hilbert_series, std_hilbert, is_homogeneous, division, divrem, divrem2, mstd + hilbert_series, hilbert_series_data, std_hilbert, is_homogeneous, division, + divrem, divrem2, mstd ############################################################################### # @@ -1451,7 +1452,7 @@ function hilbert_series(I::sideal{spoly{T}}, Qt::PolyRing) where T <: Nemo.Field end @doc raw""" - hilbert_series(I::sideal{spoly{T}}, w::Vector{<:Integer}) where T <: Nemo.FieldElem + hilbert_series(I::sideal{spoly{T}}, w::Vector{<:Integer}, Qt::PolyRing) where T <: Nemo.FieldElem Return the polynomial $Q(t)$ of Qt where $\frac{Q(t)}{\prod_i (1-t^{w_i})}$ is the Hilbert-Poincare series of $I$ for weights $\{w_i\}$. Each weight must be @@ -1468,6 +1469,37 @@ function hilbert_series(I::sideal{spoly{T}}, w::Vector{<:Integer}, Qt::PolyRing) return Qt(new_ptr) end +@doc raw""" + hilbert_series_data(I::sideal{spoly{T}}) where T <: Nemo.FieldElem + +Return the coeffcients of polynomial $Q(t)$ where $\frac{Q(t)}{\prod_i (1-t)}$ +is the Hilbert-Poincare series of $I$ for weights 1. +The generators of $I$ must be given as a Groebner basis. +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)] + return v +end + +@doc raw""" + hilbert_series_data(I::sideal{spoly{T}}, w::Vector{<:Integer}) where T <: Nemo.FieldElem + +Return the coeffcients of polynomial $Q(t)$ where $\frac{Q(t)}{\prod_i (1-t^{w_i})}$ +is the Hilbert-Poincare series of $I$ for weights $\{w_i\}$. Each weight must be +positive $w_i > 0$. +The generators of $I$ must be given as a Groebner basis. +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)] + return v +end + @doc raw""" std_hilbert(I::sideal{spoly{T}}, hs::Vector{Int32}; complete_reduction::Bool=false) where T <: Nemo.FieldElem diff --git a/test/ideal/sideal-test.jl b/test/ideal/sideal-test.jl index 5f62ca1ba..cbe962eb4 100644 --- a/test/ideal/sideal-test.jl +++ b/test/ideal/sideal-test.jl @@ -696,6 +696,14 @@ end I=Ideal(R,[x,y,z]) I=std(I) @test hilbert_series(I,Qt) == -t^3+3*t^2-3*t+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) + @test hilbert_series(I,Qt)==-t^37 + 31*t^36 - 456*t^35 + 4200*t^34 - 26775*t^33 + 121737*t^32 - 376992*t^31 + 556512*t^30 + 1739100*t^29 - 16811300*t^28 + 75314624*t^27 - 246484224*t^26 + 650872404*t^25 - 1444243500*t^24 + 2750940000*t^23 - 4555556640*t^22 + 6611884290*t^21 - 8454204990*t^20 + 9552774000*t^19 - 9552774000*t^18 + 8454204990*t^17 - 6611884290*t^16 + 4555556640*t^15 - 2750940000*t^14 + 1444243500*t^13 - 650872404*t^12 + 246484224*t^11 - 75314624*t^10 + 16811300*t^9 - 1739100*t^8 - 556512*t^7 + 376992*t^6 - 121737*t^5 + 26775*t^4 - 4200*t^3 + 456*t^2 - 31*t + 1 + v=hilbert_series_data(I) + @test v[1] == -1 + @test v[1] isa BigInt + @test length(v) == total_degree(hilbert_series(I,Qt))+1 end @testset "sideal.oscar#1702" begin