Skip to content

Commit

Permalink
fix order of ring change and option setting
Browse files Browse the repository at this point in the history
  • Loading branch information
hannes14 committed Jun 28, 2024
1 parent d5a980e commit 0ca7158
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 21 deletions.
39 changes: 19 additions & 20 deletions deps/src/ideals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ auto id_Slimgb_helper(ideal a, ring b, bool complete_reduction = false)
// bool complete_reduction= false;
unsigned int crbit;
if (complete_reduction)
auto crbit = Sy_bit(OPT_REDSB);
crbit = Sy_bit(OPT_REDSB);
else
crbit = 0;
ideal id = NULL;
Expand All @@ -144,11 +144,11 @@ auto id_Slimgb_helper(ideal a, ring b, bool complete_reduction = false)
tHomog h = testHomog;
const ring origin = currRing;
unsigned int save_opt = si_opt_1;
si_opt_1 |= crbit;
rChangeCurrRing(b);
si_opt_1 |= crbit;
id = t_rep_gb(b, a, a->rank);
si_opt_1 = save_opt;
rChangeCurrRing(origin);
si_opt_1 = save_opt;
if (n != NULL)
delete n;
}
Expand Down Expand Up @@ -187,11 +187,11 @@ auto id_Std_helper(ideal a, ring b, bool complete_reduction = false)
tHomog h = testHomog;
const ring origin = currRing;
unsigned int save_opt = si_opt_1;
si_opt_1 |= crbit;
rChangeCurrRing(b);
si_opt_1 |= crbit;
id = kStd(a, b->qideal, h, &n);
si_opt_1 = save_opt;
rChangeCurrRing(origin);
si_opt_1 = save_opt;
if (n != NULL)
delete n;
}
Expand Down Expand Up @@ -238,11 +238,11 @@ auto id_MinStd_helper(ideal a, ring b, bool complete_reduction = false)
tHomog h = testHomog;
const ring origin = currRing;
unsigned int save_opt = si_opt_1;
si_opt_1 |= crbit;
rChangeCurrRing(b);
si_opt_1 |= crbit;
id = kMin_std(a, b->qideal, h, NULL, m);
si_opt_1 = save_opt;
rChangeCurrRing(origin);
si_opt_1 = save_opt;
return std::make_tuple(id, m);
}

Expand Down Expand Up @@ -275,11 +275,11 @@ auto id_StdHilb_helper(ideal a,
tHomog h = testHomog;
const ring origin = currRing;
unsigned int save_opt = si_opt_1;
si_opt_1 |= crbit;
rChangeCurrRing(b);
si_opt_1 |= crbit;
id = kStd(a, b->qideal, h, &n, hilb);
si_opt_1 = save_opt;
rChangeCurrRing(origin);
si_opt_1 = save_opt;
if (n != NULL)
delete n;
}
Expand Down Expand Up @@ -310,15 +310,15 @@ auto id_StdHilbWeighted_helper(ideal a,
tHomog h = testHomog;
const ring origin = currRing;
unsigned int save_opt = si_opt_1;
si_opt_1 |= crbit;
rChangeCurrRing(b);
si_opt_1 |= crbit;
id = kStd(a, currRing->qideal, h,
&n, // module weights
hilb, // hilbert series
0, 0, // syzComp, newIdeal
varweights); // weights of vars
si_opt_1 = save_opt;
rChangeCurrRing(origin);
si_opt_1 = save_opt;
if (n != NULL)
delete n;
}
Expand Down Expand Up @@ -528,37 +528,36 @@ void singular_define_ideals(jlcxx::Module & Singular)

Singular.method("id_LiftStd", [](ideal m, ring o, bool complete_reduction = false) {
const ring origin = currRing;
rChangeCurrRing(o);
matrix ma = mpNew(1, 1);
unsigned int crbit;
if (complete_reduction)
crbit = Sy_bit(OPT_REDSB);
else
crbit = 0;
unsigned int save_opt = si_opt_1;
rChangeCurrRing(o);
matrix ma = mpNew(1, 1);
si_opt_1 |= crbit;
ideal res = idLiftStd(m, &ma, testHomog, NULL);
si_opt_1 = save_opt;
rChangeCurrRing(origin);
si_opt_1 = save_opt;
return std::make_tuple(res, ma);
});

Singular.method("id_LiftStdSyz", [](ideal m, ring o, bool complete_reduction = false) {
const ring origin = currRing;
rChangeCurrRing(o);
matrix ma = mpNew(1, 1);
ideal syz = idInit(1, 1);
unsigned int crbit;
if (complete_reduction)
crbit = Sy_bit(OPT_REDSB);
else
crbit = 0;
unsigned int save_opt = si_opt_1;
const ring origin = currRing;
rChangeCurrRing(o);
matrix ma = mpNew(1, 1);
ideal syz = idInit(1, 1);
si_opt_1 |= crbit;
ideal res = idLiftStd(m, &ma, testHomog, &syz);
si_opt_1 = save_opt;

rChangeCurrRing(origin);
si_opt_1 = save_opt;
return std::make_tuple(res, ma, syz);
});

Expand Down
22 changes: 22 additions & 0 deletions src/MessyHacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,28 @@ for (name, str) in [(:with_fastHC, "OPT_FASTHC")
end
end

function with_redTail(f, flag::Bool, R::PolyRingUnion)
old_flag = libSingular.set_option("OPT_REDTAIL", flag, R.ptr)
local g = nothing
try
g = f()
finally
libSingular.set_option("OPT_REDTAIL", old_flag, R.ptr)
end
return g
end

function with_redThrough(f, flag::Bool, R::PolyRingUnion)
old_flag = libSingular.set_option("OPT_REDTHROUGH", flag, R.ptr)
local g = nothing
try
g = f()
finally
libSingular.set_option("OPT_REDTHROUGH", old_flag, R.ptr)
end
return g
end

#=
messy hack #1:
Expand Down
2 changes: 1 addition & 1 deletion test/ideal/sideal-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ end
B = slimgb(I, complete_reduction=true)

@test isequal(B, Ideal(R, 2y^2 + 3, x^2 + x*y + 1)) ||
isequal(B, Ideal(x^2 + x*y + 1, 2y^2 + 3))
isequal(B, Ideal(R, x^2 + x*y + 1, 2y^2 + 3))
@test B.isGB == true
end

Expand Down

0 comments on commit 0ca7158

Please sign in to comment.