Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ext/FillArraysPDMatsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ module FillArraysPDMatsExt
import FillArrays
import FillArrays.LinearAlgebra
import PDMats
using FillArrays: mult_zeros, AbstractZeros
using PDMats: ScalMat

function PDMats.AbstractPDMat(a::LinearAlgebra.Diagonal{T,<:FillArrays.AbstractFill{T,1}}) where {T<:Real}
dim = size(a, 1)
return PDMats.ScalMat(dim, FillArrays.getindex_value(a.diag))
return ScalMat(dim, FillArrays.getindex_value(a.diag))
end

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)
Base.:*(a::AbstractZeros{T, 2} where T, b::ScalMat) = mult_zeros(a, b) # This is implemented in case ScalMat implements right multiplication

end # module
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2990,6 +2990,11 @@ end
@test a.dim == length(diag)
@test a.value == first(diag)
end
a = ScalMat(4, 1.)
for zero in (Zeros(4), Zeros(4,4))
@test a * zero === zero
end
@test Zeros(4,4) * a === Zeros(4,4)
end

@testset "isbanded/isdiag" begin
Expand Down
Loading