I want to compare matrices with element by element and find the maximum values of the matrices, like I have three 3x3 matrices
tdata = {{{1, 5, 1}, {7, 4, 2}, {2, 4, 3}}, {{2, 0, 8}, {9, 8, 2}, {2,
3, 0}}, {{2, 2, 9}, {10, 9, 5}, {9, 3, 3}}}
Then by using
MapThread[Max, tdata, 2] // MatrixForm
I can get the correct result.
{{2, 5, 9}, {10, 9, 5}, {9, 4, 3}}
However, when the matrices are complex matrices, Max function doesn't work. For example,
tdata = {{{0.323031 + 5.23687 I, 8.92856 + 1.31365 I},
{9.94387 + 3.04104 I, 8.72483 + 2.5648 I}},
{{5.96575 + 9.2521 I, 8.58461 + 2.56753 I},
{0.902715 + 3.75791 I, 4.06809 + 8.61552 I}},
{{9.36592 + 1.17263 I, 9.74628 + 2.22183 I},
{4.61866 + 4.61158 I, 9.0791 + 2.50036 I}}}
I have tried to implement a new Max function for complex matrices, but it doesn't work. Here is a demo,
complexMax[lis_] := Module[{abs = Abs[lis]}, Take[lis, Position[abs, Max[abs]][[1]]]]
Then
MapThread[complexMax, tdata, 2]
The result is like
{{complexMax[0.323031 + 5.23687 I, 5.96575 + 9.2521 I, 9.36592 + 1.17263 I],
complexMax[8.92856 + 1.31365 I, 8.58461 + 2.56753 I, 9.74628 + 2.22183 I]},
{complexMax[9.94387 + 3.04104 I, 0.902715 + 3.75791 I, 4.61866 + 4.61158 I],
complexMax[8.72483 + 2.5648 I, 4.06809 + 8.61552 I, 9.0791 + 2.50036 I]}}
Is there any idea how to solve the problem?