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

add a cache on basis in free modules #11402

Closed
hivert opened this issue May 30, 2011 · 4 comments
Closed

add a cache on basis in free modules #11402

hivert opened this issue May 30, 2011 · 4 comments

Comments

@hivert
Copy link

hivert commented May 30, 2011

Let FM be a combinatorial free module currently creating elements using the basis is very slow because the family is recreated each time:

sage: FM = CombinatorialFreeModule(QQ, ZZ)
sage: %timeit [FM.basis()[i] for i in range(100)]
5 loops, best of 3: 44.4 ms per loop

Adding a cache to basis gives a large speedup

sage: FM = CombinatorialFreeModule(QQ, ZZ)
sage: %timeit [FM.basis()[i] for i in range(100)]
125 loops, best of 3: 3.45 ms per loop

The speedup will be even larger with Simon King optimization on cache_methods.

CC: @sagetrac-sage-combinat

Component: combinatorics

Keywords: FreeModules basis cache

Author: Florent Hivert

Reviewer: Nicolas M. Thiéry

Merged: sage-4.7.1.alpha3

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

@hivert hivert added this to the sage-4.7.1 milestone May 30, 2011
@hivert hivert self-assigned this May 30, 2011
@hivert
Copy link
Author

hivert commented May 30, 2011

comment:1

Attachment: trac_11402-free_module_basis_cache-fh.patch.gz

A pretty simple one, ready for review.

@nthiery
Copy link
Contributor

nthiery commented May 31, 2011

Reviewer: Nicolas M. Thiéry

@nthiery
Copy link
Contributor

nthiery commented May 31, 2011

comment:2

I had wanted to do that for a while. Thanks!

@jdemeyer
Copy link

jdemeyer commented Jun 8, 2011

Merged: sage-4.7.1.alpha3

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

3 participants