# Sparse matrix slicing

**URL:** <https://discourse.julialang.org/t/sparse-matrix-slicing/34263>\
**Category:** General Usage\
**Tags:** question\
**Created:** [February 6, 2020, 5:45pm UTC](https://discourse.julialang.org/t/sparse-matrix-slicing/34263 "2020-02-06T17:45:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![martincornejo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martincornejo/32/13436_2.png) [@martincornejo](https://discourse.julialang.org/u/martincornejo)\
**Post date:** [February 6, 2020, 5:45pm UTC](https://discourse.julialang.org/t/sparse-matrix-slicing/34263/1 "2020-02-06T17:45:12Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![nantonel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nantonel/32/2889_2.png) [@nantonel](https://discourse.julialang.org/u/nantonel)\
**Post date:** [February 6, 2020, 5:59pm UTC](https://discourse.julialang.org/t/sparse-matrix-slicing/34263/2 "2020-02-06T17:59:12Z")

</div>

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

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

```

there was quite some discussion about [this](https://github.com/JuliaLang/julia/issues/4774)!
