Not worth worrying about for a demo, but this operation would be a lot faster if it were done in place using devectorized code. See https://github.com/lindahua/Devectorize.jl for some ideas.