Skip to content

Commit bde1e35

Browse files
ssicchafingolfin
authored andcommitted
MatrixObj: Doc, Code and Tests for MultRowVector
- Split MultRowVector to MultRowVectorLeft / MultRowVectorRight. - MultRowVector is declared a synonym for MultRowVectorLeft. - MultRowVectorOp is renamed to MultRowVectorLeftOp on the C level. - Add four argument declarations for MultRowVectorLeft( vec, mul, from, to ) and ..Right - Remove the five argument version of MultRowVector in MatrixObj. Deprecate it also in the library. This version was not used anywhere in the library or packages - Add generic and plist implementations of MultRowVector where necessary - Implement and declare ..Left and ..Right versions in matrixobj* - Only do the ..Left version in listcoef.g?. The methods from listcoef.gi are only used for integers and FFEs in the library. Adding the ..Right versions would only introduce lots of unused code. People wanting to use the ..Right versions should use vector objs. - Have a kernel function MULT_ROW_VECTOR_LEFT_RIGHT_2 which is called by MULT_ROW_VECTOR_LEFT_2 and ..RIGHT_2 - Add tests for MultRowVector
1 parent bad7cf9 commit bde1e35

File tree

11 files changed

+279
-110
lines changed

11 files changed

+279
-110
lines changed

doc/ref/obsolete.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ Here are some further name changes.
174174
<Item><C>MutableNullMat</C></Item>
175175
<Item><Ref Func="NullMat"/></Item>
176176
</Row>
177+
<Row>
178+
<Item><C>MultRowVector</C></Item>
179+
<Item><Ref Oper="MultVectorLeft"/></Item>
180+
</Row>
177181
</Table>
178182

179183

@@ -185,6 +189,11 @@ Instead of <C>PositionFirstComponent(list,obj)</C>, you may use
185189
<C>PositionProperty(list,x->x[1]=obj)</C> as a replacement, depending on
186190
your specific use case.
187191

192+
<Index Key="MultRowVector"><C>MultRowVector</C></Index>
193+
The five argument version of the operation <C>MultRowVector</C> has been
194+
deprecated in GAP 4.10 since it was unused and only available for coefficient
195+
lists.
196+
Note that <C>MultRowVector</C> was also renamed to <C>MultVectorLeft</C>.
188197

189198
<ManSection>
190199
<InfoClass Name="InfoObsolete"/>

lib/listcoef.gd

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,30 +97,28 @@ DeclareOperation(
9797

9898
#############################################################################
9999
##
100-
#O MultRowVector( <list1>, <poss1>, <list2>, <poss2>, <mul> )
101-
#O MultRowVector( <list>, <mul> )
100+
#O MultRowVectorLeft( <list>, <mul> )
102101
##
103102
## <#GAPDoc Label="MultRowVector">
104103
## <ManSection>
105-
## <Oper Name="MultRowVector" Arg='list1, [poss1, list2, poss2, ]mul'/>
104+
## <Oper Name="MultRowVector" Arg='list1, mul'/>
105+
## <Oper Name="MultRowVectorLeft" Arg='list1, mul'/>
106+
## <Returns>nothing</Returns>
106107
##
107108
## <Description>
108-
## The five argument version of this operation replaces
109-
## <A>list1</A><C>[</C><A>poss1</A><C>[</C><M>i</M><C>]]</C> by
110-
## <C><A>mul</A>*<A>list2</A>[<A>poss2</A>[</C><M>i</M><C>]]</C> for <M>i</M>
111-
## between <M>1</M> and <C>Length( <A>poss1</A> )</C>.
109+
## This operation calculates <A>mul</A>*<A>list1</A> in-place.
112110
## <P/>
113-
## The two-argument version simply multiplies each element of <A>list1</A>,
114-
## in-place, by <A>mul</A>.
111+
## Note that <C>MultRowVectorLeft</C> is just a synonym for
112+
## <C>MultRowVector</C>.
115113
## </Description>
116114
## </ManSection>
117115
## <#/GAPDoc>
118116
##
119117
DeclareOperation(
120118
"MultRowVector",
121-
[ IsMutable and IsList,
122-
IsList, IsList, IsList, IsMultiplicativeElement ] );
123-
119+
[ IsMutable and IsList,
120+
IsMultiplicativeElement ] );
121+
DeclareSynonym( "MultRowVectorLeft", MultRowVector );
124122

125123
#############################################################################
126124
##

lib/listcoef.gi

Lines changed: 22 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -262,73 +262,50 @@ end );
262262

