Ask Your Question
0

accessing the components of a vector

asked 11 years ago

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!

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 11 years ago

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.

Preview: (hide)
link

Comments

Thank you!

strangelove1221 gravatar imagestrangelove1221 ( 11 years ago )

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: 11 years ago

Seen: 3,458 times

Last updated: Sep 21 '13