Skip to content

Commit

Permalink
Use SwapMatrixRows/Columns in a few places
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Nov 11, 2024
1 parent 62bd8f0 commit 889ce08
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
26 changes: 7 additions & 19 deletions lib/matrix.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,7 @@ InstallMethod( DeterminantMatDestructive,

# make its row the current row
if i <> j then
row := mat[j]; mat[j] := mat[i]; mat[i] := row;
SwapMatrixRows(mat, j, i);
sgn := -sgn;
else
row := mat[j];
Expand Down Expand Up @@ -1566,9 +1566,7 @@ function( mat )

# ... make its row the current row, ...
if k <> j then
row := mat[j];
mat[j] := mat[k];
mat[k] := row;
SwapMatrixRows(mat, j, k);
sgn := -sgn;
else
row := mat[j];
Expand Down Expand Up @@ -1789,30 +1787,20 @@ local R,M,transform,divide,swaprow, swapcol, addcol, addrow, multcol, multrow, l

swaprow:=function(a,b)
local r;
r:=M[a];
M[a]:=M[b];
M[b]:=r;
SwapMatrixRows(M, a, b);
if transform then
r:=left[a];
left[a]:=left[b];
left[b]:=r;
SwapMatrixRows(left, a, b);
if basmat<>fail then
r:=basmat[a];
basmat[a]:=basmat[b];
basmat[b]:=r;
SwapMatrixRows(basmat, a, b);
fi;
fi;
end;

swapcol:=function(a,b)
local c;
c:=M{[1..l]}[a];
M{[1..l]}[a]:=M{[1..l]}[b];
M{[1..l]}[b]:=c;
SwapMatrixColumns(M, a, b);
if transform then
c:=right{[1..n]}[a];
right{[1..n]}[a]:=right{[1..n]}[b];
right{[1..n]}[b]:=c;
SwapMatrixColumns(right, a, b);
fi;
end;

Expand Down
4 changes: 1 addition & 3 deletions lib/zlattice.gi
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,7 @@ InstallGlobalFunction( LinearIndependentColumns, function( mat )
fi;

# Swap rows `j' and `i'.
row:= mat[j];
mat[j]:= mat[i];
mat[i]:= row;
SwapMatrixRows(mat, i, j);

# Normalize column `k'.
val:= row[k];
Expand Down

0 comments on commit 889ce08

Please sign in to comment.