Julia style? Arrays/matrix vs structs

Note that you timing is not really representative since the broadcasting doesn’t seem to be very efficient, cf:

julia> function f3!(v)
           for i in eachindex(v)
               x, y, z = v[i]
               vv = v[i]
               vv.x = 2x
               vv.y = x*y
               vv.z = x*z
           end
       end
f3! (generic function with 1 method)

julia> @btime f3!($v2)
  1.023 μs (0 allocations: 0 bytes)
1 Like