Vectors with rational entries¶
AUTHOR:
William Stein (2007)
Soroosh Yazdani (2007)
EXAMPLES:
sage: v = vector(QQ,[1,2,3,4,5])
sage: v
(1, 2, 3, 4, 5)
sage: 3*v
(3, 6, 9, 12, 15)
sage: v/2
(1/2, 1, 3/2, 2, 5/2)
sage: -v
(-1, -2, -3, -4, -5)
sage: v - v
(0, 0, 0, 0, 0)
sage: v + v
(2, 4, 6, 8, 10)
sage: v * v
55
>>> from sage.all import *
>>> v = vector(QQ,[Integer(1),Integer(2),Integer(3),Integer(4),Integer(5)])
>>> v
(1, 2, 3, 4, 5)
>>> Integer(3)*v
(3, 6, 9, 12, 15)
>>> v/Integer(2)
(1/2, 1, 3/2, 2, 5/2)
>>> -v
(-1, -2, -3, -4, -5)
>>> v - v
(0, 0, 0, 0, 0)
>>> v + v
(2, 4, 6, 8, 10)
>>> v * v
55
We make a large zero vector:
sage: k = QQ^100000; k
Vector space of dimension 100000 over Rational Field
sage: v = k(0)
sage: v[:10]
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
>>> from sage.all import *
>>> k = QQ**Integer(100000); k
Vector space of dimension 100000 over Rational Field
>>> v = k(Integer(0))
>>> v[:Integer(10)]
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
- class sage.modules.vector_rational_dense.Vector_rational_dense[source]¶
Bases:
FreeModuleElement
- list(copy=True)[source]¶
The list of entries of the vector.
INPUT:
copy
– ignored optional argument
EXAMPLES:
sage: v = vector(QQ,[1,2,3,4]) sage: a = v.list(copy=False); a [1, 2, 3, 4] sage: a[0] = 0 sage: v (1, 2, 3, 4)
>>> from sage.all import * >>> v = vector(QQ,[Integer(1),Integer(2),Integer(3),Integer(4)]) >>> a = v.list(copy=False); a [1, 2, 3, 4] >>> a[Integer(0)] = Integer(0) >>> v (1, 2, 3, 4)