Julia-ism for two-dimensional map?

Good point about reinterpret and v0.7. On v0.6.2, after deleting undef, Elrod’s @simd version takes 712 ns. Adding @inbounds brings the svec version within a few percent:

svec(xset, yset) = @inbounds reinterpret(Float64, 
        [ @SVector [x, y, f(x,y)]  for x in xset for y in yset ], 
        (3, length(xset)*length(yset)) ) ## 727 ns

And GunnarFarneback’s reduce-vcat version is twice as fast as my hcat one. Removing the transpose and using hcat makes it about twice fast again, surprisingly?

redh(xset, yset) = reduce(hcat, [[x, y, f(x, y)] for (y, x) in Iterators.product(yset, xset)]) ## 8.531 μs
1 Like