Skip to content

Commit

Permalink
side-effects of the renamings
Browse files Browse the repository at this point in the history
- turned `IsDiagonalMatrix`, `IsUpperTriangularMatrix`,
  `IsLowerTriangularMatrix` into properties,
- adjusted the default method installations,
- removed the corresponding declarations from `lib/matobj2.gd`.
  • Loading branch information
ThomasBreuer committed Aug 21, 2019
1 parent f71e5ea commit 659250f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 32 deletions.
9 changes: 1 addition & 8 deletions lib/matobj2.gd
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ DeclareOperation( "ChangedBaseDomain", [IsVectorObj,IsSemiring] );
# Changes the base domain. A copy of the row vector in the first argument is
# created, which comes in a "similar" representation but over the new
# base domain that is given in the second argument.
# The result is mutable if and only if the given vector is mutable.
# example: given a vector over GF(2), create a new vector over GF(4) with "identical" content
# so it's kind of a type conversion / coercion
# TODO: better name, e.g. VectorWithChangedBasedDomain
Expand Down Expand Up @@ -1124,14 +1125,6 @@ DeclareOperation( "TransposedMatMutable", [IsMatrixObj] );
#


DeclareOperation( "IsDiagonalMat", [IsMatrixObj] );
DeclareOperation( "IsUpperTriangularMat", [IsMatrixObj] );
DeclareOperation( "IsLowerTriangularMat", [IsMatrixObj] );
# TODO: if we allow attributes, we might just as well do the above to be
# declared as properties, so that this information is stored; but once
# again, we would only want to allow this for immutable matrix objects.
# ...

# TODO: what about the following (and also note the names...):
# - IsScalarMat, IsSquareMat, ... ?

Expand Down
30 changes: 15 additions & 15 deletions lib/matrix.gd
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ DeclareProperty( "IsGeneralizedCartanMatrix", IsMatrix );

#############################################################################
##
#O IsDiagonalMatrix( <mat> )
#O IsDiagonalMat( <mat> )
#P IsDiagonalMatrix( <mat> )
#P IsDiagonalMat( <mat> )
##
## <#GAPDoc Label="IsDiagonalMat">
## <ManSection>
## <Oper Name="IsDiagonalMatrix" Arg='mat'/>
## <Oper Name="IsDiagonalMat" Arg='mat'/>
## <Prop Name="IsDiagonalMatrix" Arg='mat'/>
## <Prop Name="IsDiagonalMat" Arg='mat'/>
##
## <Description>
## return <K>true</K> if the matrix <A>mat</A> has only zero entries
Expand All @@ -87,20 +87,20 @@ DeclareProperty( "IsGeneralizedCartanMatrix", IsMatrix );
## </ManSection>
## <#/GAPDoc>
##
DeclareOperation( "IsDiagonalMatrix", [ IsMatrixObj ] );
DeclareProperty( "IsDiagonalMatrix", IsMatrixObj );

DeclareSynonym( "IsDiagonalMat", IsDiagonalMatrix );


#############################################################################
##
#O IsUpperTriangularMatrix( <mat> )
#O IsUpperTriangularMat( <mat> )
#P IsUpperTriangularMatrix( <mat> )
#P IsUpperTriangularMat( <mat> )
##
## <#GAPDoc Label="IsUpperTriangularMat">
## <ManSection>
## <Oper Name="IsUpperTriangularMatrix" Arg='mat'/>
## <Oper Name="IsUpperTriangularMat" Arg='mat'/>
## <Prop Name="IsUpperTriangularMatrix" Arg='mat'/>
## <Prop Name="IsUpperTriangularMat" Arg='mat'/>
##
## <Description>
## return <K>true</K> if the matrix <A>mat</A> has only zero entries below
Expand All @@ -117,20 +117,20 @@ DeclareSynonym( "IsDiagonalMat", IsDiagonalMatrix );
## </ManSection>
## <#/GAPDoc>
##
DeclareOperation( "IsUpperTriangularMatrix", [ IsMatrixObj ] );
DeclareProperty( "IsUpperTriangularMatrix", IsMatrixObj );

