Skip to content
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

Make Sortex stable #2654

Merged
merged 4 commits into from
Jul 23, 2018
Merged

Make Sortex stable #2654

merged 4 commits into from
Jul 23, 2018

Conversation

ChrisJefferson
Copy link
Contributor

This patch makes sortex stable. As it is now stable and efficient, make SortingPerm use sortex.

@codecov
Copy link

codecov bot commented Jul 18, 2018

Codecov Report

Merging #2654 into master will decrease coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #2654      +/-   ##
==========================================
- Coverage   75.19%   75.19%   -0.01%     
==========================================
  Files         478      478              
  Lines      242226   242214      -12     
==========================================
- Hits       182134   182124      -10     
+ Misses      60092    60090       -2
Impacted Files Coverage Δ
lib/list.gi 70.56% <100%> (-0.1%) ⬇️
hpcgap/lib/hpc/stdtasks.g 63.93% <0%> (-0.77%) ⬇️
src/objset.c 84.59% <0%> (-0.23%) ⬇️
src/sortbase.h 100% <0%> (+2.39%) ⬆️

Copy link
Contributor

@ThomasBreuer ThomasBreuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good.
(I would call ShallowCopy directly instead of the one argument version of List, but this is perhaps just a matter of taste.)

Concerning the documentation, I am wondering whether the paragraph The default methods for all of these sorting operations ... from doc/ref/lists.xml is (a) still correct (since it is far away from the actual code) and (b) in a good place (I think such a statement would better appear in the beginning of the section Sorting Lists).

@ChrisJefferson
Copy link
Contributor Author

I agree with using ShallowCopy. Also I have now improved the documentation to describe what we actually do! (briefly, but at least correctly)

merge sort. Finally, the functions which begin <C>Shell</C> use the shell
sort which was GAP's default search algorithm before 4.9.

<Ref Oper="Sortex"/> and <Ref Attr="SortingPerm"/> are also stable.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move the paragraph to the beginning of the manual section on Sorting Lists.
In particular for someone reading the manual (and not the source),
it is not clear that this paragraph belongs to all subsections and not just to the last one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now done. Also mentioned better in the documentation for sortex that it is stable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great.
Thanks for this improvement.

merge sort. Finally, the functions which begin <C>Shell</C> use the shell
sort which was GAP's default search algorithm before 4.9.

<Ref Oper="Sortex"/> and <Ref Attr="SortingPerm"/> are also stable.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great.
Thanks for this improvement.

@stevelinton stevelinton merged commit 466b681 into gap-system:master Jul 23, 2018
InstallMethod( SortingPerm,
"for a dense and sorted list",
[ IsDenseList and IsSortedList ], SUM_FLAGS,
list -> () );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChrisJefferson any particular reason this method was removed? I see no mention of this change in the PR description nor the commit message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was part of making SortingPerm be exactly the same as SortEx.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why that requires removing this optimization, though? Now if the input is sorted, we make a copy, sort that, and compute the identity permutation from that...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could probably have been left in, I wouldn't have a problem with it being re-added but I wasn't sure it was worth it, for a fairly unusual case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this method as an illustration of the idea to avoid working by using known information.
If the presence of such methods for fairly unusual cases does not slow down
the computations in the usual cases
then these methods are beneficial.
If this is not the case then it might be interesting to discuss the situation in detail,
perhaps in some tutorial.

@fingolfin fingolfin added the release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes label Jul 30, 2018
@ChrisJefferson ChrisJefferson deleted the sortex branch August 20, 2018 10:05
@fingolfin fingolfin added kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements topic: library release notes: added PRs introducing changes that have since been mentioned in the release notes and removed release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes labels Sep 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements release notes: added PRs introducing changes that have since been mentioned in the release notes topic: library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants