On 21/02/2019 9:59, Jori Mäntysalo (TAU) wrote:
On Tue, 19 Feb 2019, TB wrote:

There is the cardinality method of IntegerVectors. Note that the default for
min_part is 0.

So this could be used for...?

I do not know the area. I was just playing with numbers (original question
was "In how many ways you can arrange a queue of 9 men and 7 women such
that no two women are next to each other?"), and noticed that
.cardinality() in sage/combinat/partition.py even has algorithm-parameter.
So I think there might be existing code just waiting for interface.

A composition can be thought as an integer vector with only natural numbers. So theoretically Compositions() could have been implemented using IntegerVectors(), which has a (buggy?) cardinality method that does use binomials coefficients, and not just naive brute force. For example:

sage: Compositions(10, length=6).cardinality()
126
sage: IntegerVectors(10, length=6, min_part=1).cardinality()
126

I do not know the exact reasons/history of implementation of combinatorial objects in Sage. Some of those are now using IntegerListsLex for enumeration with naive counting, as you noticed.

Regards,
TB

--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to