Ah of course. Thank you both for your help.

Christophe

On Mar 25, 4:00 pm, Jason Grout <jason-s...@creativetrax.com> wrote:
> Johan Oudinet wrote:
> > On Wed, Mar 25, 2009 at 11:39 AM, Christophe Oosterlynck
> > <tif...@gmail.com> wrote:
> >> Any comments on this?
>
> >> it's really strange that when getting a vector from the matrix a
>
> >>>> b = a[:,0]
> >>> you have to use an extra index when you want to select an element from
> >> that vector b:
>
> >>>> b[0][0]
> >> instead of just b[0] (this gives a list with 1 element...)
>
> > No it's not. `b' is also a matrix. So if you just give one argument,
> > you get a list of elements:
> > a[0]
> > (1,0)
> > a[0,0]
> > 1
>
> > b[0]
> > (1)
> > b[0,0]
> > 1
>
> Yep, that's right.  The b[something,something] notation will always
> return a submatrix (not a vector).  Use b[something] to get a specific
> row as a vector, or use b.row(i) or b.column(i) to get a vector of a
> specific row or column.
>
> sage: a=random_matrix(ZZ,3); a
> [-8 -1 -3]
> [-1  0  0]
> [-1  2 -1]
> sage: a.column(0)
> (-8, -1, -1)
> sage: type(a.column(0))
> <type 'sage.modules.vector_integer_dense.Vector_integer_dense'>
>
> 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
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to