On Monday 26 April 2010, Andrea Gobbi wrote:
> Hi!
> I try to find out a solution by myself, but without result.
> I have to call a singular function (vanishId) in the library
> decodegb.lib. I write:
>
> from sage.libs.singular.function import singular_function
> from sage.libs.singular.function import lib as singular_lib
> singular_lib('decodegb.lib')
> singular_lib('matrix.lib')
>
> vanish = singular_function('vanishId');
> R=PolynomialRing(GF(11),['x%s'%p for p in range(0,17)],'degrevlex');
> x=R.gens();
>
> ..
> the main program write in sage
> ..
>
> I have a list of lists, called points, and i eliminate duplicates
> here:
>
> provv=list();
>
> for i in range(0,m-1):
> cont=0;
> for j in range(i+1,m-1):
> if points[j]==points[i]:
> j=m-1;
> cont=1;
> if cont==0:
> provv.append(points[i]);
>
> Now i have to convert sage list of lists into singular list of columns
> vectors ( because vanishId takes a list of columns vectors)
>
> presing=list();
> for i in range (0,len(provv)):
> presing.append(singular.matrix(1,17,provv[i]));
>
This isn't correct. There are two different interfaces to Singular. Above
('singular_function' etc.) you are using the C/C++ interface. However, here
you are using the Singular pexpect (shell) interface.
Below, I try to reproduce the example from the Singular documentation.
sage: sage.libs.singular.lib("decodegb.lib")
sage: P.<x1,x2,x3> = PolynomialRing(GF(3),order='degrevlex')
sage: l = list(VectorSpace(GF(3),3))
sage: l
[(0, 0, 0), (1, 0, 0), (2, 0, 0), (0, 1, 0), (1, 1, 0), (2, 1, 0), (0, 2, 0),
(1, 2, 0), (2, 2, 0), (0, 0, 1), (1, 0, 1), (2, 0, 1), (0, 1, 1), (1, 1, 1),
(2, 1, 1), (0, 2, 1), (1, 2, 1), (2, 2, 1), (0, 0, 2), (1, 0, 2), (2, 0, 2),
(0, 1, 2), (1, 1, 2), (2, 1, 2), (0, 2, 2), (1, 2, 2), (2, 2, 2)]
sage: vanishId = sage.libs.singular.singular_function('vanishId')
sage: l = map(lambda n: Matrix(P,3,1,n.list()), l)
sage: l
[
[0] [1] [-1] [0] [1] [-1] [ 0] [ 1] [-1] [0] [1] [-1] [0]
[0] [0] [ 0] [1] [1] [ 1] [-1] [-1] [-1] [0] [0] [ 0] [1]
[0], [0], [ 0], [0], [0], [ 0], [ 0], [ 0], [ 0], [1], [1], [ 1], [1],
[1] [-1] [ 0] [ 1] [-1] [ 0] [ 1] [-1] [ 0] [ 1] [-1] [ 0]
[1] [ 1] [-1] [-1] [-1] [ 0] [ 0] [ 0] [ 1] [ 1] [ 1] [-1]
[1], [ 1], [ 1], [ 1], [ 1], [-1], [-1], [-1], [-1], [-1], [-1], [-1],
[ 1] [-1]
[-1] [-1]
[-1], [-1]
]
sage: vanishId(l)
? `x(1)` is not defined
? error occurred in decodegb.lib::ev line 1447: `
temp=subst(temp,x(i),p[i,1]);`
? leaving decodegb.lib::ev
skipping text from `!=` ? leaving decodegb.lib::find_index
error at token `)`
? leaving decodegb.lib::vanishId
As you can see vanishId expects certain names for generators. However, these
names are illegal in Sage which leaves us in a bad situation. I'd suggest to
use Singular directly (singular.lib, singular.vanishID, singular.ring etc.)
--
name: Martin Albrecht
_pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99
_otr: 47F43D1A 5D68C36F 468BAEBA 640E8856 D7951CCF
_www: http://www.informatik.uni-bremen.de/~malb
_jab: [email protected]
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org