Skip to content

Commit

Permalink
adjust to the discussion
Browse files Browse the repository at this point in the history
allow implications to representations that are already implied
  • Loading branch information
ThomasBreuer committed Dec 20, 2022
1 parent 290d8e3 commit d870125
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
28 changes: 15 additions & 13 deletions lib/filter.g
Original file line number Diff line number Diff line change
Expand Up @@ -285,29 +285,32 @@ end);
## Adding logical implications can change the rank of filters (see
## <Ref Func="RankFilter"/>) and consequently the rank, and so choice of
## methods for operations (see <Ref Sect="Applicable Methods and Method Selection"/>).
## By default <C>InstallTrueMethod</C> adjusts the method selection data
## structures to take care of this, but this process can be time-consuming,
## By default <Ref Func="InstallTrueMethod"/> adjusts the method selection
## data structures to take care of this,
## but this process can be time-consuming,
## so functions <Ref Func="SuspendMethodReordering"/> and
## <Ref Func="ResumeMethodReordering"/> are provided to allow control of this process.
## </Description>
## </ManSection>
## <#/GAPDoc>
##

BIND_GLOBAL( "InstallTrueMethod", function ( tofilt, from )
local i;
local fromflags, i, j;

# Check whether 'tofilt' involves or implies representations.
fromflags:= TRUES_FLAGS( WITH_IMPS_FLAGS( FLAGS_FILTER( from ) ) );
for i in TRUES_FLAGS( WITH_IMPS_FLAGS( FLAGS_FILTER( tofilt ) ) ) do
if INFO_FILTERS[i] = FNUM_REP_KERN or INFO_FILTERS[i] = FNUM_REP then
# This is allowed only if 'from' consists of representations.
for i in TRUES_FLAGS( WITH_IMPS_FLAGS( FLAGS_FILTER( from ) ) ) do
if not ( INFO_FILTERS[i] = FNUM_REP_KERN or
INFO_FILTERS[i] = FNUM_REP ) then
Error( "<tofilt> must not involve representation filters" );
fi;
od;
break;
# This is allowed only if either 'from' already implies filter 'i'
# or if 'from' consists of representations.
if not i in fromflags then
for j in fromflags do
if not ( INFO_FILTERS[j] = FNUM_REP_KERN or
INFO_FILTERS[j] = FNUM_REP ) then
Error( "<tofilt> must not involve new representation filters" );
fi;
od;
fi;
fi;
od;

Expand All @@ -321,7 +324,6 @@ BIND_GLOBAL( "InstallTrueMethod", function ( tofilt, from )
if REORDER_METHODS_SUSPENSION_LEVEL = 0 then
RECALCULATE_ALL_METHOD_RANKS();
fi;

end );


Expand Down
7 changes: 4 additions & 3 deletions tst/testinstall/method.tst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ Error, required filters [ "IsInt", "IsRat", "IsCyc", "IsExtAElement",
"IsAdditivelyCommutativeElement", "IsCommutativeElement", "IsCyclotomic" ]
for 1st argument do not match a declaration of Size
gap> InstallTrueMethod( IsInternalRep, IsList );
Error, <tofilt> must not involve representation filters
Error, <tofilt> must not involve new representation filters
gap> InstallTrueMethod( IsDenseCoeffVectorRep, IsList );
Error, <tofilt> must not involve representation filters
Error, <tofilt> must not involve new representation filters
gap> InstallTrueMethod( IsInternalRep, IsSmallIntRep );
gap> STOP_TEST("method.tst", 1);
gap> InstallTrueMethod( IsList and IsInternalRep, IsList and IsSmallIntRep );
gap> STOP_TEST("method.tst");

0 comments on commit d870125

Please sign in to comment.