# SparseMatrixCSC{Float} \* Vector{SVector}

**URL:** <https://discourse.julialang.org/t/sparsematrixcsc-float-vector-svector/29984>\
**Category:** General Usage\
**Created:** [October 16, 2019, 1:59pm UTC](https://discourse.julialang.org/t/sparsematrixcsc-float-vector-svector/29984 "2019-10-16T13:59:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cortner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cortner/32/204_2.png) [@cortner](https://discourse.julialang.org/u/cortner)\
**Post date:** [October 16, 2019, 1:59pm UTC](https://discourse.julialang.org/t/sparsematrixcsc-float-vector-svector/29984/1 "2019-10-16T13:59:25Z")

</div>

Julia allows me to multiply `Matrix{Float} * Vector{SVector}` :

```julia
using StaticArrays 
A = rand(10,10)
x = rand(SVector{3, Float64}, 10)
A * x

```

but not a `SparseMatrixCSC{Float} * Vector{SVector}` :

```julia
using SparseArrays, StaticArrays 
B = sprand(10,10, 0.1)
x = rand(SVector{3, Float64}, 10)
B * x

```

I get the following error:

```julia
julia> B * x
ERROR: MethodError: no method matching one(::Type{Any})
Closest candidates are:
  one(::Type{Union{Missing, T}}) where T at missing.jl:87
  one(::BitArray{2}) at bitarray.jl:400
  one(::Missing) at missing.jl:83
  ...
Stacktrace:
 [1] one(::Type{Any}) at ./missing.jl:87
 [2] *(::SparseMatrixCSC{Float64,Int64}, ::Array{SArray{Tuple{3},Float64,1,3},1}) at /Users/ortner/gits/julia11/usr/share/julia/stdlib/v1.1/SparseArrays/src/linalg.jl:53
 [3] top-level scope at none:0

```

The relevant line numbers are

```julia
*(A::SparseMatrixCSC{TA,S}, x::StridedVector{Tx}) where {TA,S,Tx} =
    (T = promote_type(TA, Tx); mul!(similar(x, T, A.m), A, x, one(T), zero(T)))

```

So I first need to define `promote_type` for `TA = T, Tx = SVector{T}`. Then I need to define `one` for `SVector{T}`. But even then it doesn’t work because `mul!` expects numbers:

```julia
function mul!(C::StridedVecOrMat, A::SparseMatrixCSC, B::StridedVecOrMat, α::Number, β::Number)
...

```

Maybe this is typed too strictly?

Would it be worthwhile opening issues in both `StaticArrays.jl` as well as `SparseArrays` about these, or is this just too specialised?

Are there any potential problems defining `promote_type` and `one` as I envision?
