# Automatically convert rows of a matrix to vectors

**URL:** <https://discourse.julialang.org/t/automatically-convert-rows-of-a-matrix-to-vectors/109643>\
**Category:** General Usage\
**Tags:** arrays\
**Created:** [February 2, 2024, 9:03pm UTC](https://discourse.julialang.org/t/automatically-convert-rows-of-a-matrix-to-vectors/109643 "2024-02-02T21:03:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AliceandBob](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aliceandbob/32/50045_2.png) [@AliceandBob](https://discourse.julialang.org/u/AliceandBob)\
**Post date:** [February 2, 2024, 9:03pm UTC](https://discourse.julialang.org/t/automatically-convert-rows-of-a-matrix-to-vectors/109643/1 "2024-02-02T21:03:32Z")

</div>

![image](https://global.discourse-cdn.com/julialang/original/3X/5/8/58aab07b092d00d1f807963c66fa1119b695080f.png)  
I’ve been using Julia from v0.6 but today I found this! I am very shocked! Julia will automatically convert the rows of a matrix to vectors! I know how to circumvent this, but I don’t believe I am the only one who feels uncomfortable about this.

Here’s my version info:  
julia\> versioninfo()  
Julia Version 1.9.3  
Commit bed2cd540a (2023-08-24 14:43 UTC)  
Build Info:  
Official [https://julialang.org/](https://julialang.org/) release  
Platform Info:  
OS: Windows (x86\_64-w64-mingw32)  
CPU: 20 × 12th Gen Intel(R) Core™ i7-12700H  
WORD\_SIZE: 64  
LIBM: libopenlibm  
LLVM: libLLVM-14.0.6 (ORCJIT, alderlake)  
Threads: 14 on 20 virtual cores  
Environment:  
JULIA\_EDITOR = code  
JULIA\_NUM\_THREADS =

---

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [February 2, 2024, 9:09pm UTC](https://discourse.julialang.org/t/automatically-convert-rows-of-a-matrix-to-vectors/109643/2 "2024-02-02T21:09:01Z")

</div>

I am confused. Which of these is surprising to you?  
The first one is just usual slicing, so you lose a dimension and get back a vector. The other two use collections and so you get a Matrix as slice.  
See here for more info  
[https://docs.julialang.org/en/v1/manual/arrays/#man-array-indexing](https://docs.julialang.org/en/v1/manual/arrays/#man-array-indexing)

---

<div class="post-metadata">

**Author:** ![AliceandBob](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aliceandbob/32/50045_2.png) [@AliceandBob](https://discourse.julialang.org/u/AliceandBob)\
**Post date:** [February 2, 2024, 9:13pm UTC](https://discourse.julialang.org/t/automatically-convert-rows-of-a-matrix-to-vectors/109643/3 "2024-02-02T21:13:11Z")

</div>

Oh I see it. That makes sense to me now.

---

<div class="post-metadata">

**Author:** ![mikmoore](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikmoore/32/31109_2.png) [@mikmoore](https://discourse.julialang.org/u/mikmoore)\
**Post date:** [February 2, 2024, 9:15pm UTC](https://discourse.julialang.org/t/automatically-convert-rows-of-a-matrix-to-vectors/109643/4 "2024-02-02T21:15:05Z")

</div>

Note that many people would be quite frustrated if `A[3,3]` returned a `1x1 Matrix{ComplexF64}` rather than simply a `ComplexF64`. The slicing behavior that `A[3,:]` also “drops” a dimension to return a `Vector` rather than `Matrix` is a logical extension of this concept.

Although I suppose in absolute total generality, we could have had `A[3,3]` return an `Array{ComplexF64,0}`. But that doesn’t seem very useful. `@view` still does something like this, however, since it must return an array wrapper.
