[sage-devel] Re: Multiplicative partitions of integers in python

2008-01-23 Thread Brian Granger
Here is a brute force version. I simply compute the divisors and then try multiplying size of them together. If the result is the original number, I keep it. For the small values of n and size that I deal with this is fast enough, but it would be nice to have something that scales well (algorit

[sage-devel] Re: Multiplicative partitions of integers in python

2008-01-23 Thread Brian Granger
> Well, if what you mean by factor tree is something like > http://thesaurus.maths.org/mmkb/media/png/FactorTree.png , then I think > what Brian is asking for a bit more complicated. If I understand > correctly, he's asking for the set of all the sets of numbers (prime or > composite) whose produ

[sage-devel] Re: Multiplicative partitions of integers in python

2008-01-23 Thread Brian Granger
> Quick important question: How big is the positive integer n? > I.e., is factoring integers an important difficulty? In what I am doing n is the number of processors an array is distributed over. Thus, n scales with the number of dollars a user has spend on their cluster :) This will tend to k

[sage-devel] Re: Multiplicative partitions of integers in python

2008-01-23 Thread Brian Granger
> Sorry, I missed the post where you clarified that you weren't just > looking for factor pairs. There's got to be a way to extend this idea > to make it more arbitrary, but I haven't figured it out yet. At least > we know there's going to be an upper bound on the number of elements you > have i

[sage-devel] Re: Multiplicative partitions of integers in python

2008-01-23 Thread Jacob Mitchell
John Cremona wrote: > Jacob, are you re-inventing factr trees by any chance? (Try googling > "factor tree" to see what they are). > Well, if what you mean by factor tree is something like http://thesaurus.maths.org/mmkb/media/png/FactorTree.png , then I think what Brian is asking for a bit m

[sage-devel] Re: Multiplicative partitions of integers in python

2008-01-23 Thread boothby
On Wed, 23 Jan 2008, Jacob Mitchell wrote: > > > > Jacob Mitchell wrote: >> >> John Cremona wrote: >> >>> Is a "multiplcative partition" just a factorization? >>> >>> How about this: >>> >>> sage: def mp(n): >>> : return [(d,n//d) for d in n.divisors()] >>> : >>> sage: mp(12) >>> [

[sage-devel] Re: Multiplicative partitions of integers in python

2008-01-23 Thread John Cremona
Jacob, are you re-inventing factr trees by any chance? (Try googling "factor tree" to see what they are). John On 23/01/2008, Jacob Mitchell <[EMAIL PROTECTED]> wrote: > > > > Jacob Mitchell wrote: > > > > John Cremona wrote: > > > >> Is a "multiplcative partition" just a factorization? > >> >

[sage-devel] Re: Multiplicative partitions of integers in python

2008-01-23 Thread Jacob Mitchell
Jacob Mitchell wrote: > > John Cremona wrote: > >> Is a "multiplcative partition" just a factorization? >> >> 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)] >> >> where

[sage-devel] Re: Multiplicative partitions of integers in python

2008-01-23 Thread Mike Hansen
Sorry to reply to myself, but I just realized that I haven't done support for duplicates in OrderedSetPartitions so ignore my previous post :) --Mike On Jan 23, 2008 11:47 AM, Mike Hansen <[EMAIL PROTECTED]> wrote: > > I have a simple function that (like your example) can compute things > > for

[sage-devel] Re: Multiplicative partitions of integers in python

2008-01-23 Thread Mike Hansen
> 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. Here's an example of how you can do it in Sage: sage: a = factor(2*3*3*5*7*13);a 2 * 3^2 * 5 * 7 * 13 sage: b = sum([ [f]*mult for f,mult in a],

[sage-devel] Re: Multiplicative partitions of integers in python

2008-01-23 Thread Jacob Mitchell
John Cremona wrote: > Is a "multiplcative partition" just a factorization? > > 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)] > > where of course you could eliminate the cases d=

[sage-devel] Re: Multiplicative partitions of integers in python

2008-01-23 Thread John Cremona
The I think that the keywords you need are "factor tree" or "factorization tree". John On 23/01/2008, Brian Granger <[EMAIL PROTECTED]> wrote: > > On Jan 23, 2008 11:52 AM, John Cremona <[EMAIL PROTECTED]> wrote: > > > > Is a "multiplcative partition" just a factorization? > > Yep > > > How abou

[sage-devel] Re: Multiplicative partitions of integers in python

2008-01-23 Thread Brian Granger
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)] T

[sage-devel] Re: Multiplicative partitions of integers in python

2008-01-23 Thread William Stein
On Jan 23, 2008 10:33 AM, 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) Quick important que

[sage-devel] Re: Multiplicative partitions of integers in python

2008-01-23 Thread John Cremona
Is a "multiplcative partition" just a factorization? 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)] where of course you could eliminate the cases d=1, d=n and so on. John On 23/01/2008, B