I have a function returning a (fixed and known-length) array for some input:
function bitlevels(n, x)
l = reverse(digits(x, base=2))
[repeat([0], n - length(l)); l]
end
When broadcasting this function to a vector (e.g., bitlevels.(5, [0, 2, 3, 5])
), I get an Array of Arrays instead of a Matrix.
I’d assume this has performance penalties due to pointer indirection, when those arrays become large. How can I change my implementation, so that a Matrix instead of an Array of Arrays is returned?
(Or is this actually a bad idea and I’m better off working on Arrays of Arrays?)