This looks like combinations with repetitions:
http://en.wikipedia.org/wiki/Combination#Number_of_combinations_with_repetition
so, in your example, the 2 in [2, 0, 0] tells you that you picked the
first element twice.

On Fri, Jun 15, 2012 at 8:35 AM, Aaron Meurer <[email protected]> wrote:
> I think that definitely should be factored out into iterables, though I
> don't know enough combinatorics to know what it should be called.
>
> Aaron Meurer
>
> On Jun 14, 2012, at 11:23 PM, Sean Vig <[email protected]> wrote:
>
> The thread on duplicated things finding there way into physics got me
> thinking about what could get replaced/moved, and I remembered one thing I
> did in implementing the angular momentum coupling/uncoupling algorithm that
> I figured should fall under something I'm not aware of. Basically, at one
> point, it iterates over all multi-indices of a given dimension and order.
> The total number of such indices is found as ``binomial(order+dimension-1,
> order)`` (basically n balls in m boxes) and the multi-indices are generated
> by _confignum_to_difflist (terrible name in general, but makes sense in the
> context of the algorithm). It works something like this:
>
> In [1]: from sympy.physics.quantum.spin import _confignum_to_difflist
>
> In [2]: order = 2
>
> In [3]: dimension = 3
>
> In [4]: for n in range(binomial(order+dimension-1, order)):
>    ...:     print _confignum_to_difflist(n, order, dimension)
>    ...:
> [0, 0, 2]
> [0, 1, 1]
> [0, 2, 0]
> [1, 0, 1]
> [1, 1, 0]
> [2, 0, 0]
>
> Ideally, there'd be some nice construct able represent symbolic sums over
> such multi-indices, the above behavior is only triggered when the given
> states are all numerical.
>
> The coupling/uncoupling stuff starts at L1671 and this function is at L2008
> in sympy/physics/quantum/spin.py. I keep looking back at the
> coupling/uncoupling algorithms, thinking "my god what a mess" and trying to
> fix it, this time being no different, so a) sorry if it looks horrendous, b)
> if you find something so egregious that it warrants fixing, let me know (or
> better submit a PR for it).
>
> Sean
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" 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?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" 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?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" 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?hl=en.

Reply via email to