Destructuring and broadcast

In v0.6, I used StructsOfArrays to do broadcasting with tuple output:

using StructsOfArrays

T = Float64
TV = Vector{Float64}

a = zeros(T, 10); b = copy(a)
s = StructOfArrays{NTuple{2,T}, 1, Tuple{TV, TV}}((a, b))

f(a, b) = (a + b, a * b)

s .= f.(1:10, 1:10)

A macro for the above should be simple enough. Figuring out T and TV and handling the case where a and b are not already allocated are the main challenges I can see.

2 Likes