Ask Your Question

Revision history [back]

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 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: vv = v.list()
sage: vv.append(0.5)
sage: v = vector(v.base_ring(), vv) ; v
(0, 1, 2, 1/2)
sage: v.parent()
Vector space of dimension 4 over Rational Field

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 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: vv = v.list()
sage: vv.append(0.5)
 sage: v = vector(v.base_ring(), vv) v.list() + [0.5]) ; v
(0, 1, 2, 1/2)
sage: v.parent()
Vector space of dimension 4 over Rational Field

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() + [0.5]) ; v
(0, 1, 2, 1/2)
sage: v.parent()
Vector space of dimension 4 over Rational Field

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() + [0.5]) [QQbar(1/2)]) ; v
(0, 1, 2, 1/2)
sage: v.parent()
Vector space of dimension 4 over Rational Field