alpha = [1 2 3; 4 5 6]
alpha[:, 1] # Type is Array{Int64, 1}
alpha[:, 1:2] # Type is Array{In64, 2}
I just want to prevent the automatic type conversion, but I am having an amazingly hard time figuring out how to do this. Yeah, I could just go alpha[:, 1]''
, but I want to prevent the memory reallocation. There is vec()
for going the other direction (1xn matrix) but I can't find a function for keeping a (nx1) matrix a matrix.
Use a range of length 1 instead of just an index
Instead of simply specifying the index (
Int64
) of the desired column, specify a range (UnitRange{Int64}
) of length 1:1:1
.That will trick Julia into preserving the 2D-array type (
Array{Int64,2}
) instead of returning a vector (Array{Int64,1}
).Edit: the developers discussed this topic here (thanks to Colin for pointing me to it).