23.1 Operators for Row Vectors

The rules for arithmetic operations between row vectors, are in fact the same as those for the arithmetic of lists, given in part in section Arithmetic for Lists, here we reiterate and complete that definition, in the language of vectors.

  • vec1 + vec2 O

    returns the sum of the two vectors vec1 and vec2, which must have the same length and be defined over 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 vector over the finite field F, in which case the integers are interpreted as scalar * One(F).

  • scalar + vec O
  • vec + scalar O

    returns a new vector where each entry is the sum of the scalar and the corresponding entry of the vector. The elements of vec must lie in a common field with scalar. As an exception it is also possible to add an integer scalar to a vector over the finite field F, in which case the integer is interpreted as scalar * One(F).

    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 O
  • scalar - vec O
  • vec - scalar O

    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 O

    returns the standard scalar product of vec1 and vec2, which must both have the same length and take their entries from the same field. As remarked above, the system only provides a general method for the case where the vectors lie in IsRingElementList. 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 * One(GF).

  • scalar * vec O
  • vec * scalar O

    returns the product of scalar and vector. The elements of vec must lie in a common field with scalar. 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 * One(GF).

    gap> [ 1, 2, 3 ] * [ 1/2, 1/3, 1/4 ];
    23/12
    gap> [ 1/2, 3/2, 1/2 ] * 2;
    [ 1, 3, 1 ]
    

    For the mutability of results of arithmetic operations, see Mutability and Copyability.

    Further operations with vectors as operands are defined by the matrix operations (see Operators for Matrices).

  • NormedRowVector( v ) A

    returns a scalar multiple w = c * v of the row vector v with the property that the first nonzero entry of w is an identity element in the sense of IsOne.

    gap> NormedRowVector([5,2,3]);
    [ 1, 2/5, 3/5 ]
    

    [Top] [Up] [Next] [Index]

    GAP 4 manual
    February 2000