How to broadcast for 3d-array?

You might be interested in Please read: make it easier to help you,
which shows how to use triple back-quotes to format code.

I want the element specified by [i,j,k] in the three-dimensional array to be the value when the i,j,kth element of each argument is assigned to the function.

This is something that can be done neatly with comprehensions
rather than broadcasting:

julia> v = [0.1, 0.2, 0.3, 0.4]

julia> func(a, b, c) = sin(a + b + c)

julia> [func(a, b, c) for a in v, b in v, c in v]
4×4×4 Array{Float64, 3}:
[:, :, 1] =
 0.29552   0.389418  0.479426  0.564642
 0.389418  0.479426  0.564642  0.644218
 0.479426  0.564642  0.644218  0.717356
 0.564642  0.644218  0.717356  0.783327

[:, :, 2] =
 0.389418  0.479426  0.564642  0.644218
 0.479426  0.564642  0.644218  0.717356
 0.564642  0.644218  0.717356  0.783327
 0.644218  0.717356  0.783327  0.841471

[:, :, 3] =
 0.479426  0.564642  0.644218  0.717356
 0.564642  0.644218  0.717356  0.783327
 0.644218  0.717356  0.783327  0.841471
 0.717356  0.783327  0.841471  0.891207

[:, :, 4] =
 0.564642  0.644218  0.717356  0.783327
 0.644218  0.717356  0.783327  0.841471
 0.717356  0.783327  0.841471  0.891207
 0.783327  0.841471  0.891207  0.932039
4 Likes