From b09551a10b33c748aea46048a14387efd37f5d86 Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Tue, 4 Jul 2023 09:57:32 +0200 Subject: [PATCH] Homogenize wrt. weights of ideals (#675) * Homogenize wrt. weights odf ideals * use homogenize_ideal, homogenize_ideal_with_weights --- deps/src/ideals.cpp | 8 ++++++++ src/ideal/ideal.jl | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/deps/src/ideals.cpp b/deps/src/ideals.cpp index 6c65546c6..fc4a52766 100644 --- a/deps/src/ideals.cpp +++ b/deps/src/ideals.cpp @@ -308,6 +308,14 @@ void singular_define_ideals(jlcxx::Module & Singular) Singular.method("rank", [](ideal m) { return (int)m->rank; }); + Singular.method("id_Homogenize", &id_Homogenize); + + Singular.method("id_HomogenizeW", [](ideal a, int v, jlcxx::ArrayRef w, ring r) { + intvec * ww = to_intvec(w); + ideal id = id_HomogenizeW(a, v, ww, r); + return id; + }); + Singular.method("id_Quotient", [](ideal a, ideal b, bool c, ring d) { const ring origin = currRing; rChangeCurrRing(d); diff --git a/src/ideal/ideal.jl b/src/ideal/ideal.jl index 8ab4c4005..6fc9efe99 100644 --- a/src/ideal/ideal.jl +++ b/src/ideal/ideal.jl @@ -1,7 +1,7 @@ export sideal, IdealSet, syz, lead, normalize!, is_constant, is_zerodim, fglm, fres, dimension, highcorner, jet, kbase, minimal_generating_set, independent_sets, maximal_independent_set, mres, ngens, nres, sres, - intersection, + 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, mstd @@ -197,6 +197,46 @@ function homogenize(I::sideal{S}, v::S) where S <: spoly end end +@doc raw""" + homogenize_ideal(I::sideal{S}, v::S) where S <: spoly + +Homogenization of the ideal `I` by homogenization of the generators +of a suitable Groebner Basis of `I` by the variable `v` and +return the corresponding homogeneous ideal. +The variable `v` must have weight `1`. +""" +function homogenize_ideal(I::sideal{S}, v::S) where S <: spoly + R = base_ring(I) + R == parent(v) || error("incompatible parents") + i = var_index(v) + GC.@preserve I v R begin + isone(libSingular.p_WTotaldegree(v.ptr, R.ptr)) || + error("variable must have weight 1") + ptr = libSingular.id_Homogenize(I.ptr, i, R.ptr) + return sideal{S}(R, ptr) + end +end + +@doc raw""" + homogenize_ideal_with_weights(I::sideal{S}, v::S, w::Vector{Int32}) where S <: spoly + +Homogenization of the ideal `I` wrt. weights `w` by homogenization of the +generators of a suitable Groebner Basis of `I` by the variable `v` and +return the corresponding homogeneous ideal. +The variable `v` must have weight `1`. +""" +function homogenize_ideal_with_weights(I::sideal{S}, v::S, w::Vector{Int32}) where S <: spoly + R = base_ring(I) + R == parent(v) || error("incompatible parents") + i = var_index(v) + GC.@preserve I v R begin + isone(libSingular.p_WTotaldegree(v.ptr, R.ptr)) || + error("variable must have weight 1") + ptr = libSingular.id_HomogenizeW(I.ptr, i, w, R.ptr) + return sideal{S}(R, ptr) + end +end + @doc raw""" normalize!(I::sideal)