JuliaArrays / JuliaArrays/StaticArrays.jl

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

Open
#1,209 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
844
Forks
159
Avg merge
3d 21h
Merged PRs (30d)
3

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the 1×1 MArray and SArray reproductions in the issue, then compare their isposdef and cholesky behavior with the regular 1×1 matrix example. Trace the StaticArrays path involved in these operations and add or run a regression check showing that a zero entry is not positive definite and that cholesky does not report success.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.