How to transpose a 3d array?

You don’t want to broadcast the call to permutedims here, you just need to call the function directly:

julia> x = reshape(1:12, (2, 3, 2))
2×3×2 reshape(::UnitRange{Int64}, 2, 3, 2) with eltype Int64:
[:, :, 1] =
 1  3  5
 2  4  6

[:, :, 2] =
 7   9  11
 8  10  12

julia> permutedims(x, (2, 1, 3))
3×2×2 Array{Int64, 3}:
[:, :, 1] =
 1  2
 3  4
 5  6

[:, :, 2] =
  7   8
  9  10
 11  12
2 Likes