Ask Your Question

accessing the components of a vector

asked 2013-09-21 19:06:35 +0200

anonymous user


Is there a command in Sage that allows me to access the individual components of a vector? For example, suppose I've defined a vector like a=vector([1,2,3]). I want a command like "a.1" that returns the first component of the vector, so in this case I would want a.1 to return 1. Is there a command like this in Sage? Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-09-21 19:15:28 +0200

minopret gravatar image

You can use Python sequence indexing syntax, for which the index numbers start at zero: a=vector([1,2,3]);a[0] returns 1.

edit flag offensive delete link more


Thank you!

strangelove1221 gravatar imagestrangelove1221 ( 2013-09-21 19:27:23 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-09-21 19:06:35 +0200

Seen: 3,162 times

Last updated: Sep 21 '13