On Sat, Jan 9, 2010 at 9:52 AM, <[email protected]> wrote: > A small technical note about indexing. While M[1][1] works (i.e., it gives > you the entry), M[1,1] is much, much more powerful. For example, M[1, > (1,2)] gives you a submatrix, M[1,:] gives you row 1; M[:, 1] gives you > column 1, etc. It's even more powerful than that, because you can easily do > operations involving submatrices. For example, > > M[:, (0,1)] = M[:, (1,0)] > > swaps columns 0 and 1. Do you see what is happening here?
This is excellent! Thanks very much. And very timely - it will be perfect for illustrating things coming up, like expansion by minors. > The right hand side is giving you a matrix consisting of columns 1 and 0 > (in that order). You are assigning those to whatever is on the left side of > the equals, which is a placeholder for columns 0 and 1 (in that order). So > you've swapped the columns! You can't do this sort of thing with the > M[][]-type indexing. > > Also, M[:, -1] gives you the last column. > > For documentation, see M.__getitem__? and M.__setitem__? > > We should make the indexing stuff examples in the reference manual (I don't > believe it's there now since it's for a "__" function). I've made > http://trac.sagemath.org/sage_trac/ticket/7877 to address this problem. > > Thanks, > > Jason > > > -- > You received this message because you are subscribed to the Google Groups > "sage-edu" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<sage-edu%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/sage-edu?hl=en. > > > > -- "Computer science is the new mathematics." -- Dr. Christos Papadimitriou--
You received this message because you are subscribed to the Google Groups "sage-edu" 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/sage-edu?hl=en.
