Closed
Description
Because the @SVector
macro does not evaluate the range using the local scope, I find myself transforming code like this:
function mytransform{N}(x::SVector{N})
@SVector [x[i] * i for i=1:N]
end
into this:
function mytransform{N,T}(x::SVector{N,T})
SVector{N,T}(ntuple(i -> x[i] * i, N) ...)
end
I'm not sure if the second form is as efficient, but in either case, the first version is far easier to read.
Is there any chance that @SVector
comprehensions can be made to support local variables in the range? Or, is there some other way I should be writing this?