sympy/sympy — pull request #2694 by smichr (2013-12-19 04:15:49+00:00)
Title: fix generate_bell with recursive algorithm

This fixes the generate_bell routine. A future implementation could use a non-recursive form. Ideally the Trotter-Johnson could be used but that appears to be broken not returning inversions of elements that are next to each other:

```
>>> p=Permutation(range(7))
>>> p.next_trotterjohnson().array_form;p+=1
[0, 1, 2, 3, 4, 6, 5]
>>> p.next_trotterjohnson().array_form;p+=1
[0, 1, 2, 3, 6, 4, 5]
>>> p.next_trotterjohnson().array_form;p+=1
[0, 1, 2, 5, 3, 4, 6]
```

In that last permutation, the 3,6 siwtch but then the 6 and 5 are also switched.