263263
#############################################################################
264264
##
265-
#M MultRowVector( <list1>, <poss1>, <list2>, <poss2>, <mult> )
265+
#M MultRowVectorLeft( <list>, <mul> )
266266
##
267-
InstallMethod( MultRowVector,"generic method",
267+
InstallMethod( MultRowVectorLeft,
268+
"for a mutable dense list, and a multiplicative element",
268269
true,
269270
[ IsDenseList and IsMutable,
270-
IsDenseList,
271-
IsDenseList,
272-
IsDenseList,
273271
IsMultiplicativeElement ],
274272
0,
275-
276-
function( l1, p1, l2, p2, m )
277-
l1{p1} := m * l2{p2};
278-
end );
279-
280-
InstallOtherMethod( MultRowVector,"error if immutable",true,
281-
[ IsList,IsObject,IsObject,IsObject,IsObject],0,
282-
L1_IMMUTABLE_ERROR);
283-
284-
#############################################################################
285-
##
286-
#M MultRowVector( <list>, <mul> )
287-
##
288-
InstallOtherMethod( MultRowVector,
289-
"two argument generic method",
290-
true,
291-
[ IsDenseList and IsMutable,
292-
IsMultiplicativeElement ],
293-
0,
294-
295273
function( l, m )
296274
local i;
297-
298275
for i in [ 1 .. Length(l) ] do
299276
l[i] := m * l[i];
300277
od;
301278
end );
302-
303-
InstallOtherMethod( MultRowVector,"error if immutable",true,
304-
[ IsList,IsObject],0,
279+
InstallOtherMethod( MultRowVectorLeft, "error if immutable", true,
280+
[ IsList, IsMultiplicativeElement ],
281+
0,
305282
L1_IMMUTABLE_ERROR);
306283

307-
InstallOtherMethod( MultRowVector,
308-
"Two argument kernel method for small list",
284+
InstallMethod( MultRowVectorLeft,
285+
"kernel method for a mutable dense small list, and a \
286+
multiplicative element",
309287
IsCollsElms,
310288
[ IsSmallList and IsDenseList and IsMutable,
311289
IsMultiplicativeElement ],
312290
0,
313-
MULT_ROW_VECTOR_2
291+
MULT_ROW_VECTOR_LEFT_2
314292
);
315-
316-
InstallOtherMethod( MultRowVector,
317-
"Two argument kernel method for plain list of cyclotomics and an integer",
293+
InstallMethod( MultRowVector,
294+
"kernel method for a mutable dense plain list of \
295+
cyclotomics, and a cyclotomic",
318296
IsCollsElms,
319-
[ IsSmallList and IsDenseList and IsMutable and IsPlistRep and
320-
IsCyclotomicCollection,
297+
[ IsDenseList and IsMutable and IsPlistRep and IsCyclotomicCollection,
321298
IsCyclotomic ],
322299
0,
323-
MULT_ROW_VECTOR_2_FAST
300+
MULT_ROW_VECTOR_2_FAST
324301
);
325-
326-
InstallOtherMethod( MultRowVector,
327-
"kernel method for vecffe (2 args)",
328-
IsCollsElms,
329-
[ IsRowVector and IsMutable and IsPlistRep and IsFFECollection,
330-
IsFFE],0,
331-
MULT_ROWVECTOR_VECFFES );
302+
InstallMethod( MultRowVector,
303+
"kernel method for a mutable row vector of ffes in \
304+
plain list rep, and an ffe",
305+
IsCollsElms,
306+
[ IsRowVector and IsMutable and IsPlistRep and IsFFECollection,
307+
IsFFE],0,
308+
MULT_ROWVECTOR_VECFFES );
332309

333310

334311
#############################################################################

lib/matobj.gi

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,51 @@ InstallMethod( Randomize,
577577
od;
578578
end );
579579

580+
############################################################################
581+
# Arithmetical operations:
582+
############################################################################
583+
InstallMethod( MultRowVectorLeft,
584+
"generic method for a mutable vector, and a multiplicative element",
585+
[ IsVectorObj and IsMutable, IsMultiplicativeElement ],
586+
function( v, s )
587+
local i;
588+
for i in [1 .. Length(v)] do
589+
v[i] := s * v[i];
590+
od;
591+
end );
592+
593+
InstallMethod( MultRowVectorRight,
594+
"generic method for a mutable vector, and a multiplicative element",
595+
[ IsVectorObj and IsMutable, IsMultiplicativeElement ],
596+
function( v, s )
597+
local i;
598+
for i in [1 .. Length(v)] do
599+
v[i] := v[i] * s;
600+
od;
601+
end );
602+
603+
InstallMethod( MultRowVectorLeft,
604+
"generic method for a mutable vector, a multiplicative element, an int, \
605+
and an int",
606+
[ IsVectorObj and IsMutable, IsMultiplicativeElement, IsInt, IsInt ],
607+
function( v, s, from, to )
608+
local i;
609+
for i in [from .. to] do
610+
v[i] := s * v[i];
611+
od;
612+
end );
613+
614+
InstallMethod( MultRowVectorRight,
615+
"generic method for a mutable vector, a multiplicative element, an int, \
616+
and an int",
617+
[ IsVectorObj and IsMutable, IsMultiplicativeElement, IsInt, IsInt ],
618+
function( v, s, from, to )
619+
local i;
620+
for i in [from .. to] do
621+
v[i] := v[i] * s;
622+
od;
623+
end );
624+
580625
#
581626
# Compatibility code: Install MatrixObj methods for IsMatrix.
582627
#

lib/matobj2.gd

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -384,23 +384,47 @@ DeclareOperation( "AddRowVector",
384384

385385
# TODO: rename MultRowVector to MultVector; but keep in mind that
386386
# historically there already was MultRowVector, so be careful to not break that
387-
DeclareOperation( "MultRowVector",
388-
[ IsVectorObj and IsMutable, IsObject ] );
389-
390-
#
391-
# Also, make it explicit from which side we multiply
392-
# DeclareOperation( "MultRowVectorFromLeft",
393-
# [ IsVectorObj and IsMutable, IsObject ] );
394-
# DeclareOperation( "MultRowVectorFromRight",
395-
# [ IsVectorObj and IsMutable, IsObject ] );
396-
#DeclareSynonym( "MultRowVector", MultRowVectorFromRight );
397-
398-
# do we really need the following? for what? is any code using this right now?
399-
# ( a, pa, b, pb, s ) -> a{pa} := b{pb} * s;
400-
DeclareOperation( "MultRowVector",
401-
[ IsVectorObj and IsMutable, IsList, IsVectorObj, IsList, IsObject ] );
402-
403-
# maybe have this: vec := vec{[from..to]} * scal ?? cvec has it
387+
#############################################################################
388+
##
389+
#O MultRowVector( <vec>, <mul>[, <from>, <to>] )
390+
#O MultRowVectorLeft( <vec>, <mul>[, <from>, <to>] )
391+
#O MultRowVectorRight( <vec>, <mul>[, <from>, <to>] )
392+
##
393+
## <#GAPDoc Label="MatObj_MultRowVector">
394+
## <#GAPDoc Label="MatObj_MultRowVectorLeft">
395+
## <#GAPDoc Label="MatObj_MultRowVectorRight">
396+
## <ManSection>
397+
## <Oper Name="MultRowVectorLeft" Arg='vec, mul[, from, to]'/>
398+
## <Oper Name="MultRowVectorRight" Arg='vec, mul[, from, to]'/>
399+
## <Returns>nothing</Returns>
400+
##
401+
## <Description>
402+
## Note that <C>MultRowVector</C> is only a Synonym for
403+
## <C>MultRowVectorLeft</C>.
404+
## </P>
405+
## These operations multiply <A>vec</A> with <A>mul</A> in-place and write
406+
## the result to <A>vec</A>.
407+
## <C>MultRowVectorLeft</C> multiplies <A>mul</A> to <A>vec</A> from the
408+
## left. <C>MultRowVectorRight</C> does so from the right.
409+
## </P>
410+
## The optional parameters <A>from</A> and <A>to</A> can be used to restrict
411+
## the effect of the operation to the entries
412+
## <C><A>vec</A>{[<A>from</A>..<A>to</A>]}.
413+
## This can be helpful if entries of <A>vec</A> are known to be zero.
414+
## </Description>
415+
## </ManSection>
416+
## <#/GAPDoc>
417+
##
418+
DeclareOperation( "MultRowVectorLeft",
419+
[ IsVectorObj and IsMutable, IsMultiplicativeElement ] );
420+
DeclareOperation( "MultRowVectorRight",
421+
[ IsVectorObj and IsMutable, IsMultiplicativeElement ] );
422+
DeclareOperation( "MultRowVectorLeft",
423+
[ IsVectorObj and IsMutable, IsMultiplicativeElement, IsInt, IsInt ] );
424+
DeclareOperation( "MultRowVectorRight",
425+
[ IsVectorObj and IsMutable, IsMultiplicativeElement, IsInt, IsInt ] );
426+
# Note that MultRowVector is declared a Synonym for MultRowVectorLeft in
427+
# listcoef.gd
404428

405429

406430
# The following operations for scalars and vectors are possible for scalars in the BaseDomain

lib/matobjplist.gi

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -415,30 +415,29 @@ InstallMethod( AddRowVector,
415415
fi;
416416
end );
417417

418-
InstallMethod( MultRowVector, "for a plist vector, and a scalar",
418+
InstallMethod( MultRowVectorLeft,
419+
"for a plist vector, and an object",
419420
[ IsPlistVectorRep and IsMutable, IsObject ],
420421
function( v, s )
421-
MULT_ROW_VECTOR_2(v![ELSPOS],s);
422+
MULT_ROW_VECTOR_LEFT_2(v![ELSPOS],s);
422423
end );
423424

424-
InstallMethod( MultRowVector, "for a plist vector, and a scalar",
425-
[ IsPlistVectorRep and IsIntVector and IsMutable, IsObject ],
425+
InstallMethod( MultRowVectorRight,
426+
"for a plist vector, and an object",
427+
[ IsPlistVectorRep and IsMutable, IsObject ],
426428
function( v, s )
427-
if IsSmallIntRep(s) then
428-
MULT_ROW_VECTOR_2_FAST(v![ELSPOS],s);
429-
else
430-
MULT_ROW_VECTOR_2(v![ELSPOS],s);
431-
fi;
429+
MULT_ROW_VECTOR_RIGHT_2(v![ELSPOS],s);
432430
end );
433431

434-
InstallMethod( MultRowVector,
435-
"for a plist vector, a list, a plist vector, a list, and a scalar",
436-
[ IsPlistVectorRep and IsMutable, IsList,
437-
IsPlistVectorRep, IsList, IsObject ],
438-
function( a, pa, b, pb, s )
439-
a![ELSPOS]{pa} := b![ELSPOS]{pb} * s;
432+
InstallOtherMethod( MultRowVector, "for an integer vector, and a small integer",
433+
[ IsPlistVectorRep and IsIntVector and IsMutable, IsSmallIntRep ],
434+
function( v, s )
435+
MULT_ROW_VECTOR_2_FAST(v![ELSPOS],s);
440436
end );
441437

438+
# The four argument version of MultRowVector uses the generic implementation
439+
# in matobj.gi
440+
442441
InstallMethod( \*, "for a plist vector and a scalar",
443442
[ IsPlistVectorRep, IsScalar ],
444443
function( v, s )

lib/obsolete.gd

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,33 @@ DeclareObsoleteSynonym( "MutableNullMat", "NullMat" );
559559
## Not used in any redistributed packages (11/2017)
560560
#DeclareOperation( "PositionFirstComponent", [IsList,IsObject] );
561561

562+
#############################################################################
563+
##
564+
#O MultRowVector( <list1>, <poss1>, <list2>, <poss2>, <mul> )
565+
##
566+
## <#GAPDoc Label="MultRowVector">
567+
## <ManSection>
568+
## <Oper Name="MultRowVector" Arg='list1, [poss1, list2, poss2, ]mul'/>
569+
## <Returns>nothing</Returns>
570+
##
571+
## <Description>
572+
## The two argument version of this operation is an obsolete synonym for
573+
## <C>MultVectorLeft</C>, which calculates <A>mul</A>*<A>list1</A> in-place.
574+
## New code should use <C>MultVectorLeft</C> or its synonym
575+
## <C>MultVector</C> instead.
576+
## <P/>
577+
## <E>The five argument version of this operation is kept for compatibility
578+
## with older versions of &GAP; and will be removed eventually.</E>
579+
## It replaces
580+
## <A>list1</A><C>[</C><A>poss1</A><C>[</C><M>i</M><C>]]</C> by
581+
## <C><A>mul</A>*<A>list2</A>[<A>poss2</A>[</C><M>i</M><C>]]</C> for <M>i</M>
582+
## between <M>1</M> and <C>Length( <A>poss1</A> )</C>.
583+
## </Description>
584+
## </ManSection>
585+
## <#/GAPDoc>
586+
##
587+
DeclareObsoleteSynonym( "MultRowVector", "MultVector" );
588+
562589
#############################################################################
563590
##
564591
#O ReadTest

lib/obsolete.gi

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,28 @@ end);
877877
# # fi;
878878
# end );
879879

880+
#############################################################################
881+
##
882+
#M MultRowVector( <list1>, <poss1>, <list2>, <poss2>, <mult> )
883+
##
884+
InstallOtherMethod( MultRowVector, "obsolete five argument method",
885+
true,
886+
[ IsDenseList and IsMutable,
887+
IsDenseList,
888+
IsDenseList,
889+
IsDenseList,
890+
IsMultiplicativeElement ],
891+
0,
892+
function( l1, p1, l2, p2, m )
893+
InfoObsolete(1, "This usage of `MultRowVector` is no longer",
894+
"supported and will be removed eventually." );
895+
l1{p1} := m * l2{p2};
896+
end );
897+
898+
InstallOtherMethod( MultRowVector, "error if immutable", true,
899+
[ IsList,IsObject,IsObject,IsObject,IsObject],0,
900+
L1_IMMUTABLE_ERROR);
901+
880902
#############################################################################
881903
##
882904
#F SetUserPreferences

0 commit comments

Comments
 (0)