Ask Your Question
0

accessing the components of a vector

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

anonymous user

Anonymous

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
2

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

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

Comments

Thank you!

strangelove1221 gravatar imagestrangelove1221 ( 2013-09-21 19:27:23 +0100 )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

Stats

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

Seen: 3,288 times

Last updated: Sep 21 '13