JuliaArrays / JuliaArrays/StaticArrays.jl

cholesky() behaves differently with static matrices

Open
#1,194 1 comment 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

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

  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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.