Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1×1 matrix 0 appears positive definite and cholesky doesn't fail #1209

Open
cecileane opened this issue Oct 24, 2023 · 3 comments
Open

1×1 matrix 0 appears positive definite and cholesky doesn't fail #1209

cecileane opened this issue Oct 24, 2023 · 3 comments

Comments

@cecileane
Copy link

When an MMatrix or SMatrix is of dimension 1-by-1, it is detected as being positive definite even if its entry is 0, and its cholesky decomposition does not fail. Below I'm using StaticArrays v1.6.5 and julia v1.9.2.

julia> using LinearAlgebra, StaticArrays

julia> m = MArray{Tuple{1,1}}(0.0); # 1×1 MMatrix

julia> isposdef(m) # should be false
true

julia> isposdef(cholesky(m)) # also true: cholesky didn't fail
true

julia> cholesky(m).info # 0 so it's supposedly PosDef
0

same with an SMatrix:

julia> s = SArray{Tuple{1,1}}(0.0);

julia> isposdef(s)
true

julia> isposdef(cholesky(s)) # doesn't fail
true

Things are as expected if the 1×1 matrix has a negative entry, or it it's a regular matrix:

julia> isposdef(MArray{Tuple{1,1}}(-1.0))
false

julia> isposdef([0.0;;])
false
@bstkj
Copy link

bstkj commented Nov 10, 2023

I believe this bug is fixed by JuliaLang/julia@ee3b779 (basically, a generic cholesky method is being called that does not throw an error for positive semidefinite matrices), though this has not been incorporated as of the latest stable release (1.9.3).

@jishnub
Copy link
Member

jishnub commented Jan 23, 2024

This package defines their own Cholesky implementation, which seems to still have this bug. The issue is fixed for general matrices, but not for StaticArrays.

@cecileane
Copy link
Author

Yes, thank you for this. To confirm: the bug is still here using julia v0.10.0 and StaticArrays v1.9.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants