From eb2c79476b1cea2f61b7dd4c6c8f819fd8b69ede Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Mon, 24 Jul 2023 14:59:27 +0200 Subject: [PATCH 1/3] divrem with flag complete_reduction --- src/ideal/ideal.jl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ideal/ideal.jl b/src/ideal/ideal.jl index 6fc9efe99..3b02b1a5c 100644 --- a/src/ideal/ideal.jl +++ b/src/ideal/ideal.jl @@ -747,11 +747,16 @@ the generators of `G`. Returns a tuple (Quo, Rem, U) where 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 +function divrem(I::sideal{S}, G::sideal{S}; complete_reduction::Bool = false) 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) + if complete_reduction + ptr_T,ptr_Rest,ptr_U = GC.@preserve I G R libSingular.id_DivRem_Unit(I.ptr, G.ptr, + R.ptr,0) + else + ptr_T,ptr_Rest,ptr_U = GC.@preserve I G R libSingular.id_DivRem_Unit(I.ptr, G.ptr, + R.ptr,1) + end return (smodule{S}(R,ptr_T), sideal{S}(R,ptr_Rest), smodule{S}(R,ptr_U)) end From 79673e80bf62c42438b7ba2e34904a9065fae8f8 Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Tue, 25 Jul 2023 15:13:10 +0200 Subject: [PATCH 2/3] complete_reduction for reduce (#682) --- src/ideal/ideal.jl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ideal/ideal.jl b/src/ideal/ideal.jl index 3b02b1a5c..91d70d98f 100644 --- a/src/ideal/ideal.jl +++ b/src/ideal/ideal.jl @@ -689,10 +689,14 @@ left reduction, and hence cannot be used to test containment in a two-sided idea For LETTERPLACE rings (S <: slpalg, FreeAlgebra), the reduction is two-sided as only two-sided ideals can be constructed here. """ -function reduce(I::sideal{S}, G::sideal{S}) where S <: SPolyUnion +function reduce(I::sideal{S}, G::sideal{S};complete_reduction::Bool = true) where S <: SPolyUnion check_parent(I, G) R = base_ring(I) - ptr = GC.@preserve I G R libSingular.p_Reduce(I.ptr, G.ptr, R.ptr) + if complete_reduction + ptr = GC.@preserve I G R libSingular.p_Reduce(I.ptr, G.ptr, R.ptr) + else + ptr = GC.@preserve I G R libSingular.p_Reduce(I.ptr, G.ptr, R.ptr,1) + end return sideal{S}(R, ptr, false, I.isTwoSided) end @@ -706,10 +710,14 @@ left reduction, and hence cannot be used to test membership in a two-sided ideal For LETTERPLACE rings (S <: slpalg, FreeAlgebra), the reduction is the full two-sided reduction as only two-sided ideals can be constructed here. """ -function reduce(p::S, G::sideal{S}) where S <: SPolyUnion +function reduce(p::S, G::sideal{S};complete_reduction = true) where S <: SPolyUnion R = parent(p) R == base_ring(G) || error("Incompatible base rings") - ptr = GC.@preserve p G R libSingular.p_Reduce(p.ptr, G.ptr, R.ptr) + if complete_reduction + ptr = GC.@preserve p G R libSingular.p_Reduce(p.ptr, G.ptr, R.ptr) + else + ptr = GC.@preserve p G R libSingular.p_Reduce(p.ptr, G.ptr, R.ptr,1) + end return R(ptr) end From 58f4e7ba8b9f6325ae5e2976f9e422c6574e4f7b Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Fri, 28 Jul 2023 11:12:30 +0200 Subject: [PATCH 3/3] implementation via idLift and options --- src/ideal/ideal.jl | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/ideal/ideal.jl b/src/ideal/ideal.jl index 91d70d98f..7b51b8205 100644 --- a/src/ideal/ideal.jl +++ b/src/ideal/ideal.jl @@ -747,25 +747,24 @@ function division(I::sideal{S}, G::sideal{S}) where S <: SPolyUnion end @doc raw""" - divrem(I::sideal{S}, G::sideal{S}) where S <: SPolyUnion + divrem(I::sideal{S}, G::sideal{S}; complete_reduction::Bool = false) 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)` + `Matrix(I)*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}; complete_reduction::Bool = false) where S <: SPolyUnion check_parent(I, G) R = base_ring(I) - if complete_reduction - ptr_T,ptr_Rest,ptr_U = GC.@preserve I G R libSingular.id_DivRem_Unit(I.ptr, G.ptr, - R.ptr,0) - else - ptr_T,ptr_Rest,ptr_U = GC.@preserve I G R libSingular.id_DivRem_Unit(I.ptr, G.ptr, - R.ptr,1) - end - return (smodule{S}(R,ptr_T), sideal{S}(R,ptr_Rest), smodule{S}(R,ptr_U)) + old_redsb=libSingular.set_option("OPT_REDSB",complete_reduction) + old_redtail=libSingular.set_option("OPT_REDTAIL",complete_reduction) + ptr_T,ptr_Rest,ptr_U = GC.@preserve I G R libSingular.id_Lift(G.ptr, I.ptr, true, + false, true, R.ptr) + libSingular.set_option("OPT_REDSB",old_redsb) + libSingular.set_option("OPT_REDTAIL",old_redtail) + return (smodule{S}(R,ptr_T), sideal{S}(R,ptr_Rest), smatrix{S}(R,ptr_U)) end ###############################################################################