Ticket #630 (closed enhancement: fixed)

Opened 3 years ago

Last modified 17 months ago

[with patch] mhansen's big combinatorics update

Reported by: mhansen Owned by: mhansen
Priority: major Milestone: sage-2.8.5
Component: combinatorics Keywords:
Cc: sage-combinat Author(s):
Report Upstream: Reviewer(s):
Merged in: Work issues:

Description

Includes C interface for symmetrica.

Attachments

combinat.hg Download (92.7 KB) - added by mhansen 3 years ago.
tut.patch Download (0.8 KB) - added by mhansen 3 years ago.
partitions.patch Download (1.2 KB) - added by mhansen 3 years ago.
combinat.patch Download (36.8 KB) - added by mhansen 3 years ago.
combinat2.patch Download (0.7 KB) - added by mhansen 3 years ago.

Change History

Changed 3 years ago by mhansen

Changed 3 years ago by mhansen

  • summary changed from mhansen's big combinatorics update to [with patch] mhansen's big combinatorics update

Bundle attached.

Changed 3 years ago by mhansen

  • milestone changed from sage-2.9 to sage-2.8.4.3

Changed 3 years ago by mhansen

Changed 3 years ago by was

NOTE:

The old partitions function (copied below), was vastly faster than the new Partitions(n).list() for n=30...

def partitions(n):
    r"""
    Generator of all the partitions of the integer $n$.

    INPUT:
        n -- int

    To compute the number of partitions of $n$ use
    \code{number_of_partitions(n)}.

    EXAMPLES:
        sage.: partitions(3)
        <generator object at 0xab3b3eac>
        sage: list(partitions(3))
        [(1, 1, 1), (1, 2), (3,)]


    AUTHOR: Adapted from David Eppstein, Jan Van lent, George Yoshida;
    Python Cookbook 2, Recipe 19.16.
    """
    n == ZZ(n)
    # base case of the recursion: zero is the sum of the empty tuple
    if n == 0:
        yield ( )
        return
    # modify the partitions of n-1 to form the partitions of n
    for p in partitions(n-1):
        yield (1,) + p
        if p and (len(p) < 2 or p[1] > p[0]):
            yield (p[0] + 1,) + p[1:]
sage: time v=list(partitions(30))
CPU times: user 0.03 s, sys: 0.00 s, total: 0.03 s


--
[15:59] <william_stein> mhansen -- interestingly the *old* partitions function is way faster than your new one...??
[15:59] <william_stein> old:
[15:59] <william_stein> sage: time v=list(partitions(30))
[15:59] <william_stein> CPU times: user 0.03 s, sys: 0.00 s, total: 0.03 s
[15:59] <millster> aha
[15:59] <william_stein> new:
[15:59] <william_stein> sage: time v=Partitions(30).list()
[15:59] <william_stein> CPU times: user 0.46 s, sys: 0.02 s, total: 0.48 s

Changed 3 years ago by was

  • status changed from new to closed
  • resolution set to fixed

Changed 3 years ago by mhansen

Changed 3 years ago by mhansen

Changed 3 years ago by mhansen

Changed 17 months ago by nthiery

  • cc sage-combinat added
Note: See TracTickets for help on using tickets.