Such that the length of the tuple and splatting is known at compile time. AFAIK spatting general vectors sometimes allocate something (at least I remember discussions here with this kind of issues)
thanks!
right now it’s not performance critical & sometimes a is a 2 element vector, sometimes it’s 5-elements etc…
But this will be very useful for me elsewhere & other users who come to this page w/ the same issue.
Does anyone have advice on a better way to name this issue? @mbauman
OK, it turns out not to be so simple bc I in my case I need broadcasting & s is a 10-by-1 vector, a is a 10-by-1 vector consisting of 2-element subvectors…
It works if I do a comprehension though…
julia> using StaticArrays
julia> f(x,y,z) = @. x = x + y + z
f (generic function with 2 methods)
julia> g(s,x::SVector{N}) where N = f(s,ntuple(i->x[i],N)...)
g (generic function with 2 methods)
julia> x = SVector{2,Vector{Float64}}(rand(3),rand(3));
julia> s = rand(3);
julia> @btime g($s,$x)
9.037 ns (0 allocations: 0 bytes)
3-element Vector{Float64}:
3.861199086034205e6
1.0012982079149153e7
9.331970140004177e6