This is a follow-up question from Sum of Multinomial Coefficients
I have thought about the meaning of the formula I mentioned and, with help, I implemented the following code:
supp[vec_] := Module[{support = {}, i},
Do[If[vec[[i]] != 0, AppendTo[support, i]], {i, 1, Length[vec]}];
support
];
calctrafo[n_, func_] := Module[{vecs, trafo = 0, i},
vecs = Tuples[Range[0, (n - 1)], n];
vecs = Select[vecs, Total[#] == (n - 1) &];
Do[trafo += (Multinomial @@ vecs[[i]])*func[supp[vecs[[i]]]], {i, 1, Length[vecs]}];
trafo
];
calctrafo[7, func]
The function supp gives me the support of the lists and func is a arbitrary function. This code works well for me, but I need the code to work for large n, n >= 100. The problem lies in the function Tuples, which crashes for n > 6. Is there a way to make this work for large n?
Tuples[Range[0,20],19]I loop through all possible Tuples. But there are approx. 19^20 Tuples and mathematica can't handle such a large number. Is there any other way? – rainer Mar 5 at 8:06allmyTuples=lazyTuples[Range@20,19];which will not actually calculate them all yet, then if you call for instanceallmyTuples[[21312312841789283727]]it will return only that one tuple, without having calculated all the others. If you want to iteraet over the tuples, the length can be found by callingLength[allmyTuples]. – jVincent Mar 5 at 9:12