Skip to content

Commit

Permalink
Avoid use of IsBound(t[i,j])
Browse files Browse the repository at this point in the history
... by refactoring the general fallback method for MutableTransposedMat
  • Loading branch information
fingolfin committed Jul 11, 2019
1 parent ed6e032 commit 608c6b8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/matrix.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1971,10 +1971,10 @@ InstallOtherMethod( MutableTransposedMat,
"for arbitrary lists of lists",
[ IsList ],
function( t )
local res, m, i, j;
local res, m, i, j, row;
res := [];
if Length(t)>0 and IsDenseList(t) and ForAll(t, IsDenseList) then
# special case with dense list of dense lists
# special case with dense list of dense lists
m := Maximum(List(t, Length));
for i in [m,m-1..1] do
res[i] := [];
Expand All @@ -1983,16 +1983,17 @@ InstallOtherMethod( MutableTransposedMat,
res{[1..Length(t[i])]}[i] := t[i];
od;
else
# general case, non dense lists allowed
# general case, non dense lists allowed
for i in [1..Length(t)] do
if IsBound(t[i]) then
if IsList(t[i]) then
for j in [1..Length(t[i])] do
if IsBound(t[i,j]) then
row := t[i];
if IsList(row) then
for j in [1..Length(row)] do
if IsBound(row[j]) then
if not IsBound(res[j]) then
res[j] := [];
fi;
res[j,i] := t[i,j];
res[j,i] := row[j];
fi;
od;
else
Expand Down

0 comments on commit 608c6b8

Please sign in to comment.