Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with SparseArrays #178

Closed
gdalle opened this issue Apr 21, 2022 · 0 comments
Closed

Compatibility with SparseArrays #178

gdalle opened this issue Apr 21, 2022 · 0 comments

Comments

@gdalle
Copy link
Contributor

gdalle commented Apr 21, 2022

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?

putianyi889 added a commit to putianyi889/FillArrays.jl that referenced this issue Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant