Skip to content

Commit

Permalink
Homogenize wrt. weights odf ideals
Browse files Browse the repository at this point in the history
  • Loading branch information
hannes14 committed Jun 23, 2023
1 parent 7bc1052 commit fd5ce58
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
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
40 changes: 40 additions & 0 deletions src/ideal/ideal.jl
Original file line number Diff line number Diff line change
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(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(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(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_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 fd5ce58

Please sign in to comment.