FillArrays.jl
FillArrays.jl copied to clipboard
Compatibility with SparseArrays
Hi there! I love your package, and I recently stumbled upon undefined behavior when combining it with SparseArrays. Here's the MWE:
julia> using FillArrays, SparseArrays
julia> x = Zeros(10)
10-element Zeros{Float64}
julia> y = spzeros(10)
10-element SparseVector{Float64, Int64} with 0 stored entries
julia> x'y
ERROR: MethodError: dot(::Zeros{Float64, 1, Tuple{Base.OneTo{Int64}}}, ::SparseVector{Float64, Int64}) is ambiguous. Candidates:
dot(x::AbstractVector{Tx}, y::Union{SparseVector{Ty, Ti}, SubArray{Ty, 1, <:SparseArrays.AbstractSparseMatrixCSC{Ty, Ti}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, false}, SubArray{Ty, 1, <:AbstractSparseVector{Ty, Ti}, Tuple{Base.Slice{Base.OneTo{Int64}}}, false}} where Ti) where {Tx<:Number, Ty<:Number} in SparseArrays at /home/guillaume/packages/julias/julia-1.7/share/julia/stdlib/v1.7/SparseArrays/src/sparsevector.jl:1479
dot(a::FillArrays.AbstractFill{<:Any, 1}, b::AbstractVector) in FillArrays at /home/guillaume/.julia/packages/FillArrays/5Arin/src/fillalgebra.jl:186
Possible fix, define
dot(::FillArrays.AbstractFill{Tx, 1}, ::Union{SubArray{Ty, 1, <:SparseArrays.AbstractSparseMatrixCSC{Ty, Ti}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, false} where Ti, SubArray{Ty, 1, <:AbstractSparseVector{Ty, Ti}, Tuple{Base.Slice{Base.OneTo{Int64}}}, false} where Ti, SparseVector{Ty, Ti} where Ti}) where {Tx<:Number, Ty<:Number}
Stacktrace:
[1] *(u::Adjoint{Float64, Zeros{Float64, 1, Tuple{Base.OneTo{Int64}}}}, v::SparseVector{Float64, Int64})
@ LinearAlgebra ~/packages/julias/julia-1.7/share/julia/stdlib/v1.7/LinearAlgebra/src/adjtrans.jl:291
[2] top-level scope
@ REPL[269]:1
Do you think there is an easy fix for these compatibility issues?