Skip to content

Commit

Permalink
Use generic methods for IsDiagonalMat, Is{Upper,Lower}TriangularMat
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Jan 25, 2019
1 parent be70170 commit b04f4b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 65 deletions.
62 changes: 0 additions & 62 deletions lib/matobjplist.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1160,68 +1160,6 @@ InstallMethod( Randomize, "for a mutable plist matrix",
od;
end );

InstallMethod( IsDiagonalMat, "for a plist matrix",
[ IsPlistMatrixRep ],
function( m )
local i,j,l,n;
if m![RLPOS] <> Length(m![ROWSPOS]) then
ErrorNoReturn("IsDiagonalMat: Matrix not square");
fi;
n := m![RLPOS];
l := m![ROWSPOS];
for i in [1..n] do
for j in [1..i-1] do
if not IsZero(l[i,j]) then
return false;
fi;
od;
for j in [i+1..n] do
if not IsZero(l[i,j]) then
return false;
fi;
od;
od;
return true;
end );

InstallMethod( IsLowerTriangularMat, "for a plist matrix",
[ IsPlistMatrixRep ],
function( m )
local i,j,l,n;
if m![RLPOS] <> Length(m![ROWSPOS]) then
ErrorNoReturn("IsLowerTriangularMat: Matrix not square");
fi;
n := m![RLPOS];
l := m![ROWSPOS];
for i in [1..n] do
for j in [i+1..n] do
if not IsZero(l[i,j]) then
return false;
fi;
od;
od;
return true;
end );

InstallMethod( IsUpperTriangularMat, "for a plist matrix",
[ IsPlistMatrixRep ],
function( m )
local i,j,l,n;
if m![RLPOS] <> Length(m![ROWSPOS]) then
ErrorNoReturn("IsUpperTriangularMat: Matrix not square");
fi;
n := m![RLPOS];
l := m![ROWSPOS];
for i in [1..n] do
for j in [1..i-1] do
if not IsZero(l[i,j]) then
return false;
fi;
od;
od;
return true;
end );

InstallMethod( TransposedMatMutable, "for a plist matrix",
[ IsPlistMatrixRep ],
function( m )
Expand Down
12 changes: 9 additions & 3 deletions lib/matrix.gi
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ InstallOtherMethod( IsDiagonalMat,
[ IsMatrix ],
function( mat )
local i, j,z;
if IsEmpty(mat) then return true;fi;
if NrRows(mat) = 0 then
return true;
fi;
z:=ZeroOfBaseDomain(mat);
for i in [ 1 .. NrRows( mat ) ] do
for j in [ 1 .. NrCols( mat ) ] do
Expand All @@ -189,7 +191,9 @@ InstallOtherMethod( IsUpperTriangularMat,
[ IsMatrix ],
function( mat )
local i, j,z;
if IsEmpty(mat) then return true;fi;
if NrRows(mat) = 0 then
return true;
fi;
z:=ZeroOfBaseDomain(mat);
for i in [ 1 .. NrRows( mat ) ] do
for j in [ 1 .. i-1] do
Expand All @@ -210,7 +214,9 @@ InstallOtherMethod( IsLowerTriangularMat,
[ IsMatrix ],
function( mat )
local i, j,z;
if IsEmpty(mat) then return true;fi;
if NrRows(mat) = 0 then
return true;
fi;
z:=ZeroOfBaseDomain(mat);
for i in [ 1 .. NrRows( mat ) ] do
for j in [ i+1 .. NrCols( mat ) ] do
Expand Down

0 comments on commit b04f4b6

Please sign in to comment.