I’ve seen many examples that generate a two dimensional array (matrix) from a function of two arguments against two vectors:
x = 1:100
y = 1:100
f(x,y) = x*y
z = @. f(x', y)
I want to do something analagous, but five-dimensional:
v = 1:100
w = 1:100
x = 1:100
y = 1:100
z = 1:100
g(v,w,x,y,z) = v*w*x*y*z
u = @. g(reshape(v,(1,1,1,1,100)),reshape(w,(1,1,1,100,1)),reshape(x,(1,1,100,1,1)),reshape(y,(1,100,1,1,1,1)),reshape(z,(100,1,1,1,1)))
But when I try to do the latter I get
ERROR: DimensionMismatch: arrays could not be broadcast to a common size; got a dimension with lengths 100 and 5
(I also tried nonsense like v''''
but that just results in v
again because it limits itself to 2 dimensions)
Is there a good way to do what I’m trying to do?