Ask Your Question
1

How to access variables from libsingular?

asked 2018-05-23 23:47:38 +0100

BrentBaccala gravatar image

I have some Sage code that works using the expect interface, and I'm trying to port it to libsingular.

The Singular function in question (absFactorize) returns a ring with an associated variable. In the expect interface, we setring the returned ring, then evaluate the variable name, i.e:

    R = norm_f._singular_().absFactorize()

    singular.setring(R)
    L = singular('absolute_factors')

Anybody know how to do this with libsingular?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-05-24 05:47:51 +0100

nbruin gravatar image

updated 2018-05-25 23:41:00 +0100

In order to get the routine defined you'd do something like

R.<x,y>=QQ[]
f=x^2-y^2
sage.libs.singular.function.lib("absfact.lib")
absFactorize=sage.libs.singular.function.singular_function("absFactorize")

which then would allow you to do something like

W=absFactorize(f)

Problem is: that gives back a nearly useless "RingWrap" object.

The libsingular function call interface seems to go out of its way to set the ring on every invocation (otherwise the state of the library interface would be difficult to manage). So improving RingWrap so that a "setring(W)" works likely wouldn't do something useful. Would you be able to write some singular code that wraps absFactorize and returns the data you're after in a more usable form? Then you can read in THAT function and use that instead. Looking at the design of libSingular, that seems to me the easiest solution at the moment. But I might be overlooking something.

EDIT It's tricky, though: the Singular language interpreter seems to have great trouble handling polynomials in rings that are not the current ring. Furthermore, you'll have to construct a ring in sage to serve as a parent for conversions of the relevant polynomials. I suspect it might require some direct interfacing with libsingular on cython/C level. Clearly, Singular can represent the relevant objects, but I think the current design of AbsFactorize (to wrap the answer in a ring) is guided by limitations of the language.

edit flag offensive delete link more

Comments

I was hoping for something else, but your suggestion (write a wrapper function) might be the most practical solution.

BrentBaccala gravatar imageBrentBaccala ( 2018-05-25 21:44:05 +0100 )edit

I wasn't able to get it working using only the Singular language. libsingular prohibits subroutines changing the basering, and I couldn't figure how to access the variable without changing the basering. @nbruin seems to be right - something in cython/C is probably required.

BrentBaccala gravatar imageBrentBaccala ( 2018-06-15 04:38:16 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-05-23 23:47:38 +0100

Seen: 286 times

Last updated: May 25 '18