Ask Your Question
0

Augmenting a vector

asked 11 years ago

MvG gravatar image

There are simple ways to extend a matrix to form a larger matrix: I can augment it to add columns or stack it to add rows.

Is there something similar for simple vectors? Some method of a vector object which would return the same vector with one more element added to the end? Or do I have to write that myself?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 11 years ago

tmonteil gravatar image

updated 11 years ago

According to the tab completion, appart from the .cartesian_product() method that will make a couple of vectors, there seem no direct way to do this.

You can have a look at this question and that question, though i would advise to keep track of the base ring of your initial vector (if needed) as follows:

sage: v = vector(QQ,[0,1,2]) ; v
(0, 1, 2)
sage: v.parent()
Vector space of dimension 3 over Rational Field

sage: v = vector(v.base_ring(), v.list() + [QQbar(1/2)]) ; v
(0, 1, 2, 1/2)
sage: v.parent()
Vector space of dimension 4 over Rational Field
Preview: (hide)
link

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: 1,228 times

Last updated: Oct 17 '13