Closed
Description
Problem Description
Check this out:
sage: %time Partitions(50,min_length=10).cardinality()
CPU times: user 1min 46s, sys: 14 ms, total: 1min 46s
Wall time: 1min 46s
158414
sage: %time number_of_partitions(50) - Partitions(50,max_length=9).cardinality()
CPU times: user 6.98 s, sys: 5 ms, total: 6.98 s
Wall time: 6.98 s
158414
Proposed Solution
As the code example shows, computing cardinality with min_length=
appears to be much slower than that with max_length=
. Hence, it'd be beneficial to convert one into the other by complementation (in the set of all partitions) as illustrated by the example.
Alternatives Considered
I believe the cardinalities in both cases can be computed via dynamic programming, but I did not check if Sage uses it wisely and why in one case it's much slower than in the other.
Additional Information
No response
Is there an existing issue for this?
- I have searched the existing issues for a bug report that matches the one I want to file, without success.