I have a 1-D vector of size of (nm, 1), i.e., length=nm. I need to reshape it to a n rows m cols matrix, like
1 5 9 2 6 10 3 7 11 4 8 12
, but in memory it is row-majored. So that I can access its rows efficiently.
Currently my solution is
a=collect(1:12) # say a is a length=12 Vector, the value is not important here reshaped=transpose(collect(transform(reshape(a, 4, 3))))
reshaped is a 4x3 AbstractMatrix and row-majored. Is there any former or better way to do this?
I also tried parallel assigning-based method, which is faster, but requires multithreading.