vec1 + vec2
In this form the addition operator +
evaluates to the sum of the two
vectors vec1 and vec2, which must have the same dimension and lie in
a common field. The sum is a new vector where each entry is the sum of
the corresponding entries of the vectors. As an exception it is also
possible to add an integer vector to a finite field vector, in which case
the integers are interpreted as scalar * GF.one
.
scalar + vec
vec + scalar
In this form +
evaluates to the sum of the scalar scalar and the
vector vec, which must lie in a common field. The sum is a new vector
where each entry is the sum of the scalar and the corresponding entry of
the vector. As an exception it is also possible to add an integer scalar
to a finite field vector, in which case the integer is interpreted as
scalar * GF.one
.
gap> [ 1, 2, 3 ] + [ 1/2, 1/3, 1/4 ]; [ 3/2, 7/3, 13/4 ] gap> [ 1/2, 3/2, 1/2 ] + 1/2; [ 1, 2, 1 ]
vec1 - vec2
scalar - vec
vec - scalar
The difference operator -
returns the componentwise difference of its
two operands and is defined subject to the same restrictions as +
.
gap> [ 1, 2, 3 ] - [ 1/2, 1/3, 1/4 ]; [ 1/2, 5/3, 11/4 ] gap> [ 1/2, 3/2, 1/2 ] - 1/2; [ 0, 1, 0 ]
vec1 * vec2
In this form the multiplication operator *
evaluates to the product of
the two vectors vec1 and vec2, which must have the same dimension and
lie in a common field. The product is the sum of the products of the
corresponding entries of the vectors. As an exception it is also
possible to multiply an integer vector to a finite field vector, in which
case the integers are interpreted as scalar * GF.one
.
scalar * vec
vec * scalar
In this form *
evaluates to the product of the scalar scalar and the
vector vec, which must lie in a common field. The product is a new
vector where each entry is the product of the scalar and the
corresponding entry of the vector. As an exception it is also possible
to multiply an integer scalar to a finite field vector, in which case the
integer is interpreted as scalar * GF.one
.
gap> [ 1, 2, 3 ] * [ 1/2, 1/3, 1/4 ]; 23/12 gap> [ 1/2, 3/2, 1/2 ] * 2; [ 1, 3, 1 ]
Further operations with vectors as operands are defined by the matrix operations (see Operations for Matrices).
GAP 3.4.4