Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

divrem with flag complete_reduction #681

Merged
merged 3 commits into from
Jul 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions src/ideal/ideal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -739,20 +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}) 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)
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

###############################################################################
Expand Down
Loading