On Dec 29, 2008, at 4:53 PM, Robert Bradshaw wrote:

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

Hmm...I see what you mean...

sage: N=matrix(R,2,1,[x1+x2,x1*x2])
sage: N

[x1 + x2]
[  x1*x2]
sage: y=list(N)
sage: y
  [(x1 + x2), (x1*x2)]

Curiouser and curiouser...

I guess one man's "object" is another man's ...

Is there some reason that "rows" trump "columns"?   Is this an  
artifact of implementation, e.g., a matrix is a list of rows?

Should "list(obj)" do "obj.list()"?

I'm more curious than complaining; seems a bit counterintuitive to me.

Justin

--
Justin C. Walker, Curmudgeon at Large
Institute for the Absorption of Federal Funds
-----------
Like the ski resort full of girls hunting for husbands
and husbands hunting for girls, the situation is not
as symmetrical as it might seem.
   - Alan MacKay
--


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to