From 1b4adf745f417f6234fa8be6d3199ea9d4153025 Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Tue, 21 Mar 2023 08:08:23 +0100 Subject: [PATCH] Add mstd, divrem back --- Project.toml | 4 ++-- src/ideal/ideal.jl | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index b6ef933c4..6915c3957 100644 --- a/Project.toml +++ b/Project.toml @@ -23,9 +23,9 @@ BinaryWrappers = "~0.1.1" CxxWrap = "0.11, 0.12, 0.13" Nemo = "0.33.0" RandomExtensions = "0.4.2" -Singular_jll = "~403.101.500" +Singular_jll = "~403.201.000" julia = "1.6" -libsingular_julia_jll = "~0.29.0" +libsingular_julia_jll = "~0.30.0" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/src/ideal/ideal.jl b/src/ideal/ideal.jl index 26da99a0b..43bc90a8c 100644 --- a/src/ideal/ideal.jl +++ b/src/ideal/ideal.jl @@ -3,7 +3,7 @@ export sideal, IdealSet, syz, lead, normalize!, is_constant, is_zerodim, fglm, independent_sets, maximal_independent_set, ngens, sres, intersection, quotient, reduce, eliminate, kernel, equal, contains, is_var_generated, saturation, satstd, slimgb, std, vdim, interreduce, degree, mult, - hilbert_series, std_hilbert, is_homogeneous, division + hilbert_series, std_hilbert, is_homogeneous, division, divrem, mstd ############################################################################### # @@ -542,6 +542,24 @@ function std(I::sideal{S}; complete_reduction::Bool=false) where S <: SPolyUnion return sideal{S}(R, ptr, true, I.isTwoSided) end +@doc Markdown.doc""" + mstd(I::sideal{S}; complete_reduction::Bool=false) where S <: SPolyUnion + +Compute a Groebner basis for the ideal $I$ and a minimal generating set. +Note that without `complete_reduction` set to `true`, +the generators of the Groebner basis +only have unique leading terms (up to permutation and multiplication by +constants). If `complete_reduction` is set to `true` (and the ordering is +a global ordering) then the Groebner basis is unique. +""" +function mstd(I::sideal{S}; complete_reduction::Bool=false) where S <: SPolyUnion + R = base_ring(I) + ptr,ptr_min = GC.@preserve I R libSingular.id_MinStd(I.ptr, R.ptr, complete_reduction) + libSingular.idSkipZeroes(ptr) + libSingular.idSkipZeroes(ptr_min) + return (sideal{S}(R, ptr), sideal{S}(R, ptr_min)) +end + @doc Markdown.doc""" interreduce(I::sideal{S}) where {T <: Nemo.RingElem, S <: Union{spoly{T}, spluralg{T}}} @@ -663,6 +681,23 @@ function division(I::sideal{S}, G::sideal{S}) where S <: SPolyUnion return (smodule{S}(R,ptr_T), sideal{S}(R,ptr_Rest), smodule{S}(R,ptr_U)) end +@doc Markdown.doc""" + divrem(I::sideal{S}, G::sideal{S}) where S <: SPolyUnion + +Computes a division with remainder of the generators of `I` by +the generators of `G`. Returns a tuple (Quo, Rem, U) where + `Matrix(I)*Matrix(U) = Matrix(G)*Matrix(Quo) + Matrix(Rem)` +and `Rem = normalform(I, G)`. `U` is a diagonal matrix of units differing +from the identity matrix only for local ring orderings. +""" +function divrem(I::sideal{S}, G::sideal{S}) where S <: SPolyUnion + check_parent(I, G) + R = base_ring(I) + ptr_T,ptr_Rest,ptr_U = GC.@preserve I G R libSingular.id_DivRem_Unit(I.ptr, G.ptr, + R.ptr) + return (smodule{S}(R,ptr_T), sideal{S}(R,ptr_Rest), smodule{S}(R,ptr_U)) +end + ############################################################################### # # Eliminate