Skip to content

Commit

Permalink
Special setter for size, made IsTrivial<->IsNonTrivial a true method
Browse files Browse the repository at this point in the history
and changed the corresponding immediate methods to ordinary ones.

Impact on csetgrp b/c ObjectifyWithAttr for Size
  • Loading branch information
hulpke committed Apr 24, 2018
1 parent 6c4268c commit ed5c90a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
4 changes: 4 additions & 0 deletions lib/coll.gd
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,10 @@ InstallFactorMaintenance( IsTrivial,
##
DeclareProperty( "IsNonTrivial", IsCollection );

# true methods to avoid immediate methods
InstallTrueMethod(HasIsTrivial,IsNonTrivial);
InstallTrueMethod(HasIsNonTrivial,IsTrivial);


#############################################################################
##
Expand Down
25 changes: 19 additions & 6 deletions lib/coll.gi
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ InstallMethod( PrintObj,
##
InstallImmediateMethod( IsEmpty,
IsCollection and HasSize, 0,
C -> Size( C ) = 0 );
C->Size( C ) = 0);

InstallMethod( IsEmpty,
"for a collection",
Expand All @@ -120,17 +120,17 @@ InstallMethod( IsTrivial,
[ IsCollection ],
C -> Size( C ) = 1 );

InstallImmediateMethod( IsTrivial,
IsCollection and HasIsNonTrivial, 0,
InstallMethod( IsTrivial,
[IsCollection and HasIsNonTrivial], 0,
C -> not IsNonTrivial( C ) );


#############################################################################
##
#M IsNonTrivial( <C> ) . . . . . . . . . test if a collection is nontrivial
##
InstallImmediateMethod( IsNonTrivial,
IsCollection and HasIsTrivial, 0,
InstallMethod( IsNonTrivial,
[IsCollection and HasIsTrivial], 0,
C -> not IsTrivial( C ) );

InstallMethod( IsNonTrivial,
Expand Down Expand Up @@ -173,7 +173,8 @@ InstallMethod( IsWholeFamily,
# method, as the immediate method would get called for every group that
# knows it is finite but does not know its size -- e.g. permutation, pc.
# The benefit of this is minimal beyond showing off a feature.
InstallMethod( Size,true, [IsCollection and HasIsFinite], 0,
InstallMethod( Size,true, [IsCollection and HasIsFinite],
100, # rank above object-specific methods
function ( C )
if IsFinite( C ) then
TryNextMethod();
Expand Down Expand Up @@ -3052,6 +3053,18 @@ end);
InstallMethod( CanComputeIsSubset,"default: no, unless identical",
[IsObject,IsObject],IsIdenticalObj);

# avoid immediate methods triggering multiple type changes once the Size of
# an object is known.
InstallOtherMethod(SetSize,true,[IsObject and IsAttributeStoringRep,IsObject],
100, # override system setter
function(obj,sz)
SetIsEmpty(obj,sz=0);
SetIsTrivial(obj,sz=1);
SetIsNonTrivial(obj,sz<>1);
SetIsFinite(obj,sz<>infinity);
TryNextMethod(); # to enforce size setting
end);

#############################################################################
##
#E
15 changes: 7 additions & 8 deletions lib/csetgrp.gi
Original file line number Diff line number Diff line change
Expand Up @@ -573,21 +573,20 @@ end);
InstallMethod(RightCoset,"use subgroup size",IsCollsElms,
[IsGroup and HasSize,IsObject],0,
function(U,g)
local d,fam;
local d,fam,typ;
# noch tests...

fam:=FamilyObj(U);
if not IsBound(fam!.rightCosetsDefaultSizeType) then
fam!.rightCosetsDefaultSizeType:=NewType(fam,IsRightCosetDefaultRep and
HasActingDomain and HasFunctionAction and HasRepresentative and
HasSize and HasCanonicalRepresentativeDeterminatorOfExternalSet);
fi;
typ:=NewType(fam,IsRightCosetDefaultRep and
HasActingDomain and HasFunctionAction and HasRepresentative
and HasCanonicalRepresentativeDeterminatorOfExternalSet);

d:=rec();
ObjectifyWithAttributes(d,fam!.rightCosetsDefaultSizeType,
ObjectifyWithAttributes(d,typ,
ActingDomain,U,FunctionAction,OnLeftInverse,Representative,g,
Size,Size(U),CanonicalRepresentativeDeterminatorOfExternalSet,
CanonicalRepresentativeDeterminatorOfExternalSet,
RightCosetCanonicalRepresentativeDeterminator);
SetSize(d,Size(U)); # as own setter
return d;
end);

Expand Down

0 comments on commit ed5c90a

Please sign in to comment.