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

fix quotient /saturation for smodule #835

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
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
17 changes: 17 additions & 0 deletions deps/src/ideals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,14 @@ void singular_define_ideals(jlcxx::Module & Singular)
return id;
});

Singular.method("id_Quotient_M", [](ideal a, ideal b, bool c, ring d) {
const ring origin = currRing;
rChangeCurrRing(d);
ideal id = idQuot(a, b, c, FALSE);
rChangeCurrRing(origin);
return id;
});

Singular.method("id_Intersection", [](ideal a, ideal b, ring c) {
const ring origin = currRing;
rChangeCurrRing(c);
Expand Down Expand Up @@ -580,6 +588,15 @@ void singular_define_ideals(jlcxx::Module & Singular)
return std::make_tuple(res, d);
});

Singular.method("id_Saturation_M", [](ideal I, ideal J, ring r) {
const ring origin = currRing;
rChangeCurrRing(r);
int d;
ideal res = idSaturate(I, J, d, FALSE);
rChangeCurrRing(origin);
return std::make_tuple(res, d);
});

Singular.method("id_Array2Vector", [](void * p, int a, ring o) {
return id_Array2Vector(reinterpret_cast<poly *>(p), a, o);
});
Expand Down
21 changes: 16 additions & 5 deletions src/module/module.jl
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,13 @@ function quotient(I::smodule{spoly{T}}, J::smodule{spoly{T}}) where T <: Nemo.Fi
R = base_ring(I)
S = elem_type(R)
ptr = GC.@preserve I J R libSingular.id_Quotient(I.ptr, J.ptr, I.isGB, R.ptr)
return sideal{S}(R, ptr)
end

function quotient(I::smodule{spoly{T}}, J::sideal{spoly{T}}) where T <: Nemo.FieldElem
R = base_ring(I)
S = elem_type(R)
ptr = GC.@preserve I J R libSingular.id_Quotient_M(I.ptr, J.ptr, I.isGB, R.ptr)
return Module(smatrix{spoly{T}}(R, ptr))
end

Expand All @@ -689,8 +696,10 @@ end
# Saturation
#
###############################################################################
function saturation(I::smodule{spoly{T}}, J::smodule{spoly{T}}) where T <: Nemo.FieldElem
check_parent(I, J)
function saturation(I::smodule{spoly{T}}, J::sideal{spoly{T}}) where T <: Nemo.FieldElem
if I.base_ring != J.base_ring
error("different base_ring")
end
has_global_ordering(base_ring(I)) || error("Must be over a ring with global ordering")
if !I.isGB
I = std(I)
Expand All @@ -706,10 +715,12 @@ function saturation(I::smodule{spoly{T}}, J::smodule{spoly{T}}) where T <: Nemo.
return I, k - 1
end

function saturation2(I::smodule{spoly{T}}, J::smodule{spoly{T}}) where T <: Nemo.FieldElem
check_parent(I, J)
function saturation2(I::smodule{spoly{T}}, J::sideal{spoly{T}}) where T <: Nemo.FieldElem
if I.base_ring != J.base_ring
error("different base_ring")
end
R = base_ring(I)
has_global_ordering(R) || error("Must be over a ring with global ordering")
ptr_res,k=libSingular.id_Saturation(I.ptr,J.ptr,R.ptr)
ptr_res,k=libSingular.id_Saturation_M(I.ptr,J.ptr,R.ptr)
return (Module(smatrix{spoly{T}}(R,ptr_res))),k
end
4 changes: 2 additions & 2 deletions test/module/smodule-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ end
J = Singular.Module(R, vector(R,x*y^2 + x + 1), vector(R,2x*y + 1), vector(R,x*y + 1))

A = quotient(I, J)
B = Singular.Module(R, vector(R, 2*y^2+3), vector(R, x^2+x*y+1))
B = Singular.Ideal(R, 2*y^2+3, x^2+x*y+1)
@test A[1] == B[1]
@test A[2] == B[2]
end
Expand All @@ -357,7 +357,7 @@ end
R, (x, y) = polynomial_ring(QQ, ["x", "y"])

I = Singular.Module(R, vector(R,(x^2 + x*y + 1)*(2y^2+1)^3), vector(R,(2y^2 + 3)*(2y^2+1)^2))
J = Singular.Module(R, vector(R,2y^2 + 1))
J = Singular.Ideal(R, 2y^2 + 1)

A,k = saturation(I, J)

Expand Down
Loading