Skip to content

Commit

Permalink
Merge pull request #208 from ReactiveBayes/fix-207
Browse files Browse the repository at this point in the history
Add support for `Diagonal` covariance matrices
  • Loading branch information
Nimrais authored Sep 16, 2024
2 parents da9bb3a + 2934df2 commit c0fa8ad
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/distributions/normal_family/mv_normal_mean_covariance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ end

function BayesBase.prod(
::PreserveTypeProd{Distribution},
left::MvNormalMeanCovariance{T1},
right::MvNormalMeanCovariance{T2}
left::MvNormalMeanCovariance{T1, <:AbstractVector, <:Matrix},
right::MvNormalMeanCovariance{T2, <:AbstractVector, <:Matrix}
) where {T1 <: LinearAlgebra.BlasFloat, T2 <: LinearAlgebra.BlasFloat}
xi, W = weightedmean_precision(left)

Expand Down
4 changes: 2 additions & 2 deletions src/distributions/normal_family/mv_normal_mean_precision.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ end

function BayesBase.prod(
::PreserveTypeProd{Distribution},
left::MvNormalMeanPrecision{T1},
right::MvNormalMeanPrecision{T2}
left::MvNormalMeanPrecision{T1, <:AbstractVector, <:Matrix},
right::MvNormalMeanPrecision{T2, <:AbstractVector, <:Matrix}
) where {T1 <: LinearAlgebra.BlasFloat, T2 <: LinearAlgebra.BlasFloat}
W = precision(left) + precision(right)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ end
Σ = diagm([1.0, 2.0, 3.0])
dist = MvNormalMeanCovariance(μ, Σ)

@test prod(strategy, dist, dist)
MvNormalWeightedMeanPrecision([2.0, 2.0, 2.0], diagm([2.0, 1.0, 2 / 3]))

μ = [1.0, 2.0, 3.0]
Σ = Diagonal([1.0, 2.0, 3.0])
dist = MvNormalMeanCovariance(μ, Σ)

@test prod(strategy, dist, dist)
MvNormalWeightedMeanPrecision([2.0, 2.0, 2.0], diagm([2.0, 1.0, 2 / 3]))
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ end
Λ = diagm(1 ./ [1.0, 2.0, 3.0])
dist = MvNormalMeanPrecision(μ, Λ)

@test prod(strategy, dist, dist)
MvNormalWeightedMeanPrecision([2.0, 2.0, 2.0], diagm([2.0, 1.0, 2 / 3]))

μ = [1.0, 2.0, 3.0]
Λ = Diagonal(1 ./ [1.0, 2.0, 3.0])
dist = MvNormalMeanPrecision(μ, Λ)

@test prod(strategy, dist, dist)
MvNormalWeightedMeanPrecision([2.0, 2.0, 2.0], diagm([2.0, 1.0, 2 / 3]))
end
Expand Down

0 comments on commit c0fa8ad

Please sign in to comment.