Skip to content

Commit

Permalink
Homogenize wrt. weights of ideals (#675)
Browse files Browse the repository at this point in the history
* Homogenize wrt. weights odf ideals

* use homogenize_ideal, homogenize_ideal_with_weights
  • Loading branch information
hannes14 authored Jul 4, 2023
1 parent d437eeb commit b09551a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
8 changes: 8 additions & 0 deletions deps/src/ideals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> 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);
Expand Down
42 changes: 41 additions & 1 deletion src/ideal/ideal.jl
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b09551a

Please sign in to comment.