JuliaLang / JuliaLang/LinearAlgebra.jl
Cholesky accessors of adjoints should return views
- Dominant language
- Julia
- Stars
- 77
- Forks
- 65
- Avg merge
- 3d 23h
- Merged PRs (30d)
- 10
Description
Currently accessing the lower triangular portion of a `Cholesky` object which has been stored using its upper triangle (or vice-versa) will return a copy
https://github.com/JuliaLang/julia/blob/c887c7461b379be7e0bd918f9ffa88a92cb72a97/stdlib/LinearAlgebra/src/cholesky.jl#L342-L350
To avoid unnecessary allocations, you end up with code that looks like this:
https://github.com/JuliaStats/PDMats.jl/blob/eeec1c1bfdddb8f522952f81b3f6a3d5ec8aa7bd/src/pdmat.jl#L57-L59
The logical solution is that it should return an `Adjoint` object. However this would no longer be type-stable, since the flag is stored as a value part of the `Cholesky` struct.
Possible solutions:
a) include the flag as part of the type parameter, either directly as a symbol, or store the `factor` field as a `LowerTriangular`/`UpperTriangular`.
b) get rid of the option and only ever store it as an `UpperTriangular` matrix.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the Cholesky accessor code in stdlib/LinearAlgebra/src/cholesky.jl around lines 342-350, then compare the allocation-avoiding pattern in PDMats.jl src/pdmat.jl around lines 57-59. Evaluate the proposed representation options, with type stability and lower/upper access behavior as acceptance criteria; done means the relevant accessors return views without unnecessary copies.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100