-
-
Notifications
You must be signed in to change notification settings - Fork 487
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
Improve speed of sum_of_* for CombinatorialFreeModule #33267
Comments
Commit: |
comment:1
versus before
So we get ~4x speedup on these small examples. Likely this will improve the speed across a number of methods as these two methods are used somewhat frequently. New commits:
|
comment:2
This bit, for index, coeff in index_coeff_pairs:
if index in result:
result[index] += coeff
else:
result[index] = coeff
return remove_zeros(result) makes several passes through |
comment:3
Initializing zeros would only be better in cases that are highly dense, which is fairly rare IMO. Suppose we are working in the exterior algebra of rank Now I did think about catching the
If I instead replace
This is why I settled on this. Something I have thought a bit about is having a sparse and dense version of |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:5
I did one additional optimization I noticed while reviewing #33257. |
Dependencies: #33257 |
Reviewer: Michael Orlitzky |
comment:6
Ok, it does what it says. I've been testing it on my own CFM code with no problems. One more nitpick: in cpdef dict sum_of_monomials(monomials, scalar):
r"""
Return the pointwise addition of ``monomials``.
INPUT:
- ``monomials`` -- a list of indices representing the monomials only mentions a list. I think an iterable would work there too? Not a big deal. I also spent some time trying to figure out how to remove the double-loop from |
Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. New commits:
|
comment:8
Replying to @orlitzky:
Thank you for the review.
I fixed it. Since it is a trivial change, I am allowing myself to set this back to a positive review. Feel free to revert if you disagree.
That would be bad when there are very few zeros, but say the |
Changed branch from public/performance/optimize_sum_of_in_cfm-33267 to |
We avoid using transient elements as much as possible (and using Cythonization) to speed up these methods.
Depends on #33257
CC: @fchapoton @orlitzky
Component: performance
Author: Travis Scrimshaw
Branch/Commit:
33a7e77
Reviewer: Michael Orlitzky
Issue created by migration from https://trac.sagemath.org/ticket/33267
The text was updated successfully, but these errors were encountered: