On Dec 29, 2008, at 1:38 PM, Justin Walker wrote:

> On Dec 29, 2008, at 3:32 PM, Santanu Sarkar wrote:
>
>> I write a program in SAGE as follows:
>> R.<x1,x2>=QQ[]
>> M=matrix(R,1,2,[x1+x2,x1*x2])
>> may i do following steps to extract polynomials from matrix?
>> 1) x = list(M)
>> 2) f1 = x[0]
>> 3) f2 = x[1]
>> is f1 & f2 are polynomials?
>> if not how i can get them? please help me!
>
> I think that
>
> sage: x = M.list()
>
> will do what you want.
>
> I'm not sure why list(M) doesn't do "the right thing":
>
> sage: list(M)
>   [(x1 + x2, x1*x2)]

list(M) gives a list of rows, not entries.

sage: R.<x1,x2>=QQ[]
sage: M=matrix(R,1,2,[x1+x2,x1*x2])
sage: M[0]
(x1 + x2, x1*x2)
sage: parent(M[0])
Ambient free module of rank 2 over the integral domain Multivariate  
Polynomial Ring in x1, x2 over Rational Field
sage: list(M)[0]
(x1 + x2, x1*x2)

Same with indexing with using one index. Since matrices are two- 
dimensional, this seems to be the "right thing" for me.

- Robert


--~--~---------~--~----~------------~-------~--~----~
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
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to