MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: k-permutations enumeration

  • To: mathgroup at smc.vnet.net
  • Subject: [mg116419] Re: k-permutations enumeration
  • From: "Mr. Wizard" <gleam at flashmail.com>
  • Date: Mon, 14 Feb 2011 04:27:40 -0500 (EST)

>Hi.  Just an idea. This is the same algorithm as given by others, 
>just re-worded
>
>fx[v_, n_] := Module[
>    {t},
>    t = Normal[Series[E^x, {x, 0, Max[v]}]];
>    (* Use what is already calculated *)
>    t = Product[Take[t,v[[j]] + 1], {j, Length[v]}];
>    Coefficient[n!*t, x, n]
>]
>
>fx[{4,5,8,3},15]//Timing
>
>{0.000753,187957770}
>
>= = =
>Dana DeLouis
>Mac Pro, V8=

I prefer this aesthetic, and it appears to be as quick:

kP = Coefficient[#2! \!\(
\*UnderoverscriptBox[\(\[Product]\), \(n\), \(#\)]\(
\*UnderoverscriptBox[\(\[Sum]\), \(r = 0\), \(n\)]
\*FractionBox[
SuperscriptBox[\(\[FormalX]\), \(r\)], \(r!\)]\)\), \[FormalX], #2] &


Paul 




  • Prev by Date: Re: new Graph function + combinatorica: various problems
  • Next by Date: Re: Another point about Mathematica 8.0
  • Previous by thread: Re: k-permutations enumeration
  • Next by thread: Re: k-permutations enumeration