-
Notifications
You must be signed in to change notification settings - Fork 39
Closed
Description
The following code runs into errors.
julia> using PDMats, FillArrays
julia> ScalMat(3, 1) * Zeros(3)
ERROR: MethodError: *(::ScalMat{Int64}, ::Zeros{Float64, 1, Tuple{Base.OneTo{Int64}}}) is ambiguous.
Candidates:
*(a::ScalMat, x::AbstractVector)
@ PDMats ~/.julia/packages/PDMats/cAM9h/src/scalmat.jl:43
*(a::AbstractMatrix{T}, b::FillArrays.AbstractZeros{T, 1} where T) where T
@ FillArrays ~/.julia/packages/FillArrays/lVl4c/src/fillalgebra.jl:103
Possible fix, define
*(::ScalMat{T}, ::FillArrays.AbstractZeros{T, 1} where T) where T<:RealSimilarly, the matrix multiplication also fails.
julia> ScalMat(3,1) * Zeros(3,3)
ERROR: MethodError: *(::ScalMat{Int64}, ::Zeros{Float64, 2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}) is ambiguous.
Candidates:
*(a::ScalMat, x::AbstractMatrix)
@ PDMats ~/.julia/packages/PDMats/cAM9h/src/scalmat.jl:47
*(a::AbstractMatrix, b::AbstractZeros{T, 2} where T)
@ FillArrays ~/.julia/packages/FillArrays/lVl4c/src/fillalgebra.jl:98
Possible fix, define
*(::ScalMat, ::AbstractZeros{T, 2} where T)Higher dimensional multiplication wouldn't run into this problem because there isn't a method between ScalMat and AbstractArray. Therefore, an easy fix is, as suggested, implementing two extra methods in FillArraysPDMatsExt.jl. Appending the following code to the end of FillArraysPDMatsExt.jl should work.
using FillArrays: mult_zeros, AbstractZeros
Base.:*(a::ScalMat, b::AbstractZeros{T, 1} where T) = mult_zeros(a, b)
Base.:*(a::ScalMat, b::AbstractZeros{T, 2} where T) = mult_zeros(a, b)Metadata
Metadata
Assignees
Labels
No labels