From eb37b250a155c8fa131906a67742c1ce720b36e0 Mon Sep 17 00:00:00 2001 From: Daniel Rademacher Date: Thu, 27 May 2021 11:31:28 +0200 Subject: [PATCH 01/23] Add generic functions of issue 3962. --- lib/matobj.gi | 357 +++++++++++++++++++++++++++++++++++++++++++++ lib/matobj2.gd | 23 +++ lib/matobjplist.gi | 327 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 707 insertions(+) diff --git a/lib/matobj.gi b/lib/matobj.gi index 18ebb2f4d9..0f380e4110 100644 --- a/lib/matobj.gi +++ b/lib/matobj.gi @@ -1568,3 +1568,360 @@ InstallMethod( \[\,\]\:\=, "for a matrix object, two positions, and an object", end ); +############################################################################ +# Elementary matrix operations +############################################################################ + +############################################################################ +## +#M MultMatrixRow( , , ) +## +InstallMethod( MultMatrixRow, "for a mutable matrix object, one row number, and an scalar", + [ IsMatrixObj and IsMutable, IsInt, IsObject ], + function( mat, row, scalar ) + local i; + + # Checks + if not( 0 < row and row < NrRows(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrRows(mat) "); + return fail; + fi; + + for i in [1..NrColumns(mat)] do + mat[row,i] := scalar * mat[row,i]; + od; + + end ); + + +# TODO FOR MUTABLE MATRICES +# InstallMethod( MultMatrixRow, "for a mutable matrix object, one row number, and an scalar", +# [ IsMatrixObj, IsInt, IsObject ], +# function( mat, row, scalar ) +# local One, MatRow, i, CopyMat; + + # Checks +# if not( 0 < row and row < NrRows(mat) ) then +# Print("The second argument row has to fullfill 0 < row < NrRows(mat) "); +# return fail; +# fi; + +# CopyMat := ShallowCopy(mat); + +# for i in [1..NrColumns(mat)] do +# CopyMat[row,i] := scalar * CopyMat[row,i]; +# od; + + # return Matrix(CopyMat,mat); + +# end ); + + +############################################################################ +## +#M MultMatrixColumn( , , ) +## +InstallMethod( MultMatrixColumn, "for a mutable matrix object, one column number, and an scalar", + [ IsMatrixObj and IsMutable, IsInt, IsObject ], + function( mat, column, scalar ) + local i; + + # Checks + if not( 0 < row and row < NrColumns(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrColumns(mat) "); + return fail; + fi; + + for i in [1..NrRows(mat)] do + mat[i,column] := mat[i,column] * scalar; + od; + + end ); + + + +############################################################################ +## +#M MultMatrixRowLeft( , , ) +## +InstallMethod( MultMatrixRowLeft, "for a mutable matrix object, one row number, and an scalar", + [ IsMatrixObj and IsMutable, IsInt, IsObject ], + function( mat, row, scalar ) + + MultMatrixRow(mat,row,scalar); + + end ); + +############################################################################ +## +#M MultMatrixRowRight( , , ) +## +InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, and an scalar", + [ IsMatrixObj and IsMutable, IsInt, IsObject ], + function( mat, row, scalar ) + local i; + + # Checks + if not( 0 < row and row < NrRows(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrRows(mat) "); + return fail; + fi; + + for i in [1..NrColumns(mat)] do + mat[row,i] := mat[row,i] * scalar; + od; + + end ); + +############################################################################ +## +#M MultMatrixColumnLeft( , , ) +## +InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column number, and an scalar", + [ IsMatrixObj and IsMutable, IsInt, IsObject ], + function( mat, column, scalar ) + local i; + + # Checks + if not( 0 < row and row < NrColumns(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrColumns(mat) "); + return fail; + fi; + + for i in [1..NrRows(mat)] do + mat[i,column] := scalar * mat[i,column]; + od; + + end ); + +############################################################################ +## +#M MultMatrixColumnRight( , , ) +## +InstallMethod( MultMatrixColumnRight, "for a mutable matrix object, one row number, and an scalar", + [ IsMatrixObj and IsMutable, IsInt, IsObject ], + function( mat, row, scalar ) + + MultMatrixColumn(mat,row,scalar); + + end ); + + +############################################################################ +## +#M AddMatrixRows( , , , ) +## +InstallMethod( AddMatrixRows, "for a mutable matrix object, one row number, second row number, and an scalar", + [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , + function( mat, row1, row2, scalar ) + local i; + + # Checks + if not( 0 < row1 and row1 < NrRows(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrRows(mat) "); + return fail; + fi; + if not( 0 < row2 and row2 < NrRows(mat) ) then + Print("The third argument row has to fulfill 0 < row < NrRows(mat) "); + return fail; + fi; + + if row1 <> row2 then + + for i in [1..NrColumns(mat)] do + mat[row1,i] := mat[row1,i] + scalar * mat[row2,i]; + od; + + else + MultMatrixRow(mat,row1,scalar+1); + fi; + + + end ); + + +############################################################################ +## +#M AddMatrixRowsLeft( , , , ) +## +InstallMethod( AddMatrixRowsLeft, "for a mutable matrix object, one row number, second row number, and an scalar", + [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , + function( mat, row1, row2, scalar ) + + AddMatrixRows(mat,row1,row2,scalar); + + end ); + +############################################################################ +## +#M AddMatrixRowsRight( , , , ) +## +InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, second row number, and an scalar", + [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , + function( mat, row1, row2, scalar ) + local i; + + # Checks + if not( 0 < row1 and row1 < NrRows(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrRows(mat) "); + return fail; + fi; + if not( 0 < row2 and row2 < NrRows(mat) ) then + Print("The third argument row has to fulfill 0 < row < NrRows(mat) "); + return fail; + fi; + + if row1 <> row2 then + + for i in [1..NrColumns(mat)] do + mat[row1,i] := mat[row1,i] + mat[row2,i] * scalar; + od; + + else + MultMatrixRowRight(mat,row1,scalar+1); + fi; + + end ); + +############################################################################ +## +#M AddMatrixColumns( , , , ) +## +InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and an scalar", + [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , + function( mat, column1, column2, scalar ) + local i; + + # Checks + if not( 0 < column1 and column1 < NrColumns(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrColumns(mat) "); + return fail; + fi; + if not( 0 < column2 and column2 < NrColumns(mat) ) then + Print("The third argument row has to fulfill 0 < row < NrColumns(mat) "); + return fail; + fi; + + if column1 <> column2 then + + for i in [1..NrRows(mat)] do + mat[i,column1] := mat[i,column1] + mat[i,column2] * scalar; + od; + + else + MultMatrixColumn(mat,column1,scalar+1); + fi; + + + end ); + +############################################################################ +## +#M AddMatrixColumnsLeft( , , , ) +## +InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and an scalar", + [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , + function( mat, column1, column2, scalar ) + local i; + + # Checks + if not( 0 < column1 and column1 < NrColumns(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrColumns(mat) "); + return fail; + fi; + if not( 0 < column2 and column2 < NrColumns(mat) ) then + Print("The third argument row has to fulfill 0 < row < NrColumns(mat) "); + return fail; + fi; + + if column1 <> column2 then + + for i in [1..NrRows(mat)] do + mat[i,column1] := mat[i,column1] + scalar * mat[i,column2] ; + od; + + else + MultMatrixColumnLeft(mat,column1,scalar+1); + fi; + + + end ); + + +############################################################################ +## +#M AddMatrixColumnsRight( , , , ) +## +InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and an scalar", + [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , + function( mat, column1, column2, scalar ) + + AddMatrixColumns(mat,column1,column2,scalar); + + end ); + + +############################################################################ +## +#M SwapMatrixRows( , , ) +## +InstallMethod( SwapMatrixRows, "for a mutable matrix object, one row number, second row number", + [ IsMatrixObj and IsMutable, IsInt, IsInt ], + function( mat, row1, row2 ) + local temp, i; + + if row1 <> row2 then + + # Checks + if not( 0 < row1 and row1 < NrRows(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrRows(mat) "); + return fail; + fi; + if not( 0 < row2 and row2 < NrRows(mat) ) then + Print("The third argument row has to fulfill 0 < row < NrRows(mat) "); + return fail; + fi; + + for i in [1..NrColumns(mat)] do + temp := mat[row1,i]; + mat[row1,i] := mat[row2,i]; + mat[row2,i] := temp; + od; + + fi; + + + end ); + + +############################################################################ +## +#M SwapMatrixColumns( , , ) +## +InstallMethod( SwapMatrixColumns, "for a mutable matrix object, one column number, second column number", + [ IsMatrixObj and IsMutable, IsInt, IsInt ], + function( mat, column1, column2 ) + local temp, i; + + if column1 <> column2 then + + # Checks + if not( 0 < column1 and column1 < NrColumns(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrColumns(mat) "); + return fail; + fi; + if not( 0 < column2 and column2 < NrColumns(mat) ) then + Print("The third argument row has to fulfill 0 < row < NrColumns(mat) "); + return fail; + fi; + + for i in [1..NrRows(mat)] do + temp := mat[i,column1]; + mat[i,column1] := mat[i,column2]; + mat[i,column2] := temp; + od; + + fi; + + + end ); diff --git a/lib/matobj2.gd b/lib/matobj2.gd index a5c51fb399..583cc910d8 100644 --- a/lib/matobj2.gd +++ b/lib/matobj2.gd @@ -1926,3 +1926,26 @@ DeclareOperation( "[]:=", [ IsMatrixObj, IsPosInt, IsPosInt, IsObject ] ); ## and the available methods have to be adjusted. ## + +############################################################################ +# Elementary matrix operations +############################################################################ + +############################################################################ +## +## TODO DESCRIPTION +## +DeclareOperation( "MultMatrixRow", [ IsMatrixObj and IsMutable, IsInt, IsObject ] ); +DeclareOperation( "MultMatrixColumn", [ IsMatrixObj and IsMutable, IsInt, IsObject ] ); +DeclareOperation( "MultMatrixRowLeft", [ IsMatrixObj and IsMutable, IsInt, IsObject ] ); +DeclareOperation( "MultMatrixRowRight", [ IsMatrixObj and IsMutable, IsInt, IsObject ] ); +DeclareOperation( "MultMatrixColumnLeft", [ IsMatrixObj and IsMutable, IsInt, IsObject ] ); +DeclareOperation( "MultMatrixColumnRight", [ IsMatrixObj and IsMutable, IsInt, IsObject ] ); +DeclareOperation( "AddMatrixRows", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] ); +DeclareOperation( "AddMatrixRowsLeft", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] ); +DeclareOperation( "AddMatrixRowsRight", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] ); +DeclareOperation( "AddMatrixColumns", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] ); +DeclareOperation( "AddMatrixColumnsLeft", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] ); +DeclareOperation( "AddMatrixColumnsRight", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] ); +DeclareOperation( "SwapMatrixRows", [ IsMatrixObj and IsMutable, IsInt, IsInt ] ); +DeclareOperation( "SwapMatrixColumns", [ IsMatrixObj and IsMutable, IsInt, IsInt ] ); diff --git a/lib/matobjplist.gi b/lib/matobjplist.gi index b484cb273d..79fa1cca71 100644 --- a/lib/matobjplist.gi +++ b/lib/matobjplist.gi @@ -1286,3 +1286,330 @@ InstallMethod( NewCompanionMatrix, return ll; end ); +############################################################################ +# Elementary matrix operations +############################################################################ + +############################################################################ +## +#M MultMatrixRow( , , ) +## +InstallMethod( MultMatrixRow, "for a mutable IsPlistMatrixRep, one row number, and an scalar", + [ IsRowListMatrix and IsMutable, IsInt, IsObject ], + function( mat, row, scalar ) + + # Checks + if not( 0 < row and row < NrRows(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrRows(mat) "); + return fail; + fi; + + mat[row] := scalar * mat[row]; + + end ); + + +############################################################################ +## +#M MultMatrixColumn( , , ) +## +InstallMethod( MultMatrixColumn, "for a mutable matrix object, one column number, and an scalar", + [ IsRowListMatrix and IsMutable, IsInt, IsObject ], + function( mat, column, scalar ) + local i; + + # Checks + if not( 0 < row and row < NrColumns(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrColumns(mat) "); + return fail; + fi; + + # TODO ASK MAX + + end ); + + + +############################################################################ +## +#M MultMatrixRowLeft( , , ) +## +InstallMethod( MultMatrixRowLeft, "for a mutable matrix object, one row number, and an scalar", + [ IsRowListMatrix and IsMutable, IsInt, IsObject ], + function( mat, row, scalar ) + + MultMatrixRow(mat,row,scalar); + + end ); + +############################################################################ +## +#M MultMatrixRowRight( , , ) +## +InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, and an scalar", + [ IsRowListMatrix and IsMutable, IsInt, IsObject ], + function( mat, row, scalar ) + local i; + + # Checks + if not( 0 < row and row < NrRows(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrRows(mat) "); + return fail; + fi; + + mat[row] := mat[row] * scalar; + + end ); + +############################################################################ +## +#M MultMatrixColumnLeft( , , ) +## +InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column number, and an scalar", + [ IsRowListMatrix and IsMutable, IsInt, IsObject ], + function( mat, column, scalar ) + local i; + + # Checks + if not( 0 < row and row < NrColumns(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrColumns(mat) "); + return fail; + fi; + + for i in [1..NrRows(mat)] do + mat[i,column] := scalar * mat[i,column]; + od; + + end ); + +############################################################################ +## +#M MultMatrixColumnRight( , , ) +## +InstallMethod( MultMatrixColumnRight, "for a mutable matrix object, one row number, and an scalar", + [ IsRowListMatrix and IsMutable, IsInt, IsObject ], + function( mat, row, scalar ) + + MultMatrixColumn(mat,row,scalar); + + end ); + + +############################################################################ +## +#M AddMatrixRows( , , , ) +## +InstallMethod( AddMatrixRows, "for a mutable matrix object, one row number, second row number, and an scalar", + [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , + function( mat, row1, row2, scalar ) + local i; + + # Checks + if not( 0 < row1 and row1 < NrRows(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrRows(mat) "); + return fail; + fi; + if not( 0 < row2 and row2 < NrRows(mat) ) then + Print("The third argument row has to fulfill 0 < row < NrRows(mat) "); + return fail; + fi; + + if row1 <> row2 then + + for i in [1..NrColumns(mat)] do + mat[row1,i] := mat[row1,i] + scalar * mat[row2,i]; + od; + + else + MultMatrixRow(mat,row1,scalar+1); + fi; + + + end ); + + +############################################################################ +## +#M AddMatrixRowsLeft( , , , ) +## +InstallMethod( AddMatrixRowsLeft, "for a mutable matrix object, one row number, second row number, and an scalar", + [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , + function( mat, row1, row2, scalar ) + + AddMatrixRows(mat,row1,row2,scalar); + + end ); + +############################################################################ +## +#M AddMatrixRowsRight( , , , ) +## +InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, second row number, and an scalar", + [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , + function( mat, row1, row2, scalar ) + local i; + + # Checks + if not( 0 < row1 and row1 < NrRows(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrRows(mat) "); + return fail; + fi; + if not( 0 < row2 and row2 < NrRows(mat) ) then + Print("The third argument row has to fulfill 0 < row < NrRows(mat) "); + return fail; + fi; + + if row1 <> row2 then + + for i in [1..NrColumns(mat)] do + mat[row1,i] := mat[row1,i] + mat[row2,i] * scalar; + od; + + else + MultMatrixRowRight(mat,row1,scalar+1); + fi; + + end ); + +############################################################################ +## +#M AddMatrixColumns( , , , ) +## +InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and an scalar", + [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , + function( mat, column1, column2, scalar ) + local i; + + # Checks + if not( 0 < column1 and column1 < NrColumns(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrColumns(mat) "); + return fail; + fi; + if not( 0 < column2 and column2 < NrColumns(mat) ) then + Print("The third argument row has to fulfill 0 < row < NrColumns(mat) "); + return fail; + fi; + + if column1 <> column2 then + + for i in [1..NrRows(mat)] do + mat[i,column1] := mat[i,column1] + mat[i,column2] * scalar; + od; + + else + MultMatrixColumn(mat,column1,scalar+1); + fi; + + + end ); + +############################################################################ +## +#M AddMatrixColumnsLeft( , , , ) +## +InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and an scalar", + [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , + function( mat, column1, column2, scalar ) + local i; + + # Checks + if not( 0 < column1 and column1 < NrColumns(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrColumns(mat) "); + return fail; + fi; + if not( 0 < column2 and column2 < NrColumns(mat) ) then + Print("The third argument row has to fulfill 0 < row < NrColumns(mat) "); + return fail; + fi; + + if column1 <> column2 then + + for i in [1..NrRows(mat)] do + mat[i,column1] := mat[i,column1] + scalar * mat[i,column2] ; + od; + + else + MultMatrixColumnLeft(mat,column1,scalar+1); + fi; + + + end ); + + +############################################################################ +## +#M AddMatrixColumnsRight( , , , ) +## +InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and an scalar", + [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , + function( mat, column1, column2, scalar ) + + AddMatrixColumns(mat,column1,column2,scalar); + + end ); + + +############################################################################ +## +#M SwapMatrixRows( , , ) +## +InstallMethod( SwapMatrixRows, "for a mutable matrix object, one row number, second row number", + [ IsRowListMatrix and IsMutable, IsInt, IsInt ], + function( mat, row1, row2 ) + local temp, i; + + if row1 <> row2 then + + # Checks + if not( 0 < row1 and row1 < NrRows(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrRows(mat) "); + return fail; + fi; + if not( 0 < row2 and row2 < NrRows(mat) ) then + Print("The third argument row has to fulfill 0 < row < NrRows(mat) "); + return fail; + fi; + + for i in [1..NrColumns(mat)] do + temp := mat[row1,i]; + mat[row1,i] := mat[row2,i]; + mat[row2,i] := temp; + od; + + fi; + + + end ); + + +############################################################################ +## +#M SwapMatrixColumns( , , ) +## +InstallMethod( SwapMatrixColumns, "for a mutable matrix object, one column number, second column number", + [ IsRowListMatrix and IsMutable, IsInt, IsInt ], + function( mat, column1, column2 ) + local temp, i; + + if column1 <> column2 then + + # Checks + if not( 0 < column1 and column1 < NrColumns(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrColumns(mat) "); + return fail; + fi; + if not( 0 < column2 and column2 < NrColumns(mat) ) then + Print("The third argument row has to fulfill 0 < row < NrColumns(mat) "); + return fail; + fi; + + for i in [1..NrRows(mat)] do + temp := mat[i,column1]; + mat[i,column1] := mat[i,column2]; + mat[i,column2] := temp; + od; + + fi; + + + end ); From 1b1905b2689c58956ee21bff1e5879844233f4f9 Mon Sep 17 00:00:00 2001 From: Lucas Wollenhaupt Date: Thu, 27 May 2021 12:53:02 +0200 Subject: [PATCH 02/23] Add documentation --- doc/ref/matobj.xml | 21 ++++ lib/matobj.gi | 234 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 244 insertions(+), 11 deletions(-) diff --git a/doc/ref/matobj.xml b/doc/ref/matobj.xml index 4a5acad9bb..50baa11b52 100644 --- a/doc/ref/matobj.xml +++ b/doc/ref/matobj.xml @@ -286,5 +286,26 @@ for your new type of vector or matrix objects.) + +
+Basic operations for row/column reductions + +<#Include Label="MultMatrixRow"> +<#Include Label="MultMatrixRowLeft"> +<#Include Label="MultMatrixRowRight"> +<#Include Label="MultMatrixColumn"> +<#Include Label="MultMatrixColumnLeft"> +<#Include Label="MultMatrixColumnRight"> +<#Include Label="AddMatrixRows"> +<#Include Label="AddMatrixRowsLeft"> +<#Include Label="AddMatrixRowsRight"> +<#Include Label="AddMatrixColumns"> +<#Include Label="AddMatrixColumnsLeft"> +<#Include Label="AddMatrixColumnsRight"> +<#Include Label="SwapMatrixRows"> +<#Include Label="SwapMatrixColumns"> + +
+ diff --git a/lib/matobj.gi b/lib/matobj.gi index 0f380e4110..31a319d9fd 100644 --- a/lib/matobj.gi +++ b/lib/matobj.gi @@ -1574,7 +1574,23 @@ InstallMethod( \[\,\]\:\=, "for a matrix object, two positions, and an object", ############################################################################ ## -#M MultMatrixRow( , , ) +#O MultMatrixRow( , , ) +## +## <#GAPDoc Label="MultMatrixRow"> +## +## +## +## nothing +## +## +##

+## For a matrix mat such that mat is mutable, a row index i +## and a scalar elm this operation multiplies elm with the i-th row +## in-place. +## Note that by default elm is multiplied from the left. +## +## +## <#/GAPDoc> ## InstallMethod( MultMatrixRow, "for a mutable matrix object, one row number, and an scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], @@ -1619,7 +1635,23 @@ InstallMethod( MultMatrixRow, "for a mutable matrix object, one row number, and ############################################################################ ## -#M MultMatrixColumn( , , ) +#O MultMatrixColumn( , , ) +## +## <#GAPDoc Label="MultMatrixColumn"> +## +## +## +## nothing +## +## +##

+## For a matrix mat such that mat is mutable, a column index i +## and a scalar elm this operation multiplies the i-th column with elm +## in-place. +## Note that by default elm is multiplied from the right. +## +## +## <#/GAPDoc> ## InstallMethod( MultMatrixColumn, "for a mutable matrix object, one column number, and an scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], @@ -1642,7 +1674,22 @@ InstallMethod( MultMatrixColumn, "for a mutable matrix object, one column number ############################################################################ ## -#M MultMatrixRowLeft( , , ) +#O MultMatrixRowLeft( , , ) +## +## <#GAPDoc Label="MultMatrixRowLeft"> +## +## +## +## nothing +## +## +##

+## For a matrix mat such that mat is mutable, a row index i +## and a scalar elm this operation multiplies elm with the i-th row +## in-place. +## +## +## <#/GAPDoc> ## InstallMethod( MultMatrixRowLeft, "for a mutable matrix object, one row number, and an scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], @@ -1654,7 +1701,22 @@ InstallMethod( MultMatrixRowLeft, "for a mutable matrix object, one row number, ############################################################################ ## -#M MultMatrixRowRight( , , ) +#O MultMatrixRowRight( , , ) +## +## <#GAPDoc Label="MultMatrixRowRight"> +## +## +## +## nothing +## +## +##

+## For a matrix mat such that mat is mutable, a row index i +## and a scalar elm this operation multiplies the i-th row with elm +## in-place. +## +## +## <#/GAPDoc> ## InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, and an scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], @@ -1675,7 +1737,22 @@ InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, ############################################################################ ## -#M MultMatrixColumnLeft( , , ) +#O MultMatrixColumnLeft( , , ) +## +## <#GAPDoc Label="MultMatrixColumnLeft"> +## +## +## +## nothing +## +## +##

+## For a matrix mat such that mat is mutable, a column index i +## and a scalar elm this operation multiplies elm with the i-th column +## in-place. +## +## +## <#/GAPDoc> ## InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column number, and an scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], @@ -1698,6 +1775,21 @@ InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column nu ## #M MultMatrixColumnRight( , , ) ## +## <#GAPDoc Label="MultMatrixColumnRight"> +## +## +## +## nothing +## +## +##

+## For a matrix mat such that mat is mutable, a column index i +## and a scalar elm this operation multiplies the i-th column with elm +## in-place. +## +## +## <#/GAPDoc> +## InstallMethod( MultMatrixColumnRight, "for a mutable matrix object, one row number, and an scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) @@ -1711,6 +1803,22 @@ InstallMethod( MultMatrixColumnRight, "for a mutable matrix object, one row numb ## #M AddMatrixRows( , , , ) ## +## <#GAPDoc Label="AddMatrixRows"> +## +## +## +## nothing +## +## +##

+## For a matrix mat such that mat is mutable, row indices i and j +## and a scalar elm this operation adds the product of elm and the j-th row +## to the i-th row in-place. +## Note that by default elm is multiplied from the left. +## +## +## <#/GAPDoc> +## InstallMethod( AddMatrixRows, "for a mutable matrix object, one row number, second row number, and an scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , function( mat, row1, row2, scalar ) @@ -1744,6 +1852,21 @@ InstallMethod( AddMatrixRows, "for a mutable matrix object, one row number, seco ## #M AddMatrixRowsLeft( , , , ) ## +## <#GAPDoc Label="AddMatrixRowsLeft"> +## +## +## +## nothing +## +## +##

+## For a matrix mat such that mat is mutable, row indices i and j +## and a scalar elm this operation adds the product of elm and the j-th row +## to the i-th row in-place. +## +## +## <#/GAPDoc> +## InstallMethod( AddMatrixRowsLeft, "for a mutable matrix object, one row number, second row number, and an scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , function( mat, row1, row2, scalar ) @@ -1754,7 +1877,22 @@ InstallMethod( AddMatrixRowsLeft, "for a mutable matrix object, one row number, ############################################################################ ## -#M AddMatrixRowsRight( , , , ) +#O AddMatrixRowsRight( , , , ) +## +## <#GAPDoc Label="AddMatrixRowsRight"> +## +## +## +## nothing +## +## +##

+## For a matrix mat such that mat is mutable, row indices i and j +## and a scalar elm this operation adds the product of the j-th row and elm +## to the i-th row in-place. +## +## +## <#/GAPDoc> ## InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, second row number, and an scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , @@ -1785,7 +1923,23 @@ InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, ############################################################################ ## -#M AddMatrixColumns( , , , ) +#O AddMatrixColumns( , , , ) +## +## <#GAPDoc Label="AddMatrixColumns"> +## +## +## +## nothing +## +## +##

+## For a matrix mat such that mat is mutable, column indices i and j +## and a scalar elm this operation adds the product of the j-th column and elm +## to the i-th column in-place. +## Note that by default elm is multiplied from the right. +## +## +## <#/GAPDoc> ## InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and an scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , @@ -1817,7 +1971,22 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number ############################################################################ ## -#M AddMatrixColumnsLeft( , , , ) +#O AddMatrixColumnsLeft( , , , ) +## +## <#GAPDoc Label="AddMatrixColumnsLeft"> +## +## +## +## nothing +## +## +##

+## For a matrix mat such that mat is mutable, column indices i and j +## and a scalar elm this operation adds the product of elm and the j-th column +## to the i-th column in-place. +## +## +## <#/GAPDoc> ## InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and an scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , @@ -1850,7 +2019,22 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number ############################################################################ ## -#M AddMatrixColumnsRight( , , , ) +#M AddMatrixColumnsRight( , , , ) +## +## <#GAPDoc Label="AddMatrixColumnsRight"> +## +## +## +## nothing +## +## +##

+## For a matrix mat such that mat is mutable, column indices i and j +## and a scalar elm this operation adds the product of the j-th column and elm +## to the i-th column in-place. +## +## +## <#/GAPDoc> ## InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and an scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , @@ -1863,7 +2047,21 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number ############################################################################ ## -#M SwapMatrixRows( , , ) +#O SwapMatrixRows( , , ) +## +## <#GAPDoc Label="SwapMatrixRows"> +## +## +## +## nothing +## +## +##

+## For a matrix mat such that mat is mutable and row indices i and j +## this operation swaps the indicated rows in mat in-place. +## +## +## <#/GAPDoc> ## InstallMethod( SwapMatrixRows, "for a mutable matrix object, one row number, second row number", [ IsMatrixObj and IsMutable, IsInt, IsInt ], @@ -1896,7 +2094,21 @@ InstallMethod( SwapMatrixRows, "for a mutable matrix object, one row number, sec ############################################################################ ## -#M SwapMatrixColumns( , , ) +#O SwapMatrixColumns( , , ) +## +## <#GAPDoc Label="SwapMatrixColumns"> +## +## +## +## nothing +## +## +##

+## For a matrix mat such that mat is mutable and column indices i and j +## this operation swaps the indicated columns in mat in-place. +## +## +## <#/GAPDoc> ## InstallMethod( SwapMatrixColumns, "for a mutable matrix object, one column number, second column number", [ IsMatrixObj and IsMutable, IsInt, IsInt ], From c1cb279556e285f88fcfbb043f3cd088165c27ba Mon Sep 17 00:00:00 2001 From: Lucas Wollenhaupt Date: Thu, 27 May 2021 13:16:20 +0200 Subject: [PATCH 03/23] Fix daniels mistakes --- lib/matobj.gi | 44 ++++++++++++++++++++++---------------------- lib/matobjplist.gi | 38 +++++++++++++++++++------------------- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/lib/matobj.gi b/lib/matobj.gi index 31a319d9fd..1f70354ee6 100644 --- a/lib/matobj.gi +++ b/lib/matobj.gi @@ -1603,7 +1603,7 @@ InstallMethod( MultMatrixRow, "for a mutable matrix object, one row number, and return fail; fi; - for i in [1..NrColumns(mat)] do + for i in [1..NrCols(mat)] do mat[row,i] := scalar * mat[row,i]; od; @@ -1624,7 +1624,7 @@ InstallMethod( MultMatrixRow, "for a mutable matrix object, one row number, and # CopyMat := ShallowCopy(mat); -# for i in [1..NrColumns(mat)] do +# for i in [1..NrCols(mat)] do # CopyMat[row,i] := scalar * CopyMat[row,i]; # od; @@ -1659,8 +1659,8 @@ InstallMethod( MultMatrixColumn, "for a mutable matrix object, one column number local i; # Checks - if not( 0 < row and row < NrColumns(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrColumns(mat) "); + if not( 0 < column and column < NrCols(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrCols(mat) "); return fail; fi; @@ -1729,7 +1729,7 @@ InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, return fail; fi; - for i in [1..NrColumns(mat)] do + for i in [1..NrCols(mat)] do mat[row,i] := mat[row,i] * scalar; od; @@ -1760,8 +1760,8 @@ InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column nu local i; # Checks - if not( 0 < row and row < NrColumns(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrColumns(mat) "); + if not( 0 < column and column < NrCols(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrCols(mat) "); return fail; fi; @@ -1836,7 +1836,7 @@ InstallMethod( AddMatrixRows, "for a mutable matrix object, one row number, seco if row1 <> row2 then - for i in [1..NrColumns(mat)] do + for i in [1..NrCols(mat)] do mat[row1,i] := mat[row1,i] + scalar * mat[row2,i]; od; @@ -1911,7 +1911,7 @@ InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, if row1 <> row2 then - for i in [1..NrColumns(mat)] do + for i in [1..NrCols(mat)] do mat[row1,i] := mat[row1,i] + mat[row2,i] * scalar; od; @@ -1947,12 +1947,12 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number local i; # Checks - if not( 0 < column1 and column1 < NrColumns(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrColumns(mat) "); + if not( 0 < column1 and column1 < NrCols(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrCols(mat) "); return fail; fi; - if not( 0 < column2 and column2 < NrColumns(mat) ) then - Print("The third argument row has to fulfill 0 < row < NrColumns(mat) "); + if not( 0 < column2 and column2 < NrCols(mat) ) then + Print("The third argument row has to fulfill 0 < row < NrCols(mat) "); return fail; fi; @@ -1994,12 +1994,12 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number local i; # Checks - if not( 0 < column1 and column1 < NrColumns(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrColumns(mat) "); + if not( 0 < column1 and column1 < NrCols(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrCols(mat) "); return fail; fi; - if not( 0 < column2 and column2 < NrColumns(mat) ) then - Print("The third argument row has to fulfill 0 < row < NrColumns(mat) "); + if not( 0 < column2 and column2 < NrCols(mat) ) then + Print("The third argument row has to fulfill 0 < row < NrCols(mat) "); return fail; fi; @@ -2080,7 +2080,7 @@ InstallMethod( SwapMatrixRows, "for a mutable matrix object, one row number, sec return fail; fi; - for i in [1..NrColumns(mat)] do + for i in [1..NrCols(mat)] do temp := mat[row1,i]; mat[row1,i] := mat[row2,i]; mat[row2,i] := temp; @@ -2118,12 +2118,12 @@ InstallMethod( SwapMatrixColumns, "for a mutable matrix object, one column numbe if column1 <> column2 then # Checks - if not( 0 < column1 and column1 < NrColumns(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrColumns(mat) "); + if not( 0 < column1 and column1 < NrCols(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrCols(mat) "); return fail; fi; - if not( 0 < column2 and column2 < NrColumns(mat) ) then - Print("The third argument row has to fulfill 0 < row < NrColumns(mat) "); + if not( 0 < column2 and column2 < NrCols(mat) ) then + Print("The third argument row has to fulfill 0 < row < NrCols(mat) "); return fail; fi; diff --git a/lib/matobjplist.gi b/lib/matobjplist.gi index 79fa1cca71..0e8d4dcedc 100644 --- a/lib/matobjplist.gi +++ b/lib/matobjplist.gi @@ -1319,8 +1319,8 @@ InstallMethod( MultMatrixColumn, "for a mutable matrix object, one column number local i; # Checks - if not( 0 < row and row < NrColumns(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrColumns(mat) "); + if not( 0 < column and column < NrCols(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrCols(mat) "); return fail; fi; @@ -1371,8 +1371,8 @@ InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column nu local i; # Checks - if not( 0 < row and row < NrColumns(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrColumns(mat) "); + if not( 0 < column and column < NrCols(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrCols(mat) "); return fail; fi; @@ -1416,7 +1416,7 @@ InstallMethod( AddMatrixRows, "for a mutable matrix object, one row number, seco if row1 <> row2 then - for i in [1..NrColumns(mat)] do + for i in [1..NrCols(mat)] do mat[row1,i] := mat[row1,i] + scalar * mat[row2,i]; od; @@ -1461,7 +1461,7 @@ InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, if row1 <> row2 then - for i in [1..NrColumns(mat)] do + for i in [1..NrCols(mat)] do mat[row1,i] := mat[row1,i] + mat[row2,i] * scalar; od; @@ -1481,12 +1481,12 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number local i; # Checks - if not( 0 < column1 and column1 < NrColumns(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrColumns(mat) "); + if not( 0 < column1 and column1 < NrCols(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrCols(mat) "); return fail; fi; - if not( 0 < column2 and column2 < NrColumns(mat) ) then - Print("The third argument row has to fulfill 0 < row < NrColumns(mat) "); + if not( 0 < column2 and column2 < NrCols(mat) ) then + Print("The third argument row has to fulfill 0 < row < NrCols(mat) "); return fail; fi; @@ -1513,12 +1513,12 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number local i; # Checks - if not( 0 < column1 and column1 < NrColumns(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrColumns(mat) "); + if not( 0 < column1 and column1 < NrCols(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrCols(mat) "); return fail; fi; - if not( 0 < column2 and column2 < NrColumns(mat) ) then - Print("The third argument row has to fulfill 0 < row < NrColumns(mat) "); + if not( 0 < column2 and column2 < NrCols(mat) ) then + Print("The third argument row has to fulfill 0 < row < NrCols(mat) "); return fail; fi; @@ -1570,7 +1570,7 @@ InstallMethod( SwapMatrixRows, "for a mutable matrix object, one row number, sec return fail; fi; - for i in [1..NrColumns(mat)] do + for i in [1..NrCols(mat)] do temp := mat[row1,i]; mat[row1,i] := mat[row2,i]; mat[row2,i] := temp; @@ -1594,12 +1594,12 @@ InstallMethod( SwapMatrixColumns, "for a mutable matrix object, one column numbe if column1 <> column2 then # Checks - if not( 0 < column1 and column1 < NrColumns(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrColumns(mat) "); + if not( 0 < column1 and column1 < NrCols(mat) ) then + Print("The second argument row has to fulfill 0 < row < NrCols(mat) "); return fail; fi; - if not( 0 < column2 and column2 < NrColumns(mat) ) then - Print("The third argument row has to fulfill 0 < row < NrColumns(mat) "); + if not( 0 < column2 and column2 < NrCols(mat) ) then + Print("The third argument row has to fulfill 0 < row < NrCols(mat) "); return fail; fi; From 02673a0b0a4fe9410f01d6f9141b3d4a51fb76ba Mon Sep 17 00:00:00 2001 From: Lucas Wollenhaupt Date: Thu, 27 May 2021 15:34:48 +0200 Subject: [PATCH 04/23] Tests for SwapMatrixRows and -Columns --- tst/testinstall/MatrixObj/ElementaryMatrices.tst | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tst/testinstall/MatrixObj/ElementaryMatrices.tst diff --git a/tst/testinstall/MatrixObj/ElementaryMatrices.tst b/tst/testinstall/MatrixObj/ElementaryMatrices.tst new file mode 100644 index 0000000000..fa004ef3ad --- /dev/null +++ b/tst/testinstall/MatrixObj/ElementaryMatrices.tst @@ -0,0 +1,10 @@ +gap> START_TEST("ElementaryMatrices.tst"); +gap> mat := [[2,4,5],[7,11,-4],[-3,20,0]];; +gap> SwapMatrixRows(mat,1,3); +gap> mat=[ [ -3, 20, 0 ], [ 7, 11, -4 ], [ 2, 4, 5 ] ]; +true +gap> mat := [[2,4,5],[7,11,-4],[-3,20,0]];; +gap> SwapMatrixColumns(mat,1,3); +gap> mat=[ [ 5, 4, 2 ], [ -4, 11, 7 ], [ 0, 20, -3 ] ]; +true +gap> STOP_TEST("ElementaryMatrices.tst",1); \ No newline at end of file From d0cec9770ee123a2f283247d4c0359ca6793a0aa Mon Sep 17 00:00:00 2001 From: Lucas Wollenhaupt Date: Thu, 27 May 2021 15:35:37 +0200 Subject: [PATCH 05/23] Checks fixed --- lib/matobj.gi | 64 +++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/lib/matobj.gi b/lib/matobj.gi index 1f70354ee6..72af4420df 100644 --- a/lib/matobj.gi +++ b/lib/matobj.gi @@ -1598,8 +1598,8 @@ InstallMethod( MultMatrixRow, "for a mutable matrix object, one row number, and local i; # Checks - if not( 0 < row and row < NrRows(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrRows(mat) "); + if not( 0 < row and row <= NrRows(mat) ) then + Print("The second argument row has to fulfill 0 < row <= NrRows(mat) "); return fail; fi; @@ -1659,8 +1659,8 @@ InstallMethod( MultMatrixColumn, "for a mutable matrix object, one column number local i; # Checks - if not( 0 < column and column < NrCols(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrCols(mat) "); + if not( 0 < column and column <= NrCols(mat) ) then + Print("The second argument row has to fulfill 0 < row <= NrCols(mat) "); return fail; fi; @@ -1724,8 +1724,8 @@ InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, local i; # Checks - if not( 0 < row and row < NrRows(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrRows(mat) "); + if not( 0 < row and row <= NrRows(mat) ) then + Print("The second argument row has to fulfill 0 < row <= NrRows(mat) "); return fail; fi; @@ -1760,8 +1760,8 @@ InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column nu local i; # Checks - if not( 0 < column and column < NrCols(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrCols(mat) "); + if not( 0 < column and column <= NrCols(mat) ) then + Print("The second argument row has to fulfill 0 < row <= NrCols(mat) "); return fail; fi; @@ -1825,12 +1825,12 @@ InstallMethod( AddMatrixRows, "for a mutable matrix object, one row number, seco local i; # Checks - if not( 0 < row1 and row1 < NrRows(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrRows(mat) "); + if not( 0 < row1 and row1 <= NrRows(mat) ) then + Print("The second argument row has to fulfill 0 < row <= NrRows(mat) "); return fail; fi; - if not( 0 < row2 and row2 < NrRows(mat) ) then - Print("The third argument row has to fulfill 0 < row < NrRows(mat) "); + if not( 0 < row2 and row2 <= NrRows(mat) ) then + Print("The third argument row has to fulfill 0 < row <= NrRows(mat) "); return fail; fi; @@ -1900,12 +1900,12 @@ InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, local i; # Checks - if not( 0 < row1 and row1 < NrRows(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrRows(mat) "); + if not( 0 < row1 and row1 <= NrRows(mat) ) then + Print("The second argument row has to fulfill 0 < row <= NrRows(mat) "); return fail; fi; - if not( 0 < row2 and row2 < NrRows(mat) ) then - Print("The third argument row has to fulfill 0 < row < NrRows(mat) "); + if not( 0 < row2 and row2 <= NrRows(mat) ) then + Print("The third argument row has to fulfill 0 < row <= NrRows(mat) "); return fail; fi; @@ -1947,12 +1947,12 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number local i; # Checks - if not( 0 < column1 and column1 < NrCols(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrCols(mat) "); + if not( 0 < column1 and column1 <= NrCols(mat) ) then + Print("The second argument row has to fulfill 0 < row <= NrCols(mat) "); return fail; fi; - if not( 0 < column2 and column2 < NrCols(mat) ) then - Print("The third argument row has to fulfill 0 < row < NrCols(mat) "); + if not( 0 < column2 and column2 <= NrCols(mat) ) then + Print("The third argument row has to fulfill 0 < row <= NrCols(mat) "); return fail; fi; @@ -1994,12 +1994,12 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number local i; # Checks - if not( 0 < column1 and column1 < NrCols(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrCols(mat) "); + if not( 0 < column1 and column1 <= NrCols(mat) ) then + Print("The second argument row has to fulfill 0 < row <= NrCols(mat) "); return fail; fi; - if not( 0 < column2 and column2 < NrCols(mat) ) then - Print("The third argument row has to fulfill 0 < row < NrCols(mat) "); + if not( 0 < column2 and column2 <= NrCols(mat) ) then + Print("The third argument row has to fulfill 0 < row <= NrCols(mat) "); return fail; fi; @@ -2071,12 +2071,12 @@ InstallMethod( SwapMatrixRows, "for a mutable matrix object, one row number, sec if row1 <> row2 then # Checks - if not( 0 < row1 and row1 < NrRows(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrRows(mat) "); + if not( 0 < row1 and row1 <= NrRows(mat) ) then + Print("The second argument row has to fulfill 0 < row <= NrRows(mat) "); return fail; fi; - if not( 0 < row2 and row2 < NrRows(mat) ) then - Print("The third argument row has to fulfill 0 < row < NrRows(mat) "); + if not( 0 < row2 and row2 <= NrRows(mat) ) then + Print("The third argument row has to fulfill 0 < row <= NrRows(mat) "); return fail; fi; @@ -2118,12 +2118,12 @@ InstallMethod( SwapMatrixColumns, "for a mutable matrix object, one column numbe if column1 <> column2 then # Checks - if not( 0 < column1 and column1 < NrCols(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrCols(mat) "); + if not( 0 < column1 and column1 <= NrCols(mat) ) then + Print("The second argument row has to fulfill 0 < row <= NrCols(mat) "); return fail; fi; - if not( 0 < column2 and column2 < NrCols(mat) ) then - Print("The third argument row has to fulfill 0 < row < NrCols(mat) "); + if not( 0 < column2 and column2 <= NrCols(mat) ) then + Print("The third argument row has to fulfill 0 < row <= NrCols(mat) "); return fail; fi; From 9472dbf513b1a79a7024455ce8ae7485f3aa7a7b Mon Sep 17 00:00:00 2001 From: Lucas Wollenhaupt Date: Thu, 27 May 2021 16:18:18 +0200 Subject: [PATCH 06/23] Corrections --- lib/matobj.gi | 95 ++++++++++++----------------------------- lib/matobjplist.gi | 104 +++++++++++++++++++-------------------------- 2 files changed, 72 insertions(+), 127 deletions(-) diff --git a/lib/matobj.gi b/lib/matobj.gi index 72af4420df..14b172f866 100644 --- a/lib/matobj.gi +++ b/lib/matobj.gi @@ -1592,15 +1592,14 @@ InstallMethod( \[\,\]\:\=, "for a matrix object, two positions, and an object", ## ## <#/GAPDoc> ## -InstallMethod( MultMatrixRow, "for a mutable matrix object, one row number, and an scalar", +InstallMethod( MultMatrixRow, "for a mutable matrix object, one row number, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) local i; # Checks if not( 0 < row and row <= NrRows(mat) ) then - Print("The second argument row has to fulfill 0 < row <= NrRows(mat) "); - return fail; + ErrorNoReturn("the second argument has to fulfill 0 < row <= NrRows(mat) "); fi; for i in [1..NrCols(mat)] do @@ -1610,29 +1609,6 @@ InstallMethod( MultMatrixRow, "for a mutable matrix object, one row number, and end ); -# TODO FOR MUTABLE MATRICES -# InstallMethod( MultMatrixRow, "for a mutable matrix object, one row number, and an scalar", -# [ IsMatrixObj, IsInt, IsObject ], -# function( mat, row, scalar ) -# local One, MatRow, i, CopyMat; - - # Checks -# if not( 0 < row and row < NrRows(mat) ) then -# Print("The second argument row has to fullfill 0 < row < NrRows(mat) "); -# return fail; -# fi; - -# CopyMat := ShallowCopy(mat); - -# for i in [1..NrCols(mat)] do -# CopyMat[row,i] := scalar * CopyMat[row,i]; -# od; - - # return Matrix(CopyMat,mat); - -# end ); - - ############################################################################ ## #O MultMatrixColumn( , , ) @@ -1653,15 +1629,14 @@ InstallMethod( MultMatrixRow, "for a mutable matrix object, one row number, and ## ## <#/GAPDoc> ## -InstallMethod( MultMatrixColumn, "for a mutable matrix object, one column number, and an scalar", +InstallMethod( MultMatrixColumn, "for a mutable matrix object, one column number, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, column, scalar ) local i; # Checks if not( 0 < column and column <= NrCols(mat) ) then - Print("The second argument row has to fulfill 0 < row <= NrCols(mat) "); - return fail; + ErrorNoReturn("the second argument column has to fulfill 0 < column <= NrCols(mat) "); fi; for i in [1..NrRows(mat)] do @@ -1691,7 +1666,7 @@ InstallMethod( MultMatrixColumn, "for a mutable matrix object, one column number ## ## <#/GAPDoc> ## -InstallMethod( MultMatrixRowLeft, "for a mutable matrix object, one row number, and an scalar", +InstallMethod( MultMatrixRowLeft, "for a mutable matrix object, one row number, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) @@ -1718,15 +1693,14 @@ InstallMethod( MultMatrixRowLeft, "for a mutable matrix object, one row number, ## ## <#/GAPDoc> ## -InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, and an scalar", +InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) local i; # Checks if not( 0 < row and row <= NrRows(mat) ) then - Print("The second argument row has to fulfill 0 < row <= NrRows(mat) "); - return fail; + ErrorNoReturn("the second argument row has to fulfill 0 < row <= NrRows(mat) "); fi; for i in [1..NrCols(mat)] do @@ -1754,15 +1728,14 @@ InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, ## ## <#/GAPDoc> ## -InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column number, and an scalar", +InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column number, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, column, scalar ) local i; # Checks if not( 0 < column and column <= NrCols(mat) ) then - Print("The second argument row has to fulfill 0 < row <= NrCols(mat) "); - return fail; + ErrorNoReturn("the second argument column has to fulfill 0 < column <= NrCols(mat) "); fi; for i in [1..NrRows(mat)] do @@ -1790,7 +1763,7 @@ InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column nu ## ## <#/GAPDoc> ## -InstallMethod( MultMatrixColumnRight, "for a mutable matrix object, one row number, and an scalar", +InstallMethod( MultMatrixColumnRight, "for a mutable matrix object, one row number, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) @@ -1819,19 +1792,17 @@ InstallMethod( MultMatrixColumnRight, "for a mutable matrix object, one row numb ## ## <#/GAPDoc> ## -InstallMethod( AddMatrixRows, "for a mutable matrix object, one row number, second row number, and an scalar", +InstallMethod( AddMatrixRows, "for a mutable matrix object, one row number, second row number, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , function( mat, row1, row2, scalar ) local i; # Checks if not( 0 < row1 and row1 <= NrRows(mat) ) then - Print("The second argument row has to fulfill 0 < row <= NrRows(mat) "); - return fail; + ErrorNoReturn("the second argument row has to fulfill 0 < row <= NrRows(mat) "); fi; if not( 0 < row2 and row2 <= NrRows(mat) ) then - Print("The third argument row has to fulfill 0 < row <= NrRows(mat) "); - return fail; + ErrorNoReturn("the third argument row has to fulfill 0 < row <= NrRows(mat) "); fi; if row1 <> row2 then @@ -1867,7 +1838,7 @@ InstallMethod( AddMatrixRows, "for a mutable matrix object, one row number, seco ## ## <#/GAPDoc> ## -InstallMethod( AddMatrixRowsLeft, "for a mutable matrix object, one row number, second row number, and an scalar", +InstallMethod( AddMatrixRowsLeft, "for a mutable matrix object, one row number, second row number, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , function( mat, row1, row2, scalar ) @@ -1894,19 +1865,17 @@ InstallMethod( AddMatrixRowsLeft, "for a mutable matrix object, one row number, ## ## <#/GAPDoc> ## -InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, second row number, and an scalar", +InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, second row number, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , function( mat, row1, row2, scalar ) local i; # Checks if not( 0 < row1 and row1 <= NrRows(mat) ) then - Print("The second argument row has to fulfill 0 < row <= NrRows(mat) "); - return fail; + ErrorNoReturn("the second argument row has to fulfill 0 < row <= NrRows(mat) "); fi; if not( 0 < row2 and row2 <= NrRows(mat) ) then - Print("The third argument row has to fulfill 0 < row <= NrRows(mat) "); - return fail; + ErrorNoReturn("the third argument row has to fulfill 0 < row <= NrRows(mat) "); fi; if row1 <> row2 then @@ -1941,19 +1910,17 @@ InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, ## ## <#/GAPDoc> ## -InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and an scalar", +InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , function( mat, column1, column2, scalar ) local i; # Checks if not( 0 < column1 and column1 <= NrCols(mat) ) then - Print("The second argument row has to fulfill 0 < row <= NrCols(mat) "); - return fail; + ErrorNoReturn("the second argument column has to fulfill 0 < column <= NrCols(mat) "); fi; if not( 0 < column2 and column2 <= NrCols(mat) ) then - Print("The third argument row has to fulfill 0 < row <= NrCols(mat) "); - return fail; + ErrorNoReturn("the third argument column has to fulfill 0 < column <= NrCols(mat) "); fi; if column1 <> column2 then @@ -1988,19 +1955,17 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number ## ## <#/GAPDoc> ## -InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and an scalar", +InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , function( mat, column1, column2, scalar ) local i; # Checks if not( 0 < column1 and column1 <= NrCols(mat) ) then - Print("The second argument row has to fulfill 0 < row <= NrCols(mat) "); - return fail; + ErrorNoReturn("the second argument column has to fulfill 0 < column <= NrCols(mat) "); fi; if not( 0 < column2 and column2 <= NrCols(mat) ) then - Print("The third argument row has to fulfill 0 < row <= NrCols(mat) "); - return fail; + ErrorNoReturn("the third argument column has to fulfill 0 < column <= NrCols(mat) "); fi; if column1 <> column2 then @@ -2036,7 +2001,7 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number ## ## <#/GAPDoc> ## -InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and an scalar", +InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , function( mat, column1, column2, scalar ) @@ -2072,12 +2037,10 @@ InstallMethod( SwapMatrixRows, "for a mutable matrix object, one row number, sec # Checks if not( 0 < row1 and row1 <= NrRows(mat) ) then - Print("The second argument row has to fulfill 0 < row <= NrRows(mat) "); - return fail; + ErrorNoReturn("the second argument row has to fulfill 0 < row <= NrRows(mat) "); fi; if not( 0 < row2 and row2 <= NrRows(mat) ) then - Print("The third argument row has to fulfill 0 < row <= NrRows(mat) "); - return fail; + ErrorNoReturn("the third argument row has to fulfill 0 < row <= NrRows(mat) "); fi; for i in [1..NrCols(mat)] do @@ -2119,12 +2082,10 @@ InstallMethod( SwapMatrixColumns, "for a mutable matrix object, one column numbe # Checks if not( 0 < column1 and column1 <= NrCols(mat) ) then - Print("The second argument row has to fulfill 0 < row <= NrCols(mat) "); - return fail; + ErrorNoReturn("the second argument column has to fulfill 0 < column <= NrCols(mat) "); fi; if not( 0 < column2 and column2 <= NrCols(mat) ) then - Print("The third argument row has to fulfill 0 < row <= NrCols(mat) "); - return fail; + ErrorNoReturn("the third argument column has to fulfill 0 < column <= NrCols(mat) "); fi; for i in [1..NrRows(mat)] do diff --git a/lib/matobjplist.gi b/lib/matobjplist.gi index 0e8d4dcedc..a1699585f2 100644 --- a/lib/matobjplist.gi +++ b/lib/matobjplist.gi @@ -1294,14 +1294,13 @@ InstallMethod( NewCompanionMatrix, ## #M MultMatrixRow( , , ) ## -InstallMethod( MultMatrixRow, "for a mutable IsPlistMatrixRep, one row number, and an scalar", +InstallMethod( MultMatrixRow, "for a mutable IsPlistMatrixRep, one row number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) # Checks - if not( 0 < row and row < NrRows(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrRows(mat) "); - return fail; + if not( 0 < row and row <= NrRows(mat) ) then + ErrorNoReturn("the second argument row has to fulfill 0 < row <= NrRows(mat) "); fi; mat[row] := scalar * mat[row]; @@ -1313,15 +1312,14 @@ InstallMethod( MultMatrixRow, "for a mutable IsPlistMatrixRep, one row number, a ## #M MultMatrixColumn( , , ) ## -InstallMethod( MultMatrixColumn, "for a mutable matrix object, one column number, and an scalar", +InstallMethod( MultMatrixColumn, "for a mutable matrix object, one column number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsObject ], function( mat, column, scalar ) local i; # Checks - if not( 0 < column and column < NrCols(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrCols(mat) "); - return fail; + if not( 0 < column and column <= NrCols(mat) ) then + ErrorNoReturn("the second argument column has to fulfill 0 < column <= NrCols(mat) "); fi; # TODO ASK MAX @@ -1334,7 +1332,7 @@ InstallMethod( MultMatrixColumn, "for a mutable matrix object, one column number ## #M MultMatrixRowLeft( , , ) ## -InstallMethod( MultMatrixRowLeft, "for a mutable matrix object, one row number, and an scalar", +InstallMethod( MultMatrixRowLeft, "for a mutable matrix object, one row number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) @@ -1346,15 +1344,14 @@ InstallMethod( MultMatrixRowLeft, "for a mutable matrix object, one row number, ## #M MultMatrixRowRight( , , ) ## -InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, and an scalar", +InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) local i; # Checks - if not( 0 < row and row < NrRows(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrRows(mat) "); - return fail; + if not( 0 < row and row <= NrRows(mat) ) then + ErrorNoReturn("the second argument row has to fulfill 0 < row <= NrRows(mat) "); fi; mat[row] := mat[row] * scalar; @@ -1365,15 +1362,14 @@ InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, ## #M MultMatrixColumnLeft( , , ) ## -InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column number, and an scalar", +InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsObject ], function( mat, column, scalar ) local i; # Checks - if not( 0 < column and column < NrCols(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrCols(mat) "); - return fail; + if not( 0 < column and column <= NrCols(mat) ) then + ErrorNoReturn("the second argument column has to fulfill 0 < column <= NrCols(mat) "); fi; for i in [1..NrRows(mat)] do @@ -1386,7 +1382,7 @@ InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column nu ## #M MultMatrixColumnRight( , , ) ## -InstallMethod( MultMatrixColumnRight, "for a mutable matrix object, one row number, and an scalar", +InstallMethod( MultMatrixColumnRight, "for a mutable matrix object, one row number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) @@ -1399,19 +1395,17 @@ InstallMethod( MultMatrixColumnRight, "for a mutable matrix object, one row numb ## #M AddMatrixRows( , , , ) ## -InstallMethod( AddMatrixRows, "for a mutable matrix object, one row number, second row number, and an scalar", +InstallMethod( AddMatrixRows, "for a mutable matrix object, one row number, second row number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , function( mat, row1, row2, scalar ) local i; # Checks - if not( 0 < row1 and row1 < NrRows(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrRows(mat) "); - return fail; + if not( 0 < row1 and row1 <= NrRows(mat) ) then + ErrorNoReturn("the second argument row has to fulfill 0 < row <= NrRows(mat) "); fi; - if not( 0 < row2 and row2 < NrRows(mat) ) then - Print("The third argument row has to fulfill 0 < row < NrRows(mat) "); - return fail; + if not( 0 < row2 and row2 <= NrRows(mat) ) then + ErrorNoReturn("the third argument row has to fulfill 0 < row <= NrRows(mat) "); fi; if row1 <> row2 then @@ -1432,7 +1426,7 @@ InstallMethod( AddMatrixRows, "for a mutable matrix object, one row number, seco ## #M AddMatrixRowsLeft( , , , ) ## -InstallMethod( AddMatrixRowsLeft, "for a mutable matrix object, one row number, second row number, and an scalar", +InstallMethod( AddMatrixRowsLeft, "for a mutable matrix object, one row number, second row number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , function( mat, row1, row2, scalar ) @@ -1444,19 +1438,17 @@ InstallMethod( AddMatrixRowsLeft, "for a mutable matrix object, one row number, ## #M AddMatrixRowsRight( , , , ) ## -InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, second row number, and an scalar", +InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, second row number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , function( mat, row1, row2, scalar ) local i; # Checks - if not( 0 < row1 and row1 < NrRows(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrRows(mat) "); - return fail; + if not( 0 < row1 and row1 <= NrRows(mat) ) then + ErrorNoReturn("the second argument row has to fulfill 0 < row <= NrRows(mat) "); fi; - if not( 0 < row2 and row2 < NrRows(mat) ) then - Print("The third argument row has to fulfill 0 < row < NrRows(mat) "); - return fail; + if not( 0 < row2 and row2 <= NrRows(mat) ) then + ErrorNoReturn("the third argument row has to fulfill 0 < row <= NrRows(mat) "); fi; if row1 <> row2 then @@ -1475,19 +1467,17 @@ InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, ## #M AddMatrixColumns( , , , ) ## -InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and an scalar", +InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , function( mat, column1, column2, scalar ) local i; # Checks - if not( 0 < column1 and column1 < NrCols(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrCols(mat) "); - return fail; + if not( 0 < column1 and column1 <= NrCols(mat) ) then + ErrorNoReturn("the second argument column has to fulfill 0 < column <= NrCols(mat) "); fi; - if not( 0 < column2 and column2 < NrCols(mat) ) then - Print("The third argument row has to fulfill 0 < row < NrCols(mat) "); - return fail; + if not( 0 < column2 and column2 <= NrCols(mat) ) then + ErrorNoReturn("the third argument column has to fulfill 0 < column <= NrCols(mat) "); fi; if column1 <> column2 then @@ -1507,19 +1497,17 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number ## #M AddMatrixColumnsLeft( , , , ) ## -InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and an scalar", +InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , function( mat, column1, column2, scalar ) local i; # Checks - if not( 0 < column1 and column1 < NrCols(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrCols(mat) "); - return fail; + if not( 0 < column1 and column1 <= NrCols(mat) ) then + ErrorNoReturn("the second argument column has to fulfill 0 < column <= NrCols(mat) "); fi; - if not( 0 < column2 and column2 < NrCols(mat) ) then - Print("The third argument row has to fulfill 0 < row < NrCols(mat) "); - return fail; + if not( 0 < column2 and column2 <= NrCols(mat) ) then + ErrorNoReturn("the third argument column has to fulfill 0 < column <= NrCols(mat) "); fi; if column1 <> column2 then @@ -1540,7 +1528,7 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number ## #M AddMatrixColumnsRight( , , , ) ## -InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and an scalar", +InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , function( mat, column1, column2, scalar ) @@ -1561,13 +1549,11 @@ InstallMethod( SwapMatrixRows, "for a mutable matrix object, one row number, sec if row1 <> row2 then # Checks - if not( 0 < row1 and row1 < NrRows(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrRows(mat) "); - return fail; + if not( 0 < row1 and row1 <= NrRows(mat) ) then + ErrorNoReturn("the second argument row has to fulfill 0 < row <= NrRows(mat) "); fi; - if not( 0 < row2 and row2 < NrRows(mat) ) then - Print("The third argument row has to fulfill 0 < row < NrRows(mat) "); - return fail; + if not( 0 < row2 and row2 <= NrRows(mat) ) then + ErrorNoReturn("the third argument row has to fulfill 0 < row <= NrRows(mat) "); fi; for i in [1..NrCols(mat)] do @@ -1594,13 +1580,11 @@ InstallMethod( SwapMatrixColumns, "for a mutable matrix object, one column numbe if column1 <> column2 then # Checks - if not( 0 < column1 and column1 < NrCols(mat) ) then - Print("The second argument row has to fulfill 0 < row < NrCols(mat) "); - return fail; + if not( 0 < column1 and column1 <= NrCols(mat) ) then + ErrorNoReturn("the second argument column has to fulfill 0 < column <= NrCols(mat) "); fi; - if not( 0 < column2 and column2 < NrCols(mat) ) then - Print("The third argument row has to fulfill 0 < row < NrCols(mat) "); - return fail; + if not( 0 < column2 and column2 <= NrCols(mat) ) then + ErrorNoReturn("the third argument column has to fulfill 0 < column <= NrCols(mat) "); fi; for i in [1..NrRows(mat)] do From 1035a6f93a85ea97bf885f07b3cda3a5de36cb63 Mon Sep 17 00:00:00 2001 From: Lucas Wollenhaupt Date: Thu, 27 May 2021 16:18:56 +0200 Subject: [PATCH 07/23] Tests: corrections for MatrixObj --- tst/testinstall/MatrixObj/ElementaryMatrices.tst | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tst/testinstall/MatrixObj/ElementaryMatrices.tst b/tst/testinstall/MatrixObj/ElementaryMatrices.tst index fa004ef3ad..ff5e164a02 100644 --- a/tst/testinstall/MatrixObj/ElementaryMatrices.tst +++ b/tst/testinstall/MatrixObj/ElementaryMatrices.tst @@ -1,10 +1,14 @@ gap> START_TEST("ElementaryMatrices.tst"); -gap> mat := [[2,4,5],[7,11,-4],[-3,20,0]];; + +# +gap> mat := Matrix( [[2,4,5],[7,11,-4],[-3,20,0]]);; gap> SwapMatrixRows(mat,1,3); -gap> mat=[ [ -3, 20, 0 ], [ 7, 11, -4 ], [ 2, 4, 5 ] ]; +gap> mat= Matrix( [ [ -3, 20, 0 ], [ 7, 11, -4 ], [ 2, 4, 5 ] ]); true -gap> mat := [[2,4,5],[7,11,-4],[-3,20,0]];; + +# +gap> mat := Matrix( [[2,4,5],[7,11,-4],[-3,20,0]]);; gap> SwapMatrixColumns(mat,1,3); -gap> mat=[ [ 5, 4, 2 ], [ -4, 11, 7 ], [ 0, 20, -3 ] ]; +gap> mat= Matrix( [ [ 5, 4, 2 ], [ -4, 11, 7 ], [ 0, 20, -3 ] ]); true gap> STOP_TEST("ElementaryMatrices.tst",1); \ No newline at end of file From 800d82dd02348cfd9cec1c83918780627fd5b8be Mon Sep 17 00:00:00 2001 From: Lucas Wollenhaupt Date: Thu, 27 May 2021 17:30:22 +0200 Subject: [PATCH 08/23] Touch up with Sergio and Thomas' suggestions --- doc/ref/matobj.xml | 4 - lib/matobj.gi | 235 +++++++++--------------------------------- lib/matobj2.gd | 8 +- lib/matobjplist.gi | 247 ++++----------------------------------------- 4 files changed, 73 insertions(+), 421 deletions(-) diff --git a/doc/ref/matobj.xml b/doc/ref/matobj.xml index 50baa11b52..0618aa2fb2 100644 --- a/doc/ref/matobj.xml +++ b/doc/ref/matobj.xml @@ -291,17 +291,13 @@ for your new type of vector or matrix objects.) Basic operations for row/column reductions <#Include Label="MultMatrixRow"> -<#Include Label="MultMatrixRowLeft"> <#Include Label="MultMatrixRowRight"> <#Include Label="MultMatrixColumn"> <#Include Label="MultMatrixColumnLeft"> -<#Include Label="MultMatrixColumnRight"> <#Include Label="AddMatrixRows"> -<#Include Label="AddMatrixRowsLeft"> <#Include Label="AddMatrixRowsRight"> <#Include Label="AddMatrixColumns"> <#Include Label="AddMatrixColumnsLeft"> -<#Include Label="AddMatrixColumnsRight"> <#Include Label="SwapMatrixRows"> <#Include Label="SwapMatrixColumns"> diff --git a/lib/matobj.gi b/lib/matobj.gi index 14b172f866..3711e28d5a 100644 --- a/lib/matobj.gi +++ b/lib/matobj.gi @@ -1579,15 +1579,16 @@ InstallMethod( \[\,\]\:\=, "for a matrix object, two positions, and an object", ## <#GAPDoc Label="MultMatrixRow"> ## ## +## ## ## nothing ## ## ##

-## For a matrix mat such that mat is mutable, a row index i -## and a scalar elm this operation multiplies elm with the i-th row -## in-place. -## Note that by default elm is multiplied from the left. +## Multiplies the i-th row of the mutable matrix mat with the scalar +## elm from the left in-place. +##

+## MultMatrixRowLeft is a synonym for MultMatrixRow. ## ## ## <#/GAPDoc> @@ -1616,15 +1617,16 @@ InstallMethod( MultMatrixRow, "for a mutable matrix object, one row number, and ## <#GAPDoc Label="MultMatrixColumn"> ## ## +## ## ## nothing ## ## ##

-## For a matrix mat such that mat is mutable, a column index i -## and a scalar elm this operation multiplies the i-th column with elm -## in-place. -## Note that by default elm is multiplied from the right. +## Multiplies the i-th column of the mutable matrix mat with the scalar +## elm from the right in-place. +##

+## MultMatrixColumnRight is a synonym for MultMatrixColumn. ## ## ## <#/GAPDoc> @@ -1645,34 +1647,6 @@ InstallMethod( MultMatrixColumn, "for a mutable matrix object, one column number end ); - - -############################################################################ -## -#O MultMatrixRowLeft( , , ) -## -## <#GAPDoc Label="MultMatrixRowLeft"> -## -## -## -## nothing -## -## -##

-## For a matrix mat such that mat is mutable, a row index i -## and a scalar elm this operation multiplies elm with the i-th row -## in-place. -## -## -## <#/GAPDoc> -## -InstallMethod( MultMatrixRowLeft, "for a mutable matrix object, one row number, and a scalar", - [ IsMatrixObj and IsMutable, IsInt, IsObject ], - function( mat, row, scalar ) - - MultMatrixRow(mat,row,scalar); - - end ); ############################################################################ ## @@ -1686,9 +1660,8 @@ InstallMethod( MultMatrixRowLeft, "for a mutable matrix object, one row number, ## ## ##

-## For a matrix mat such that mat is mutable, a row index i -## and a scalar elm this operation multiplies the i-th row with elm -## in-place. +## Multiplies the i-th row of the mutable matrix mat with the scalar +## elm from the right in-place. ## ## ## <#/GAPDoc> @@ -1721,9 +1694,8 @@ InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, ## ## ##

-## For a matrix mat such that mat is mutable, a column index i -## and a scalar elm this operation multiplies elm with the i-th column -## in-place. +## Multiplies the i-th column of the mutable matrix mat with the scalar +## elm from the left in-place. ## ## ## <#/GAPDoc> @@ -1744,33 +1716,6 @@ InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column nu end ); -############################################################################ -## -#M MultMatrixColumnRight( , , ) -## -## <#GAPDoc Label="MultMatrixColumnRight"> -## -## -## -## nothing -## -## -##

-## For a matrix mat such that mat is mutable, a column index i -## and a scalar elm this operation multiplies the i-th column with elm -## in-place. -## -## -## <#/GAPDoc> -## -InstallMethod( MultMatrixColumnRight, "for a mutable matrix object, one row number, and a scalar", - [ IsMatrixObj and IsMutable, IsInt, IsObject ], - function( mat, row, scalar ) - - MultMatrixColumn(mat,row,scalar); - - end ); - ############################################################################ ## @@ -1779,15 +1724,16 @@ InstallMethod( MultMatrixColumnRight, "for a mutable matrix object, one row numb ## <#GAPDoc Label="AddMatrixRows"> ## ## +## ## ## nothing ## ## ##

-## For a matrix mat such that mat is mutable, row indices i and j -## and a scalar elm this operation adds the product of elm and the j-th row -## to the i-th row in-place. -## Note that by default elm is multiplied from the left. +## Adds the product of elm with the j-th row of the mutable matrix mat to its i-th +## row in-place. The j-th row is multiplied with elm from the left. +##

+## AddMatrixRowsLeft is a synonym for AddMatrixRows. ## ## ## <#/GAPDoc> @@ -1804,47 +1750,13 @@ InstallMethod( AddMatrixRows, "for a mutable matrix object, one row number, seco if not( 0 < row2 and row2 <= NrRows(mat) ) then ErrorNoReturn("the third argument row has to fulfill 0 < row <= NrRows(mat) "); fi; - - if row1 <> row2 then - - for i in [1..NrCols(mat)] do - mat[row1,i] := mat[row1,i] + scalar * mat[row2,i]; - od; - - else - MultMatrixRow(mat,row1,scalar+1); - fi; - - - end ); - -############################################################################ -## -#M AddMatrixRowsLeft( , , , ) -## -## <#GAPDoc Label="AddMatrixRowsLeft"> -## -## -## -## nothing -## -## -##

-## For a matrix mat such that mat is mutable, row indices i and j -## and a scalar elm this operation adds the product of elm and the j-th row -## to the i-th row in-place. -## -## -## <#/GAPDoc> -## -InstallMethod( AddMatrixRowsLeft, "for a mutable matrix object, one row number, second row number, and a scalar", - [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , - function( mat, row1, row2, scalar ) - - AddMatrixRows(mat,row1,row2,scalar); - + for i in [1..NrCols(mat)] do + mat[row1,i] := mat[row1,i] + scalar * mat[row2,i]; + od; + end ); + ############################################################################ ## @@ -1858,9 +1770,8 @@ InstallMethod( AddMatrixRowsLeft, "for a mutable matrix object, one row number, ## ## ##

-## For a matrix mat such that mat is mutable, row indices i and j -## and a scalar elm this operation adds the product of the j-th row and elm -## to the i-th row in-place. +## Adds the product of elm with the j-th row of the mutable matrix mat to its i-th +## row in-place. The j-th row is multiplied with elm from the right. ## ## ## <#/GAPDoc> @@ -1878,16 +1789,10 @@ InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, ErrorNoReturn("the third argument row has to fulfill 0 < row <= NrRows(mat) "); fi; - if row1 <> row2 then - - for i in [1..NrCols(mat)] do - mat[row1,i] := mat[row1,i] + mat[row2,i] * scalar; - od; - - else - MultMatrixRowRight(mat,row1,scalar+1); - fi; - + for i in [1..NrCols(mat)] do + mat[row1,i] := mat[row1,i] + mat[row2,i] * scalar; + od; + end ); ############################################################################ @@ -1897,15 +1802,16 @@ InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, ## <#GAPDoc Label="AddMatrixColumns"> ## ## +## ## ## nothing ## ## ##

-## For a matrix mat such that mat is mutable, column indices i and j -## and a scalar elm this operation adds the product of the j-th column and elm -## to the i-th column in-place. -## Note that by default elm is multiplied from the right. +## Adds the product of elm with the j-th column of the mutable matrix mat to its i-th +## column in-place. The j-th column is multiplied with elm from the right. +##

+## AddMatrixColumnsRight is a synonym for AddMatrixColumns. ## ## ## <#/GAPDoc> @@ -1922,18 +1828,11 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number if not( 0 < column2 and column2 <= NrCols(mat) ) then ErrorNoReturn("the third argument column has to fulfill 0 < column <= NrCols(mat) "); fi; - - if column1 <> column2 then - - for i in [1..NrRows(mat)] do - mat[i,column1] := mat[i,column1] + mat[i,column2] * scalar; - od; - - else - MultMatrixColumn(mat,column1,scalar+1); - fi; - - + + for i in [1..NrRows(mat)] do + mat[i,column1] := mat[i,column1] + mat[i,column2] * scalar; + od; + end ); ############################################################################ @@ -1948,9 +1847,8 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number ## ## ##

-## For a matrix mat such that mat is mutable, column indices i and j -## and a scalar elm this operation adds the product of elm and the j-th column -## to the i-th column in-place. +## Adds the product of elm with the j-th column of the mutable matrix mat to its i-th +## column in-place. The j-th column is multiplied with elm from the left. ## ## ## <#/GAPDoc> @@ -1967,46 +1865,11 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number if not( 0 < column2 and column2 <= NrCols(mat) ) then ErrorNoReturn("the third argument column has to fulfill 0 < column <= NrCols(mat) "); fi; - - if column1 <> column2 then - - for i in [1..NrRows(mat)] do - mat[i,column1] := mat[i,column1] + scalar * mat[i,column2] ; - od; - - else - MultMatrixColumnLeft(mat,column1,scalar+1); - fi; - - - end ); - -############################################################################ -## -#M AddMatrixColumnsRight( , , , ) -## -## <#GAPDoc Label="AddMatrixColumnsRight"> -## -## -## -## nothing -## -## -##

-## For a matrix mat such that mat is mutable, column indices i and j -## and a scalar elm this operation adds the product of the j-th column and elm -## to the i-th column in-place. -## -## -## <#/GAPDoc> -## -InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and a scalar", - [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , - function( mat, column1, column2, scalar ) - - AddMatrixColumns(mat,column1,column2,scalar); - + for i in [1..NrRows(mat)] do + mat[i,column1] := mat[i,column1] + scalar * mat[i,column2] ; + od; + end ); @@ -2022,8 +1885,7 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number ## ## ##

-## For a matrix mat such that mat is mutable and row indices i and j -## this operation swaps the indicated rows in mat in-place. +## Swaps the i-th row and j-th row of a mutable matrix mat. ## ## ## <#/GAPDoc> @@ -2067,8 +1929,7 @@ InstallMethod( SwapMatrixRows, "for a mutable matrix object, one row number, sec ## ## ##

-## For a matrix mat such that mat is mutable and column indices i and j -## this operation swaps the indicated columns in mat in-place. +## Swaps the i-th column and j-th column of a mutable matrix mat. ## ## ## <#/GAPDoc> diff --git a/lib/matobj2.gd b/lib/matobj2.gd index 583cc910d8..c7cab96ca5 100644 --- a/lib/matobj2.gd +++ b/lib/matobj2.gd @@ -1936,16 +1936,16 @@ DeclareOperation( "[]:=", [ IsMatrixObj, IsPosInt, IsPosInt, IsObject ] ); ## TODO DESCRIPTION ## DeclareOperation( "MultMatrixRow", [ IsMatrixObj and IsMutable, IsInt, IsObject ] ); +DeclareSynonym( "MultMatrixRowLeft", MultMatrixRow); DeclareOperation( "MultMatrixColumn", [ IsMatrixObj and IsMutable, IsInt, IsObject ] ); -DeclareOperation( "MultMatrixRowLeft", [ IsMatrixObj and IsMutable, IsInt, IsObject ] ); -DeclareOperation( "MultMatrixRowRight", [ IsMatrixObj and IsMutable, IsInt, IsObject ] ); +DeclareSynonym( "MultMatrixRowRight", MultMatrixColumn); DeclareOperation( "MultMatrixColumnLeft", [ IsMatrixObj and IsMutable, IsInt, IsObject ] ); DeclareOperation( "MultMatrixColumnRight", [ IsMatrixObj and IsMutable, IsInt, IsObject ] ); DeclareOperation( "AddMatrixRows", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] ); -DeclareOperation( "AddMatrixRowsLeft", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] ); +DeclareSynonym( "AddMatrixRowsLeft", AddMatrixRows); DeclareOperation( "AddMatrixRowsRight", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] ); DeclareOperation( "AddMatrixColumns", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] ); +DeclareSynonym( "AddMatrixColumnsRight", AddMatrixColumns); DeclareOperation( "AddMatrixColumnsLeft", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] ); -DeclareOperation( "AddMatrixColumnsRight", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] ); DeclareOperation( "SwapMatrixRows", [ IsMatrixObj and IsMutable, IsInt, IsInt ] ); DeclareOperation( "SwapMatrixColumns", [ IsMatrixObj and IsMutable, IsInt, IsInt ] ); diff --git a/lib/matobjplist.gi b/lib/matobjplist.gi index a1699585f2..259f780eb2 100644 --- a/lib/matobjplist.gi +++ b/lib/matobjplist.gi @@ -1294,7 +1294,7 @@ InstallMethod( NewCompanionMatrix, ## #M MultMatrixRow( , , ) ## -InstallMethod( MultMatrixRow, "for a mutable IsPlistMatrixRep, one row number, and a scalar", +InstallMethod( MultMatrixRow, "for a mutable IsRowListMatrix, one row number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) @@ -1308,43 +1308,11 @@ InstallMethod( MultMatrixRow, "for a mutable IsPlistMatrixRep, one row number, a end ); -############################################################################ -## -#M MultMatrixColumn( , , ) -## -InstallMethod( MultMatrixColumn, "for a mutable matrix object, one column number, and a scalar", - [ IsRowListMatrix and IsMutable, IsInt, IsObject ], - function( mat, column, scalar ) - local i; - - # Checks - if not( 0 < column and column <= NrCols(mat) ) then - ErrorNoReturn("the second argument column has to fulfill 0 < column <= NrCols(mat) "); - fi; - - # TODO ASK MAX - - end ); - - - -############################################################################ -## -#M MultMatrixRowLeft( , , ) -## -InstallMethod( MultMatrixRowLeft, "for a mutable matrix object, one row number, and a scalar", - [ IsRowListMatrix and IsMutable, IsInt, IsObject ], - function( mat, row, scalar ) - - MultMatrixRow(mat,row,scalar); - - end ); - ############################################################################ ## #M MultMatrixRowRight( , , ) ## -InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, and a scalar", +InstallMethod( MultMatrixRowRight, "for a mutable IsRowListMatrix, one row number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) local i; @@ -1358,44 +1326,12 @@ InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, end ); -############################################################################ -## -#M MultMatrixColumnLeft( , , ) -## -InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column number, and a scalar", - [ IsRowListMatrix and IsMutable, IsInt, IsObject ], - function( mat, column, scalar ) - local i; - - # Checks - if not( 0 < column and column <= NrCols(mat) ) then - ErrorNoReturn("the second argument column has to fulfill 0 < column <= NrCols(mat) "); - fi; - - for i in [1..NrRows(mat)] do - mat[i,column] := scalar * mat[i,column]; - od; - - end ); - -############################################################################ -## -#M MultMatrixColumnRight( , , ) -## -InstallMethod( MultMatrixColumnRight, "for a mutable matrix object, one row number, and a scalar", - [ IsRowListMatrix and IsMutable, IsInt, IsObject ], - function( mat, row, scalar ) - - MultMatrixColumn(mat,row,scalar); - - end ); - ############################################################################ ## #M AddMatrixRows( , , , ) ## -InstallMethod( AddMatrixRows, "for a mutable matrix object, one row number, second row number, and a scalar", +InstallMethod( AddMatrixRows, "for a mutable IsRowListMatrix, one row number, second row number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , function( mat, row1, row2, scalar ) local i; @@ -1407,38 +1343,17 @@ InstallMethod( AddMatrixRows, "for a mutable matrix object, one row number, seco if not( 0 < row2 and row2 <= NrRows(mat) ) then ErrorNoReturn("the third argument row has to fulfill 0 < row <= NrRows(mat) "); fi; - - if row1 <> row2 then - - for i in [1..NrCols(mat)] do - mat[row1,i] := mat[row1,i] + scalar * mat[row2,i]; - od; - - else - MultMatrixRow(mat,row1,scalar+1); - fi; - - - end ); - -############################################################################ -## -#M AddMatrixRowsLeft( , , , ) -## -InstallMethod( AddMatrixRowsLeft, "for a mutable matrix object, one row number, second row number, and a scalar", - [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , - function( mat, row1, row2, scalar ) - - AddMatrixRows(mat,row1,row2,scalar); - + mat[row1] := mat[row1] + scalar * mat[row2]; + end ); + ############################################################################ ## #M AddMatrixRowsRight( , , , ) ## -InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, second row number, and a scalar", +InstallMethod( AddMatrixRowsRight, "for a mutable IsRowListMatrix, one row number, second row number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , function( mat, row1, row2, scalar ) local i; @@ -1451,149 +1366,29 @@ InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, ErrorNoReturn("the third argument row has to fulfill 0 < row <= NrRows(mat) "); fi; - if row1 <> row2 then - - for i in [1..NrCols(mat)] do - mat[row1,i] := mat[row1,i] + mat[row2,i] * scalar; - od; - - else - MultMatrixRowRight(mat,row1,scalar+1); - fi; - - end ); + mat[row1] := mat[row1] + mat[row2] * scalar; -############################################################################ -## -#M AddMatrixColumns( , , , ) -## -InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and a scalar", - [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , - function( mat, column1, column2, scalar ) - local i; - - # Checks - if not( 0 < column1 and column1 <= NrCols(mat) ) then - ErrorNoReturn("the second argument column has to fulfill 0 < column <= NrCols(mat) "); - fi; - if not( 0 < column2 and column2 <= NrCols(mat) ) then - ErrorNoReturn("the third argument column has to fulfill 0 < column <= NrCols(mat) "); - fi; - - if column1 <> column2 then - - for i in [1..NrRows(mat)] do - mat[i,column1] := mat[i,column1] + mat[i,column2] * scalar; - od; - - else - MultMatrixColumn(mat,column1,scalar+1); - fi; - - end ); -############################################################################ -## -#M AddMatrixColumnsLeft( , , , ) -## -InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and a scalar", - [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , - function( mat, column1, column2, scalar ) - local i; - - # Checks - if not( 0 < column1 and column1 <= NrCols(mat) ) then - ErrorNoReturn("the second argument column has to fulfill 0 < column <= NrCols(mat) "); - fi; - if not( 0 < column2 and column2 <= NrCols(mat) ) then - ErrorNoReturn("the third argument column has to fulfill 0 < column <= NrCols(mat) "); - fi; - - if column1 <> column2 then - - for i in [1..NrRows(mat)] do - mat[i,column1] := mat[i,column1] + scalar * mat[i,column2] ; - od; - - else - MultMatrixColumnLeft(mat,column1,scalar+1); - fi; - - - end ); - - -############################################################################ -## -#M AddMatrixColumnsRight( , , , ) -## -InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and a scalar", - [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , - function( mat, column1, column2, scalar ) - - AddMatrixColumns(mat,column1,column2,scalar); - - end ); - - ############################################################################ ## #M SwapMatrixRows( , , ) ## -InstallMethod( SwapMatrixRows, "for a mutable matrix object, one row number, second row number", +InstallMethod( SwapMatrixRows, "for a mutable IsRowListMatrix, one row number, second row number", [ IsRowListMatrix and IsMutable, IsInt, IsInt ], function( mat, row1, row2 ) local temp, i; - - if row1 <> row2 then - - # Checks - if not( 0 < row1 and row1 <= NrRows(mat) ) then - ErrorNoReturn("the second argument row has to fulfill 0 < row <= NrRows(mat) "); - fi; - if not( 0 < row2 and row2 <= NrRows(mat) ) then - ErrorNoReturn("the third argument row has to fulfill 0 < row <= NrRows(mat) "); - fi; - - for i in [1..NrCols(mat)] do - temp := mat[row1,i]; - mat[row1,i] := mat[row2,i]; - mat[row2,i] := temp; - od; - - fi; - - - end ); - -############################################################################ -## -#M SwapMatrixColumns( , , ) -## -InstallMethod( SwapMatrixColumns, "for a mutable matrix object, one column number, second column number", - [ IsRowListMatrix and IsMutable, IsInt, IsInt ], - function( mat, column1, column2 ) - local temp, i; - - if column1 <> column2 then - - # Checks - if not( 0 < column1 and column1 <= NrCols(mat) ) then - ErrorNoReturn("the second argument column has to fulfill 0 < column <= NrCols(mat) "); - fi; - if not( 0 < column2 and column2 <= NrCols(mat) ) then - ErrorNoReturn("the third argument column has to fulfill 0 < column <= NrCols(mat) "); - fi; - - for i in [1..NrRows(mat)] do - temp := mat[i,column1]; - mat[i,column1] := mat[i,column2]; - mat[i,column2] := temp; - od; - + # Checks + if not( 0 < row1 and row1 <= NrRows(mat) ) then + ErrorNoReturn("the second argument row has to fulfill 0 < row <= NrRows(mat) "); fi; - - - end ); + if not( 0 < row2 and row2 <= NrRows(mat) ) then + ErrorNoReturn("the third argument row has to fulfill 0 < row <= NrRows(mat) "); + fi; + + temp := mat[row1]; + mat[row1] := mat[row2]; + mat[row2] := temp; + + end ); \ No newline at end of file From 63eb721da4fa8b54f9887e4aa2a6c68467a12042 Mon Sep 17 00:00:00 2001 From: Anna Sucker Date: Fri, 28 May 2021 11:33:25 +0200 Subject: [PATCH 09/23] WIP documentation --- lib/matobj.gi | 56 +++++++++++++++++---------------------------------- 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/lib/matobj.gi b/lib/matobj.gi index 3711e28d5a..de82e0483a 100644 --- a/lib/matobj.gi +++ b/lib/matobj.gi @@ -1574,12 +1574,10 @@ InstallMethod( \[\,\]\:\=, "for a matrix object, two positions, and an object", ############################################################################ ## -#O MultMatrixRow( , , ) -## ## <#GAPDoc Label="MultMatrixRow"> ## -## -## +## +## ## ## nothing ## @@ -1588,7 +1586,7 @@ InstallMethod( \[\,\]\:\=, "for a matrix object, two positions, and an object", ## Multiplies the i-th row of the mutable matrix mat with the scalar ## elm from the left in-place. ##

-## MultMatrixRowLeft is a synonym for MultMatrixRow. +## is a synonym of . ## ## ## <#/GAPDoc> @@ -1612,12 +1610,10 @@ InstallMethod( MultMatrixRow, "for a mutable matrix object, one row number, and ############################################################################ ## -#O MultMatrixColumn( , , ) -## ## <#GAPDoc Label="MultMatrixColumn"> ## -## -## +## +## ## ## nothing ## @@ -1626,7 +1622,7 @@ InstallMethod( MultMatrixRow, "for a mutable matrix object, one row number, and ## Multiplies the i-th column of the mutable matrix mat with the scalar ## elm from the right in-place. ##

-## MultMatrixColumnRight is a synonym for MultMatrixColumn. +## is a synonym of . ## ## ## <#/GAPDoc> @@ -1650,11 +1646,9 @@ InstallMethod( MultMatrixColumn, "for a mutable matrix object, one column number ############################################################################ ## -#O MultMatrixRowRight( , , ) -## ## <#GAPDoc Label="MultMatrixRowRight"> ## -## +## ## ## nothing ## @@ -1684,11 +1678,9 @@ InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, ############################################################################ ## -#O MultMatrixColumnLeft( , , ) -## ## <#GAPDoc Label="MultMatrixColumnLeft"> ## -## +## ## ## nothing ## @@ -1719,12 +1711,10 @@ InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column nu ############################################################################ ## -#M AddMatrixRows( , , , ) -## ## <#GAPDoc Label="AddMatrixRows"> ## -## -## +## +## ## ## nothing ## @@ -1733,7 +1723,7 @@ InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column nu ## Adds the product of elm with the j-th row of the mutable matrix mat to its i-th ## row in-place. The j-th row is multiplied with elm from the left. ##

-## AddMatrixRowsLeft is a synonym for AddMatrixRows. +## is a synonym of . ## ## ## <#/GAPDoc> @@ -1760,11 +1750,9 @@ InstallMethod( AddMatrixRows, "for a mutable matrix object, one row number, seco ############################################################################ ## -#O AddMatrixRowsRight( , , , ) -## ## <#GAPDoc Label="AddMatrixRowsRight"> ## -## +## ## ## nothing ## @@ -1797,12 +1785,10 @@ InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, ############################################################################ ## -#O AddMatrixColumns( , , , ) -## ## <#GAPDoc Label="AddMatrixColumns"> ## -## -## +## +## ## ## nothing ## @@ -1811,7 +1797,7 @@ InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, ## Adds the product of elm with the j-th column of the mutable matrix mat to its i-th ## column in-place. The j-th column is multiplied with elm from the right. ##

-## AddMatrixColumnsRight is a synonym for AddMatrixColumns. +## is a synonym of . ## ## ## <#/GAPDoc> @@ -1837,11 +1823,9 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number ############################################################################ ## -#O AddMatrixColumnsLeft( , , , ) -## ## <#GAPDoc Label="AddMatrixColumnsLeft"> ## -## +## ## ## nothing ## @@ -1875,11 +1859,9 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number ############################################################################ ## -#O SwapMatrixRows( , , ) -## ## <#GAPDoc Label="SwapMatrixRows"> ## -## +## ## ## nothing ## @@ -1919,11 +1901,9 @@ InstallMethod( SwapMatrixRows, "for a mutable matrix object, one row number, sec ############################################################################ ## -#O SwapMatrixColumns( , , ) -## ## <#GAPDoc Label="SwapMatrixColumns"> ## -## +## ## ## nothing ## From 0cf7ec9a4dd6a0745867f7445b6244c036ead331 Mon Sep 17 00:00:00 2001 From: Anna Sucker Date: Sat, 29 May 2021 11:09:37 +0200 Subject: [PATCH 10/23] Removed bound checks and moved doc in .gd file --- lib/matobj.gi | 282 +++++-------------------------------------------- lib/matobj2.gd | 185 +++++++++++++++++++++++++++++++- 2 files changed, 205 insertions(+), 262 deletions(-) diff --git a/lib/matobj.gi b/lib/matobj.gi index de82e0483a..5cefa85969 100644 --- a/lib/matobj.gi +++ b/lib/matobj.gi @@ -1572,34 +1572,10 @@ InstallMethod( \[\,\]\:\=, "for a matrix object, two positions, and an object", # Elementary matrix operations ############################################################################ -############################################################################ -## -## <#GAPDoc Label="MultMatrixRow"> -## -## -## -## -## nothing -## -## -##

-## Multiplies the i-th row of the mutable matrix mat with the scalar -## elm from the left in-place. -##

-## is a synonym of . -## -## -## <#/GAPDoc> -## -InstallMethod( MultMatrixRow, "for a mutable matrix object, one row number, and a scalar", +InstallMethod( MultMatrixRow, "for a mutable matrix object, one row index, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) local i; - - # Checks - if not( 0 < row and row <= NrRows(mat) ) then - ErrorNoReturn("the second argument has to fulfill 0 < row <= NrRows(mat) "); - fi; for i in [1..NrCols(mat)] do mat[row,i] := scalar * mat[row,i]; @@ -1607,68 +1583,25 @@ InstallMethod( MultMatrixRow, "for a mutable matrix object, one row number, and end ); - ############################################################################ -## -## <#GAPDoc Label="MultMatrixColumn"> -## -## -## -## -## nothing -## -## -##

-## Multiplies the i-th column of the mutable matrix mat with the scalar -## elm from the right in-place. -##

-## is a synonym of . -## -## -## <#/GAPDoc> -## -InstallMethod( MultMatrixColumn, "for a mutable matrix object, one column number, and a scalar", + +InstallMethod( MultMatrixColumn, "for a mutable matrix object, one column index, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, column, scalar ) local i; - - # Checks - if not( 0 < column and column <= NrCols(mat) ) then - ErrorNoReturn("the second argument column has to fulfill 0 < column <= NrCols(mat) "); - fi; for i in [1..NrRows(mat)] do mat[i,column] := mat[i,column] * scalar; od; end ); - ############################################################################ -## -## <#GAPDoc Label="MultMatrixRowRight"> -## -## -## -## nothing -## -## -##

-## Multiplies the i-th row of the mutable matrix mat with the scalar -## elm from the right in-place. -## -## -## <#/GAPDoc> -## -InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, and a scalar", + +InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row index, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) local i; - - # Checks - if not( 0 < row and row <= NrRows(mat) ) then - ErrorNoReturn("the second argument row has to fulfill 0 < row <= NrRows(mat) "); - fi; for i in [1..NrCols(mat)] do mat[row,i] := mat[row,i] * scalar; @@ -1677,30 +1610,11 @@ InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, end ); ############################################################################ -## -## <#GAPDoc Label="MultMatrixColumnLeft"> -## -## -## -## nothing -## -## -##

-## Multiplies the i-th column of the mutable matrix mat with the scalar -## elm from the left in-place. -## -## -## <#/GAPDoc> -## -InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column number, and a scalar", + +InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column index, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, column, scalar ) local i; - - # Checks - if not( 0 < column and column <= NrCols(mat) ) then - ErrorNoReturn("the second argument column has to fulfill 0 < column <= NrCols(mat) "); - fi; for i in [1..NrRows(mat)] do mat[i,column] := scalar * mat[i,column]; @@ -1708,74 +1622,25 @@ InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column nu end ); - ############################################################################ -## -## <#GAPDoc Label="AddMatrixRows"> -## -## -## -## -## nothing -## -## -##

-## Adds the product of elm with the j-th row of the mutable matrix mat to its i-th -## row in-place. The j-th row is multiplied with elm from the left. -##

-## is a synonym of . -## -## -## <#/GAPDoc> -## -InstallMethod( AddMatrixRows, "for a mutable matrix object, one row number, second row number, and a scalar", + +InstallMethod( AddMatrixRows, "for a mutable matrix object, one row index, second row index, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , function( mat, row1, row2, scalar ) local i; - - # Checks - if not( 0 < row1 and row1 <= NrRows(mat) ) then - ErrorNoReturn("the second argument row has to fulfill 0 < row <= NrRows(mat) "); - fi; - if not( 0 < row2 and row2 <= NrRows(mat) ) then - ErrorNoReturn("the third argument row has to fulfill 0 < row <= NrRows(mat) "); - fi; for i in [1..NrCols(mat)] do mat[row1,i] := mat[row1,i] + scalar * mat[row2,i]; od; end ); - + + ############################################################################ -############################################################################ -## -## <#GAPDoc Label="AddMatrixRowsRight"> -## -## -## -## nothing -## -## -##

-## Adds the product of elm with the j-th row of the mutable matrix mat to its i-th -## row in-place. The j-th row is multiplied with elm from the right. -## -## -## <#/GAPDoc> -## -InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, second row number, and a scalar", +InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row index, second row index, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , function( mat, row1, row2, scalar ) local i; - - # Checks - if not( 0 < row1 and row1 <= NrRows(mat) ) then - ErrorNoReturn("the second argument row has to fulfill 0 < row <= NrRows(mat) "); - fi; - if not( 0 < row2 and row2 <= NrRows(mat) ) then - ErrorNoReturn("the third argument row has to fulfill 0 < row <= NrRows(mat) "); - fi; for i in [1..NrCols(mat)] do mat[row1,i] := mat[row1,i] + mat[row2,i] * scalar; @@ -1784,36 +1649,11 @@ InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row number, end ); ############################################################################ -## -## <#GAPDoc Label="AddMatrixColumns"> -## -## -## -## -## nothing -## -## -##

-## Adds the product of elm with the j-th column of the mutable matrix mat to its i-th -## column in-place. The j-th column is multiplied with elm from the right. -##

-## is a synonym of . -## -## -## <#/GAPDoc> -## -InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and a scalar", + +InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column index, second column index, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , function( mat, column1, column2, scalar ) local i; - - # Checks - if not( 0 < column1 and column1 <= NrCols(mat) ) then - ErrorNoReturn("the second argument column has to fulfill 0 < column <= NrCols(mat) "); - fi; - if not( 0 < column2 and column2 <= NrCols(mat) ) then - ErrorNoReturn("the third argument column has to fulfill 0 < column <= NrCols(mat) "); - fi; for i in [1..NrRows(mat)] do mat[i,column1] := mat[i,column1] + mat[i,column2] * scalar; @@ -1822,120 +1662,48 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number end ); ############################################################################ -## -## <#GAPDoc Label="AddMatrixColumnsLeft"> -## -## -## -## nothing -## -## -##

-## Adds the product of elm with the j-th column of the mutable matrix mat to its i-th -## column in-place. The j-th column is multiplied with elm from the left. -## -## -## <#/GAPDoc> -## -InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column number, second column number, and a scalar", + +InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column index, second column index, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , function( mat, column1, column2, scalar ) local i; - - # Checks - if not( 0 < column1 and column1 <= NrCols(mat) ) then - ErrorNoReturn("the second argument column has to fulfill 0 < column <= NrCols(mat) "); - fi; - if not( 0 < column2 and column2 <= NrCols(mat) ) then - ErrorNoReturn("the third argument column has to fulfill 0 < column <= NrCols(mat) "); - fi; for i in [1..NrRows(mat)] do mat[i,column1] := mat[i,column1] + scalar * mat[i,column2] ; od; - + end ); - -############################################################################ -## -## <#GAPDoc Label="SwapMatrixRows"> -## -## -## -## nothing -## -## -##

-## Swaps the i-th row and j-th row of a mutable matrix mat. -## -## -## <#/GAPDoc> -## -InstallMethod( SwapMatrixRows, "for a mutable matrix object, one row number, second row number", +############################################################################ + +InstallMethod( SwapMatrixRows, "for a mutable matrix object, one row index, second row index", [ IsMatrixObj and IsMutable, IsInt, IsInt ], function( mat, row1, row2 ) local temp, i; if row1 <> row2 then - - # Checks - if not( 0 < row1 and row1 <= NrRows(mat) ) then - ErrorNoReturn("the second argument row has to fulfill 0 < row <= NrRows(mat) "); - fi; - if not( 0 < row2 and row2 <= NrRows(mat) ) then - ErrorNoReturn("the third argument row has to fulfill 0 < row <= NrRows(mat) "); - fi; - for i in [1..NrCols(mat)] do temp := mat[row1,i]; mat[row1,i] := mat[row2,i]; mat[row2,i] := temp; - od; - + od; fi; - - - end ); + end ); ############################################################################ -## -## <#GAPDoc Label="SwapMatrixColumns"> -## -## -## -## nothing -## -## -##

-## Swaps the i-th column and j-th column of a mutable matrix mat. -## -## -## <#/GAPDoc> -## -InstallMethod( SwapMatrixColumns, "for a mutable matrix object, one column number, second column number", + +InstallMethod( SwapMatrixColumns, "for a mutable matrix object, one column index, second column index", [ IsMatrixObj and IsMutable, IsInt, IsInt ], function( mat, column1, column2 ) local temp, i; if column1 <> column2 then - - # Checks - if not( 0 < column1 and column1 <= NrCols(mat) ) then - ErrorNoReturn("the second argument column has to fulfill 0 < column <= NrCols(mat) "); - fi; - if not( 0 < column2 and column2 <= NrCols(mat) ) then - ErrorNoReturn("the third argument column has to fulfill 0 < column <= NrCols(mat) "); - fi; - for i in [1..NrRows(mat)] do temp := mat[i,column1]; mat[i,column1] := mat[i,column2]; mat[i,column2] := temp; - od; - + od; fi; - end ); diff --git a/lib/matobj2.gd b/lib/matobj2.gd index c7cab96ca5..241a950404 100644 --- a/lib/matobj2.gd +++ b/lib/matobj2.gd @@ -1930,22 +1930,197 @@ DeclareOperation( "[]:=", [ IsMatrixObj, IsPosInt, IsPosInt, IsObject ] ); ############################################################################ # Elementary matrix operations ############################################################################ - +# ############################################################################ ## -## TODO DESCRIPTION +## <#GAPDoc Label="MultMatrixRow"> +## +## +## +## +## nothing +## +## +##

+## Multiplies the i-th row of the mutable matrix mat with the scalar +## elm from the left in-place. +##

+## is a synonym of . +## +## +## <#/GAPDoc> ## DeclareOperation( "MultMatrixRow", [ IsMatrixObj and IsMutable, IsInt, IsObject ] ); DeclareSynonym( "MultMatrixRowLeft", MultMatrixRow); + +############################################################################ +## +## <#GAPDoc Label="MultMatrixRowRight"> +## +## +## +## nothing +## +## +##

+## Multiplies the i-th row of the mutable matrix mat with the scalar +## elm from the right in-place. +## +## +## <#/GAPDoc> +## +DeclareOperation( "MultMatrixRowRight", [ IsMatrixObj and IsMutable, IsInt, IsObject ]); + +############################################################################ +## +## <#GAPDoc Label="MultMatrixColumn"> +## +## +## +## +## nothing +## +## +##

+## Multiplies the i-th column of the mutable matrix mat with the scalar +## elm from the right in-place. +##

+## is a synonym of . +## +## +## <#/GAPDoc> +## DeclareOperation( "MultMatrixColumn", [ IsMatrixObj and IsMutable, IsInt, IsObject ] ); -DeclareSynonym( "MultMatrixRowRight", MultMatrixColumn); +DeclareSynonym( "MultMatrixColumnRight", MultMatrixColumn); + +############################################################################ +## +## <#GAPDoc Label="MultMatrixColumnLeft"> +## +## +## +## nothing +## +## +##

+## Multiplies the i-th column of the mutable matrix mat with the scalar +## elm from the left in-place. +## +## +## <#/GAPDoc> +## DeclareOperation( "MultMatrixColumnLeft", [ IsMatrixObj and IsMutable, IsInt, IsObject ] ); -DeclareOperation( "MultMatrixColumnRight", [ IsMatrixObj and IsMutable, IsInt, IsObject ] ); + +############################################################################ +## +## <#GAPDoc Label="AddMatrixRows"> +## +## +## +## +## nothing +## +## +##

+## Adds the product of elm with the j-th row of the mutable matrix mat to its i-th +## row in-place. The j-th row is multiplied with elm from the left. +##

+## is a synonym of . +## +## +## <#/GAPDoc> +## DeclareOperation( "AddMatrixRows", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] ); DeclareSynonym( "AddMatrixRowsLeft", AddMatrixRows); + +############################################################################ +## +## <#GAPDoc Label="AddMatrixRowsRight"> +## +## +## +## nothing +## +## +##

+## Adds the product of elm with the j-th row of the mutable matrix mat to its i-th +## row in-place. The j-th row is multiplied with elm from the right. +## +## +## <#/GAPDoc> +## DeclareOperation( "AddMatrixRowsRight", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] ); + +############################################################################ +## +## <#GAPDoc Label="AddMatrixColumns"> +## +## +## +## +## nothing +## +## +##

+## Adds the product of elm with the j-th column of the mutable matrix mat to its i-th +## column in-place. The j-th column is multiplied with elm from the right. +##

+## is a synonym of . +## +## +## <#/GAPDoc> +## DeclareOperation( "AddMatrixColumns", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] ); DeclareSynonym( "AddMatrixColumnsRight", AddMatrixColumns); + +############################################################################ +## +## <#GAPDoc Label="AddMatrixColumnsLeft"> +## +## +## +## nothing +## +## +##

+## Adds the product of elm with the j-th column of the mutable matrix mat to its i-th +## column in-place. The j-th column is multiplied with elm from the left. +## +## +## <#/GAPDoc> +## DeclareOperation( "AddMatrixColumnsLeft", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] ); + +############################################################################ +## +## <#GAPDoc Label="SwapMatrixRows"> +## +## +## +## nothing +## +## +##

+## Swaps the i-th row and j-th row of a mutable matrix mat. +## +## +## <#/GAPDoc> +## DeclareOperation( "SwapMatrixRows", [ IsMatrixObj and IsMutable, IsInt, IsInt ] ); -DeclareOperation( "SwapMatrixColumns", [ IsMatrixObj and IsMutable, IsInt, IsInt ] ); + +############################################################################ +## +## <#GAPDoc Label="SwapMatrixColumns"> +## +## +## +## nothing +## +## +##

+## Swaps the i-th column and j-th column of a mutable matrix mat. +## +## +## <#/GAPDoc> +## +DeclareOperation( "SwapMatrixColumns", [ IsMatrixObj and IsMutable, IsInt, IsInt ] ); \ No newline at end of file From 7fdf647fcb78e4023f68207514ddbd4c715856dd Mon Sep 17 00:00:00 2001 From: Daniel Rademacher Date: Sat, 29 May 2021 18:29:38 +0200 Subject: [PATCH 11/23] Tests for all functions and removed checks for IsRowListMatrix --- lib/matobj.gi | 2 +- lib/matobjplist.gi | 41 +--------- .../MatrixObj/ElementaryMatrices.tst | 74 ++++++++++++++++++- 3 files changed, 76 insertions(+), 41 deletions(-) diff --git a/lib/matobj.gi b/lib/matobj.gi index 5cefa85969..ab14011071 100644 --- a/lib/matobj.gi +++ b/lib/matobj.gi @@ -1663,7 +1663,7 @@ InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column index, ############################################################################ -InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column index, second column index, and a scalar", +InstallMethod( AddMatrixColumnsLeft, "for a mutable matrix object, one column index, second column index, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , function( mat, column1, column2, scalar ) local i; diff --git a/lib/matobjplist.gi b/lib/matobjplist.gi index 259f780eb2..6bc71f7ddb 100644 --- a/lib/matobjplist.gi +++ b/lib/matobjplist.gi @@ -1297,11 +1297,6 @@ InstallMethod( NewCompanionMatrix, InstallMethod( MultMatrixRow, "for a mutable IsRowListMatrix, one row number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) - - # Checks - if not( 0 < row and row <= NrRows(mat) ) then - ErrorNoReturn("the second argument row has to fulfill 0 < row <= NrRows(mat) "); - fi; mat[row] := scalar * mat[row]; @@ -1315,12 +1310,6 @@ InstallMethod( MultMatrixRow, "for a mutable IsRowListMatrix, one row number, an InstallMethod( MultMatrixRowRight, "for a mutable IsRowListMatrix, one row number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) - local i; - - # Checks - if not( 0 < row and row <= NrRows(mat) ) then - ErrorNoReturn("the second argument row has to fulfill 0 < row <= NrRows(mat) "); - fi; mat[row] := mat[row] * scalar; @@ -1334,15 +1323,6 @@ InstallMethod( MultMatrixRowRight, "for a mutable IsRowListMatrix, one row numbe InstallMethod( AddMatrixRows, "for a mutable IsRowListMatrix, one row number, second row number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , function( mat, row1, row2, scalar ) - local i; - - # Checks - if not( 0 < row1 and row1 <= NrRows(mat) ) then - ErrorNoReturn("the second argument row has to fulfill 0 < row <= NrRows(mat) "); - fi; - if not( 0 < row2 and row2 <= NrRows(mat) ) then - ErrorNoReturn("the third argument row has to fulfill 0 < row <= NrRows(mat) "); - fi; mat[row1] := mat[row1] + scalar * mat[row2]; @@ -1356,15 +1336,6 @@ InstallMethod( AddMatrixRows, "for a mutable IsRowListMatrix, one row number, se InstallMethod( AddMatrixRowsRight, "for a mutable IsRowListMatrix, one row number, second row number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , function( mat, row1, row2, scalar ) - local i; - - # Checks - if not( 0 < row1 and row1 <= NrRows(mat) ) then - ErrorNoReturn("the second argument row has to fulfill 0 < row <= NrRows(mat) "); - fi; - if not( 0 < row2 and row2 <= NrRows(mat) ) then - ErrorNoReturn("the third argument row has to fulfill 0 < row <= NrRows(mat) "); - fi; mat[row1] := mat[row1] + mat[row2] * scalar; @@ -1377,18 +1348,10 @@ InstallMethod( AddMatrixRowsRight, "for a mutable IsRowListMatrix, one row numbe InstallMethod( SwapMatrixRows, "for a mutable IsRowListMatrix, one row number, second row number", [ IsRowListMatrix and IsMutable, IsInt, IsInt ], function( mat, row1, row2 ) - local temp, i; - - # Checks - if not( 0 < row1 and row1 <= NrRows(mat) ) then - ErrorNoReturn("the second argument row has to fulfill 0 < row <= NrRows(mat) "); - fi; - if not( 0 < row2 and row2 <= NrRows(mat) ) then - ErrorNoReturn("the third argument row has to fulfill 0 < row <= NrRows(mat) "); - fi; + local temp; temp := mat[row1]; mat[row1] := mat[row2]; mat[row2] := temp; - end ); \ No newline at end of file + end ); diff --git a/tst/testinstall/MatrixObj/ElementaryMatrices.tst b/tst/testinstall/MatrixObj/ElementaryMatrices.tst index ff5e164a02..8debdebe82 100644 --- a/tst/testinstall/MatrixObj/ElementaryMatrices.tst +++ b/tst/testinstall/MatrixObj/ElementaryMatrices.tst @@ -11,4 +11,76 @@ gap> mat := Matrix( [[2,4,5],[7,11,-4],[-3,20,0]]);; gap> SwapMatrixColumns(mat,1,3); gap> mat= Matrix( [ [ 5, 4, 2 ], [ -4, 11, 7 ], [ 0, 20, -3 ] ]); true -gap> STOP_TEST("ElementaryMatrices.tst",1); \ No newline at end of file + +# +gap> mat := Matrix( [[2,4,5],[7,11,-4],[-3,20,0]]);; +gap> MultMatrixRow(mat,2,-4); +gap> mat= Matrix( [ [2,4,5], [ -28, -44, 16 ], [-3,20,0]]); +true + +# +gap> mat := Matrix( [[2,4,5],[7,11,-4],[-3,20,0]]);; +gap> MultMatrixRowLeft(mat,2,5); +gap> mat= Matrix( [ [2,4,5], [ 35, 55, -20 ], [-3,20,0]]); +true + +# +gap> mat := Matrix( [[2,4,5],[7,11,-4],[-3,20,0]]);; +gap> MultMatrixRowRight(mat,3,-1); +gap> mat= Matrix( [ [2,4,5], [7,11,-4], [3,-20,0]]); +true + +# +gap> mat := Matrix( [[2,4,5],[7,11,-4],[-3,20,0]]);; +gap> MultMatrixColumn(mat,3,2); +gap> mat= Matrix( [ [2,4,10], [7,11,-8], [-3,20,0]]); +true + +# +gap> mat := Matrix( [[2,4,5],[7,11,-4],[-3,20,0]]);; +gap> MultMatrixColumnRight(mat,1,-3); +gap> mat= Matrix( [ [-6,4,5], [-21,11,-4], [9,20,0]]); +true + +# +gap> mat := Matrix( [[2,4,5],[7,11,-4],[-3,20,0]]);; +gap> MultMatrixColumnLeft(mat,2,4); +gap> mat= Matrix( [ [2,16,5], [7,44,-4], [-3,80,0]]); +true + +# +gap> mat := Matrix( [[2,4,5],[7,11,-4],[-3,20,0]]);; +gap> AddMatrixRows(mat,2,1,-3); +gap> mat= Matrix( [ [2,4,5], [1,-1,-19], [-3,20,0]]); +true + +# +gap> mat := Matrix( [[2,4,5],[7,11,-4],[-3,20,0]]);; +gap> AddMatrixRowsLeft(mat,3,2,2); +gap> mat= Matrix( [ [2,4,5], [7,11,-4], [11,42,-8]]); +true + +# +gap> mat := Matrix( [[2,4,5],[7,11,-4],[-3,20,0]]);; +gap> AddMatrixRowsRight(mat,1,3,-3); +gap> mat= Matrix( [ [11,-56,5], [7,11,-4], [-3,20,0]]); +true + +# +gap> mat := Matrix( [[2,4,5],[7,11,-4],[-3,20,0]]);; +gap> AddMatrixColumns(mat,2,1,-3); +gap> mat= Matrix( [ [2,-2,5], [7,-10,-4], [-3,29,0]]); +true + +# +gap> mat := Matrix( [[2,4,5],[7,11,-4],[-3,20,0]]);; +gap> AddMatrixColumnsRight(mat,3,2,2); +gap> mat= Matrix( [ [2,4,13], [7,11,18], [-3,20,40]]); +true + +# +gap> mat := Matrix( [[2,4,5],[7,11,-4],[-3,20,0]]);; +gap> AddMatrixColumnsLeft(mat,1,3,-3); +gap> mat= Matrix( [ [-13,4,5], [19,11,-4], [-3,20,0]]); +true +gap> STOP_TEST("ElementaryMatrices.tst",1); From e334988e0ad2b0651bd4a205870456c1dc138926 Mon Sep 17 00:00:00 2001 From: danielrademacher <33546089+danielrademacher@users.noreply.github.com> Date: Wed, 2 Jun 2021 13:13:54 +0200 Subject: [PATCH 12/23] Improvement of swapping rows Co-authored-by: Max Horn --- lib/matobjplist.gi | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/matobjplist.gi b/lib/matobjplist.gi index 6bc71f7ddb..0c1b6a1dda 100644 --- a/lib/matobjplist.gi +++ b/lib/matobjplist.gi @@ -1348,10 +1348,6 @@ InstallMethod( AddMatrixRowsRight, "for a mutable IsRowListMatrix, one row numbe InstallMethod( SwapMatrixRows, "for a mutable IsRowListMatrix, one row number, second row number", [ IsRowListMatrix and IsMutable, IsInt, IsInt ], function( mat, row1, row2 ) - local temp; - - temp := mat[row1]; - mat[row1] := mat[row2]; - mat[row2] := temp; + mat{[row1,row2]} := mat{[row2,row1]}; end ); From e08f21803dafe5cd65a7c3e914bdef5260a7423f Mon Sep 17 00:00:00 2001 From: danielrademacher <33546089+danielrademacher@users.noreply.github.com> Date: Wed, 2 Jun 2021 13:15:51 +0200 Subject: [PATCH 13/23] Newline at the end of file Co-authored-by: Max Horn --- lib/matobj2.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matobj2.gd b/lib/matobj2.gd index 241a950404..4a34a9bec5 100644 --- a/lib/matobj2.gd +++ b/lib/matobj2.gd @@ -2123,4 +2123,4 @@ DeclareOperation( "SwapMatrixRows", [ IsMatrixObj and IsMutable, IsInt, IsInt ] ## ## <#/GAPDoc> ## -DeclareOperation( "SwapMatrixColumns", [ IsMatrixObj and IsMutable, IsInt, IsInt ] ); \ No newline at end of file +DeclareOperation( "SwapMatrixColumns", [ IsMatrixObj and IsMutable, IsInt, IsInt ] ); From 592fdbda4ffe0a79703db6669e839cf51e12b70d Mon Sep 17 00:00:00 2001 From: Daniel Rademacher Date: Wed, 2 Jun 2021 13:42:04 +0200 Subject: [PATCH 14/23] Old version of swapmatrixrows --- lib/matobjplist.gi | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/matobjplist.gi b/lib/matobjplist.gi index 0c1b6a1dda..37c918d27f 100644 --- a/lib/matobjplist.gi +++ b/lib/matobjplist.gi @@ -1348,6 +1348,11 @@ InstallMethod( AddMatrixRowsRight, "for a mutable IsRowListMatrix, one row numbe InstallMethod( SwapMatrixRows, "for a mutable IsRowListMatrix, one row number, second row number", [ IsRowListMatrix and IsMutable, IsInt, IsInt ], function( mat, row1, row2 ) - mat{[row1,row2]} := mat{[row2,row1]}; + local temp; + + temp := mat[row1]; + mat[row1] := mat[row2]; + mat[row2] := temp; + #mat{[row1,row2]} := mat{[row2,row1]}; end ); From d4f30c51f063bd0202425fe84b51ffcbf8744704 Mon Sep 17 00:00:00 2001 From: Daniel Rademacher Date: Wed, 2 Jun 2021 14:00:06 +0200 Subject: [PATCH 15/23] Move documentary of RowListMatrix --- lib/matobjplist.gi | 70 ------------------------------------ lib/matrobjrowlist.gi | 83 +++++++++++++++++++++++++++++++++++++++++++ lib/read5.g | 1 + 3 files changed, 84 insertions(+), 70 deletions(-) create mode 100644 lib/matrobjrowlist.gi diff --git a/lib/matobjplist.gi b/lib/matobjplist.gi index 37c918d27f..b484cb273d 100644 --- a/lib/matobjplist.gi +++ b/lib/matobjplist.gi @@ -1286,73 +1286,3 @@ InstallMethod( NewCompanionMatrix, return ll; end ); -############################################################################ -# Elementary matrix operations -############################################################################ - -############################################################################ -## -#M MultMatrixRow( , , ) -## -InstallMethod( MultMatrixRow, "for a mutable IsRowListMatrix, one row number, and a scalar", - [ IsRowListMatrix and IsMutable, IsInt, IsObject ], - function( mat, row, scalar ) - - mat[row] := scalar * mat[row]; - - end ); - - -############################################################################ -## -#M MultMatrixRowRight( , , ) -## -InstallMethod( MultMatrixRowRight, "for a mutable IsRowListMatrix, one row number, and a scalar", - [ IsRowListMatrix and IsMutable, IsInt, IsObject ], - function( mat, row, scalar ) - - mat[row] := mat[row] * scalar; - - end ); - - -############################################################################ -## -#M AddMatrixRows( , , , ) -## -InstallMethod( AddMatrixRows, "for a mutable IsRowListMatrix, one row number, second row number, and a scalar", - [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , - function( mat, row1, row2, scalar ) - - mat[row1] := mat[row1] + scalar * mat[row2]; - - end ); - - -############################################################################ -## -#M AddMatrixRowsRight( , , , ) -## -InstallMethod( AddMatrixRowsRight, "for a mutable IsRowListMatrix, one row number, second row number, and a scalar", - [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , - function( mat, row1, row2, scalar ) - - mat[row1] := mat[row1] + mat[row2] * scalar; - - end ); - -############################################################################ -## -#M SwapMatrixRows( , , ) -## -InstallMethod( SwapMatrixRows, "for a mutable IsRowListMatrix, one row number, second row number", - [ IsRowListMatrix and IsMutable, IsInt, IsInt ], - function( mat, row1, row2 ) - local temp; - - temp := mat[row1]; - mat[row1] := mat[row2]; - mat[row2] := temp; - #mat{[row1,row2]} := mat{[row2,row1]}; - - end ); diff --git a/lib/matrobjrowlist.gi b/lib/matrobjrowlist.gi new file mode 100644 index 0000000000..b5e5a71698 --- /dev/null +++ b/lib/matrobjrowlist.gi @@ -0,0 +1,83 @@ +############################################################################# +## +## This file is part of GAP, a system for computational discrete algebra. +## +## SPDX-License-Identifier: GPL-2.0-or-later +## +## Copyright of GAP belongs to its developers, whose names are too numerous +## to list here. Please refer to the COPYRIGHT file for details. +## + + + +############################################################################ +# Elementary matrix operations +############################################################################ + +############################################################################ +## +#M MultMatrixRow( , , ) +## +InstallMethod( MultMatrixRow, "for a mutable IsRowListMatrix, one row number, and a scalar", + [ IsRowListMatrix and IsMutable, IsInt, IsObject ], + function( mat, row, scalar ) + + mat[row] := scalar * mat[row]; + + end ); + + +############################################################################ +## +#M MultMatrixRowRight( , , ) +## +InstallMethod( MultMatrixRowRight, "for a mutable IsRowListMatrix, one row number, and a scalar", + [ IsRowListMatrix and IsMutable, IsInt, IsObject ], + function( mat, row, scalar ) + + mat[row] := mat[row] * scalar; + + end ); + + +############################################################################ +## +#M AddMatrixRows( , , , ) +## +InstallMethod( AddMatrixRows, "for a mutable IsRowListMatrix, one row number, second row number, and a scalar", + [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , + function( mat, row1, row2, scalar ) + + mat[row1] := mat[row1] + scalar * mat[row2]; + + end ); + + +############################################################################ +## +#M AddMatrixRowsRight( , , , ) +## +InstallMethod( AddMatrixRowsRight, "for a mutable IsRowListMatrix, one row number, second row number, and a scalar", + [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , + function( mat, row1, row2, scalar ) + + mat[row1] := mat[row1] + mat[row2] * scalar; + + end ); + +############################################################################ +## +#M SwapMatrixRows( , , ) +## +InstallMethod( SwapMatrixRows, "for a mutable IsRowListMatrix, one row number, second row number", + [ IsRowListMatrix and IsMutable, IsInt, IsInt ], + function( mat, row1, row2 ) + local temp; + + temp := mat[row1]; + mat[row1] := mat[row2]; + mat[row2] := temp; + #mat{[row1,row2]} := mat{[row2,row1]}; + + end ); + diff --git a/lib/read5.g b/lib/read5.g index f9a69c9fb8..d29f20b8b3 100644 --- a/lib/read5.g +++ b/lib/read5.g @@ -108,6 +108,7 @@ ReadLib( "fldabnum.gi" ); ReadLib( "padics.gi" ); ReadLib( "matobj.gi" ); +ReadLib( "matrobjrowlist.gi" ); ReadLib( "vecmat.gi" ); ReadLib( "vec8bit.gi" ); ReadLib( "mat8bit.gi" ); From 1e2226c1a1e8fa1918d5ea65670b2e19cfe4a265 Mon Sep 17 00:00:00 2001 From: Daniel Rademacher Date: Wed, 2 Jun 2021 14:10:02 +0200 Subject: [PATCH 16/23] Synch master to PR --- lib/matobj2.gd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matobj2.gd b/lib/matobj2.gd index bb5f526909..5d41248de0 100644 --- a/lib/matobj2.gd +++ b/lib/matobj2.gd @@ -1811,8 +1811,8 @@ DeclareOperation( "Randomize", [ IsMatrixOrMatrixObj and IsMutable, IsRandomSour #O [ , ] #O [ , ]:= ## -DeclareOperation( "[]", [ IsMatrixObj, IsPosInt, IsPosInt ] ); -DeclareOperation( "[]:=", [ IsMatrixObj, IsPosInt, IsPosInt, IsObject ] ); +DeclareOperation( "[]", [ IsMatrixOrMatrixObj, IsPosInt, IsPosInt ] ); +DeclareOperation( "[]:=", [ IsMatrixOrMatrixObj, IsPosInt, IsPosInt, IsObject ] ); ############################################################################ From e31c2b436a22e8ab59234e103600cc0c4229527e Mon Sep 17 00:00:00 2001 From: Daniel Rademacher Date: Tue, 8 Jun 2021 17:54:08 +0200 Subject: [PATCH 17/23] Improvement of documentary: Change synonyms and give an explanation. --- lib/matobj.gi | 8 ++++---- lib/matobj2.gd | 32 ++++++++++++++++---------------- lib/matrobjrowlist.gi | 4 ++-- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/matobj.gi b/lib/matobj.gi index ca3b379b3d..cf3be39853 100644 --- a/lib/matobj.gi +++ b/lib/matobj.gi @@ -1573,7 +1573,7 @@ InstallMethod( \[\,\]\:\=, "for a matrix object, two positions, and an object", # Elementary matrix operations ############################################################################ -InstallMethod( MultMatrixRow, "for a mutable matrix object, one row index, and a scalar", +InstallMethod( MultMatrixRowLeft, "for a mutable matrix object, one row index, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) local i; @@ -1586,7 +1586,7 @@ InstallMethod( MultMatrixRow, "for a mutable matrix object, one row index, and a ############################################################################ -InstallMethod( MultMatrixColumn, "for a mutable matrix object, one column index, and a scalar", +InstallMethod( MultMatrixColumnRight, "for a mutable matrix object, one column index, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, column, scalar ) local i; @@ -1625,7 +1625,7 @@ InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column in ############################################################################ -InstallMethod( AddMatrixRows, "for a mutable matrix object, one row index, second row index, and a scalar", +InstallMethod( AddMatrixRowsLeft, "for a mutable matrix object, one row index, second row index, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , function( mat, row1, row2, scalar ) local i; @@ -1651,7 +1651,7 @@ InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row index, ############################################################################ -InstallMethod( AddMatrixColumns, "for a mutable matrix object, one column index, second column index, and a scalar", +InstallMethod( AddMatrixColumnsRight, "for a mutable matrix object, one column index, second column index, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , function( mat, column1, column2, scalar ) local i; diff --git a/lib/matobj2.gd b/lib/matobj2.gd index 5d41248de0..fdbad59838 100644 --- a/lib/matobj2.gd +++ b/lib/matobj2.gd @@ -1823,8 +1823,8 @@ DeclareOperation( "[]:=", [ IsMatrixOrMatrixObj, IsPosInt, IsPosInt, IsObject ] ## ## <#GAPDoc Label="MultMatrixRow"> ## -## ## +## ## ## nothing ## @@ -1833,13 +1833,13 @@ DeclareOperation( "[]:=", [ IsMatrixOrMatrixObj, IsPosInt, IsPosInt, IsObject ] ## Multiplies the i-th row of the mutable matrix mat with the scalar ## elm from the left in-place. ##

-## is a synonym of . +## is a synonym of . This was chosen because linear combinations of rows of matrices are usually written as v \cdot A = [v_1, ... ,v_n] \cdot A which multiplies scalars from the left. ## ## ## <#/GAPDoc> ## -DeclareOperation( "MultMatrixRow", [ IsMatrixObj and IsMutable, IsInt, IsObject ] ); -DeclareSynonym( "MultMatrixRowLeft", MultMatrixRow); +DeclareOperation( "MultMatrixRowLeft", [ IsMatrixObj and IsMutable, IsInt, IsObject ] ); +DeclareSynonym( "MultMatrixRow", MultMatrixRowLeft); ############################################################################ ## @@ -1863,8 +1863,8 @@ DeclareOperation( "MultMatrixRowRight", [ IsMatrixObj and IsMutable, IsInt, IsOb ## ## <#GAPDoc Label="MultMatrixColumn"> ## -## ## +## ## ## nothing ## @@ -1873,13 +1873,13 @@ DeclareOperation( "MultMatrixRowRight", [ IsMatrixObj and IsMutable, IsInt, IsOb ## Multiplies the i-th column of the mutable matrix mat with the scalar ## elm from the right in-place. ##

-## is a synonym of . +## is a synonym of . This was chosen because linear combinations of columns of matrices are usually written as A \cdot v^T = A \cdot [v_1, ... ,v_n]^T which multiplies scalars from the right. ## ## ## <#/GAPDoc> ## -DeclareOperation( "MultMatrixColumn", [ IsMatrixObj and IsMutable, IsInt, IsObject ] ); -DeclareSynonym( "MultMatrixColumnRight", MultMatrixColumn); +DeclareOperation( "MultMatrixColumnRight", [ IsMatrixObj and IsMutable, IsInt, IsObject ] ); +DeclareSynonym( "MultMatrixColumn", MultMatrixColumnRight); ############################################################################ ## @@ -1903,8 +1903,8 @@ DeclareOperation( "MultMatrixColumnLeft", [ IsMatrixObj and IsMutable, IsInt, Is ## ## <#GAPDoc Label="AddMatrixRows"> ## -## ## +## ## ## nothing ## @@ -1913,13 +1913,13 @@ DeclareOperation( "MultMatrixColumnLeft", [ IsMatrixObj and IsMutable, IsInt, Is ## Adds the product of elm with the j-th row of the mutable matrix mat to its i-th ## row in-place. The j-th row is multiplied with elm from the left. ##

-## is a synonym of . +## is a synonym of . This was chosen because linear combinations of rows of matrices are usually written as v \cdot A = [v_1, ... ,v_n] \cdot A which multiplies scalars from the left. ## ## ## <#/GAPDoc> ## -DeclareOperation( "AddMatrixRows", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] ); -DeclareSynonym( "AddMatrixRowsLeft", AddMatrixRows); +DeclareOperation( "AddMatrixRowsLeft", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] ); +DeclareSynonym( "AddMatrixRows", AddMatrixRowsLeft); ############################################################################ ## @@ -1943,8 +1943,8 @@ DeclareOperation( "AddMatrixRowsRight", [ IsMatrixObj and IsMutable, IsInt, IsIn ## ## <#GAPDoc Label="AddMatrixColumns"> ## -## ## +## ## ## nothing ## @@ -1953,13 +1953,13 @@ DeclareOperation( "AddMatrixRowsRight", [ IsMatrixObj and IsMutable, IsInt, IsIn ## Adds the product of elm with the j-th column of the mutable matrix mat to its i-th ## column in-place. The j-th column is multiplied with elm from the right. ##

-## is a synonym of . +## is a synonym of . This was chosen because linear combinations of columns of matrices are usually written as A \cdot v^T = A \cdot [v_1, ... ,v_n]^T which multiplies scalars from the right. ## ## ## <#/GAPDoc> ## -DeclareOperation( "AddMatrixColumns", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] ); -DeclareSynonym( "AddMatrixColumnsRight", AddMatrixColumns); +DeclareOperation( "AddMatrixColumnsRight", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] ); +DeclareSynonym( "AddMatrixColumns", AddMatrixColumnsRight); ############################################################################ ## diff --git a/lib/matrobjrowlist.gi b/lib/matrobjrowlist.gi index b5e5a71698..442124b698 100644 --- a/lib/matrobjrowlist.gi +++ b/lib/matrobjrowlist.gi @@ -18,7 +18,7 @@ ## #M MultMatrixRow( , , ) ## -InstallMethod( MultMatrixRow, "for a mutable IsRowListMatrix, one row number, and a scalar", +InstallMethod( MultMatrixRowLeft, "for a mutable IsRowListMatrix, one row number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) @@ -44,7 +44,7 @@ InstallMethod( MultMatrixRowRight, "for a mutable IsRowListMatrix, one row numbe ## #M AddMatrixRows( , , , ) ## -InstallMethod( AddMatrixRows, "for a mutable IsRowListMatrix, one row number, second row number, and a scalar", +InstallMethod( AddMatrixRowsLeft, "for a mutable IsRowListMatrix, one row number, second row number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , function( mat, row1, row2, scalar ) From 9423dcaca3cf3b9e4a7dc74b5bc7c0b3c25f3e7c Mon Sep 17 00:00:00 2001 From: Daniel Rademacher Date: Tue, 8 Jun 2021 17:59:55 +0200 Subject: [PATCH 18/23] Docu improvement: Added a explanation for the synonym choice of MultVector for MultVectorLeft. --- lib/matobj2.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matobj2.gd b/lib/matobj2.gd index fdbad59838..2e00e7bf38 100644 --- a/lib/matobj2.gd +++ b/lib/matobj2.gd @@ -614,7 +614,7 @@ DeclareOperation( "AddVector", ##

## Note that ## is just a synonym for -## . +## . This was chosen because vectors in GAP are by default row vectors and scalar multiplication is usually written as a \cdot v = a \cdot [v_1,...v_n] = [a\cdot v_1,...a\cdot v_n] with scalars being applied from the left. ##

## If the optional parameters from and to are given then ## only the index range [from..to] is guaranteed to be From 334b3b10eb3c0f74e1f5674ab6fab04204803fb7 Mon Sep 17 00:00:00 2001 From: Daniel Rademacher Date: Tue, 8 Jun 2021 18:11:59 +0200 Subject: [PATCH 19/23] Docu correction: Added linebreak in documentation and corrected the tag error. --- lib/matobj2.gd | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/matobj2.gd b/lib/matobj2.gd index 2e00e7bf38..11c9f851d6 100644 --- a/lib/matobj2.gd +++ b/lib/matobj2.gd @@ -614,7 +614,10 @@ DeclareOperation( "AddVector", ##

## Note that ## is just a synonym for -## . This was chosen because vectors in GAP are by default row vectors and scalar multiplication is usually written as a \cdot v = a \cdot [v_1,...v_n] = [a\cdot v_1,...a\cdot v_n] with scalars being applied from the left. +## . This was chosen because vectors in +## GAP are by default row vectors and scalar multiplication is usually written as +## a \cdot v = a \cdot [v_1,...,v_n] = [a\cdot v_1,...,a\cdot v_n] with scalars being +## applied from the left. ##

## If the optional parameters from and to are given then ## only the index range [from..to] is guaranteed to be @@ -1833,7 +1836,9 @@ DeclareOperation( "[]:=", [ IsMatrixOrMatrixObj, IsPosInt, IsPosInt, IsObject ] ## Multiplies the i-th row of the mutable matrix mat with the scalar ## elm from the left in-place. ##

-## is a synonym of . This was chosen because linear combinations of rows of matrices are usually written as v \cdot A = [v_1, ... ,v_n] \cdot A which multiplies scalars from the left. +## is a synonym of . This was chosen +## because linear combinations of rows of matrices are usually written as +## v \cdot A = [v_1, ... ,v_n] \cdot A which multiplies scalars from the left. ## ## ## <#/GAPDoc> @@ -1873,7 +1878,9 @@ DeclareOperation( "MultMatrixRowRight", [ IsMatrixObj and IsMutable, IsInt, IsOb ## Multiplies the i-th column of the mutable matrix mat with the scalar ## elm from the right in-place. ##

-## is a synonym of . This was chosen because linear combinations of columns of matrices are usually written as A \cdot v^T = A \cdot [v_1, ... ,v_n]^T which multiplies scalars from the right. +## is a synonym of . This was +## chosen because linear combinations of columns of matrices are usually written as +## A \cdot v^T = A \cdot [v_1, ... ,v_n]^T which multiplies scalars from the right. ## ## ## <#/GAPDoc> @@ -1913,7 +1920,9 @@ DeclareOperation( "MultMatrixColumnLeft", [ IsMatrixObj and IsMutable, IsInt, Is ## Adds the product of elm with the j-th row of the mutable matrix mat to its i-th ## row in-place. The j-th row is multiplied with elm from the left. ##

-## is a synonym of . This was chosen because linear combinations of rows of matrices are usually written as v \cdot A = [v_1, ... ,v_n] \cdot A which multiplies scalars from the left. +## is a synonym of . This was chosen +## because linear combinations of rows of matrices are usually written as +## v \cdot A = [v_1, ... ,v_n] \cdot A which multiplies scalars from the left. ## ## ## <#/GAPDoc> @@ -1953,7 +1962,9 @@ DeclareOperation( "AddMatrixRowsRight", [ IsMatrixObj and IsMutable, IsInt, IsIn ## Adds the product of elm with the j-th column of the mutable matrix mat to its i-th ## column in-place. The j-th column is multiplied with elm from the right. ##

-## is a synonym of . This was chosen because linear combinations of columns of matrices are usually written as A \cdot v^T = A \cdot [v_1, ... ,v_n]^T which multiplies scalars from the right. +## is a synonym of . This was +## chosen because linear combinations of columns of matrices are usually written as +## A \cdot v^T = A \cdot [v_1, ... ,v_n]^T which multiplies scalars from the right. ## ## ## <#/GAPDoc> From b663332537ce51ea8426e70aa1c79d288248bfd3 Mon Sep 17 00:00:00 2001 From: Daniel Rademacher Date: Thu, 10 Jun 2021 00:06:28 +0200 Subject: [PATCH 20/23] Docu improvement: Remove old todo list. --- lib/matobj2.gd | 129 ------------------------------------------------- 1 file changed, 129 deletions(-) diff --git a/lib/matobj2.gd b/lib/matobj2.gd index 11c9f851d6..d7928eef2e 100644 --- a/lib/matobj2.gd +++ b/lib/matobj2.gd @@ -2023,132 +2023,3 @@ DeclareOperation( "SwapMatrixRows", [ IsMatrixObj and IsMutable, IsInt, IsInt ] ## <#/GAPDoc> ## DeclareOperation( "SwapMatrixColumns", [ IsMatrixObj and IsMutable, IsInt, IsInt ] ); - - -############################################################################# -## -## Open items: -## -## - renaming issues: -## - There are functions 'RankMat', 'IsDiagonalMat', etc. -## We should consistently introduce the corresponding names -## 'RankMatrix', 'IsDiagonalMatrix', etc. as main names, -## and keep the 'Mat' names as synonyms, -## and also keep these old names as documented if applicable. -## -## - There are functions 'BaseIntMat', 'TriangulizeIntegerMat', etc. -## Introduce the corresponding names 'BaseIntegerMatrix', -## 'TriangulizeIntegerMatrix', etc. as main names, keep the -## 'IntMat' or 'IntegerMat' names as synonyms, -## and also keep the old names as documented if applicable. -## -## - There is a problem with the operation 'Matrix'. -## An *attribute* with this name is declared for certain semigroups, -## in 'lib/reesmat.gd'. -## In 'lib/matobj2.gd', 'Matrix' is declared as a *mutable attribute* -## for lists; if it would not be declared as such then GAP's standard -## machinery would cause that 'Matrix( )' returns an *immutable* -## value, which is not acceptable. -## The declaration as a mutable attribute in 'lib/matobj2.gd' works -## because this file is read before 'lib/reesmat.gd', -## but the consequence is that the attribute values in the semigroup -## context are also mutable (try the manual example for 'Matrix'); -## this is a bug. -## (One could turn any attribute into a mutable one, by adding a -## corresponding declaration early enough.) -## -## - Just remove some downrankings of methods? -## (There are comments in the code that this should be possible -## from GAP 4.10 on.) -## -## - The entry for "unbind a list entry" in the Reference Manual is -## syntactically wrong, it is shown as 'Unbind( list[, n] )', -## which means that 'n' is an optional argument. -## The problem is that GAPDoc interprets 'Arg="list[n]"' this way, -## and inserts the comma. -## -## - Document 'PostMakeImmutable', -## then mention that matrix objects may have to install methods for it. -## -## - Do we really want to force 'IsCopyable' for all vector and matrix -## objects? -## One could think of an implementation where the objects are pointers -## to data files which are just readable. -## In such a situation, it is confusing that the object claims to be -## copyable but 'ShallowCopy' or 'MutableCopyMatrix' will not work. -## -## - Should 'IsRowVector' imply 'IsVectorObj', -## in analogy to the implication from 'IsMatrix' to 'IsMatrixObj'? -## On the one hand, there are only few operations involving row vectors -## where this question is relevant. -## On the other hand, the description of these operations becomes easier -## if this implication holds (see 'RowsOfMatrix'). -## -## - Should more list like operations be documented for vector objects? -## For example 'Position' and 'PositionProperty' would be candidates; -## a comment in an earlier version of the interface states that they -## are left out to simplify the interface. -## -## - For the various constructors, perhaps imitate what we do -## for e.g. group constructors: -## Admit to omit the filter, -## and try to choose a "good" default representation? -## -## - Replace 'ChangedBaseDomain' (which is defined for both vector and -## matrix objects) by 'VectorWithChangedBaseDomain', -## 'MatrixWithChangedBasedDomain'? -## -## - Is the ordering of arguments sensible and consistent? -## (For example, -## better define 'CopySubMatrix( dst, drows, dcols, src, srows, scols )', -## and unify the argument order in 'NewMatrix( filt, R, ncols, list )' -## and 'Matrix( filt, R, list, ncols )'? -## And what about 'NullMat'/'ZeroMatrix' and -## 'IdentityMat'/'IdentityMatrix'?) -## -## - Are the argument names sensible and consistent? For example we sometimes -## write "rep" and sometimes "filt" for the same thing. -## And we sometimes write "rows, colss", other times "ncols", or "m,n", or... -## -## - Are the operations for vector and matrix objects consistent? -## -## - How is 'WeightOfVector' related to 'WeightVecFFE', 'DistanceVecFFE'? -## Should just 'WeightOfVector' be documented? -## -## - Would it be sensible to have a recursive version of 'ShallowCopy', -## with an optional argument that limits the depth? -## (Note that 'StructuralCopy' is not an operation.) -## 'MutableCopyMatrix' (which is defined and used in 'lib/matrix.g*' -## but is not documented) could then be replaced by a depth 2 call -## of that operation. -## On the other hand, the name 'MutableCopyMatrix' is quite suggestive, -## perhaps 'MutableCopyVector' would be a better name for 'ShallowCopy'. -## -## - We state explicitly that we do not specify the behaviour if the -## base domains or dimensions or representation types do not fit. -## This is because of efficiency reasons. -## On the other hand, we could suggest to signal an error (with a useful -## error message if possible) except in the following cases: -## - Properties such as 'IsOne' can return 'false' if a problem occurs -## (such as a non-square matrix). -## - 'Inverse' for a not invertible matrix should return 'fail', -## according to the general documentation of 'Inverse'. -## (Note that 'fail' results make sense only if one can rely on them -## --for *all* matrix object representations, and this is something which -## we do not want to guarentee.) -## -## - We have to define what shall happen if the result of an operation -## is a vector or matrix object but cannot get the same base domain -## the input(s). -## I think this happens only for -## - the division of a vector/matrix by a scalar, -## where some entry of the result is not in the base domain, and -## - the inversion of a matrix that is not invertible over the base domain. -## (Are there other dangerous operations?) -## In such situations, we can either signal an error -## or create a vector/matrix object over a different base domain, -## for example by delegating to 'Vector( )' or 'Matrix( )', -## respectively. -## Once we decide what we want, this must be documented, -## and the available methods have to be adjusted. -## From 73e5d5114b6fbdfe1f72561cde040a800083b83b Mon Sep 17 00:00:00 2001 From: Daniel Rademacher Date: Thu, 10 Jun 2021 00:15:08 +0200 Subject: [PATCH 21/23] Docu improvement: First and second row/column number -> two row/column numbers --- lib/matobj.gi | 20 ++++++++++---------- lib/matrobjrowlist.gi | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/matobj.gi b/lib/matobj.gi index cf3be39853..b78ac38082 100644 --- a/lib/matobj.gi +++ b/lib/matobj.gi @@ -1573,7 +1573,7 @@ InstallMethod( \[\,\]\:\=, "for a matrix object, two positions, and an object", # Elementary matrix operations ############################################################################ -InstallMethod( MultMatrixRowLeft, "for a mutable matrix object, one row index, and a scalar", +InstallMethod( MultMatrixRowLeft, "for a mutable matrix object, one row number, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) local i; @@ -1586,7 +1586,7 @@ InstallMethod( MultMatrixRowLeft, "for a mutable matrix object, one row index, a ############################################################################ -InstallMethod( MultMatrixColumnRight, "for a mutable matrix object, one column index, and a scalar", +InstallMethod( MultMatrixColumnRight, "for a mutable matrix object, one column number, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, column, scalar ) local i; @@ -1599,7 +1599,7 @@ InstallMethod( MultMatrixColumnRight, "for a mutable matrix object, one column i ############################################################################ -InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row index, and a scalar", +InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) local i; @@ -1612,7 +1612,7 @@ InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row index, ############################################################################ -InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column index, and a scalar", +InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column number, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, column, scalar ) local i; @@ -1625,7 +1625,7 @@ InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column in ############################################################################ -InstallMethod( AddMatrixRowsLeft, "for a mutable matrix object, one row index, second row index, and a scalar", +InstallMethod( AddMatrixRowsLeft, "for a mutable matrix object, two row numbers, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , function( mat, row1, row2, scalar ) local i; @@ -1638,7 +1638,7 @@ InstallMethod( AddMatrixRowsLeft, "for a mutable matrix object, one row index, s ############################################################################ -InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row index, second row index, and a scalar", +InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, two row numbers, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , function( mat, row1, row2, scalar ) local i; @@ -1651,7 +1651,7 @@ InstallMethod( AddMatrixRowsRight, "for a mutable matrix object, one row index, ############################################################################ -InstallMethod( AddMatrixColumnsRight, "for a mutable matrix object, one column index, second column index, and a scalar", +InstallMethod( AddMatrixColumnsRight, "for a mutable matrix object, two column numbers, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , function( mat, column1, column2, scalar ) local i; @@ -1664,7 +1664,7 @@ InstallMethod( AddMatrixColumnsRight, "for a mutable matrix object, one column i ############################################################################ -InstallMethod( AddMatrixColumnsLeft, "for a mutable matrix object, one column index, second column index, and a scalar", +InstallMethod( AddMatrixColumnsLeft, "for a mutable matrix object, two column numbers, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsInt, IsObject ] , function( mat, column1, column2, scalar ) local i; @@ -1677,7 +1677,7 @@ InstallMethod( AddMatrixColumnsLeft, "for a mutable matrix object, one column in ############################################################################ -InstallMethod( SwapMatrixRows, "for a mutable matrix object, one row index, second row index", +InstallMethod( SwapMatrixRows, "for a mutable matrix object, one row number, second row index", [ IsMatrixObj and IsMutable, IsInt, IsInt ], function( mat, row1, row2 ) local temp, i; @@ -1694,7 +1694,7 @@ InstallMethod( SwapMatrixRows, "for a mutable matrix object, one row index, seco ############################################################################ -InstallMethod( SwapMatrixColumns, "for a mutable matrix object, one column index, second column index", +InstallMethod( SwapMatrixColumns, "for a mutable matrix object, one column number, second column index", [ IsMatrixObj and IsMutable, IsInt, IsInt ], function( mat, column1, column2 ) local temp, i; diff --git a/lib/matrobjrowlist.gi b/lib/matrobjrowlist.gi index 442124b698..355394a862 100644 --- a/lib/matrobjrowlist.gi +++ b/lib/matrobjrowlist.gi @@ -44,7 +44,7 @@ InstallMethod( MultMatrixRowRight, "for a mutable IsRowListMatrix, one row numbe ## #M AddMatrixRows( , , , ) ## -InstallMethod( AddMatrixRowsLeft, "for a mutable IsRowListMatrix, one row number, second row number, and a scalar", +InstallMethod( AddMatrixRowsLeft, "for a mutable IsRowListMatrix, two row numbers, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , function( mat, row1, row2, scalar ) @@ -57,7 +57,7 @@ InstallMethod( AddMatrixRowsLeft, "for a mutable IsRowListMatrix, one row number ## #M AddMatrixRowsRight( , , , ) ## -InstallMethod( AddMatrixRowsRight, "for a mutable IsRowListMatrix, one row number, second row number, and a scalar", +InstallMethod( AddMatrixRowsRight, "for a mutable IsRowListMatrix, two row numbers, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsInt, IsObject ] , function( mat, row1, row2, scalar ) From a77ed466ea40b27e706d8286b0ef42ee9734e276 Mon Sep 17 00:00:00 2001 From: Daniel Rademacher Date: Thu, 10 Jun 2021 00:18:07 +0200 Subject: [PATCH 22/23] Docu improvement: First and second row/column number -> two row/column numbers --- lib/matobj.gi | 4 ++-- lib/matrobjrowlist.gi | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/matobj.gi b/lib/matobj.gi index b78ac38082..bf43f41e35 100644 --- a/lib/matobj.gi +++ b/lib/matobj.gi @@ -1677,7 +1677,7 @@ InstallMethod( AddMatrixColumnsLeft, "for a mutable matrix object, two column nu ############################################################################ -InstallMethod( SwapMatrixRows, "for a mutable matrix object, one row number, second row index", +InstallMethod( SwapMatrixRows, "for a mutable matrix object, and two row numbers", [ IsMatrixObj and IsMutable, IsInt, IsInt ], function( mat, row1, row2 ) local temp, i; @@ -1694,7 +1694,7 @@ InstallMethod( SwapMatrixRows, "for a mutable matrix object, one row number, sec ############################################################################ -InstallMethod( SwapMatrixColumns, "for a mutable matrix object, one column number, second column index", +InstallMethod( SwapMatrixColumns, "for a mutable matrix object, and two column numbers", [ IsMatrixObj and IsMutable, IsInt, IsInt ], function( mat, column1, column2 ) local temp, i; diff --git a/lib/matrobjrowlist.gi b/lib/matrobjrowlist.gi index 355394a862..1a12a77fa4 100644 --- a/lib/matrobjrowlist.gi +++ b/lib/matrobjrowlist.gi @@ -69,7 +69,7 @@ InstallMethod( AddMatrixRowsRight, "for a mutable IsRowListMatrix, two row numbe ## #M SwapMatrixRows( , , ) ## -InstallMethod( SwapMatrixRows, "for a mutable IsRowListMatrix, one row number, second row number", +InstallMethod( SwapMatrixRows, "for a mutable IsRowListMatrix, and two row numbers", [ IsRowListMatrix and IsMutable, IsInt, IsInt ], function( mat, row1, row2 ) local temp; From 6c6f503228fc11cc5a56607d7da6bf4f8cc647eb Mon Sep 17 00:00:00 2001 From: Daniel Rademacher Date: Thu, 10 Jun 2021 00:23:11 +0200 Subject: [PATCH 23/23] Docu improvement: one row/column -> a row/column. --- lib/matobj.gi | 8 ++++---- lib/matrobjrowlist.gi | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/matobj.gi b/lib/matobj.gi index bf43f41e35..e4fa250fe0 100644 --- a/lib/matobj.gi +++ b/lib/matobj.gi @@ -1573,7 +1573,7 @@ InstallMethod( \[\,\]\:\=, "for a matrix object, two positions, and an object", # Elementary matrix operations ############################################################################ -InstallMethod( MultMatrixRowLeft, "for a mutable matrix object, one row number, and a scalar", +InstallMethod( MultMatrixRowLeft, "for a mutable matrix object, a row number, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) local i; @@ -1586,7 +1586,7 @@ InstallMethod( MultMatrixRowLeft, "for a mutable matrix object, one row number, ############################################################################ -InstallMethod( MultMatrixColumnRight, "for a mutable matrix object, one column number, and a scalar", +InstallMethod( MultMatrixColumnRight, "for a mutable matrix object, a column number, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, column, scalar ) local i; @@ -1599,7 +1599,7 @@ InstallMethod( MultMatrixColumnRight, "for a mutable matrix object, one column n ############################################################################ -InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, and a scalar", +InstallMethod( MultMatrixRowRight, "for a mutable matrix object, a row number, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) local i; @@ -1612,7 +1612,7 @@ InstallMethod( MultMatrixRowRight, "for a mutable matrix object, one row number, ############################################################################ -InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, one column number, and a scalar", +InstallMethod( MultMatrixColumnLeft, "for a mutable matrix object, a column number, and a scalar", [ IsMatrixObj and IsMutable, IsInt, IsObject ], function( mat, column, scalar ) local i; diff --git a/lib/matrobjrowlist.gi b/lib/matrobjrowlist.gi index 1a12a77fa4..f1d6c69e2d 100644 --- a/lib/matrobjrowlist.gi +++ b/lib/matrobjrowlist.gi @@ -18,7 +18,7 @@ ## #M MultMatrixRow( , , ) ## -InstallMethod( MultMatrixRowLeft, "for a mutable IsRowListMatrix, one row number, and a scalar", +InstallMethod( MultMatrixRowLeft, "for a mutable IsRowListMatrix, a row number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsObject ], function( mat, row, scalar ) @@ -31,7 +31,7 @@ InstallMethod( MultMatrixRowLeft, "for a mutable IsRowListMatrix, one row number ## #M MultMatrixRowRight( , , ) ## -InstallMethod( MultMatrixRowRight, "for a mutable IsRowListMatrix, one row number, and a scalar", +InstallMethod( MultMatrixRowRight, "for a mutable IsRowListMatrix, a row number, and a scalar", [ IsRowListMatrix and IsMutable, IsInt, IsObject ], function( mat, row, scalar )