On Jan 23, 2008 11:52 AM, John Cremona <[EMAIL PROTECTED]> wrote: > > Is a "multiplcative partition" just a factorization?
Yep > How about this: > > sage: def mp(n): > ....: return [(d,n//d) for d in n.divisors()] > ....: > sage: mp(12) > [(1, 12), (2, 6), (3, 4), (4, 3), (6, 2), (12, 1)] That is basically the route that I am taking. But there is one additional complication. I need to be able to compute partitions of a given size: 12 => [(2,6),(3,4)] # for size=2 12 => [(2,2,3)] # for size=3 etc. I have a simple function that (like your example) can compute things for size=2. I am trying to figure out how to generalize to arbitrary size. Brian > where of course you could eliminate the cases d=1, d=n and so on. > > John > > > On 23/01/2008, Brian Granger <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > I am working on a parallel/distributed array library for > > python/ipython. For this library I need to be able to compute the > > multiplicative partitions of positive integers: > > > > 12 => (2,6), (3,4) > > > > A few questions about this: > > > > 1) Is there a good algorithm for computing these. I can think of > > silly ways of doing it, but I imagine there are more efficient ways. > > > > 2) Does anyone know of a implementation of such an algorithms (python, c, > > etc.) > > > > 3) Does anyone know of a BSD license compatible (please don't shoot me > > :) ) implementation. Because these distributed arrays are being > > developed as a part of ipython, it needs to be BSD. > > > > Thanks! > > > > Brian > > > > > > > > > > -- > John Cremona > > > > --~--~---------~--~----~------------~-------~--~----~ 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://www.sagemath.org -~----------~----~----~----~------~----~------~--~---