JuliaArrays / JuliaArrays/StaticArrays.jl

In-place `cholesky` fails for `Hermitian` with a non-Hermitian parent

Open
#1,173 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

julia> M = @MMatrix [30 1; 2 30]
2×2 MMatrix{2, 2, Int64, 4} with indices SOneTo(2)×SOneTo(2):
 30   1
  2  30

julia> isposdef(Hermitian(Matrix(M)))
true

julia> cholesky!(Hermitian(M))
ERROR: PosDefException: matrix is not Hermitian; Cholesky factorization failed.
Stacktrace:
 [1] non_hermitian_error()
   @ StaticArrays ~/Dropbox/JuliaPackages/StaticArrays.jl/src/cholesky.jl:2
 [2] #cholesky#532
   @ ~/Dropbox/JuliaPackages/StaticArrays.jl/src/cholesky.jl:4 [inlined]
 [3] cholesky
   @ ~/Dropbox/JuliaPackages/StaticArrays.jl/src/cholesky.jl:3 [inlined]
 [4] _chol!
   @ ~/Dropbox/JuliaPackages/StaticArrays.jl/src/cholesky.jl:11 [inlined]
 [5] cholesky!(A::Hermitian{Int64, MMatrix{2, 2, Int64, 4}}, ::NoPivot; check::Bool)
   @ LinearAlgebra ~/packages/julias/julia-1.9/share/julia/stdlib/v1.9/LinearAlgebra/src/cholesky.jl:267
 [6] cholesky!
   @ ~/packages/julias/julia-1.9/share/julia/stdlib/v1.9/LinearAlgebra/src/cholesky.jl:266 [inlined]
 [7] cholesky!(A::Hermitian{Int64, MMatrix{2, 2, Int64, 4}})
   @ LinearAlgebra ~/packages/julias/julia-1.9/share/julia/stdlib/v1.9/LinearAlgebra/src/cholesky.jl:266
 [8] top-level scope
   @ REPL[24]:1

This should not check if the parent is also hermitian

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

Reproduce the example with Julia and inspect src/cholesky.jl, especially the in-place cholesky! dispatch shown in the stack trace. Trace why a Hermitian wrapper around a non-Hermitian parent is rejected, then verify the example completes successfully without the erroneous parent check.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.