DeclareSynonym( "IsUpperTriangularMat", IsUpperTriangularMatrix );


#############################################################################
##
#O IsLowerTriangularMatrix( <mat> )
#O IsLowerTriangularMat( <mat> )
#P IsLowerTriangularMatrix( <mat> )
#P IsLowerTriangularMat( <mat> )
##
## <#GAPDoc Label="IsLowerTriangularMat">
## <ManSection>
## <Oper Name="IsLowerTriangularMatrix" Arg='mat'/>
## <Oper Name="IsLowerTriangularMat" Arg='mat'/>
## <Prop Name="IsLowerTriangularMatrix" Arg='mat'/>
## <Prop Name="IsLowerTriangularMat" Arg='mat'/>
##
## <Description>
## return <K>true</K> if the matrix <A>mat</A> has only zero entries above
Expand All @@ -147,7 +147,7 @@ DeclareSynonym( "IsUpperTriangularMat", IsUpperTriangularMatrix );
## </ManSection>
## <#/GAPDoc>
##
DeclareOperation( "IsLowerTriangularMatrix", [ IsMatrixObj ] );
DeclareProperty( "IsLowerTriangularMatrix", IsMatrixObj );

DeclareSynonym( "IsLowerTriangularMat", IsLowerTriangularMatrix );

Expand Down
24 changes: 15 additions & 9 deletions lib/matrix.gi
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ InstallMethod( IsGeneralizedCartanMatrix,

#############################################################################
##
#M IsDiagonalMat(<mat>)
#M IsDiagonalMatrix(<mat>)
##
InstallMethod( IsDiagonalMat,
InstallMethod( IsDiagonalMatrix,
"for a matrix",
[ IsMatrixObj ],
function( mat )
Expand All @@ -176,14 +176,14 @@ InstallMethod( IsDiagonalMat,
return true;
end);

InstallOtherMethod( IsDiagonalMat, [ IsEmpty ], ReturnTrue );
InstallTrueMethod( IsDiagonalMatrix, IsMatrixObj and IsEmptyMatrix );


#############################################################################
##
#M IsUpperTriangularMat(<mat>)
#M IsUpperTriangularMatrix(<mat>)
##
InstallMethod( IsUpperTriangularMat,
InstallMethod( IsUpperTriangularMatrix,
"for a matrix",
[ IsMatrixObj ],
function( mat )
Expand All @@ -202,9 +202,9 @@ InstallMethod( IsUpperTriangularMat,

#############################################################################
##
#M IsLowerTriangularMat(<mat>)
#M IsLowerTriangularMatrix(<mat>)
##
InstallMethod( IsLowerTriangularMat,
InstallMethod( IsLowerTriangularMatrix,
"for a matrix",
[ IsMatrixObj ],
function( mat )
Expand All @@ -223,9 +223,9 @@ InstallMethod( IsLowerTriangularMat,

#############################################################################
##
#M DiagonalOfMat(<mat>) . . . . . . . . . . . . . . . . diagonal of matrix
#M DiagonalOfMatrix(<mat>) . . . . . . . . . . . . . . . diagonal of matrix
##
InstallGlobalFunction( DiagonalOfMat, function ( mat )
InstallGlobalFunction( DiagonalOfMatrix, function ( mat )
local diag, i;

diag := [];
Expand Down Expand Up @@ -3272,6 +3272,12 @@ InstallGlobalFunction( NullMat, function ( arg )
fi;
zero := Zero(f);

# # special treatment for 0-dimensional spaces
# if m = 0 or n = 0 then
# return NullMapMatrix;
# fi;
#T Adding this would break a test.

# make an empty row
row := ListWithIdenticalEntries(n,zero);
ConvertToVectorRepNC( row, f );
Expand Down

0 comments on commit 659250f

Please sign in to comment.