On 7/7/10 1:26 AM, Johan Grönqvist wrote:
2010-07-07 09:10, Kwankyu skrev:
Does Sage have a command to get the mirror image matrix
[3,2,1]
[6,5,4]
from the matrix
[1,2,3]
[4,5,6]
Like this?
sage: m = Matrix([[1,2,3],[4,5,6]])
sage: m
[1 2 3]
[4 5 6]
sage: m2 = m[::, ::-1]
sage: m2
[3 2 1]
[6 5 4]
That last line could also have one less colon (like normal python indexing):
m2=m[:,::-1]
The first : means "all rows", or [0,1] in this case. The second
notation is shorthand for [2,1,0] in this case (all columns with a step
of -1, so basically, all columns in reverse order). So the above
notation is just shorthand for:
m2=m[[0,1],[2,1,0]]
Thanks,
Jason
--
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
URL: http://www.sagemath.org