Suppose I have a 8by6by4by2by2 matrix called m. There is in total 8*6*4 2by2 matrices. I want to map a function over these 2by2 matrices. Each dimension in m contains a 2by2 matrix for some specific parameters. My example code and solution is:
m = RandomReal[{0, 1}, {8, 6, 4, 2, 2}];
m2 = Flatten[m, 2];(* 8*6*4 matrices of size 2by2*)
f[m_] := Total@Eigenvalues[m]
Map[f, m2]
However, then I cannot reconstitute the result in the original order of m.
Is there some other way to map over multidimensional matrices?
I have to reconstitute the result of map in order to first average the result over first dimension, 8 here, and then plot the 6by4 matrix in a contour plot.
Map[]:Map[f, m2, {3}]. – J. M.'s missing motivation May 23 '16 at 16:49Map,Total... . Is there any source about that. – MOON May 23 '16 at 18:09