diff --git a/src/pdmat.jl b/src/pdmat.jl index bc09e3e..0e44780 100644 --- a/src/pdmat.jl +++ b/src/pdmat.jl @@ -42,7 +42,7 @@ Base.convert(::Type{AbstractPDMat{T}}, a::PDMat) where {T<:Real} = convert(PDMat ### Basics Base.size(a::PDMat) = (a.dim, a.dim) -Base.Matrix(a::PDMat) = copy(a.mat) +Base.Matrix(a::PDMat) = Matrix(a.mat) LinearAlgebra.diag(a::PDMat) = diag(a.mat) LinearAlgebra.cholesky(a::PDMat) = a.chol diff --git a/test/specialarrays.jl b/test/specialarrays.jl index e896d72..75468ba 100644 --- a/test/specialarrays.jl +++ b/test/specialarrays.jl @@ -28,6 +28,8 @@ using StaticArrays Y = @SMatrix rand(4, 10) for A in (PDS, D, E, C) + @test Matrix(A) isa Matrix + if !(A isa Cholesky) # `*(::Cholesky, ::SArray)` is not defined @test A * x isa SVector{4, Float64} diff --git a/test/testutils.jl b/test/testutils.jl index 96843c9..32bd5a9 100644 --- a/test/testutils.jl +++ b/test/testutils.jl @@ -98,6 +98,11 @@ function pdtest_basics(C, Cmat::Matrix, d::Int, verbose::Int) if C isa AbstractPDMat @test M === C end + + _pdt(verbose, "Matrix") + M = Matrix(C) + @test M isa Matrix + @test M == Cmat end