Iterate MapThread with matrices
You can use Tuples
:
Tuples[f[{a, b, c}, {a, b, c}]]
{f[a, a], f[a, b], f[a, c], f[b, a], f[b, b], f[b, c], f[c, a], f[c, b], f[c, c]}
f @@@ Tuples[{a, b, c}, 2]
same result
Tuples[f[{a, b}, {r, s, t}, {x, y}]]
{f[a, r, x], f[a, r, y], f[a, s, x], f[a, s, y], f[a, t, x], f[a, t, y], f[b, r, x], f[b, r, y], f[b, s, x], f[b, s, y], f[b, t, x], f[b, t, y]}
f @@@ Tuples[{{a, b}, {r, s, t}, {x, y}}]
same result
p = {a, b};
p1 = {a, a, b, b};
Tuples[f[p, p1]]
{f[a, a], f[a, a], f[a, b], f[a, b], f[b, a], f[b, a], f[b, b], f[b, b]}
You could also use Tuples
as follows:
Tuples[f[a,b,c], 2]
{f[a, a], f[a, b], f[a, c], f[b, a], f[b, b], f[b, c], f[c, a], f[c, b], f[c, c]}
If f
evaluates, and you want to do this for matrices, you could do:
p = RandomInteger[1, {3, 2, 2}];
Block[{KroneckerProduct}, Tuples[KroneckerProduct @@ p, 2]] //Dimensions
{9, 4, 4}