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

option handling, fix #808 #810

Merged
merged 12 commits into from
Jun 29, 2024
66 changes: 66 additions & 0 deletions deps/src/singular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,72 @@ JLCXX_MODULE define_julia_module(jlcxx::Module & Singular)
}
return old_value;
});
// all of the global setters return the previous value
Singular.method("set_option", [](std::string opt, bool value, ring r) {
hannes14 marked this conversation as resolved.
Show resolved Hide resolved
bool old_value = false;
ring oldring=currRing;
if (r!=NULL) rChangeCurrRing(r);
if (false)
;
fingolfin marked this conversation as resolved.
Show resolved Hide resolved
SETTER(si_opt_2, V_QUIET)
SETTER(si_opt_2, V_QRING)
SETTER(si_opt_2, V_SHOW_MEM)
SETTER(si_opt_2, V_YACC)
SETTER(si_opt_2, V_REDEFINE)
SETTER(si_opt_2, V_LOAD_LIB)
SETTER(si_opt_2, V_DEBUG_LIB)
SETTER(si_opt_2, V_LOAD_PROC)
SETTER(si_opt_2, V_DEF_RES)
SETTER(si_opt_2, V_SHOW_USE)
SETTER(si_opt_2, V_IMAP)
SETTER(si_opt_2, V_PROMPT)
SETTER(si_opt_2, V_NSB)
SETTER(si_opt_2, V_CONTENTSB)
SETTER(si_opt_2, V_CANCELUNIT)
SETTER(si_opt_2, V_MODPSOLVSB)
SETTER(si_opt_2, V_UPTORADICAL)
SETTER(si_opt_2, V_FINDMONOM)
SETTER(si_opt_2, V_COEFSTRAT)
SETTER(si_opt_2, V_IDLIFT)
SETTER(si_opt_2, V_LENGTH)
SETTER(si_opt_2, V_ALLWARN)
SETTER(si_opt_2, V_INTERSECT_ELIM)
SETTER(si_opt_2, V_INTERSECT_SYZ)
SETTER(si_opt_2, V_DEG_STOP)

SETTER(si_opt_1, OPT_PROT)
SETTER(si_opt_1, OPT_REDSB)
SETTER(si_opt_1, OPT_NOT_BUCKETS)
SETTER(si_opt_1, OPT_NOT_SUGAR)
SETTER(si_opt_1, OPT_INTERRUPT)
SETTER(si_opt_1, OPT_SUGARCRIT)
SETTER(si_opt_1, OPT_DEBUG)
SETTER(si_opt_1, OPT_REDTHROUGH)
SETTER(si_opt_1, OPT_NO_SYZ_MINIM)
SETTER(si_opt_1, OPT_RETURN_SB)
SETTER(si_opt_1, OPT_FASTHC)
SETTER(si_opt_1, OPT_OLDSTD)
SETTER(si_opt_1, OPT_STAIRCASEBOUND)
SETTER(si_opt_1, OPT_MULTBOUND)
SETTER(si_opt_1, OPT_DEGBOUND)
SETTER(si_opt_1, OPT_REDTAIL)
SETTER(si_opt_1, OPT_INTSTRATEGY)
SETTER(si_opt_1, OPT_FINDET)
SETTER(si_opt_1, OPT_INFREDTAIL)
SETTER(si_opt_1, OPT_SB_1)
SETTER(si_opt_1, OPT_NOTREGULARITY)
SETTER(si_opt_1, OPT_WEIGHTM)
else
{
std::cerr << "unknown option " << opt << std::endl;
}
if (r!=NULL)
{
r->options=si_opt_1;
rChangeCurrRing(oldring);
}
return old_value;
});

#undef SETTER

Expand Down
8 changes: 4 additions & 4 deletions src/ideal/ideal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -847,12 +847,12 @@ 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)
old_redsb=libSingular.set_option("OPT_REDSB",complete_reduction)
old_redtail=libSingular.set_option("OPT_REDTAIL",complete_reduction)
old_redsb=libSingular.set_option("OPT_REDSB",complete_reduction,R.ptr)
old_redtail=libSingular.set_option("OPT_REDTAIL",complete_reduction,R.ptr)
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)
libSingular.set_option("OPT_REDSB",old_redsb,R.ptr)
libSingular.set_option("OPT_REDTAIL",old_redtail,R.ptr)
return (smodule{S}(R,ptr_T), sideal{S}(R,ptr_Rest), smodule{S}(R,ptr_U))
end

Expand Down
8 changes: 4 additions & 4 deletions src/module/module.jl
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,12 @@ from the identity matrix only for local ring orderings.
function divrem(I::smodule{S}, G::smodule{S}; complete_reduction::Bool = false) where S <: SPolyUnion
check_parent(I, G)
R = base_ring(I)
old_redsb=libSingular.set_option("OPT_REDSB",complete_reduction)
old_redtail=libSingular.set_option("OPT_REDTAIL",complete_reduction)
old_redsb=libSingular.set_option("OPT_REDSB",complete_reduction,R.ptr)
old_redtail=libSingular.set_option("OPT_REDTAIL",complete_reduction,R.ptr)
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)
libSingular.set_option("OPT_REDSB",old_redsb,R.ptr)
libSingular.set_option("OPT_REDTAIL",old_redtail,R.ptr)
return (smodule{S}(R,ptr_T), smodule{S}(R,ptr_Rest), smodule{S}(R,ptr_U))
end

Expand Down
1 change: 1 addition & 0 deletions test/ideal-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ include("ideal/sideal-test.jl")

include("ideal/quotient-test.jl")

include("ideal/freealg-test.jl")
25 changes: 25 additions & 0 deletions test/ideal/freealg-test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@testset "freealg" begin
R, (u11,u12,u13,u14,
u21,u22,u23,u24,
u31,u32,u33,u34,
u41,u42,u43,u44) = FreeAlgebra(QQ, ["u11", "u12", "u13", "u14",
"u21", "u22", "u23", "u24",
"u31", "u32", "u33", "u34",
"u41", "u42", "u43", "u44"], 7)
#rs1 = u11 + u12 + u13 + u14 - 1
rs2 = u21 + u22 + u23 + u24 - 1
rs3 = u31 + u32 + u33 + u34 - 1
rs4 = u41 + u42 + u43 + u44 - 1
cs1 = u11 + u21 + u31 + u41 - 1
cs2 = u12 + u22 + u32 + u42 - 1
cs3 = u13 + u23 + u33 + u43 - 1
cs4 = u14 + u24 + u34 + u44 - 1

Singular.libSingular.set_option("OPT_REDTAIL",false,R.ptr)
fingolfin marked this conversation as resolved.
Show resolved Hide resolved

J1 = Ideal(R,[rs2,rs3,rs4,cs1,cs2,cs3,cs4])
J1=std(J1)

@test J1[7] == u11 + u21 + u31 + u41 - 1

end
4 changes: 2 additions & 2 deletions test/module/smodule-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ end
v3 = v1 + v2

w1 = vector(R, y, y)
w2 = vector(R, x - y, y^2 - y)
w2 = vector(R, x, y^2)

M = Singular.Module(R, v1, v2, v3)
MM = Singular.minimal_generating_set(M)

@test MM[1] == w1 && MM[2] == w2
@test MM[1] == w1 && MM[2] == -v2
end

@testset "smodule.manipulation" begin
Expand Down
Loading