invenia / PDMatsExtras.jl

Extra Positive (Semi-)Definite Matricies
MIT License
8 stars 6 forks source link

`posdef(::WoodburyPDMat)` is not always correct #29

Open tpgillam opened 2 years ago

tpgillam commented 2 years ago

In the case that S has all entries being zero, which is permitted, the resulting matrix will be positive semi-definite, but only positive definite if all the following are true:

For example, this matrix is positive semi-definite, but not positive definite:

julia> A, D, S = ([1 2 3; 4 1 7]', Diagonal([1, 2]), Diagonal([0, 0, 0]))
([1 4; 2 1; 3 7], [1 0; 0 2], [0 0 0; 0 0 0; 0 0 0])

julia> x = WoodburyPDMat(A, D, S)
3×3 WoodburyPDMat{Int64, Adjoint{Int64, Matrix{Int64}}, Diagonal{Int64, Vector{Int64}}, Diagonal{Int64, Vector{Int64}}}:
 33  10   59
 10   6   20
 59  20  107

julia> isposdef(x)
true

julia> isposdef(Matrix(x))
false

(I do wonder whether there should be a ispossemidef function defined somewhere central, e.g. LinearAlgebra or maybe PDMats. since being PSD is useful, and often sufficient for many useful algorithms to apply)