From a182ffcd4667b6f5bb1a8adacd0c39eb7d6f54f2 Mon Sep 17 00:00:00 2001 From: Tianyi Pu <912396513@qq.com> Date: Tue, 30 Jan 2024 08:18:55 +0000 Subject: [PATCH 1/3] fix #178 --- ext/FillArraysSparseArraysExt.jl | 7 +++++-- test/runtests.jl | 11 ++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ext/FillArraysSparseArraysExt.jl b/ext/FillArraysSparseArraysExt.jl index 6a82f246..fbe10f56 100644 --- a/ext/FillArraysSparseArraysExt.jl +++ b/ext/FillArraysSparseArraysExt.jl @@ -1,10 +1,11 @@ module FillArraysSparseArraysExt using SparseArrays +using SparseArrays: SparseVectorUnion import Base: convert, kron using FillArrays -using FillArrays: RectDiagonalFill, RectOrDiagonalFill, ZerosVector, ZerosMatrix, getindex_value -using LinearAlgebra +using FillArrays: RectDiagonalFill, RectOrDiagonalFill, ZerosVector, ZerosMatrix, getindex_value, AbstractFillVector, _fill_dot +import LinearAlgebra: dot, kron, I ################## ## Sparse arrays @@ -56,4 +57,6 @@ end # TODO: remove in v2.0 @deprecate kron(E1::RectDiagonalFill, E2::RectDiagonalFill) kron(sparse(E1), sparse(E2)) +dot(x::AbstractFillVector, y::SparseVectorUnion) = _fill_dot(x, y) + end # module diff --git a/test/runtests.jl b/test/runtests.jl index be4b8fec..b4d64933 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1391,9 +1391,14 @@ end @test axes(E .+ E) === axes(E) end -@testset "Issue #31" begin - @test convert(SparseMatrixCSC{Float64,Int64}, Zeros{Float64}(3, 3)) == spzeros(3, 3) - @test sparse(Zeros(4, 2)) == spzeros(4, 2) +@testset "Issues" begin + @testset "#31" begin + @test convert(SparseMatrixCSC{Float64,Int64}, Zeros{Float64}(3, 3)) == spzeros(3, 3) + @test sparse(Zeros(4, 2)) == spzeros(4, 2) + end + @testset "#178" begin + @test Zeros(10)'*spzeros(10) == 0 + end end @testset "Adjoint/Transpose/permutedims" begin From e64ae49673095e4cbe4c7c34a31f376f1b8f62d3 Mon Sep 17 00:00:00 2001 From: Tianyi Pu <912396513@qq.com> Date: Tue, 30 Jan 2024 08:28:48 +0000 Subject: [PATCH 2/3] Update FillArraysSparseArraysExt.jl --- ext/FillArraysSparseArraysExt.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/FillArraysSparseArraysExt.jl b/ext/FillArraysSparseArraysExt.jl index fbe10f56..126debfd 100644 --- a/ext/FillArraysSparseArraysExt.jl +++ b/ext/FillArraysSparseArraysExt.jl @@ -57,6 +57,7 @@ end # TODO: remove in v2.0 @deprecate kron(E1::RectDiagonalFill, E2::RectDiagonalFill) kron(sparse(E1), sparse(E2)) +# Ambiguity. see #178 dot(x::AbstractFillVector, y::SparseVectorUnion) = _fill_dot(x, y) end # module From 2bad2727843bf0f7c43e62f70ddf125bbd9e7fe9 Mon Sep 17 00:00:00 2001 From: Tianyi Pu <912396513@qq.com> Date: Tue, 30 Jan 2024 11:43:48 +0000 Subject: [PATCH 3/3] try to fix --- ext/FillArraysSparseArraysExt.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ext/FillArraysSparseArraysExt.jl b/ext/FillArraysSparseArraysExt.jl index 126debfd..caa40a8b 100644 --- a/ext/FillArraysSparseArraysExt.jl +++ b/ext/FillArraysSparseArraysExt.jl @@ -58,6 +58,11 @@ end @deprecate kron(E1::RectDiagonalFill, E2::RectDiagonalFill) kron(sparse(E1), sparse(E2)) # Ambiguity. see #178 -dot(x::AbstractFillVector, y::SparseVectorUnion) = _fill_dot(x, y) +if VERSION >= v"1.8" + dot(x::AbstractFillVector, y::SparseVectorUnion) = _fill_dot(x, y) +else + dot(x::AbstractFillVector{<:Number}, y::SparseVectorUnion{<:Number}) = _fill_dot(x, y) +end + end # module