1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
|
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<!-- %% -->
<!-- %A vector.xml GAP documentation Martin Schönert -->
<!-- %A Alexander Hulpke -->
<!-- %% -->
<!-- %% -->
<!-- %Y (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland -->
<!-- %Y Copyright (C) 2002 The GAP Group -->
<!-- %% -->
<Chapter Label="Row Vectors">
<Heading>Row Vectors</Heading>
Just as in mathematics, a vector in &GAP; is any object which
supports appropriate addition and scalar multiplication operations
(see Chapter <Ref Chap="Vector Spaces"/>).
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 <E>row vectors</E>.
<!-- %% The basic design of the row vector support in &GAP; 4 is due to -->
<!-- %% Martin Schönert. Frank Celler added the special support for -->
<!-- %% vectors over the field of two elements; Steve Linton added special -->
<!-- %% support for vectors over fields of sizes between 3 and 256; and Werner -->
<!-- %% Nickel added special methods for vectors over large finite fields. -->
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="sect:IsRowVector">
<Heading>IsRowVector (Filter)</Heading>
<#Include Label="IsRowVector">
</Section>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Operators for Row Vectors">
<Heading>Operators for Row Vectors</Heading>
The rules for arithmetic operations involving row vectors are in fact
special cases of those for the arithmetic of lists,
as given in Section <Ref Sect="Arithmetic for Lists"/>
and the following sections,
here we reiterate that definition, in the language of vectors.
<P/>
Note that the additive behaviour sketched below is defined only for lists in
the category <Ref Filt="IsGeneralizedRowVector"/>,
and the multiplicative behaviour is defined only for lists in the category
<Ref Filt="IsMultiplicativeGeneralizedRowVector"/>.
<P/>
<Index Subkey="vectors">addition</Index>
<C><A>vec1</A> + <A>vec2</A></C>
<P/>
returns the sum of the two row vectors <A>vec1</A> and <A>vec2</A>.
Probably the most usual situation is that <A>vec1</A> and <A>vec2</A> 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.
<P/>
In more general situations, the sum of two row vectors need not be a row
vector, for example adding an integer vector <A>vec1</A> and a vector
<A>vec2</A> over a finite field yields the list of pointwise sums,
which will be a mixture of finite field elements and integers if <A>vec1</A>
is longer than <A>vec2</A>.
<P/>
<Index Subkey="vector and scalar">addition</Index>
<C><A>scalar</A> + <A>vec</A></C>
<P/>
<C><A>vec</A> + <A>scalar</A></C>
<P/>
returns the sum of the scalar <A>scalar</A> and the row vector <A>vec</A>.
Probably the most usual situation is that the elements of <A>vec</A> lie in a
common field with <A>scalar</A>;
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.
<P/>
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.
<P/>
<Example><![CDATA[
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 ]
]]></Example>
<P/>
<Index Subkey="vectors">subtraction</Index>
<Index Subkey="scalar and vector">subtraction</Index>
<Index Subkey="vector and scalar">subtraction</Index>
<C><A>vec1</A> - <A>vec2</A></C>
<P/>
<C><A>scalar</A> - <A>vec</A></C>
<P/>
<C><A>vec</A> - <A>scalar</A></C>
<P/>
Subtracting a vector or scalar is defined as adding its additive inverse,
so the statements for the addition hold likewise.
<P/>
<Example><![CDATA[
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 ]
]]></Example>
<P/>
<Index Subkey="scalar and vector">multiplication</Index>
<Index Subkey="vector and scalar">multiplication</Index>
<C><A>scalar</A> * <A>vec</A></C>
<P/>
<C><A>vec</A> * <A>scalar</A></C>
<P/>
returns the product of the scalar <A>scalar</A> and the row vector <A>vec</A>.
Probably the most usual situation is that the elements of <A>vec</A> lie in a
common field with <A>scalar</A>;
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.
<P/>
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.
<P/>
<Example><![CDATA[
gap> [ 1/2, 3/2, 1/2 ] * 2;
[ 1, 3, 1 ]
]]></Example>
<P/>
<Index Subkey="vectors">multiplication</Index>
<C><A>vec1</A> * <A>vec2</A></C>
<P/>
returns the standard scalar product of <A>vec1</A> and <A>vec2</A>,
i.e., the sum of the products of the corresponding entries of the vectors.
Probably the most usual situation is that <A>vec1</A> and <A>vec2</A> have
the same length and are defined over a common field;
in this case the sum is an element of this field.
<P/>
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.
<P/>
<Example><![CDATA[
gap> [ 1, 2, 3 ] * [ 1/2, 1/3, 1/4 ];
23/12
]]></Example>
<P/>
For the mutability of results of arithmetic operations,
see <Ref Sect="Mutability and Copyability"/>.
<P/>
Further operations with vectors as operands are defined by the matrix
operations, see <Ref Sect="Operators for Matrices"/>.
<#Include Label="NormedRowVector">
</Section>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Row Vectors over Finite Fields">
<Heading>Row Vectors over Finite Fields</Heading>
&GAP; can use compact formats to store row vectors over fields of
order at most 256, based on those used by the Meat-Axe
<Cite Key="Rin93"/>. This format also permits extremely efficient vector
arithmetic. On the other hand element access and assignment is
significantly slower than for plain lists.
<P/>
The function
<Ref Func="ConvertToVectorRep" Label="for a list (and a field)"/> is used to
convert a list into a compressed vector, or to rewrite a compressed vector
over another field.
Note that this function is <E>much</E> 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 <Q>natural</Q> field of the problem.
<#Include Label="ConvertToVectorRep">
<#Include Label="ImmutableVector">
<#Include Label="NumberFFVector">
</Section>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Coefficient List Arithmetic">
<Heading>Coefficient List Arithmetic</Heading>
<#Include Label="[1]{listcoef}">
<#Include Label="AddRowVector">
<#Include Label="AddCoeffs">
<#Include Label="MultVector">
<#Include Label="CoeffsMod">
</Section>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Shifting and Trimming Coefficient Lists">
<Heading>Shifting and Trimming Coefficient Lists</Heading>
<#Include Label="[3]{listcoef}">
<#Include Label="LeftShiftRowVector">
<#Include Label="RightShiftRowVector">
<#Include Label="ShrinkRowVector">
<#Include Label="RemoveOuterCoeffs">
</Section>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Functions for Coding Theory">
<Heading>Functions for Coding Theory</Heading>
<#Include Label="[4]{listcoef}">
<#Include Label="WeightVecFFE">
<#Include Label="DistanceVecFFE">
<#Include Label="DistancesDistributionVecFFEsVecFFE">
<#Include Label="DistancesDistributionMatFFEVecFFE">
<#Include Label="AClosestVectorCombinationsMatFFEVecFFE">
<#Include Label="CosetLeadersMatFFE">
</Section>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Vectors as coefficients of polynomials">
<Heading>Vectors as coefficients of polynomials</Heading>
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 <Ref Chap="Polynomials and Rational Functions"/>), the
operations described in this section are on a lower level.
<P/>
<#Include Label="[2]{listcoef}">
<#Include Label="ValuePol">
<!-- %\ Declaration{MultCoeffs} -->
<!-- %\ beginexample -->
<!-- %gap> a:=[];;l:=[1,2,3,4];;m:=[5,6,7];; -->
<!-- %gap> MultCoeffs(a,l,4,m,3); -->
<!-- %6 -->
<!-- %gap> a; -->
<!-- %[ 5, 16, 34, 52, 45, 28 ] -->
<!-- %\ endexample -->
<#Include Label="ProductCoeffs">
<#Include Label="ReduceCoeffs">
<#Include Label="ReduceCoeffsMod">
<#Include Label="PowerModCoeffs">
<#Include Label="ShiftedCoeffs">
</Section>
</Chapter>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<!-- %% -->
<!-- %E -->
|