Skip to content

Commit

Permalink
Add support for LinearAlgebra.I fixes #784 (#785)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielgellner authored and kleinschmidt committed Oct 8, 2018
1 parent 7a756c5 commit 8bdcda6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/multivariate/mvnormal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,10 @@ function MvNormal(μ::Vector{T}, σ::Real) where T<:Real
R = Base.promote_eltype(μ, σ)
MvNormal(convert(AbstractArray{R}, μ), R(σ))
end

function MvNormal::Vector{T}, σ::UniformScaling{S}) where {T<:Real,S<:Real}
R = Base.promote_eltype(μ, σ.λ)
MvNormal(convert(AbstractArray{R}, μ), R.λ))
end
MvNormal::Matrix{T}) where {T<:Real} = MvNormal(PDMat(Σ))
MvNormal::Vector{T}) where {T<:Real} = MvNormal(PDiagMat(abs2.(σ)))
MvNormal(d::Int, σ::Real) = MvNormal(ScalMat(d, abs2(σ)))
Expand Down
3 changes: 3 additions & 0 deletions test/mvnormal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ d = MvNormalCanon(Array{Float32}(mu), Array{Float32}(h), PDMat(Array{Float32}(J)
@test typeof(convert(MvNormalCanon{Float64}, d)) == typeof(MvNormalCanon(mu, h, PDMat(J)))
@test typeof(convert(MvNormalCanon{Float64}, d.μ, d.h, d.J)) == typeof(MvNormalCanon(mu, h, PDMat(J)))

@test typeof(MvNormal(mu, I)) == typeof(MvNormal(mu, 1))
@test typeof(MvNormal(mu, 3 * I)) == typeof(MvNormal(mu, 3))
@test typeof(MvNormal(mu, 0.1f0 * I)) == typeof(MvNormal(mu, 0.1))
##### MLE

# a slow but safe way to implement MLE for verification
Expand Down

0 comments on commit 8bdcda6

Please sign in to comment.