JuliaLang / JuliaLang/LinearAlgebra.jl
Dividing diagonal by triangular matrix returns sparse matrix
- Dominant language
- Julia
- Stars
- 77
- Forks
- 65
- Avg merge
- 3d 23h
- Merged PRs (30d)
- 10
Description
Depending on what types are used, dividing a diagonal matrix by a triangular matrix returns a sparse matrix, even though the result is triangular. I think it would make a lot more sense to return a matrix with a triangular type instead.
```julia
julia> VERSION
v"1.3.0-rc1.0"
julia> n = 3;
julia> L = rand(n, n);
julia> D = rand(n);
julia> tril(L)\diagm(D)
3×3 Array{Float64,2}:
0.0666276 0.0 0.0
-0.115247 1.0267 0.0
0.0406685 -0.656616 0.507579
julia> LowerTriangular(L)\diagm(D)
3×3 Array{Float64,2}:
0.0666276 0.0 0.0
-0.115247 1.0267 0.0
0.0406685 -0.656616 0.507579
julia> tril(L)\Diagonal(D)
3×3 SparseArrays.SparseMatrixCSC{Float64,Int64} with 6 stored entries:
[1, 1] = 0.0666276
[2, 1] = -0.115247
[3, 1] = 0.0406685
[2, 2] = 1.0267
[3, 2] = -0.656616
[3, 3] = 0.507579
julia> LowerTriangular(L)\Diagonal(D)
3×3 SparseArrays.SparseMatrixCSC{Float64,Int64} with 6 stored entries:
[1, 1] = 0.0666276
[2, 1] = -0.115247
[3, 1] = 0.0406685
[2, 2] = 1.0267
[3, 2] = -0.656616
[3, 3] = 0.507579
```
It's very similar to what was addressed here: JuliaLang/julia#27999
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the provided Julia examples for triangular and diagonal matrix division, comparing the result types. Trace the dispatch used by triangular-matrix solve with Diagonal and add or update coverage so the result retains a triangular type rather than becoming sparse.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100