Ok, I found the proper way to do it, maybe someone would be interested
in, so I paste here some code.

On 3 Lut, 13:08, Kakaz <[email protected]> wrote:
> Here is Sage code I try to use:
> singular.LIB('ncall.lib')
> R=singular.ring(0,'(x,y,z,a,b)','dp')
>
> This are commutativity relations defined by formula: xi*xj=c[i,j]
> *xj*xi + d[i,j].
> Note that for generators a,b we have pure commutative relations since
> C = 1 for this elements
> Also below we have definition for D matrix, and for a,b generators
> there are D=0 elements, so a,b commute with every other generators.
>
> C=singular.matrix(5,5,'1,-1,-1,1,1,-1,1,-1,1,1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,1,1');C
> D=singular.matrix(5,5,'0,0,-y,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0');D
> S=C.nc_algebra(D)
> S;#Note that below we have noncommutative relations!!!
> ///
> //   characteristic : 0
> //   number of vars : 5
> //        block   1 : ordering dp
> //                  : names    x y z a b
> //        block   2 : ordering C
> //   noncommutative relations: ...
> S.set_ring()
> x=singular('x');x
> y=singular('y');y;z=singular('z');z;a=singular('a');a;b=singular
> ('b');b
> x*y
> z*x#<- here You see non-zero element from D matrix.
>
> <p><strong>And there are the troubles!!!!</strong></p>
> <p><strong>From manual we know that substitute returns the same value
> if substitute cannot be performed. So is this this case? Or maybe I
> should use direct singular function for substitution? How?</strong></
> p>
> <p>Examples of substitutions:</p>
>
> f = a*x+ b*y+ 2*z + a*b*x + b*x*a*y;f
> f.substitute(x=1);f.substitute(x=y);f.substitute(x=a);
>
> gives:
> x*y*a*b+x*a*b+x*a+y*b+2*z
> x*y*a*b+x*a*b+x*a+y*b+2*z
> x*y*a*b+x*a*b+x*a+y*b+2*z
> Which is the same!
So I try to experiment with code below:

sage: f
x*y*a*b+x*a*b+x*a+y*b+2*z

sage: g=singular.substitute(a*x+ b*y+ 2*z + a*b*x + b*x*a*y,x,x*y);g
x*y^2*a*b+x*y*a*b+x*y*a+y*b+2*z
#good: that is mean that when I paste whole polynomial into substitute
it works. So the problem is with names and references between sage and
singular, which I do not understand clearly. But my goal is to have
sage object named h which represent singular object poly f. So I try
code as below:

sage: singular.eval('poly f=a*x+ b*y+ 2*z + a*b*x + b*x*a*y')
'// ** redefining f **'

sage: singular.eval('poly h=substitute(%s,x,x*y)'%f.name())
'poly h=substitute(sage84,x,x*y);'

sage: h=singular('h');h
x*y^2*a*b+x*y*a*b+x*y*a+y*b+2*z

sage: h==g
True

I do not know if it is useful for anyone, but I learn a lot from that
example!
I simple words ( for me) it means that sage and singular, used
together has two different name spaces. And if something has to be
computed within singular ( substitute(f,x,x*y) ) must operate on
object which is named in singular ( so f is not proper name until I
create such object in singular with poly f = ...).

f from sage does not have any knowledge about singular method and
meaning for f even if is defined as f =  singular('f') which means
that it is only _copy_of_value_ . Is that last sentence true?

Best regards!
Kazek

-- 
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

Reply via email to