timholy / timholy/PositiveFactorizations.jl

cholesky(Positive, ...) does not play nicely with StaticArrays.jl

Open
#32 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
40
Forks
12
PR merge metrics
No merged PRs in 30d

Description

Hey, thanks for this great library!
We recently encountered that PositiveFactorizations.jl loses type information in case if input is a StaticArray.

julia> L = @SArray rand(3, 3)
3×3 SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
 0.0501647  0.544364  0.896714
 0.243666   0.328148  0.929278
 0.755197   0.661655  0.979631

julia> A = L'L
3×3 SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
 0.632212  0.606946  1.01123
 0.606946  0.841801  1.44126
 1.01123   1.44126   2.62733

julia> inv(cholesky(A)) # Original Base function returns StaticArray
3×3 SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
  5.27106    -5.37836    0.921597
 -5.37836    25.0268   -11.6587
  0.921597  -11.6587     6.42145

julia> inv(cholesky(PositiveFactorizations.Positive, A))
3×3 Matrix{Float64}:
  5.27106    -5.37836    0.921597
 -5.37836    25.0268   -11.6587
  0.921597  -11.6587     6.42145

Not sure if it is easy to fix, but would be great to make it work with StaticArrays as well.

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 by reproducing the reported cholesky(Positive, A) behavior with the StaticArrays example, then inspect the PositiveFactorizations cholesky and inv entry points. Done means the positive-factorization path preserves the StaticArray result type like Base cholesky does, with a regression check for the shown case.

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
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.