--
You received this message because you are subscribed to the Google Groups "SeqFan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seqfan+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/seqfan/CANXmBjwh2508d-7rVo_B1k64_T6bmy2%3DVt-OCfwbnkyOZRf7-g%40mail.gmail.com.
My machine (desktop, 5y old but fairly capable) takes about 50s to compute A001055(13585283712000) = 4258036618 using some code rather brainlessly derived from the paper by Shamik Ghosh cited on the A001055 page. Is that "easily" enough? (I am on the fence as to whether or not it is.) I have no particular reason to think that this is anything like the optimal way to do it, but it seemed plausibly not too slow. I haven't verified the correctness of Ghosh's algorithm nor tested my own code very carefully, but it does correctly compute all the values listed on the OEIS A001055 page.
Here's the code; it uses my own little library of mathematical functions but anyone who is interested enough to try to run it at all is unlikely to have trouble finding or making implementations of the gcd and all_divisors functions (noting that all_divisors is only needed for _small_ numbers here, and trial division will be fine; this is also why I have implemented the ordinary integer partition function in the ridiculous way you can see below). My apologies in advance if the indentation gets messed up between me and the reader.
import functools, itertools
from fractions import Fraction as F
from g import gcd, all_divisors, factor_with_multiplicities
def intify(x):
if x.denominator == 1: return x.numerator
return x
def content(f):
"""GCD of all entries in f."""
c = 0
for a in f:
c = gcd(c, a)
if c == 1: return c
return c
def lam(f):
return intify(sum(F(1,d) for d in all_divisors(content(f))))
def smaller(f):
return itertools.product(*(range(a+1) for a in f))
def sub(f,g):
return tuple(a-b for (a,b) in zip(f,g))
def accumulate(a, coeff, f):
for (j,b) in enumerate(f):
a[j] += coeff*b
def p(n):
"""Number of partitions of n."""
assert(n <= 20)
return
[1,1,2,3,5,7,11,15,22,30,42,56,77,101,135,176,231,297,385,490,627][n]
# (ha ha)
@functools.cache
def mp(f):
"""Number of multiplicative partitions of a number whose prime
factorization
is product pj^f[j]; f is a tuple of nonnegative integers."""
if sum(1 for a in f if a>0) <= 1: return p(sum(f))
pf = [0 for a in f]
for g in smaller(f):
if all(a==0 for a in g): continue
accumulate(pf, intify(lam(g)*mp(sub(f,g))), g)
#print(" ", pf, g, lam(g), mp(sub(f,g)))
pf = [intify(a) for a in pf]
# pf should now be p(f) f
result = sum(pf) // sum(f)
#print(f, "->", result)
return result
def mp1(n):
return mp(tuple(r for (p,r) in factor_with_multiplicities(n)))
--
g
To view this discussion visit https://groups.google.com/d/msgid/seqfan/93d4097b-83b8-4f4d-9917-39e1aedc8c94%40pobox.com.
Still not easy enough for "easy" if you ask me.
--
You received this message because you are subscribed to the Google Groups "SeqFan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seqfan+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/seqfan/CAB%2B0_%3D%3DnSBzUQO3CBpKvpj8BXQ08Y4sUEUf9snkby3V%2BTWR_aw%40mail.gmail.com.
To view this discussion visit https://groups.google.com/d/msgid/seqfan/CAAOnSgT5bQ35kKXVJcmc8h4%2Bh4%2BS1%2BbMeTs%2B%3Dm_p9q9y3EJxfw%40mail.gmail.com.
To view this discussion visit https://groups.google.com/d/msgid/seqfan/CAAOnSgT5bQ35kKXVJcmc8h4%2Bh4%2BS1%2BbMeTs%2B%3Dm_p9q9y3EJxfw%40mail.gmail.com.
To view this discussion visit https://groups.google.com/d/msgid/seqfan/CADy-sGEt5dd6W-Qf1BBNyNOBQK05a76x0Sig7WQOXoXznRLukw%40mail.gmail.com.
To view this discussion visit https://groups.google.com/d/msgid/seqfan/CADy-sGEt5dd6W-Qf1BBNyNOBQK05a76x0Sig7WQOXoXznRLukw%40mail.gmail.com.