Skip to content

Commit 1bef8f7

Browse files
committed
Add *(::woodburyPDMat, ::Diagonal)
1 parent f582184 commit 1bef8f7

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/woodbury_pd_mat.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,6 @@ end
8888
# NOTE: the parameterisation to scale up the Woodbury matrix is not unique. Here we
8989
# implement one way to scale it.
9090
*(a::WoodburyPDMat, c::Real) = WoodburyPDMat(a.A, a.D * c, a.S * c)
91+
*(c::Real, a::WoodburyPDMat) = a * c
92+
*(a::WoodburyPDMat, c::Diagonal{T}) where {T<:Real} = WoodburyPDMat(sqrt(c) * a.A, a.D, a.S * c)
93+
*(c::Diagonal{T}, a::WoodburyPDMat) where {T<:Real} = a * c

test/woodbury_pd_mat.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
c = 2.0
4444
@test c * W == W * c
4545
@test c * W_dense c * W atol=1e-6
46+
47+
c = Diagonal(2.0 * ones(4))
48+
@test c * W == W * c
49+
@test c * W_dense c * W_dense atol=1e-6
4650
end
4751

4852
@testset "MvNormal logpdf" begin

0 commit comments

Comments
 (0)