Okay, I got some new results:

Changing permanent() slightly in matrix2.pyx:

        print "entering permanent() - m: ",m," n: ",n
        from sage.rings.arith import binomial
        for r from 1 <= r < m+1:
            lst = _choose(n, r)
            print "lst", lst
            tmp = []
            for cols in lst:
                tmp.append(self.prod_of_row_sums(cols))
            s = sum(tmp)
            # sn = (-1)^(m-r)
            if (m - r) % 2 == 0:
                sn = 1
            else:
                sn = -1
            perm = perm + sn * binomial(n-r, m-r) * s
        print "exiting permanent() - perm: ", perm

Where _choose is defined as:

def _choose(int n, int t):
    """
    Returns all possible sublists of length t from range(n)

    Based on algoritm L from Knuth's taocp part 4: 7.2.1.3 p.4

    AUTHOR:
        -- Jaap Spies (2007-10-22)
    """

    x = []
    c = range(t)
    c.append(n)
    c.append(0)
    j = 0

    while j < t:
        x.append(c[:t])
        j = 0
        while c[j]+1 == c[j+1]:
           c[j] = j
           j = j+1
        c[j] = c[j]+1

    return x
[end of _choose code]

At some point the refcount for the list elements goes FUBAR (this is
not the first occurence of this, but those scrolled off my screen):

We should get  (r=1 in this case):
entering permanent() - m:  7  n:  7
lst [[1],[2],[3],[4],[5],[6]]

But we get:

entering permanent() - m:  7  n:  7
lst [[<refcnt -2137432134 at 0x92f70ac>], [<refcnt -2137432183 at
0x92f70a0>], [<refcnt -2137464436 at 0x92f7094>], [<refcnt -2138866030
at 0x92f7088>], [4], [5], [6]]

I assume on 64 bit boxen the refcount is 64 bit, so we never see the
issue on sage.math.

So does anybody have any idea what is wrong?

Cheers,

Michael


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to