JuliaStats / PDMats.jl

Uniform Interface for positive definite matrices of various structures
Other
104 stars 43 forks source link

Shouldn't isposdef return true for AbstractPDMats? #121

Closed oschulz closed 2 years ago

oschulz commented 3 years ago

Currently, we get

julia> isposdef(PDMat([1.0 0.0; 0.0 1.0]))
ERROR: MethodError: no method matching cholesky(::Hermitian{Float64,PDMat{Float64,Array{Float64,2}}}; check=false)

julia> isposdef(PDiagMat([1.0, 1.0]))
ERROR: MethodError: no method matching cholesky(::Hermitian{Float64,PDiagMat{Float64,Array{Float64,1}}}; check=false)

julia> isposdef(ScalMat(2, 3.0))
ERROR: MethodError: no method matching cholesky(::Hermitian{Float64,ScalMat{Float64}}; check=false)

Shouldn't we define

LinearAlgebra.isposdef(::AbstractPDMat) = true

since AbstractPDMats are positive definite by definition?

oschulz commented 3 years ago

I guess we'll probably want to define

LinearAlgebra.ishermitian(::AbstractPDMat) = true

as well, to do that in O(1), since the default implementation will actually test it?