Closed DanielVandH closed 1 month ago
This is probably an ArrayLayouts.jl issue: we need to override cholesky for SubArray of LayoutMatrix to call cholesky_layout or something
It does go through that code, I think the issue is when it calls cholcopy
since
julia> LinearAlgebra.cholcopy(B) # bad
10×10 Matrix{Float64}:
0.617164 0.308407 0.170248 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.308407 1.00335 0.332173 0.605791 0.0 0.0 0.0 0.0 0.0 0.0
0.170248 0.332173 0.214511 0.236248 0.159116 0.0 0.0 0.0 0.0 0.0
0.0 0.605791 0.236248 0.550771 0.27541 0.018336 0.0 0.0 0.0 0.0
0.0 0.0 0.159116 0.27541 1.04702 0.591206 0.56485 0.0 0.0 0.0
0.0 0.0 0.0 0.018336 0.591206 0.976661 1.05175 0.184048 0.0 0.0
0.0 0.0 0.0 0.0 0.56485 1.05175 1.24 0.510496 0.100412 0.0
0.0 0.0 0.0 0.0 0.0 0.184048 0.510496 0.983012 0.314483 0.0262631
0.0 0.0 0.0 0.0 0.0 0.0 0.100412 0.314483 0.245317 0.266145
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0262631 0.266145 0.532169
julia> LinearAlgebra.cholcopy(Symmetric(B)) # good
10×10 Symmetric{Float64, BandedMatrix{Float64, Matrix{Float64}, Base.OneTo{Int64}}}:
0.617164 0.308407 0.170248 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
0.308407 1.00335 0.332173 0.605791 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
0.170248 0.332173 0.214511 0.236248 0.159116 ⋅ ⋅ ⋅ ⋅ ⋅
⋅ 0.605791 0.236248 0.550771 0.27541 0.018336 ⋅ ⋅ ⋅ ⋅
⋅ ⋅ 0.159116 0.27541 1.04702 0.591206 0.56485 ⋅ ⋅ ⋅
⋅ ⋅ ⋅ 0.018336 0.591206 0.976661 1.05175 0.184048 ⋅ ⋅
⋅ ⋅ ⋅ ⋅ 0.56485 1.05175 1.24 0.510496 0.100412 ⋅
⋅ ⋅ ⋅ ⋅ ⋅ 0.184048 0.510496 0.983012 0.314483 0.0262631
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.100412 0.314483 0.245317 0.266145
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.0262631 0.266145 0.532169
julia> LinearAlgebra.cholcopy(Symmetric(view(B, :, :))) # bad
10×10 Symmetric{Float64, Matrix{Float64}}:
0.617164 0.308407 0.170248 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.308407 1.00335 0.332173 0.605791 0.0 0.0 0.0 0.0 0.0 0.0
0.170248 0.332173 0.214511 0.236248 0.159116 0.0 0.0 0.0 0.0 0.0
0.0 0.605791 0.236248 0.550771 0.27541 0.018336 0.0 0.0 0.0 0.0
0.0 0.0 0.159116 0.27541 1.04702 0.591206 0.56485 0.0 0.0 0.0
0.0 0.0 0.0 0.018336 0.591206 0.976661 1.05175 0.184048 0.0 0.0
0.0 0.0 0.0 0.0 0.56485 1.05175 1.24 0.510496 0.100412 0.0
0.0 0.0 0.0 0.0 0.0 0.184048 0.510496 0.983012 0.314483 0.0262631
0.0 0.0 0.0 0.0 0.0 0.0 0.100412 0.314483 0.245317 0.266145
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0262631 0.266145 0.532169
Probably just needs a similar method for SubArrays here. I'll make a pr
Presumably (?) it would be possible for the latter to also return something like a
which knows the structure. Not 100% sure how views propagate in all the code.