Skip to content

Commit

Permalink
option handling, fix #808
Browse files Browse the repository at this point in the history
Some options in Singular are local to the "current ring"
(OPT_INTSTRATEGY,OPT_REDTHROUGH,OPT_REDTAIL,OPT_REDTAIL_SYZ).
In Singular.jl there is no "current ring": modified ring change
to keep tghe current (global) setting of options except the
needed changes due to the properties of a ring.
  • Loading branch information
hannes14 committed Jun 12, 2024
1 parent b57cb8e commit 66c100d
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 129 deletions.
13 changes: 7 additions & 6 deletions deps/src/caller.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "caller.h"
#include "ideals.h"

#include <Singular/tok.h>
#include <Singular/grammar.h>
Expand Down Expand Up @@ -252,7 +253,7 @@ jl_value_t * get_julia_type_from_sleftv(leftv ret)
jl_value_t * get_ring_content(ring r)
{
ring save = currRing;
rChangeCurrRing(r);
rChangeCurrRing_wo_options(r);

// count elements
idhdl h = r->idroot;
Expand Down Expand Up @@ -283,7 +284,7 @@ jl_value_t * get_ring_content(ring r)
nr++;
}
JL_GC_POP();
rChangeCurrRing(save);
rChangeCurrRing_wo_options(save);
return reinterpret_cast<jl_value_t *>(result);
}

Expand Down Expand Up @@ -409,9 +410,9 @@ jl_value_t * convert_nested_list(void * l_void)
void * create_syStrategy_data(syStrategy res, ring o)
{
const ring origin = currRing;
rChangeCurrRing(o);
rChangeCurrRing_wo_options(o);
syStrategy temp = syCopy(res);
rChangeCurrRing(origin);
rChangeCurrRing_wo_options(origin);
return reinterpret_cast<void *>(temp);
}

Expand Down Expand Up @@ -489,9 +490,9 @@ void singular_define_caller(jlcxx::Module & Singular)
Singular.method("jl_array_to_void",
[](jl_value_t * args_val, jl_value_t * types_val, ring R) {
auto origin = currRing;
rChangeCurrRing(R);
rChangeCurrRing_wo_options(R);
lists l = jl_array_to_list_helper(args_val, types_val);
rChangeCurrRing(origin);
rChangeCurrRing_wo_options(origin);
return (void *)l;
});

Expand Down
5 changes: 3 additions & 2 deletions deps/src/coeffs.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "coeffs.h"
#include "ideals.h"

auto transExt_helper(coeffs cf, jlcxx::ArrayRef<uint8_t *> param)
{
Expand Down Expand Up @@ -26,9 +27,9 @@ poly transExt_to_poly(number a, coeffs cf, ring r)
ring ext = cf->extRing;
nMapFunc nMap = n_SetMap(ext->cf, r->cf);
const ring origin = currRing;
rChangeCurrRing(r);
rChangeCurrRing_wo_options(r);
poly p = p_PermPoly(NUM((fraction)a), NULL, ext, r, nMap, NULL);
rChangeCurrRing(origin);
rChangeCurrRing_wo_options(origin);
return p;
}

Expand Down
Loading

0 comments on commit 66c100d

Please sign in to comment.