Comment #2 on issue 2544 by [email protected]: Matrix(...)[i] for
non-vector matrices should not be supported.
http://code.google.com/p/sympy/issues/detail?id=2544
In [29]: a=np.matrix(((1,2,3),(4,5,6),(7,8,9)))
In [30]: a[0]
Out[30]: [[1 2 3]]
In [31]: a[1]
Out[31]: [[4 5 6]]
In [32]: a[2]
Out[32]: [[7 8 9]]
In [33]: a[0:2]
Out[33]:
[[1 2 3]
[4 5 6]]
In [34]: a[0:3]
Out[34]:
[[1 2 3]
[4 5 6]
[7 8 9]]
In [35]: a = matrix((1,2,3)).T
In [36]: a
Out[36]:
[[1]
[2]
[3]]
In [37]: a[0]
Out[37]: [[1]]
In [38]: a[1]
Out[38]: [[2]]
In [39]: a[2]
Out[39]: [[3]]
In [40]: a[0,0]
Out[40]: 1
numpy treats single indices a[i] as shorthand for a[i, :].
This way, A[0] would not give the first element of the vector matrix, but
would give a Matrix of shape 1 * 1.
I think, the numpy approach is more explicit. A[i, 0] would still work for
vector matrices.
We could also think of deriving a class Vector from Matrix, which overrides
the getitem setitem method, if we really want the vector syntax.
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
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/sympy-issues?hl=en.