Matrix of Functions to Function that returns a Matrix
Perhaps this?:
mat = ConstantArray[Function[{t}, t^2], {2, 2}]
(*
{{Function[{t}, t^2], Function[{t}, t^2]},
{Function[{t}, t^2], Function[{t}, t^2]}}
*)
Block[{t},
Function @@ {{t}, mat[[All, All, 2]]}
]
(* Function[{t}, {{t^2, t^2}, {t^2, t^2}}] *)
Here is another approach. Let's create a small matrix of Function
objects to play with:
m = {{Function[{t}, Sin[t]], Function[{t}, Cos[t]]},
{Function[{t}, Sinc[t]], Function[{t}, Tan[t]]}};
Then, we can create your M
function as follows:
Clear[mm]
mm[m_][x_] := Map[#[x] &, m, {ArrayDepth[m]}]
You can see that passing an argument to mm returns a matrix-valued result:
mm[m][2]
(* Out: {{Sin[2], Cos[2]}, {Sinc[2], Tan[2]}} *)
This, of course, works for symbolic arguments as well (e.g. mm[m][e]
).
ClearAll[f]
f[mat_][t_] := Map[Through @ # @ t &] @ mat
Example:
mat = {{Cos, Sin}, {Function[t, t^2], 1 + # &}};
f[mat][t]
{{Cos[t], Sin[t]}, {t^2, 1 + t}}
f[mat][π]
{{-1, 0}, {π^2, 1 + π}}
Also
ClearAll[f2]
f2[mat_][t_] := Map[Construct[#, t] &, mat, {2}]
f2[mat][t]
{{Cos[t], Sin[t]}, {t^2, 1 + t}}