Row Vectors

Just as in mathematics, a vector in &GAP; is any object which supports appropriate addition and scalar multiplication operations (see Chapter ). As in mathematics, an especially important class of vectors are those represented by a list of coefficients with respect to some basis. These correspond roughly to the &GAP; concept of row vectors.

IsRowVector (Filter)
<#Include Label="IsRowVector">

Operators for Row Vectors

The rules for arithmetic operations involving row vectors are in fact special cases of those for the arithmetic of lists, as given in Section and the following sections, here we reiterate that definition, in the language of vectors.

Note that the additive behaviour sketched below is defined only for lists in the category , and the multiplicative behaviour is defined only for lists in the category .

addition
vec1 + vec2

returns the sum of the two row vectors vec1 and vec2. Probably the most usual situation is that vec1 and vec2 have the same length and are defined over a common field; in this case the sum is a new row vector over the same field where each entry is the sum of the corresponding entries of the vectors.

In more general situations, the sum of two row vectors need not be a row vector, for example adding an integer vector vec1 and a vector vec2 over a finite field yields the list of pointwise sums, which will be a mixture of finite field elements and integers if vec1 is longer than vec2.

addition
scalar + vec

vec + scalar

returns the sum of the scalar scalar and the row vector vec. Probably the most usual situation is that the elements of vec lie in a common field with scalar; in this case the sum is a new row vector over the same field where each entry is the sum of the scalar and the corresponding entry of the vector.

More general situations are for example the sum of an integer scalar and a vector over a finite field, or the sum of a finite field element and an integer vector.

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 ]

subtraction
subtraction
subtraction
vec1 - vec2

scalar - vec

vec - scalar

Subtracting a vector or scalar is defined as adding its additive inverse, so the statements for the addition hold likewise.

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 ]

multiplication
multiplication
scalar * vec

vec * scalar

returns the product of the scalar scalar and the row vector vec. Probably the most usual situation is that the elements of vec lie in a common field with scalar; in this case the product is a new row vector over the same field where each entry is the product of the scalar and the corresponding entry of the vector.

More general situations are for example the product of an integer scalar and a vector over a finite field, or the product of a finite field element and an integer vector.

gap> [ 1/2, 3/2, 1/2 ] * 2; [ 1, 3, 1 ]

multiplication
vec1 * vec2

returns the standard scalar product of vec1 and vec2, i.e., the sum of the products of the corresponding entries of the vectors. Probably the most usual situation is that vec1 and vec2 have the same length and are defined over a common field; in this case the sum is an element of this field.

More general situations are for example the inner product of an integer vector and a vector over a finite field, or the inner product of two row vectors of different lengths.

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

For the mutability of results of arithmetic operations, see .

Further operations with vectors as operands are defined by the matrix operations, see .

<#Include Label="NormedRowVector">

Row Vectors over Finite Fields

&GAP; can use compact formats to store row vectors over fields of order at most 256, based on those used by the Meat-Axe . This format also permits extremely efficient vector arithmetic. On the other hand element access and assignment is significantly slower than for plain lists.

The function is used to convert a list into a compressed vector, or to rewrite a compressed vector over another field. Note that this function is much faster when it is given a field (or field size) as an argument, rather than having to scan the vector and try to decide the field. Supplying the field can also avoid errors and/or loss of performance, when one vector from some collection happens to have all of its entries over a smaller field than the natural field of the problem.

<#Include Label="ConvertToVectorRep"> <#Include Label="NumberFFVector">

Coefficient List Arithmetic
<#Include Label="[1]{listcoef}"> <#Include Label="AddRowVector"> <#Include Label="AddCoeffs"> <#Include Label="MultRowVector"> <#Include Label="CoeffsMod">

Shifting and Trimming Coefficient Lists
<#Include Label="[3]{listcoef}"> <#Include Label="LeftShiftRowVector"> <#Include Label="RightShiftRowVector"> <#Include Label="ShrinkRowVector"> <#Include Label="RemoveOuterCoeffs">

Functions for Coding Theory
<#Include Label="[4]{listcoef}"> <#Include Label="WeightVecFFE"> <#Include Label="DistanceVecFFE"> <#Include Label="DistancesDistributionVecFFEsVecFFE"> <#Include Label="DistancesDistributionMatFFEVecFFE"> <#Include Label="AClosestVectorCombinationsMatFFEVecFFE"> <#Include Label="CosetLeadersMatFFE">

Vectors as coefficients of polynomials

A list of ring elements can be interpreted as a row vector or the list of coefficients of a polynomial. There are a couple of functions that implement arithmetic operations based on these interpretations. &GAP; contains proper support for polynomials (see ), the operations described in this section are on a lower level.

<#Include Label="[2]{listcoef}"> <#Include Label="ValuePol">

<#Include Label="ProductCoeffs"> <#Include Label="ReduceCoeffs"> <#Include Label="ReduceCoeffsMod"> <#Include Label="PowerModCoeffs"> <#Include Label="ShiftedCoeffs">