# Fastest way to create a NxNxNxN dimensional matrix

I have a function that outputs a complex number

Func[x_,y_]:= blah blah;


I have constructed a table of all possible values of this function.

Bar = Table[Func[x,y],{x,1,N},{y,1,N}];


I do this so it can be faster accessed in the next step. I need to compute the following matrix/table of all possible values of two of these functions multiplied by each other.

result = Table[Bar[[x,z]] Bar[[y,w]], {x,1,N}, {y,1,N}, {w,1,N}, {z,1,N}];


And this actually takes quite some time, because this table would have around 150^4 entries for N=150. How can I speed this up? It currently takes around 1 hour using ParallelTable.

What is the fastest way to make a table of this size and store it to memory to be accessed in a calculation?

EDIT:

Bar has the following symmetry:

Bar[[x,y]] = Bar[[y,x]]

-
Please include a working minimal example with a reasonable choice for Func. You might be able to get some speedup with memoization. Some linear algebra manipulations might also help. –  The Toad Mar 28 '14 at 3:43
Func is already evaluated and stored in Bar so what is being done in result is a multiplication of 2 complex numbers from Bar. –  Bass Mar 28 '14 at 3:54
Ok, but still you ought to provide a representative function for Func, as it is hard to talk about "speed up" without it. If Func happens to have some sort of symmetry, it can be exploited. For example, see my answer here: mathematica.stackexchange.com/a/19801/5 Your question appears pretty similar to that one, but because of a Toeplitz symmetry, it was possible to get the result by different means. –  The Toad Mar 28 '14 at 4:03
Ah, okay. Well, I updated the post with the only symmetry of Func or Bar. –  Bass Mar 28 '14 at 4:22
Outer[] may be of assistance ... –  dwa Mar 28 '14 at 5:46