Skip to content

Commit 1102683

Browse files
authored
Merge pull request #117 from mossr/master
PDMat: convert Matrix type to the same Cholesky type
2 parents 6d1caa7 + f0c6aea commit 1102683

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/pdmat.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ struct PDMat{T<:Real,S<:AbstractMatrix} <: AbstractPDMat{T}
99
PDMat{T,S}(d::Int,m::AbstractMatrix{T},c::CholType{T,S}) where {T,S} = new{T,S}(d,m,c)
1010
end
1111

12-
function PDMat(mat::AbstractMatrix,chol::CholType)
12+
function PDMat(mat::AbstractMatrix,chol::CholType{T,S}) where {T,S}
1313
d = size(mat, 1)
1414
size(chol, 1) == d ||
1515
throw(DimensionMismatch("Dimensions of mat and chol are inconsistent."))
16-
PDMat{eltype(mat),typeof(mat)}(d, mat, chol)
16+
PDMat{T,S}(d, convert(S, mat), chol)
1717
end
1818

1919
PDMat(mat::Matrix) = PDMat(mat, cholesky(mat))

test/pdmtypes.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,5 @@ a = PDMat([1 0.5; 0.5 1])
4848
@inferred whiten(a, ones(2))
4949
@inferred unwhiten(a, ones(2))
5050

51+
# convert Matrix type to the same Cholesky type (#117)
52+
@test PDMat([1 0; 0 1]) == [1.0 0.0; 0.0 1.0]

0 commit comments

Comments
 (0)