Status: Valid
Owner: ----
Labels: Type-Defect Priority-Medium Cache

New issue 3205 by [email protected]: Apply proper caching for the Bell incomplete polynomials (of the second kind).
http://code.google.com/p/sympy/issues/detail?id=3205

Bell incomplete polynomials [2], [3] are implemented in [1] as a method `_bell_incomplete_poly` of the class `bell(Function)`

This function is recursive.

1. First problem

Now this function is cached partially , since the method "__new__" of base class "Function" is wrapped by @cacheit.

But this common wrapper cached the whole list of arguments.

X = symbols("x:101"); Y = symbols("y:101");
bell(100, 3, X)
2 sec
bell(100, 3, X)
0 sec
bell(100, 3, Y)
Again 2 sec

It is needed that regardless of X and Y arguments, internal coefficients of bell(100, 3, ...) themselves would be cached.

2. Second problem.

As this function is recursive then for e.g. bell(500, 3,...) the stack will overflow, if the cache is empty initially.

To avoid this the enveloping from recursive to plane circle must be used.

For ordinary recursion poly and numbers the "@recurrence_memo" is used, but Bell incomplete poly has 2D recursion, so either "@assoc_recurrence_memo" must be used or another special method.

Notes:

Possibly, the algorithm
May be the lower level seems to be a perspective direction (for this recursive method), with some internal structure.

2-d kind Bell polynomials, as yo can see, have property that the "order" of monomials (if we weight-ed the x_1, x_2 variables) are the same $j_1+2j_2+3j_2+\dotsb=n$. So the structure is sparse. But may be exists another combinatorial method


[1] sympy/functions/combinatorial/numbers.py
[2] http://en.wikipedia.org/wiki/Bell_polynomials
[3] http://mathworld.wolfram.com/BellPolynomial.html

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to