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

Does anyone know how to fix this error?

using MatrixMarket
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:…

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.

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).

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.

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