2
$\begingroup$

I need to create a table indexed form a list. e.g.:

list={{i, 3}, {j, 4}};

would give the table

Table[..., {i,3}, {j,4}];

Of course I need this because I have to create some complicated table inside a function where I do not know the number of indices i, j, k, ..., but I have a list of that with their extrema. How can I achieve this?

Edit

I know I have been a bit obscure, I'm only trying to write a function generating all possible plane partitions of a given number. Do you have any suggestions?

$\endgroup$
  • 1
    $\begingroup$ Could you please elaborate on what you are trying to do? It would be useful if you could show a sample input and output. $\endgroup$ – e.doroskevic Jun 20 '16 at 22:49
  • 2
    $\begingroup$ Table[{i, j} , Evaluate[## & @@ list]]? $\endgroup$ – kglr Jun 20 '16 at 22:50
  • $\begingroup$ Have you seen the MathWorld notebook? $\endgroup$ – J. M. will be back soon Jun 20 '16 at 23:11
  • $\begingroup$ @J.M. I saw that nb but I didn't understand how to get that table just after the graph... I get an error like: Combinatorica Graph and Permutations functionality has been \ superseded by preloaded functionality. The package now being loaded \ may conflict with this. Please see the Compatibility Guide for \ details. $\endgroup$ – MaPo Jun 20 '16 at 23:14
  • 1
    $\begingroup$ Table[something,Evaluate[Sequence@@t]] $\endgroup$ – Wjx Jun 21 '16 at 0:07
3
$\begingroup$

A not-that-fast solution could be easily written:

f[dat_, part_] := 
  Outer[SortBy[#, -# &] & /@ Internal`PartitionRagged[##] &, 
   Permutations@dat, part, 1, 1];
PlanePartitions[n_] := 
 Module[{pt = IntegerPartitions@n, inp}, 
  inp = {#, IntegerPartitions@Length@#} & /@ pt; 
  Select[Flatten[f @@@ inp, 2], 
   With[{t = PadRight[#, {n, n}]}, 
     SortBy[#, -# &] & /@ Transpose@t == Transpose@t] &]]

It will partition the number, then choose multiple split method, create results and select what we want~

But efficiency is the great drawback of this method. Time sequence is shown below, and as you can see, when the number gets big, the running time canget quite nasty.

{0.000275014, 0.000390956, 0.000966028, 0.00265924, 0.00912323,
0.0196355, 0.0552106, 0.15279, 0.449698, 1.15818, 3.15831, 8.46536,
26.8032}

If I find a better solution, I'll update~

Hope this can help you~

$\endgroup$
  • $\begingroup$ The time consumed is about 2.5 times longer when n is increased by 1. $\endgroup$ – Wjx Jun 21 '16 at 0:52
  • $\begingroup$ Also you can plot them using ArrayPlot/@PlanePartitions@9 $\endgroup$ – Wjx Jun 21 '16 at 3:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.