Deinterleave data

You don’t need this check, because reshape already checks this. That’s why I suggested simply:

deinterleave(a, nc, ns) = transpose(reshape(a, nc, ns))

Or, if you want to add some types (which don’t help performance at all! … they are effectively just a form of documentation):

deinterleave(a::AbstractVector, nc::Integer, ns::Integer) = transpose(reshape(a, Int(nc), Int(ns)))

(I added the Int conversions because reshape requires Int arguments.) Even simpler, you could do:

deinterleave(a::AbstractVector, nc::Integer) = transpose(reshape(a, Int(nc), :))

since reshape will calculate the second dimension for you.