Ask Your Question
0

Augmenting a vector

asked 2013-10-17 12:42:32 +0100

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-10-17 13:08:32 +0100

tmonteil gravatar image

updated 2013-10-17 13:21:04 +0100

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
edit flag offensive delete link more

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-10-17 12:42:32 +0100

Seen: 1,070 times

Last updated: Oct 17 '13