Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions hpcgap/lib/basis.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,17 @@ InstallMethod( Coefficients,
fi;
end );

InstallOtherMethod( Coefficients,
"for empty basis and empty list",
[ IsBasis and IsEmpty, IsEmpty and IsList ], SUM_FLAGS,
function( B, v )
if v = Zero( UnderlyingLeftModule( B ) ) then
return [];
else
return fail;
fi;
end );

InstallMethod( LinearCombination,
"for empty basis and empty list",
[ IsBasis and IsEmpty, IsList and IsEmpty ], SUM_FLAGS,
Expand Down
11 changes: 11 additions & 0 deletions lib/basis.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,17 @@ InstallMethod( Coefficients,
fi;
end );

InstallOtherMethod( Coefficients,
"for empty basis and empty list",
[ IsBasis and IsEmpty, IsEmpty and IsList ], SUM_FLAGS,
function( B, v )
if v = Zero( UnderlyingLeftModule( B ) ) then
return [];
else
return fail;
fi;
end );

InstallMethod( LinearCombination,
"for empty basis and empty list",
[ IsBasis and IsEmpty, IsList and IsEmpty ], SUM_FLAGS,
Expand Down
12 changes: 11 additions & 1 deletion lib/modulrow.gi
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,15 @@ InstallMethod( \in,
and IsSubset( LeftActingDomain( M ), v );
end );

# TODO: HACK: properly document this
InstallMethod( \in,
"for empty list and vector space with length 0 vector",
[ IsEmpty and IsList, IsFreeLeftModule and IsFullRowModule ],
SUM_FLAGS, # can't do better
function( v, M )
return DimensionOfVectors(M) = 0;
end );


#############################################################################
##
Expand Down Expand Up @@ -535,7 +544,8 @@ InstallMethod( EnumeratorByBasis,
zerovector := Zero( V ),
dimension := Dimension( V ) ) );

if IsField( F ) and Size( F ) < 256 and IsInternalRep( One( F ) ) then
if IsField( F ) and Size( F ) < 256 and Dimension( V ) > 0 and
IsInternalRep( One( F ) ) then
# Use a more efficient method for `Position'.
enum!.NumberElement:= PosVecEnumFF;
SetFilterObj( enum, IsQuickPositionList );
Expand Down
17 changes: 17 additions & 0 deletions tst/testbugfix/2018-01-29-empty-list-in-vecspace.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# See <https://github.com/gap-system/gap/issues/2117>
#
gap> V := GF(5)^0;;
gap> e := Enumerator(V);;
gap> Position(e, Zero(V));
1
gap> Coefficients(Basis(V), Zero(V));
[ ]

#
gap> V := GF(257)^0;;
gap> e := Enumerator(V);;
gap> Position(e, Zero(V));
1
gap> Coefficients(Basis(V), Zero(V));
[ ]