diff --git a/doc/ref/obsolete.xml b/doc/ref/obsolete.xml
index 3a11e45ecd..78542d4319 100644
--- a/doc/ref/obsolete.xml
+++ b/doc/ref/obsolete.xml
@@ -174,6 +174,10 @@ Here are some further name changes.
- MutableNullMat
+
+ - MultRowVector
+
+
@@ -185,6 +189,11 @@ Instead of PositionFirstComponent(list,obj), you may use
PositionProperty(list,x->x[1]=obj) as a replacement, depending on
your specific use case.
+MultRowVector
+The five argument version of the operation MultRowVector has been
+deprecated in GAP 4.8 since it was unused and only available for coefficient
+lists.
+Note that MultRowVector was also renamed to MultVectorLeft.
diff --git a/doc/ref/vector.xml b/doc/ref/vector.xml
index fd336ebd96..7afeb6c600 100644
--- a/doc/ref/vector.xml
+++ b/doc/ref/vector.xml
@@ -190,7 +190,7 @@ than the natural
field of the problem.
<#Include Label="[1]{listcoef}">
<#Include Label="AddRowVector">
<#Include Label="AddCoeffs">
-<#Include Label="MultRowVector">
+<#Include Label="MultVector">
<#Include Label="CoeffsMod">
diff --git a/hpcgap/lib/ffeconway.gi b/hpcgap/lib/ffeconway.gi
index c69fbbca15..3d5637dadb 100644
--- a/hpcgap/lib/ffeconway.gi
+++ b/hpcgap/lib/ffeconway.gi
@@ -950,7 +950,7 @@ InstallMethod(InverseOp,
s := t;
od;
Assert(1,Length(a) = 1);
- MultRowVector(r,Inverse(a[1]));
+ MultVector(r,Inverse(a[1]));
if AssertionLevel() >= 2 then
t := ProductCoeffs(x![1],r);
fam!.ConwayFldEltReducers[d](t);
diff --git a/hpcgap/lib/polyrat.gi b/hpcgap/lib/polyrat.gi
index 614de28a49..b035c2ab0e 100644
--- a/hpcgap/lib/polyrat.gi
+++ b/hpcgap/lib/polyrat.gi
@@ -563,7 +563,7 @@ local fam,gcd, u, v, w, val, r, s;
od;
#gcd := u * (a/u[Length(u)]);
gcd:=u;
- MultRowVector(gcd,a/u[Length(u)]);
+ MultVector(gcd,a/u[Length(u)]);
ReduceCoeffsMod(gcd,p);
# and return the polynomial
@@ -933,19 +933,19 @@ BindGlobal("RPGcdRepresentationModPrime",function(R,f,g,p)
# convert and back into polynomials
if 0 = Length(g) then
#sx := q * sx;
- MultRowVector(sx,q);
+ MultVector(sx,q);
ReduceCoeffsMod(sx,p);
return [ LaurentPolynomialByCoefficients(brci[1],sx,0,brci[2]),
Zero(brci[1]) ];
else
#hx := q * sx;
hx:=ShallowCopy(sx);
- MultRowVector(hx,q);
+ MultVector(hx,q);
ReduceCoeffsMod(hx,p);
hx := LaurentPolynomialByCoefficients(brci[1],hx,0,brci[2]);
AddCoeffs(s,ProductCoeffs(sx,f),-1);
#s := q * s;
- MultRowVector(s,q);
+ MultVector(s,q);
ReduceCoeffsMod(s,p);
s := LaurentPolynomialByCoefficients(brci[1],s,0,brci[2]);
g := LaurentPolynomialByCoefficients(brci[1],g,0,brci[2]);
diff --git a/hpcgap/lib/vec8bit.gi b/hpcgap/lib/vec8bit.gi
index b116eecfd2..d393cf6b41 100644
--- a/hpcgap/lib/vec8bit.gi
+++ b/hpcgap/lib/vec8bit.gi
@@ -592,15 +592,15 @@ InstallOtherMethod( AddRowVector, "For 2 8 bit vectors",
#############################################################################
##
-#M MultRowVector( , )
+#M MultVector( , )
##
## multiply by in place
##
-InstallOtherMethod( MultRowVector, "For an 8 bit vector and an ffe",
+InstallOtherMethod( MultVector, "For an 8 bit vector and an ffe",
IsCollsElms, [ IsRowVector and Is8BitVectorRep,
IsFFE and IsInternalRep], 0,
- MULT_ROWVECTOR_VEC8BITS);
+ MULT_VECTOR_VEC8BITS);
#############################################################################
##
diff --git a/hpcgap/lib/vecmat.gi b/hpcgap/lib/vecmat.gi
index f1fe2e3cd8..f52f82e8f0 100644
--- a/hpcgap/lib/vecmat.gi
+++ b/hpcgap/lib/vecmat.gi
@@ -1795,13 +1795,13 @@ end);
#############################################################################
##
-#M MultRowVector( , )
+#M MultVector( , )
##
-InstallOtherMethod( MultRowVector, "for GF(2) vector and char 2 scalar",
+InstallOtherMethod( MultVector, "for GF(2) vector and char 2 scalar",
IsCollsElms, [IsGF2VectorRep and IsRowVector and IsMutable,
IsFFE], 0,
- MULT_ROW_VECTOR_GF2VECS_2);
+ MULT_VECTOR_GF2VECS_2);
#############################################################################
##
@@ -2360,7 +2360,7 @@ InstallMethod( Randomize, "for a mutable gf2 vector",
[ IsGF2VectorRep and IsMutable ],
function( v )
local i;
- MultRowVector(v,0);
+ MultVector(v,0);
for i in [1..Length(v)] do
if Random(0,1) = 1 then v[i] := Z(2); fi;
od;
@@ -2370,7 +2370,7 @@ InstallMethod( Randomize, "for a mutable gf2 vector and a random source",
[ IsGF2VectorRep and IsMutable, IsRandomSource ],
function( v, rs )
local i;
- MultRowVector(v,0);
+ MultVector(v,0);
for i in [1..Length(v)] do
if Random(rs,0,1) = 1 then v[i] := Z(2); fi;
od;
diff --git a/hpcgap/lib/vspcrow.gi b/hpcgap/lib/vspcrow.gi
index cea336bb51..297ca1fc46 100644
--- a/hpcgap/lib/vspcrow.gi
+++ b/hpcgap/lib/vspcrow.gi
@@ -1570,7 +1570,7 @@ InstallMethod( CloseMutableBasis,
# If necessary add the sifted vector, and update the basis info.
j := PositionNot( v, zero );
if j <= ncols then
- MultRowVector( v, Inverse( v[j] ) );
+ MultVector( v, Inverse( v[j] ) );
Add( basisvectors, v );
heads[j]:= Length( basisvectors );
fi;
diff --git a/lib/claspcgs.gi b/lib/claspcgs.gi
index 88f691b09e..1dfa73bb47 100644
--- a/lib/claspcgs.gi
+++ b/lib/claspcgs.gi
@@ -208,7 +208,7 @@ local classes, # classes to be constructed, the result
if IsIdenticalObj( FamilyObj( U ), FamilyObj( cl.candidates ) ) then
for c in cl.candidates do
exp:=ExponentsOfPcElement( N, LeftQuotient( h, c ) );
- MultRowVector( exp, One( field ) );
+ MultVector( exp, One( field ) );
w:=exp * N!.subspace.projection;
exp{ N!.subspace.baseComplement }:=
exp{ N!.subspace.baseComplement }-w;
diff --git a/lib/ffeconway.gi b/lib/ffeconway.gi
index 122721a29d..7d4e1b070d 100644
--- a/lib/ffeconway.gi
+++ b/lib/ffeconway.gi
@@ -915,7 +915,7 @@ InstallMethod(InverseOp,
s := t;
od;
Assert(1,Length(a) = 1);
- MultRowVector(r,Inverse(a[1]));
+ MultVector(r,Inverse(a[1]));
if AssertionLevel() >= 2 then
t := ProductCoeffs(x![1],r);
fam!.ConwayFldEltReducers[d](t);
diff --git a/lib/grpffmat.gi b/lib/grpffmat.gi
index cc072ae035..f7c7e0630b 100644
--- a/lib/grpffmat.gi
+++ b/lib/grpffmat.gi
@@ -502,7 +502,7 @@ InstallMethod( Random,
local m;
m:= RandomInvertibleMat( DimensionOfMatrixGroup( G ),
FieldOfMatrixGroup( G ) );
- MultRowVector(m[1], DeterminantMat(m)^-1);
+ MultVector(m[1], DeterminantMat(m)^-1);
MakeImmutable(m);
ConvertToMatrixRep(m, FieldOfMatrixGroup(G));
return m;
diff --git a/lib/listcoef.gd b/lib/listcoef.gd
index 8188b21262..717e223c4c 100644
--- a/lib/listcoef.gd
+++ b/lib/listcoef.gd
@@ -97,30 +97,29 @@ DeclareOperation(
#############################################################################
##
-#O MultRowVector( , , , , )
-#O MultRowVector( , )
+#O MultVectorLeft( , )
##
-## <#GAPDoc Label="MultRowVector">
+## <#GAPDoc Label="MultVector">
##
-##
+##
+##
+## nothing
##
##
-## The five argument version of this operation replaces
-## list1[poss1[i]] by
-## mul*list2[poss2[i]] for i
-## between 1 and Length( poss1 ).
+## This operation calculates mul*list1 in-place.
##
-## The two-argument version simply multiplies each element of list1,
-## in-place, by mul.
+## Note that MultVector is just a synonym for
+## MultVectorLeft.
##
##
## <#/GAPDoc>
##
DeclareOperation(
- "MultRowVector",
- [ IsMutable and IsList,
- IsList, IsList, IsList, IsMultiplicativeElement ] );
-
+ "MultVectorLeft",
+ [ IsMutable and IsList,
+ IsObject ] );
+# For VectorObj objects there also exists a MultVectorRight operation
+DeclareSynonym( "MultVector", MultVectorLeft );
#############################################################################
##
diff --git a/lib/listcoef.gi b/lib/listcoef.gi
index 11f0f9448b..521e64d972 100644
--- a/lib/listcoef.gi
+++ b/lib/listcoef.gi
@@ -262,73 +262,44 @@ end );
#############################################################################
##
-#M MultRowVector( , , , , )
+#M MultVectorLeft( , )
##
-InstallMethod( MultRowVector,"generic method",
- true,
- [ IsDenseList and IsMutable,
- IsDenseList,
- IsDenseList,
- IsDenseList,
- IsMultiplicativeElement ],
- 0,
-
-function( l1, p1, l2, p2, m )
- l1{p1} := m * l2{p2};
-end );
-
-InstallOtherMethod( MultRowVector,"error if immutable",true,
- [ IsList,IsObject,IsObject,IsObject,IsObject],0,
- L1_IMMUTABLE_ERROR);
-
-#############################################################################
-##
-#M MultRowVector( , )
-##
-InstallOtherMethod( MultRowVector,
- "two argument generic method",
- true,
+InstallMethod( MultVectorLeft,
+ "for a mutable dense list, and an object",
[ IsDenseList and IsMutable,
- IsMultiplicativeElement ],
- 0,
-
+ IsObject ],
function( l, m )
local i;
-
for i in [ 1 .. Length(l) ] do
l[i] := m * l[i];
od;
end );
-
-InstallOtherMethod( MultRowVector,"error if immutable",true,
- [ IsList,IsObject],0,
+InstallOtherMethod( MultVectorLeft, "error if immutable",
+ [ IsList, IsObject ],
L1_IMMUTABLE_ERROR);
-InstallOtherMethod( MultRowVector,
- "Two argument kernel method for small list",
+InstallMethod( MultVectorLeft,
+ "kernel method for a mutable dense small list, and an object",
IsCollsElms,
[ IsSmallList and IsDenseList and IsMutable,
- IsMultiplicativeElement ],
- 0,
- MULT_ROW_VECTOR_2
+ IsObject ],
+ MULT_VECTOR_LEFT_2
);
-
-InstallOtherMethod( MultRowVector,
- "Two argument kernel method for plain list of cyclotomics and an integer",
+InstallMethod( MultVectorLeft,
+ "kernel method for a mutable dense plain list of \
+cyclotomics, and a cyclotomic",
IsCollsElms,
- [ IsSmallList and IsDenseList and IsMutable and IsPlistRep and
- IsCyclotomicCollection,
+ [ IsDenseList and IsMutable and IsPlistRep and IsCyclotomicCollection,
IsCyclotomic ],
- 0,
- MULT_ROW_VECTOR_2_FAST
+ MULT_VECTOR_2_FAST
);
-
-InstallOtherMethod( MultRowVector,
- "kernel method for vecffe (2 args)",
- IsCollsElms,
- [ IsRowVector and IsMutable and IsPlistRep and IsFFECollection,
- IsFFE],0,
- MULT_ROWVECTOR_VECFFES );
+InstallMethod( MultVectorLeft,
+ "kernel method for a mutable row vector of ffes in \
+plain list rep, and an ffe",
+ IsCollsElms,
+ [ IsRowVector and IsMutable and IsPlistRep and IsFFECollection,
+ IsFFE],0,
+ MULT_VECTOR_VECFFES );
#############################################################################
diff --git a/lib/matobj.gi b/lib/matobj.gi
index f53d9426b8..3e117bbe47 100644
--- a/lib/matobj.gi
+++ b/lib/matobj.gi
@@ -568,6 +568,51 @@ InstallMethod( Randomize,
od;
end );
+############################################################################
+# Arithmetical operations:
+############################################################################
+InstallMethod( MultVectorLeft,
+ "generic method for a mutable vector, and an object",
+ [ IsVectorObj and IsMutable, IsObject ],
+ function( v, s )
+ local i;
+ for i in [1 .. Length(v)] do
+ v[i] := s * v[i];
+ od;
+ end );
+
+InstallMethod( MultVectorRight,
+ "generic method for a mutable vector, and an object",
+ [ IsVectorObj and IsMutable, IsObject ],
+ function( v, s )
+ local i;
+ for i in [1 .. Length(v)] do
+ v[i] := v[i] * s;
+ od;
+ end );
+
+InstallMethod( MultVectorLeft,
+ "generic method for a mutable vector, an object, an int, \
+and an int",
+ [ IsVectorObj and IsMutable, IsObject, IsInt, IsInt ],
+ function( v, s, from, to )
+ local i;
+ for i in [from .. to] do
+ v[i] := s * v[i];
+ od;
+ end );
+
+InstallMethod( MultVectorRight,
+ "generic method for a mutable vector, an object, an int, \
+and an int",
+ [ IsVectorObj and IsMutable, IsObject, IsInt, IsInt ],
+ function( v, s, from, to )
+ local i;
+ for i in [from .. to] do
+ v[i] := v[i] * s;
+ od;
+ end );
+
#
# Compatibility code: Install MatrixObj methods for IsMatrix.
#
diff --git a/lib/matobj2.gd b/lib/matobj2.gd
index 619c0d176f..ba9c808c5e 100644
--- a/lib/matobj2.gd
+++ b/lib/matobj2.gd
@@ -382,25 +382,48 @@ DeclareOperation( "AddRowVector",
-# TODO: rename MultRowVector to MultVector; but keep in mind that
-# historically there already was MultRowVector, so be careful to not break that
-DeclareOperation( "MultRowVector",
+#############################################################################
+##
+#O MultVector( , [, , ] )
+#O MultVectorLeft( , [, , ] )
+#O MultVectorRight( , [, , ] )
+##
+## <#GAPDoc Label="MatObj_MultVectorLeft">
+##
+##
+##
+##
+## nothing
+##
+##
+## These operations multiply mul with vec in-place
+## where MultVectorLeft multiplies with mul from the left
+## and MultVectorRight does so from the right.
+##
+## Note that MultVector is just a synonym for
+## MultVectorLeft.
+##
+## If the optional parameters from and to are given only the
+## index range [from..to] is guaranteed to be
+## affected. Other indices may be affected, if it is more convenient
+## to do so.
+## This can be helpful if entries of vec are known to be zero.
+##
+## If from is bigger than to, the operation does nothing.
+##
+##
+## <#/GAPDoc>
+##
+DeclareOperation( "MultVectorLeft",
[ IsVectorObj and IsMutable, IsObject ] );
-
-#
-# Also, make it explicit from which side we multiply
-# DeclareOperation( "MultRowVectorFromLeft",
-# [ IsVectorObj and IsMutable, IsObject ] );
-# DeclareOperation( "MultRowVectorFromRight",
-# [ IsVectorObj and IsMutable, IsObject ] );
-#DeclareSynonym( "MultRowVector", MultRowVectorFromRight );
-
-# do we really need the following? for what? is any code using this right now?
-# ( a, pa, b, pb, s ) -> a{pa} := b{pb} * s;
-DeclareOperation( "MultRowVector",
- [ IsVectorObj and IsMutable, IsList, IsVectorObj, IsList, IsObject ] );
-
-# maybe have this: vec := vec{[from..to]} * scal ?? cvec has it
+DeclareOperation( "MultVectorRight",
+ [ IsVectorObj and IsMutable, IsObject ] );
+DeclareOperation( "MultVectorLeft",
+ [ IsVectorObj and IsMutable, IsObject, IsInt, IsInt ] );
+DeclareOperation( "MultVectorRight",
+ [ IsVectorObj and IsMutable, IsObject, IsInt, IsInt ] );
+# Note that MultVector is declared a synonym for MultVectorLeft in
+# listcoef.gd
# The following operations for scalars and vectors are possible for scalars in the BaseDomain
@@ -578,7 +601,7 @@ DeclareOperation( "Randomize", [IsVectorObj and IsMutable,IsRandomSource] );
##
## TODO: link to ExtractSubVector
##
-## TODO: In AddRowVector and MultRowVector, the destination is always the first argument;
+## TODO: In AddRowVector and MultVector, the destination is always the first argument;
## it would be better if we were consistent...
##
## TODO: Maybe also have a version of this as follows:
diff --git a/lib/matobjplist.gi b/lib/matobjplist.gi
index 7cca5603ed..efd8efd3e3 100644
--- a/lib/matobjplist.gi
+++ b/lib/matobjplist.gi
@@ -415,30 +415,29 @@ InstallMethod( AddRowVector,
fi;
end );
-InstallMethod( MultRowVector, "for a plist vector, and a scalar",
+InstallMethod( MultVectorLeft,
+ "for a plist vector, and an object",
[ IsPlistVectorRep and IsMutable, IsObject ],
function( v, s )
- MULT_ROW_VECTOR_2(v![ELSPOS],s);
+ MULT_VECTOR_LEFT_2(v![ELSPOS],s);
end );
-InstallMethod( MultRowVector, "for a plist vector, and a scalar",
- [ IsPlistVectorRep and IsIntVector and IsMutable, IsObject ],
+InstallMethod( MultVectorRight,
+ "for a plist vector, and an object",
+ [ IsPlistVectorRep and IsMutable, IsObject ],
function( v, s )
- if IsSmallIntRep(s) then
- MULT_ROW_VECTOR_2_FAST(v![ELSPOS],s);
- else
- MULT_ROW_VECTOR_2(v![ELSPOS],s);
- fi;
+ MULT_VECTOR_RIGHT_2(v![ELSPOS],s);
end );
-InstallMethod( MultRowVector,
- "for a plist vector, a list, a plist vector, a list, and a scalar",
- [ IsPlistVectorRep and IsMutable, IsList,
- IsPlistVectorRep, IsList, IsObject ],
- function( a, pa, b, pb, s )
- a![ELSPOS]{pa} := b![ELSPOS]{pb} * s;
+InstallOtherMethod( MultVectorLeft, "for an integer vector, and a small integer",
+ [ IsPlistVectorRep and IsIntVector and IsMutable, IsSmallIntRep ],
+ function( v, s )
+ MULT_VECTOR_2_FAST(v![ELSPOS],s);
end );
+# The four argument version of MultVectorLeft / ..Right uses the generic
+# implementation in matobj.gi
+
InstallMethod( \*, "for a plist vector and a scalar",
[ IsPlistVectorRep, IsScalar ],
function( v, s )
diff --git a/lib/matrix.gi b/lib/matrix.gi
index f95d23feee..83a8e6d06e 100644
--- a/lib/matrix.gi
+++ b/lib/matrix.gi
@@ -410,10 +410,10 @@ BindGlobal( "Matrix_OrderPolynomialInner", function( fld, mat, vec, vecs)
if piv <=d then
x := Inverse(w[piv]);
- MultRowVector(p, x);
+ MultVector(p, x);
MakeImmutable(p);
pols[piv] := p;
- MultRowVector(w, x );
+ MultVector(w, x );
MakeImmutable(w);
vecs[piv] := w;
vec := vec*mat;
@@ -537,7 +537,7 @@ BindGlobal( "Matrix_MinimalPolynomialSameField", function( fld, mat, ind )
piv := PositionNonZero(w, piv);
until piv > n or not IsBound(base[piv]);
if piv <= n then
- MultRowVector(w,Inverse(w[piv]));
+ MultVector(w,Inverse(w[piv]));
MakeImmutable(w);
base[piv] := w;
dim := dim+1;
@@ -1347,11 +1347,11 @@ InstallMethod( DeterminantMatDestructive,
row2 := mat[j];
mult := -row2[k];
if mult <> zero then
- MultRowVector( row2, piv );
+ MultVector( row2, piv );
AddRowVector( row2, row, mult, k, m );
- MultRowVector( row2, Inverse(det) );
+ MultVector( row2, Inverse(det) );
else
- MultRowVector( row2, piv/det);
+ MultVector( row2, piv/det);
fi;
od;
@@ -1429,7 +1429,7 @@ function( mat )
# ... and normalize the row.
x := row[k];
det := det * x;
- MultRowVector( mat[k], Inverse(x) );
+ MultVector( mat[k], Inverse(x) );
# clear all entries in this column, adjust only columns > k
# (Note that we need not clear the rows from 'k+1' to 'j'.)
@@ -1703,11 +1703,11 @@ local R,M,transform,divide,swaprow, swapcol, addcol, addrow, multcol, multrow, l
end;
multrow:=function(a,m)
- MultRowVector(M[a],m);
+ MultVector(M[a],m);
if transform then
- MultRowVector(left[a],m);
+ MultVector(left[a],m);
if basmat<>fail then
- MultRowVector(basmat[a],1/m);
+ MultVector(basmat[a],1/m);
fi;
fi;
end;
@@ -2304,7 +2304,7 @@ InstallMethod( SemiEchelonMatDestructive,
if inv = fail then
return fail;
fi;
- MultRowVector( row, inv );
+ MultVector( row, inv );
Add( vectors, row );
Add( nzheads, j );
heads[j]:= Length( vectors );
@@ -2952,7 +2952,7 @@ InstallMethod( TriangulizeMat,
if x = fail then
TryNextMethod();
fi;
- MultRowVector( row, x );
+ MultVector( row, x );
mat[i] := row;
# clear all entries in this column
diff --git a/lib/meataxe.gi b/lib/meataxe.gi
index a3f9007f64..bf21d27c82 100644
--- a/lib/meataxe.gi
+++ b/lib/meataxe.gi
@@ -420,7 +420,7 @@ SMTX_SpinnedBasis:=function( arg )
subdim:=subdim + 1;
leadpos[subdim]:=j;
#w:=(w[j]^-1) * w;
- MultRowVector(w,w[j]^-1);
+ MultVector(w,w[j]^-1);
Add( ans, w );
if subdim = dim then
ans:=ImmutableMatrix(F,ans);
diff --git a/lib/obsolete.gd b/lib/obsolete.gd
index 3ca4e7a874..84b5b2bdbc 100644
--- a/lib/obsolete.gd
+++ b/lib/obsolete.gd
@@ -529,6 +529,33 @@ end);
## still used by GAPDoc (01/2016)
DeclareOperation( "PositionFirstComponent", [IsList,IsObject] );
+#############################################################################
+##
+#O MultRowVector( , , , , )
+##
+## <#GAPDoc Label="MultRowVector_Obsolete">
+##
+##
+## nothing
+##
+##
+## The two argument version of this operation is an obsolete synonym for
+## MultVectorLeft, which calculates mul*list1 in-place.
+## New code should use MultVectorLeft or its synonym
+## MultVector instead.
+##
+## The five argument version of this operation is kept for compatibility
+## with older versions of &GAP; and will be removed eventually.
+## It replaces
+## list1[poss1[i]] by
+## mul*list2[poss2[i]] for i
+## between 1 and Length( poss1 ).
+##
+##
+## <#/GAPDoc>
+##
+DeclareObsoleteSynonym( "MultRowVector", "MultVector" );
+
#############################################################################
##
#O ReadTest
diff --git a/lib/obsolete.gi b/lib/obsolete.gi
index dd969594fd..1c42ae203f 100644
--- a/lib/obsolete.gi
+++ b/lib/obsolete.gi
@@ -168,7 +168,7 @@ InstallGlobalFunction( DiagonalizeIntMatNormDriven, function ( mat )
mat{[d..nrrows]}[pivl] := col;
fi;
if mat[d][d] < 0 then
- MultRowVector(mat[d],-1);
+ MultVector(mat[d],-1);
fi;
# now perform row operations so that the entries in the
@@ -252,7 +252,7 @@ InstallGlobalFunction( DiagonalizeIntMatNormDriven, function ( mat )
mat{[d..nrrows]}[pivl] := col;
fi;
if mat[d][d] < 0 then
- MultRowVector(mat[d],-1);
+ MultVector(mat[d],-1);
fi;
# now perform row operations so that the entries in the
@@ -877,6 +877,28 @@ local lo,up,s;
# fi;
end );
+#############################################################################
+##
+#M MultVector( , , , , )
+##
+InstallOtherMethod( MultVector, "obsolete five argument method",
+ true,
+ [ IsDenseList and IsMutable,
+ IsDenseList,
+ IsDenseList,
+ IsDenseList,
+ IsObject ],
+ 0,
+function( l1, p1, l2, p2, m )
+ InfoObsolete(1, "This usage of `MultVector` is no longer",
+ "supported and will be removed eventually." );
+ l1{p1} := m * l2{p2};
+end );
+
+InstallOtherMethod( MultVector, "error if immutable", true,
+ [ IsList,IsObject,IsObject,IsObject,IsObject],0,
+ L1_IMMUTABLE_ERROR);
+
#############################################################################
##
#F SetUserPreferences
diff --git a/lib/onecohom.gi b/lib/onecohom.gi
index 3e79fb5f8b..c9d924ea28 100644
--- a/lib/onecohom.gi
+++ b/lib/onecohom.gi
@@ -1238,14 +1238,14 @@ local cobounds,cocycles, # base of one coboundaries and cocycles
Append(RS,OCSmallEquationMatrix(ocr,rels[i],g));
od;
RR:=OCSmallEquationVector(ocr,rels[i]);
- MultRowVector(RR,-One(ocr.field));
+ MultVector(RR,-One(ocr.field));
else
for g in gens do
Append(RS,OCEquationMatrix(ocr,rels[i],g));
od;
RR:=OCEquationVector(ocr,rels[i]);
- MultRowVector(RR,-One(ocr.field));
+ MultVector(RR,-One(ocr.field));
fi;
diff --git a/lib/polyrat.gi b/lib/polyrat.gi
index df4edad824..5ec054c0e2 100644
--- a/lib/polyrat.gi
+++ b/lib/polyrat.gi
@@ -551,7 +551,7 @@ local fam,gcd, u, v, w, val, r, s;
od;
#gcd := u * (a/u[Length(u)]);
gcd:=u;
- MultRowVector(gcd,a/u[Length(u)]);
+ MultVector(gcd,a/u[Length(u)]);
ReduceCoeffsMod(gcd,p);
# and return the polynomial
@@ -921,19 +921,19 @@ BindGlobal("RPGcdRepresentationModPrime",function(R,f,g,p)
# convert and back into polynomials
if 0 = Length(g) then
#sx := q * sx;
- MultRowVector(sx,q);
+ MultVector(sx,q);
ReduceCoeffsMod(sx,p);
return [ LaurentPolynomialByCoefficients(brci[1],sx,0,brci[2]),
Zero(brci[1]) ];
else
#hx := q * sx;
hx:=ShallowCopy(sx);
- MultRowVector(hx,q);
+ MultVector(hx,q);
ReduceCoeffsMod(hx,p);
hx := LaurentPolynomialByCoefficients(brci[1],hx,0,brci[2]);
AddCoeffs(s,ProductCoeffs(sx,f),-1);
#s := q * s;
- MultRowVector(s,q);
+ MultVector(s,q);
ReduceCoeffsMod(s,p);
s := LaurentPolynomialByCoefficients(brci[1],s,0,brci[2]);
g := LaurentPolynomialByCoefficients(brci[1],g,0,brci[2]);
diff --git a/lib/sparsevectorsorted.gi b/lib/sparsevectorsorted.gi
index b15804a25c..5d4a7d60b5 100644
--- a/lib/sparsevectorsorted.gi
+++ b/lib/sparsevectorsorted.gi
@@ -74,7 +74,7 @@ InstallGlobalFunction(SparseVectorBySortedList, function(arg)
return l;
end);
-## AddRowVector, MultRowVector
+## AddRowVector, MultVector
## products with scalars, scalar product, AddCoeffs, MultCoeffs,
## more coeffs functions
## maybe product with matrices
@@ -267,9 +267,9 @@ InstallMethod(DIFF, [IsSparseRowVector and IsSparseListBySortedListRep, IsSparse
function(v1,v2) return SUM(v1, AINV(v2)); end);
-InstallOtherMethod( MultRowVector, [IsSparseRowVector and IsSparseListBySortedListRep and IsMutable, IsMultiplicativeElement],
+InstallOtherMethod( MultVector, [IsSparseRowVector and IsSparseListBySortedListRep and IsMutable, IsMultiplicativeElement],
function(v,x)
- MultRowVector(v![SL_VALS],x);
+ MultVector(v![SL_VALS],x);
end);
InstallMethod( \*, [IsSparseRowVector and IsSparseListBySortedListRep, IsMultiplicativeElement],
diff --git a/lib/vec8bit.gi b/lib/vec8bit.gi
index 62599ddad6..7c02f62185 100644
--- a/lib/vec8bit.gi
+++ b/lib/vec8bit.gi
@@ -573,15 +573,15 @@ InstallOtherMethod( AddRowVector, "For 2 8 bit vectors",
#############################################################################
##
-#M MultRowVector( , )
+#M MultVector( , )
##
## multiply by in place
##
-InstallOtherMethod( MultRowVector, "For an 8 bit vector and an ffe",
+InstallOtherMethod( MultVector, "For an 8 bit vector and an ffe",
IsCollsElms, [ IsRowVector and Is8BitVectorRep,
IsFFE and IsInternalRep], 0,
- MULT_ROWVECTOR_VEC8BITS);
+ MULT_VECTOR_VEC8BITS);
#############################################################################
##
diff --git a/lib/vecmat.gi b/lib/vecmat.gi
index 0790f66343..46826ed467 100644
--- a/lib/vecmat.gi
+++ b/lib/vecmat.gi
@@ -1590,13 +1590,13 @@ end);
#############################################################################
##
-#M MultRowVector( , )
+#M MultVector( , )
##
-InstallOtherMethod( MultRowVector, "for GF(2) vector and char 2 scalar",
+InstallOtherMethod( MultVector, "for GF(2) vector and char 2 scalar",
IsCollsElms, [IsGF2VectorRep and IsRowVector and IsMutable,
IsFFE], 0,
- MULT_ROW_VECTOR_GF2VECS_2);
+ MULT_VECTOR_GF2VECS_2);
#############################################################################
##
@@ -2155,7 +2155,7 @@ InstallMethod( Randomize, "for a mutable gf2 vector",
[ IsGF2VectorRep and IsMutable ],
function( v )
local i;
- MultRowVector(v,0);
+ MultVector(v,0);
for i in [1..Length(v)] do
if Random(0,1) = 1 then v[i] := Z(2); fi;
od;
@@ -2165,7 +2165,7 @@ InstallMethod( Randomize, "for a mutable gf2 vector and a random source",
[ IsGF2VectorRep and IsMutable, IsRandomSource ],
function( v, rs )
local i;
- MultRowVector(v,0);
+ MultVector(v,0);
for i in [1..Length(v)] do
if Random(rs,0,1) = 1 then v[i] := Z(2); fi;
od;
diff --git a/lib/vspcmat.gi b/lib/vspcmat.gi
index f4a5f99021..6068c5fa1f 100644
--- a/lib/vspcmat.gi
+++ b/lib/vspcmat.gi
@@ -1072,7 +1072,7 @@ InstallMethod( CloseMutableBasis,
if j <= n then
scalar:= Inverse( v[i][j] );
for k in [ 1 .. m ] do
- MultRowVector( v[k], scalar );
+ MultVector( v[k], scalar );
od;
Add( basisvectors, v );
heads[i][j]:= Length( basisvectors );
diff --git a/lib/vspcrow.gi b/lib/vspcrow.gi
index 9b4da0d879..8a473cef55 100644
--- a/lib/vspcrow.gi
+++ b/lib/vspcrow.gi
@@ -1565,7 +1565,7 @@ InstallMethod( CloseMutableBasis,
# If necessary add the sifted vector, and update the basis info.
j := PositionNonZero( v );
if j <= ncols then
- MultRowVector( v, Inverse( v[j] ) );
+ MultVector( v, Inverse( v[j] ) );
Add( basisvectors, v );
heads[j]:= Length( basisvectors );
fi;
diff --git a/src/listoper.c b/src/listoper.c
index a15545c7f6..545beb0d28 100644
--- a/src/listoper.c
+++ b/src/listoper.c
@@ -1347,7 +1347,7 @@ Obj FuncINV_MATRIX_IMMUTABLE( Obj self, Obj mat)
/* We need these to redispatch when the user has supplied a replacement value. */
static Obj AddRowVectorOp; /* BH changed to static */
-static Obj MultRowVectorOp; /* BH changed to static */
+static Obj MultVectorLeftOp; /* BH changed to static */
Obj FuncADD_ROW_VECTOR_5( Obj self,
Obj list1,
@@ -1579,33 +1579,50 @@ Obj FuncADD_ROW_VECTOR_2_FAST ( Obj self,
/****************************************************************************
**
-*F FuncMULT_ROW_VECTOR_2( , , )
+*F FuncMULT_VECTOR_LEFT_RIGHT_2( , , )
**
-** This function destructively multiplies the entries of by
-** It does very little checking
+** This function destructively multiplies the entries of by .
+** It multiplies with from the left if is not 0 and from the
+** right otherwise.
+** It does very little checking.
**
*/
-Obj FuncMULT_ROW_VECTOR_2( Obj self,
- Obj list,
- Obj mult )
+Obj FuncMULT_VECTOR_LEFT_RIGHT_2(Obj self, Obj list, Obj mult, UInt left)
{
UInt i;
Obj prd;
UInt len = LEN_LIST(list);
- for (i = 1; i <= len; i++)
- {
- prd = ELMW_LIST(list,i);
- prd = PROD(prd,mult);
- ASS_LIST(list,i,prd);
- CHANGED_BAG(list);
- }
+ if (left != 0)
+ for (i = 1; i <= len; i++) {
+ prd = ELMW_LIST(list, i);
+ prd = PROD(mult, prd);
+ ASS_LIST(list, i, prd);
+ CHANGED_BAG(list);
+ }
+ else
+ for (i = 1; i <= len; i++) {
+ prd = ELMW_LIST(list, i);
+ prd = PROD(prd, mult);
+ ASS_LIST(list, i, prd);
+ CHANGED_BAG(list);
+ }
return 0;
}
+Obj FuncMULT_VECTOR_LEFT_2(Obj self, Obj list, Obj mult)
+{
+ return FuncMULT_VECTOR_LEFT_RIGHT_2(self, list, mult, 1);
+}
+
+Obj FuncMULT_VECTOR_RIGHT_2(Obj self, Obj list, Obj mult)
+{
+ return FuncMULT_VECTOR_LEFT_RIGHT_2(self, list, mult, 0);
+}
+
/****************************************************************************
**
-*F FuncMULT_ROW_VECTOR_2_FAST( , , )
+*F FuncMULT_VECTOR_2_FAST( , , )
**
** This function destructively multiplies the entries of by
** It does very little checking
@@ -1614,7 +1631,7 @@ Obj FuncMULT_ROW_VECTOR_2( Obj self,
** multiplier
*/
-Obj FuncMULT_ROW_VECTOR_2_FAST( Obj self,
+Obj FuncMULT_VECTOR_2_FAST( Obj self,
Obj list,
Obj mult )
{
@@ -1674,7 +1691,7 @@ Obj FuncPROD_VEC_MAT_DEFAULT( Obj self,
if (res == (Obj)0)
{
res = SHALLOW_COPY_OBJ(vecr);
- CALL_2ARGS(MultRowVectorOp,res,elt);
+ CALL_2ARGS(MultVectorLeftOp, res, elt);
}
else
CALL_3ARGS(AddRowVectorOp, res, vecr, elt);
@@ -1692,7 +1709,7 @@ Obj FuncPROD_VEC_MAT_DEFAULT( Obj self,
*F FuncINV_MAT_DEFAULT
**
** A faster version of InvMat for those matrices for whose rows AddRowVector
-** and MultRowVector make sense (and might have fast kernel methods)
+** and MultVectorLeft make sense (and might have fast kernel methods)
**
*/
@@ -1793,8 +1810,8 @@ Obj InvMatWithRowVecs( Obj mat, UInt mut)
if (!EQ(x, one))
{
xi = INV(x);
- CALL_2ARGS(MultRowVectorOp, row, xi);
- CALL_2ARGS(MultRowVectorOp, row2, xi);
+ CALL_2ARGS(MultVectorLeftOp, row, xi);
+ CALL_2ARGS(MultVectorLeftOp, row2, xi);
}
/* Clear the entries. We know that we can ignore the entries in rows i..j */
@@ -2221,7 +2238,7 @@ static Obj FuncMONOM_PROD( Obj self, Obj m1, Obj m2 ) {
**
*V GVarFuncs . . . . . . . . . . . . . . . . . . list of functions to export
*/
-static StructGVarFunc GVarFuncs [] = {
+static StructGVarFunc GVarFuncs[] = {
GVAR_FUNC(EQ_LIST_LIST_DEFAULT, 2, "listL, listR"),
GVAR_FUNC(LT_LIST_LIST_DEFAULT, 2, "listL, listR"),
@@ -2252,8 +2269,9 @@ static StructGVarFunc GVarFuncs [] = {
GVAR_FUNC(ADD_ROW_VECTOR_3_FAST, 3, "list1, list2, mult"),
GVAR_FUNC(ADD_ROW_VECTOR_2, 2, "list1, list2"),
GVAR_FUNC(ADD_ROW_VECTOR_2_FAST, 2, "list1, list2"),
- GVAR_FUNC(MULT_ROW_VECTOR_2, 2, "list, mult"),
- GVAR_FUNC(MULT_ROW_VECTOR_2_FAST, 2, "list, mult"),
+ GVAR_FUNC(MULT_VECTOR_LEFT_2, 2, "list, mult"),
+ GVAR_FUNC(MULT_VECTOR_RIGHT_2, 2, "list, mult"),
+ GVAR_FUNC(MULT_VECTOR_2_FAST, 2, "list, mult"),
GVAR_FUNC(PROD_VEC_MAT_DEFAULT, 2, "vec, mat"),
GVAR_FUNC(INV_MAT_DEFAULT_MUTABLE, 1, "mat"),
GVAR_FUNC(INV_MAT_DEFAULT_SAME_MUTABILITY, 1, "mat"),
@@ -2284,7 +2302,7 @@ static Int InitKernel (
InitHdlrFuncsFromTable( GVarFuncs );
InitFopyGVar( "AddRowVector", &AddRowVectorOp );
- InitFopyGVar( "MultRowVector", &MultRowVectorOp );
+ InitFopyGVar("MultVectorLeft", &MultVectorLeftOp);
InitFopyGVar( "ConvertToMatrixRep", &ConvertToMatrixRep );
diff --git a/src/vec8bit.c b/src/vec8bit.c
index 7512603b08..8f65d738c6 100644
--- a/src/vec8bit.c
+++ b/src/vec8bit.c
@@ -1750,12 +1750,12 @@ void AddVec8BitVec8BitMultInner( Obj sum,
/****************************************************************************
**
-*F FuncMULT_ROW_VECTOR( , , )
+*F FuncMULT_VECTOR( , , )
**
** In-place scalar multiply
*/
-Obj FuncMULT_ROWVECTOR_VEC8BITS( Obj self, Obj vec, Obj mul)
+Obj FuncMULT_VECTOR_VEC8BITS( Obj self, Obj vec, Obj mul)
{
UInt q;
q = FIELD_VEC8BIT(vec);
@@ -5955,7 +5955,7 @@ static StructGVarFunc GVarFuncs [] = {
GVAR_FUNC(ADD_ROWVECTOR_VEC8BITS_5, 5, "gfqvecl, gfqvecr, mul, from, to"),
GVAR_FUNC(ADD_ROWVECTOR_VEC8BITS_3, 3, "gfqvecl, gfqvecr, mul"),
GVAR_FUNC(ADD_ROWVECTOR_VEC8BITS_2, 2, "gfqvecl, gfqvecr"),
- GVAR_FUNC(MULT_ROWVECTOR_VEC8BITS, 2, "gfqvec, ffe"),
+ GVAR_FUNC(MULT_VECTOR_VEC8BITS, 2, "gfqvec, ffe"),
GVAR_FUNC(POSITION_NONZERO_VEC8BIT, 2, "vec8bit, zero"),
GVAR_FUNC(POSITION_NONZERO_VEC8BIT3, 3, "vec8bit, zero, from"),
GVAR_FUNC(APPEND_VEC8BIT, 2, "vec8bitl, vec8bitr"),
diff --git a/src/vecffe.c b/src/vecffe.c
index acbb29bc44..f17f402c13 100644
--- a/src/vecffe.c
+++ b/src/vecffe.c
@@ -764,13 +764,13 @@ Obj FuncADD_ROWVECTOR_VECFFES_3( Obj self, Obj vecL, Obj vecR, Obj mult )
}
/****************************************************************************
**
-*F FuncMULT_ROWVECTOR_VECFFES( , , )
+*F FuncMULT_VECTOR_VECFFES( , , )
**
*/
-static Obj MultRowVectorOp; /* BH changed to static */
+static Obj MultVectorLeftOp; /* BH changed to static */
-Obj FuncMULT_ROWVECTOR_VECFFES( Obj self, Obj vec, Obj mult )
+Obj FuncMULT_VECTOR_VECFFES( Obj self, Obj vec, Obj mult )
{
Obj *ptr;
FFV valM;
@@ -802,10 +802,10 @@ Obj FuncMULT_ROWVECTOR_VECFFES( Obj self, Obj vec, Obj mult )
/* check the characteristic */
if (CHAR_FF(fld) != CHAR_FF(FLD_FFE(mult))) {
mult = ErrorReturnObj(
- "MultRowVector: has different field",
+ "MultVector: has different field",
0L, 0L,
"you can replace via 'return ;'");
- return CALL_2ARGS(MultRowVectorOp, vec, mult);
+ return CALL_2ARGS(MultVectorLeftOp, vec, mult);
}
/* if the multiplier is over a non subfield then redispatch */
@@ -1117,7 +1117,7 @@ static StructGVarFunc GVarFuncs [] = {
GVAR_FUNC(ADD_ROWVECTOR_VECFFES_3, 3, "vecl, vecr, mult"),
GVAR_FUNC(ADD_ROWVECTOR_VECFFES_2, 2, "vecl, vecr"),
- GVAR_FUNC(MULT_ROWVECTOR_VECFFES, 2, "vec, mult"),
+ GVAR_FUNC(MULT_VECTOR_VECFFES, 2, "vec, mult"),
GVAR_FUNC(IS_VECFFE, 1, "vec"),
GVAR_FUNC(COMMON_FIELD_VECFFE, 1, "vec"),
GVAR_FUNC(SMALLEST_FIELD_VECFFE, 1, "vec"),
diff --git a/src/vecgf2.c b/src/vecgf2.c
index fce280e1c8..40699d3368 100644
--- a/src/vecgf2.c
+++ b/src/vecgf2.c
@@ -2605,11 +2605,11 @@ Obj FuncSUM_GF2VEC_GF2VEC (
/****************************************************************************
**
-*F FuncMULT_ROW_VECTOR_GF2VECS_2( , , )
+*F FuncMULT_VECTOR_GF2VECS_2( , , )
** . . . . . sum of GF2 vectors
**
*/
-Obj FuncMULT_ROW_VECTOR_GF2VECS_2 (
+Obj FuncMULT_VECTOR_GF2VECS_2 (
Obj self,
Obj vl,
Obj mul )
@@ -4718,7 +4718,7 @@ static StructGVarFunc GVarFuncs [] = {
GVAR_FUNC(SHRINKCOEFFS_GF2VEC, 1, "gf2vec"),
GVAR_FUNC(POSITION_NONZERO_GF2VEC, 2, "gf2vec, zero"),
GVAR_FUNC(POSITION_NONZERO_GF2VEC3, 3, "gf2vec, zero, from"),
- GVAR_FUNC(MULT_ROW_VECTOR_GF2VECS_2, 2, "gf2vecl, mul"),
+ GVAR_FUNC(MULT_VECTOR_GF2VECS_2, 2, "gf2vecl, mul"),
GVAR_FUNC(APPEND_GF2VEC, 2, "gf2vecl, gf2vecr"),
GVAR_FUNC(SHALLOWCOPY_GF2VEC, 1, "gf2vec"),
GVAR_FUNC(NUMBER_GF2VEC, 1, "gf2vec"),
diff --git a/tst/test-matobj/MultVector.tst b/tst/test-matobj/MultVector.tst
new file mode 100644
index 0000000000..a13a7b5bf3
--- /dev/null
+++ b/tst/test-matobj/MultVector.tst
@@ -0,0 +1,45 @@
+gap> START_TEST("MultVector.tst");
+
+# Finite Fields
+gap> v := NewVector( IsPlistVectorRep, GF(5), [Z(5)^1, Z(5)^2, Z(5)^0, Z(5)^4, 0*Z(5), Z(5)^3 ] );
+
+gap> MultVector(v, Z(5)^3);
+gap> Unpack(v);
+[ Z(5)^0, Z(5), Z(5)^3, Z(5)^3, 0*Z(5), Z(5)^2 ]
+gap> MultVector(v, -1);
+gap> Unpack(v);
+[ Z(5)^2, Z(5)^3, Z(5), Z(5), 0*Z(5), Z(5)^0 ]
+gap> MultVector(v, Z(5)^3, 3, 4);
+gap> Unpack(v);
+[ Z(5)^2, Z(5)^3, Z(5)^0, Z(5)^0, 0*Z(5), Z(5)^0 ]
+
+# Integers
+gap> n := NewVector( IsPlistVectorRep, Integers, [1,2,0] );
+
+gap> IsIntVector(n);
+true
+gap> MultVector(n, 2);
+gap> Unpack(n);
+[ 2, 4, 0 ]
+
+# Quaternions: multiplication from left and right
+gap> Q := QuaternionAlgebra( Rationals );
+
+gap> q := NewVector( IsPlistVectorRep, Q, [One(Q), Zero(Q), Q.2, Q.3] );
+
+gap> MultVectorRight(q, Q.2);
+gap> Unpack(q);
+[ i, 0*e, (-1)*e, (-1)*k ]
+gap> MultVectorLeft(q, Q.2);
+gap> Unpack(q);
+[ (-1)*e, 0*e, (-1)*i, j ]
+gap> MultVectorRight(q, 1);
+gap> Unpack(q);
+[ (-1)*e, 0*e, (-1)*i, j ]
+gap> MultVectorRight(q, Q.2, 3, 4);
+gap> Unpack(q);
+[ (-1)*e, 0*e, e, (-1)*k ]
+gap> MultVectorLeft(q, Q.2, 3, 4);
+gap> Unpack(q);
+[ (-1)*e, 0*e, i, j ]
+gap> STOP_TEST("MultVector.tst");