# MethodError Vector{T} for input ::SparseArrays.SparseMatrixCSC{Float64, Int64}

**URL:** <https://discourse.julialang.org/t/methoderror-vector-t-for-input-sparsearrays-sparsematrixcsc-float64-int64/61600>\
**Category:** General Usage\
**Tags:** linearalgebra\
**Created:** [May 21, 2021, 6:01pm UTC](https://discourse.julialang.org/t/methoderror-vector-t-for-input-sparsearrays-sparsematrixcsc-float64-int64/61600 "2021-05-21T18:01:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@Thomas](https://discourse.julialang.org/u/Thomas)\
**Post date:** [May 21, 2021, 6:01pm UTC](https://discourse.julialang.org/t/methoderror-vector-t-for-input-sparsearrays-sparsematrixcsc-float64-int64/61600/1 "2021-05-21T18:01:15Z")

</div>

Does anyone know how to fix this error?

> using MatrixMarket  
> c=MatrixMarket.mmread(“c.mtx”)  
> Vector(c)

gives

> ERROR: MethodError: no method matching (Vector{T} where T)(::SparseArrays.SparseMatrixCSC{Float64, Int64})

where

> 80174116×1 SparseArrays.SparseMatrixCSC{Float64, Int64} with 2 stored entries:…

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [May 22, 2021, 12:57pm UTC](https://discourse.julialang.org/t/methoderror-vector-t-for-input-sparsearrays-sparsematrixcsc-float64-int64/61600/2 "2021-05-22T12:57:08Z")

</div>

Do you expect there to be a `Vector` constructor from `SparseMatrixCSC`? Do you want it to contain the storage column, or each element of the represented matrix?

If it’s the first, I think `x.colptr` does the trick.

Btw, of you write a self-contained example it’s much easier to debug. I don’t have access to your file.

---

<div class="post-metadata">

**Author:** ![Thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@Thomas](https://discourse.julialang.org/u/Thomas)\
**Post date:** [May 22, 2021, 1:11pm UTC](https://discourse.julialang.org/t/methoderror-vector-t-for-input-sparsearrays-sparsematrixcsc-float64-int64/61600/3 "2021-05-22T13:11:24Z")

</div>

Thanks for the hint. I am digging more into the documentation of Sparse Arrays. c.mtx stores a column vector that I generate from another application. After reading, `dump(c)` returns

> SparseArrays.SparseMatrixCSC{Float64, Int64}  
> m: Int64 80174116  
> n: Int64 1  
> colptr: Array{Int64}((2,)) [1, 3]  
> rowval: Array{Int64}((2,)) [25575481, 52682266]  
> nzval: Array{Float64}((2,)) [-1.0, 1.0]

I think Vector(c) should give me the vector object with sparse entry as specified in SparseMatrixCSC. My code works for when c is constructed within Julia (of different type then SparseMatrixCSC i think).

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [May 22, 2021, 1:18pm UTC](https://discourse.julialang.org/t/methoderror-vector-t-for-input-sparsearrays-sparsematrixcsc-float64-int64/61600/4 "2021-05-22T13:18:46Z")

</div>

What do you need it for? There is `vec(x)`, but that doesn’t create a real vector either (luckily, because that’s a lot of zeros). Most applications should be able to just use the `SparseMatrixCSC` directly.

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [May 22, 2021, 1:24pm UTC](https://discourse.julialang.org/t/methoderror-vector-t-for-input-sparsearrays-sparsematrixcsc-float64-int64/61600/5 "2021-05-22T13:24:13Z")

</div>

The other way to think of this is, your object represents an `n \times 1` matrix, not a vector. `Matrix(x)` works. If you want a vector, you should be using `SparseVector`, which _does_ have a constructor from `SparseMatrixCSC`
