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 12, 2024
1 parent 62bd8f0 commit bad562a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
31 changes: 8 additions & 23 deletions lib/matrix.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1488,11 +1488,10 @@ InstallMethod( DeterminantMatDestructive,
i := i + 1;

# make its row the current row
row := mat[j];
if i <> j then
row := mat[j]; mat[j] := mat[i]; mat[i] := row;
SwapMatrixRows(mat, j, i);
sgn := -sgn;
else
row := mat[j];
fi;
piv := row[k];

Expand Down Expand Up @@ -1566,9 +1565,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 @@ -1788,31 +1785,19 @@ local R,M,transform,divide,swaprow, swapcol, addcol, addrow, multcol, multrow, l
fi;

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
3 changes: 1 addition & 2 deletions lib/zlattice.gi
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ InstallGlobalFunction( LinearIndependentColumns, function( mat )

# 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 bad562a

Please sign in to comment.