-
Notifications
You must be signed in to change notification settings - Fork 175
Reorder methods after new implications are added #2521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
be8920b
Record rank adjustment in METHODS_OPERATION
stevelinton 7812f31
Add RECALCULATE_ALL_METHOD_RANKS function which does what it says.
stevelinton a3cabba
Increase size of HIDDEN_IMPS_CACHE and WITH_IMPS_CACHE to speed up RE…
stevelinton 953bc86
Make sure RANK_FILTERS is always set promptly, then remove the test f…
stevelinton 5c4a76c
Automatically reorder methods after library or package loading, or In…
stevelinton d51f79e
Add test
stevelinton 1d1279d
Documentation
stevelinton 97cecad
HPCGAP support
stevelinton 533c1b6
Handle Constructors
stevelinton d03cd97
Use COPY_LIST_ENTRIES in method installation to avoid making an inter…
stevelinton e29f5b9
Support passing a function of no arguments as the rank adjustment to …
stevelinton 28d3d3f
Reset reordering status on quit from break loop.
stevelinton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,6 +171,62 @@ BIND_GLOBAL( "InstallTrueMethodNewFilter", function ( tofilt, from ) | |
| end ); | ||
|
|
||
|
|
||
| ############################################################################# | ||
| ## | ||
| #F SuspendMethodReordering( ) | ||
| #F ResumeMethodReordering( ) | ||
| #F ResetMethodReordering( ) | ||
| ## | ||
| ## <#GAPDoc Label="MethodReordering"> | ||
| ## <ManSection> | ||
| ## <Func Name="SuspendMethodReordering" Arg=""/> | ||
| ## <Func Name="ResumeMethodReordering" Arg=""/> | ||
| ## <Func Name="ResetMethodReordering" Arg=""/> | ||
| ## | ||
| ## <Description> | ||
| ## These functions control whether the method reordering process | ||
| ## described in <Ref Func="InstallTrueMethod"/> is invoked or not. Since this | ||
| ## process can be comparatively time-consuming, it is usually suspended when | ||
| ## a lot of implications are due to be installed, for instance when loading | ||
| ## the library, or a package. This is done by calling <C>SuspendMethodReordering()</C> | ||
| ## once the installations are done, <C>ResumeMethodReordering()</C> should be called. | ||
| ## These pairs of calls can be nested. When the outermost pair is complete, method | ||
| ## reordering takes place and is enabled in <C>InstallTrueMethod</C> thereafter. | ||
| ## | ||
| ## <C>ResetMethodReordering()</C> effectively exits all nested suspensions, resuming | ||
| ## reordering immediately. This function is mainly provided for error recovery and | ||
| ## similar purposes and is called on quitting from a break loop. | ||
| ## </Description> | ||
| ## </ManSection> | ||
| ## <#/GAPDoc> | ||
|
|
||
| # | ||
| # This function will be defined in oper.g | ||
| # | ||
| RECALCULATE_ALL_METHOD_RANKS := fail; | ||
|
|
||
| REORDER_METHODS_SUSPENSION_LEVEL := 1; | ||
|
|
||
| BIND_GLOBAL( "SuspendMethodReordering", function() | ||
| REORDER_METHODS_SUSPENSION_LEVEL := REORDER_METHODS_SUSPENSION_LEVEL + 1; | ||
| end); | ||
|
|
||
|
|
||
| BIND_GLOBAL( "ResumeMethodReordering", function() | ||
| if REORDER_METHODS_SUSPENSION_LEVEL > 0 then | ||
| REORDER_METHODS_SUSPENSION_LEVEL := REORDER_METHODS_SUSPENSION_LEVEL - 1; | ||
| fi; | ||
| if REORDER_METHODS_SUSPENSION_LEVEL <= 0 then | ||
| RECALCULATE_ALL_METHOD_RANKS(); | ||
| fi; | ||
| end); | ||
|
|
||
| BIND_GLOBAL( "ResetMethodReordering", function() | ||
| REORDER_METHODS_SUSPENSION_LEVEL := 0; | ||
| RECALCULATE_ALL_METHOD_RANKS(); | ||
| end); | ||
|
|
||
|
|
||
| ############################################################################# | ||
| ## | ||
| #F InstallTrueMethod( <newfil>, <filt> ) | ||
|
|
@@ -209,18 +265,33 @@ end ); | |
| ## This means that after the above implication has been installed, | ||
| ## one can rely on the fact that every object in the filter | ||
| ## <C>IsGroup and IsCyclic</C> will also be in the filter | ||
| ## <Ref Func="IsCommutative"/>. | ||
| ## <Ref Func="IsCommutative"/>.<P/> | ||
| ## | ||
| ## 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, so functions | ||
| ## <Ref Func="SuspendMethodReordering"/> and <Ref Func="ResumeMethodReordering"/> | ||
| ## are provided to allow control of this process. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's good to document this somewhere. But do we really want to document it for the public? I.e. perhaps move this out of the GAPDoc comment; or put it inside an XML comment? |
||
| ## </Description> | ||
| ## </ManSection> | ||
| ## <#/GAPDoc> | ||
| ## | ||
|
|
||
| BIND_GLOBAL( "InstallTrueMethod", function ( tofilt, from ) | ||
|
|
||
| InstallTrueMethodNewFilter( tofilt, from ); | ||
|
|
||
| # clear the caches because we do not know if filter <from> is new | ||
| CLEAR_HIDDEN_IMP_CACHE( from ); | ||
| CLEAR_IMP_CACHE(); | ||
|
|
||
| # maybe rerank methods to take account of new implication | ||
| if REORDER_METHODS_SUSPENSION_LEVEL = 0 then | ||
| RECALCULATE_ALL_METHOD_RANKS(); | ||
| fi; | ||
|
|
||
| end ); | ||
|
|
||
|
|
||
|
|
@@ -424,11 +495,7 @@ BIND_GLOBAL( "RankFilter", function( filter ) | |
| all := WITH_IMPS_FLAGS(flags); | ||
| fi; | ||
| for i in TRUES_FLAGS(all) do | ||
| if IsBound(RANK_FILTERS[i]) then | ||
| rank := rank + RANK_FILTERS[i]; | ||
| else | ||
| rank := rank + 1; | ||
| fi; | ||
| od; | ||
| return rank; | ||
| end ); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to make this publicly documented? Why?