JuliaArrays / JuliaArrays/StaticArrays.jl
cholesky() behaves differently with static matrices
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 844
- Forks
- 159
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 3
Description
Below I create identical non-Hermitian matrices of types Matrix and SMatrix, then call cholesky() with check=false, i.e. don't throw errors.
using LinearAlgebra, StaticArrays
mat = randn(10, 10)
v = rand(10)
mat -= v * v'
smat = SMatrix{10, 10, Float64, 100}(mat)
using LinearAlgebra, StaticArrays
mat = randn(10, 10)
v = rand(10)
mat -= v * v'
smat = SMatrix{10, 10, Float64, 100}(mat)
display(issuccess(cholesky(mat; check=false))) # No error
display(issuccess(StaticArrays._cholesky(Size(smat), smat, false))) # No error
display(issuccess(cholesky(smat; check=false))) # Error
The Base implementation throws no error, as expected. However, the StaticArrays implementation throws a PosDefException error.
There is an issue with line 4 of src/cholesky.jl. I believe it should be:
!check || ishermitian(A) || non_hermitian_error()
The penultimate line of my script suggests this will work. However, there should probably be a test case or two to confirm.
I would submit a PR request, but I haven't yet started building and developing Julia and the standard library locally yet, and don't think I'm ready to start quite yet.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read src/cholesky.jl at line 4 and compare the StaticArrays behavior with Base cholesky when check=false. Add regression tests covering equivalent Matrix and SMatrix inputs, then confirm both calls have matching success behavior without an unexpected PosDefException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100