Sparse matrix slicing

I have a doubt regarding slicing sparse matrices. For a n x m sparse matrix (for example A = sparse([1; 2; 3], 1:3, 1.0, 18, 3)), when slicing the first row A[1,:] the result is a sparse vector, but instead of a row vector it is a column vector. For me this was an unexpected behavior, is it how it is supposed to be? Or am I overseeing something?

In Julia when you slice a matrix you always get vectors:

julia> A = randn(2,2); size(A[:,1]), size(A[1,:])
((2,), (2,))

there was quite some discussion about this!

1 Like