The standard linalg function isposdef does not work for symmetric matrices (recent git master):
x = rand(5, 5)
x = x*x'
isposdef(x)
isposdef(Symmetric(x))
The last line fails with an error:
ERROR: MethodError: no method matching isposdef!(::Symmetric{Float64,Array{Float64,2}})
which I guess is caused by a missing definition. One workaround is to access underlying matrix directly but it is inconvenient:
isposdef(Symmetric(x).data)
I think this behavior is not correct and surprising for each user, I have not found any mention of such limitation in the documentation. There is an additional implementation for Diagonal matrices and this works fine:
isposdef(Diagonal(rand(1, 5)))
@fredrikekre Why is ishermitian(A) necessary here? You're just passing a Hermitian/Symmetric matrix, right?
For cases like this:
julia> A = complex.(rand(2, 2), rand(2, 2))
2×2 Array{Complex{Float64},2}:
0.127036+0.875987im 0.702463+0.796754im
0.631628+0.488688im 0.214832+0.825713im
julia> ishermitian(Symmetric(A))
false
@fredrikekre I see, thanks. I forgot that one can make a complex symmetric matrix.
I think the post 0.6 solution should be to store info in the Cholesky type and delay throwing. That is what we do for LU and BunchKaufman and then we could just have isposdef(F::Cholesky) = F.info == 0 and something like isposdef(A::AbstractMatrix) = ishermitian(A) && isposdef(cholfact(A)).
Most helpful comment
I think the post 0.6 solution should be to store
infoin theCholeskytype and delay throwing. That is what we do forLUandBunchKaufmanand then we could just haveisposdef(F::Cholesky) = F.info == 0and something likeisposdef(A::AbstractMatrix) = ishermitian(A) && isposdef(cholfact(A)).