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

Speed up Posets and toric Chow group #11559

Open
vbraun opened this issue Jun 30, 2011 · 46 comments
Open

Speed up Posets and toric Chow group #11559

vbraun opened this issue Jun 30, 2011 · 46 comments

Comments

@vbraun
Copy link
Member

vbraun commented Jun 30, 2011

To my surprise, computing the Chow group spends most of the time comparing cones instead of doing linear algebra. 3/4 of the time is spent in PosetElement.__eq__():

   return self.parent() == other.parent() \
          and self.element == other.element \
          and self.vertex == other.vertex

Reordering this to first compare self.vertex == other.vertex speeds it up dramatically.

Patch has some other fixes. Changes the Chow group to use sparse matrices.

CC: @sagetrac-sage-combinat

Component: algebraic geometry

Keywords: toric, sd40.5

Author: Volker Braun

Branch/Commit: u/chapoton/11559 @ a16336e

Reviewer: Andrey Novoseltsev, Jan Keitel

Issue created by migration from https://trac.sagemath.org/ticket/11559

@vbraun
Copy link
Member Author

vbraun commented Jun 30, 2011

Attachment: trac_11559_fix_Chow_group.patch.gz

Updated patch

@novoselt
Copy link
Member

novoselt commented Jul 1, 2011

comment:1

Can you clarify why hermit_form was replaced with echelon_form?

Also I don't like the very last change with forceful passing of check=False to the parent constructor. I think the correct way is to always pass whatever was received from the user and if it leads to a slowdown somewhere, then in that somewhere one should use check=False.

@novoselt
Copy link
Member

novoselt commented Jul 1, 2011

Reviewer: Andrey Novoseltsev

@rbeezer
Copy link
Mannequin

rbeezer mannequin commented Jul 1, 2011

comment:2

I took a look at this earlier, so I'll add my 2 cents worth.

hermite_form is a straight replacement for echelon_form. Now that we have a rref command to obtain results over fields, I personally think it would be nice if "hermite form" went away, I think it confuses too many non-specialists.

I was going to vouch for the posets and linear algebra, but I don't know the Chow group stuff, so it is good that Andrey is on this one.

Rob

@vbraun
Copy link
Member Author

vbraun commented Jul 1, 2011

comment:3

hermite_form is an alias for echelon_form for dense ZZ-matrices. Sparse ZZ-matrices currently don't have a hermite_form method, though I'll add that back in #11558.

I'm passing check=False to the element constructor because the input for the base constructor is computed. Usually when you extend some element class, you pass user-specified arguments through to the base constructor and its necessary to check their validity. Though I didn't see it taking much time when benchmarking, so if you insist I'll be happy to take it out again.

@hivert
Copy link

hivert commented Jul 2, 2011

comment:5

What kind of parents are you using. Normally they should be unique so that
parent comparisons should be done with is and thus instantaneous. Moreover, I
don't think your solution is correct because in some case you will end up
comparing things where eq will simply break. I'll try to cook an example.

Florent

@hivert
Copy link

hivert commented Jul 2, 2011

comment:6

I should also mention that before touching anything in posets you should test you code with #10998 applied. There where a major rewrite in posets with a lot of speedups and cleanups.

Florent

@vbraun
Copy link
Member Author

vbraun commented Jul 2, 2011

comment:7

I agree that parents should be unique. The original code compared parents with == and I didn't change it.

My point is that the PosetElement.element comparison is potentially slow. In fact, I don't understand why PosetElement.__eq__ compares both vertex and element, I am under the impression that there is a bijection between vertices and elements.

The reordering does break comparison between PosetElements and other classes, though I'm not sure if we care. The patch does conflict with #10998, so that one needs to be reviewed first.

@novoselt
Copy link
Member

Changed dependencies from #11558 to #11558, #10998

@seblabbe
Copy link
Contributor

comment:9

Same lines are edited by #12351. One will have to adapt to the other one.

@novoselt
Copy link
Member

comment:10

Does not apply on Sage-5.0.beta4!

@nthiery
Copy link
Contributor

nthiery commented Feb 16, 2012

comment:11

Replying to @novoselt:

Does not apply on Sage-5.0.beta4!

If it's the hunk in the poset code that fails, that's normal. #10998 already integrates this change (in fact a slightly better one).

@novoselt
Copy link
Member

novoselt commented Mar 7, 2012

Work Issues: rebasing

@novoselt
Copy link
Member

Changed work issues from rebasing to none

@novoselt
Copy link
Member

comment:13

Hey Volker,

Changing posets to compare again vertices first still shaves off a second on testing Chow group module - do you have an example where it used to be crucial? In any case if you are fine with my rebasing let's merge it!

@novoselt
Copy link
Member

Changed keywords from none to toric, sd40.5

@novoselt
Copy link
Member

Changed dependencies from #11558, #10998 to #11558, #10998, #13023

@novoselt
Copy link
Member

Rebased for Sage-5.1.beta0

@novoselt
Copy link
Member

comment:15

Attachment: trac_11559_fix_Chow_group.2.patch.gz

Now works fine after file move.

@sagetrac-jkeitel
Copy link
Mannequin

sagetrac-jkeitel mannequin commented Jul 9, 2014

Changed branch from u/chapoton/11559 to u/jkeitel/11559

@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@fchapoton
Copy link
Contributor

comment:29

This ticket seems to confuse the patchbot. But maybe any ticket would..

@fchapoton fchapoton modified the milestones: sage-6.4, sage-6.6 Mar 25, 2015
@fchapoton
Copy link
Contributor

comment:30

Put to need info just to stop the bots loop-testing this ticket.

@novoselt
Copy link
Member

comment:31

Related or not - when I click on the branch name to see the differences, it shows the intent to DELETE TWO MODULES completely!!! I do not see commits that attempt to do it, however.

@fchapoton
Copy link
Contributor

New commits:

b94f43dMerge branch 'u/jkeitel/11559' of ssh://trac.sagemath.org:22/sage into 11559

@fchapoton
Copy link
Contributor

Changed commit from 85a053d to b94f43d

@fchapoton
Copy link
Contributor

Changed branch from u/jkeitel/11559 to u/chapoton/11559

@fchapoton fchapoton modified the milestones: sage-6.6, sage-6.7 May 5, 2015
@pjbruin
Copy link
Contributor

pjbruin commented Jun 4, 2015

comment:34

Some patchbots are still testing this ticket, but there are various doctest failures; setting this back to "needs_work".

@fchapoton
Copy link
Contributor

Changed dependencies from #11558, #10998, #13023 to none

@fchapoton

This comment has been minimized.

@fchapoton fchapoton modified the milestones: sage-6.7, sage-7.1 Mar 2, 2016
@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 14, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

a16336eMerge branch 'u/chapoton/11559' in 8.1.b5

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 14, 2017

Changed commit from b94f43d to a16336e

@mkoeppe mkoeppe removed this from the sage-7.1 milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants