Skip to content

Commit

Permalink
PDMat: convert Matrix type to the same Cholesky type
Browse files Browse the repository at this point in the history
  • Loading branch information
mossr committed Aug 12, 2020
1 parent 00804c3 commit 987faf8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pdmat.jl
Expand Up @@ -9,11 +9,11 @@ struct PDMat{T<:Real,S<:AbstractMatrix} <: AbstractPDMat{T}
PDMat{T,S}(d::Int,m::AbstractMatrix{T},c::CholType{T,S}) where {T,S} = new{T,S}(d,m,c)
end

function PDMat(mat::AbstractMatrix,chol::CholType)
function PDMat(mat::AbstractMatrix,chol::CholType{T,S}) where {T,S}
d = size(mat, 1)
size(chol, 1) == d ||
throw(DimensionMismatch("Dimensions of mat and chol are inconsistent."))
PDMat{eltype(mat),typeof(mat)}(d, mat, chol)
PDMat{T,S}(d, convert(S, mat), chol)
end

PDMat(mat::Matrix) = PDMat(mat, cholesky(mat))
Expand Down

0 comments on commit 987faf8

Please sign in to comment.