A little background first... 

I have been working on Mathics, <https://mathics.org/> a open-source 
implementation of the Wolfram Language.

Mathics relies heavily on sympy.  

For a little while I have been working on ensuring that Steve Skiena's 
Combinatorica  
<https://www.abebooks.com/servlet/BookDetailsPL?bi=30794099489&searchurl=isbn%3D0201509431%26sortby%3D17&cm_sp=snippet-_-srp1-_-title1>
 works 
on Mathics. In doing this, I was looking for a sympy equivalent to 
PartitionsP[]  <https://reference.wolfram.com/language/ref/PartitionsP.html>
. 

I couldn't find anything so initially I was generating all of the 
partitions using sympy.utilities.iterables.partitions and then taking the 
length.

This is horribly inefficent. Therefore I thought, I'd use the algorition in 
Skiena's book which makes use of Euler's recurrence for the number of 
partitions.

It took a little bit of tweaking to get it to be reasonably efficient in 
Python. The current impelemtation  is here 
<https://github.com/mathics/Mathics/blob/master/mathics/builtin/combinatorial.py#L105-L136>
.

This might be of interest and use in sympy as well,  so I'd like to mention 
it here. 

And if there is already such a routine in sympy, I'd would be grateful to 
know about. 

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/86983b10-976c-4862-b959-367cd3772a4dn%40googlegroups.com.

Reply via email to