-
Notifications
You must be signed in to change notification settings - Fork 38
Closed
Description
julia> using BandedMatrices, LinearAlgebra
julia> L = brand(10, 10, 2, 0); B = BandedMatrix(Symmetric(L * L'));
julia> cholesky(Symmetric(B)) # good
Cholesky{Float64, BandedMatrix{Float64, Matrix{Float64}, Base.OneTo{Int64}}}
U factor:
10×10 UpperTriangular{Float64, BandedMatrix{Float64, Matrix{Float64}, Base.OneTo{Int64}}}:
0.959058 0.698054 0.15382 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ 0.184258 0.432745 0.686227 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ 0.311502 0.977993 0.642646 ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ 0.148787 0.285363 0.155638 ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ 0.0493197 0.259591 0.55198 ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ 0.293538 0.124905 0.113931 ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.769331 0.620623 0.106919 ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.462947 0.723893 0.75173
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.714449 0.32878
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.215385
julia> cholesky(Symmetric(B[1:end-1, 1:end-1])) # good
Cholesky{Float64, BandedMatrix{Float64, Matrix{Float64}, Base.OneTo{Int64}}}
U factor:
9×9 UpperTriangular{Float64, BandedMatrix{Float64, Matrix{Float64}, Base.OneTo{Int64}}}:
0.959058 0.698054 0.15382 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ 0.184258 0.432745 0.686227 ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ 0.311502 0.977993 0.642646 ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ 0.148787 0.285363 0.155638 ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ 0.0493197 0.259591 0.55198 ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ 0.293538 0.124905 0.113931 ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.769331 0.620623 0.106919
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.462947 0.723893
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.714449
julia> cholesky(Symmetric(@view B[1:end-1, 1:end-1])) # bad
Cholesky{Float64, Matrix{Float64}}
U factor:
9×9 UpperTriangular{Float64, Matrix{Float64}}:
0.959058 0.698054 0.15382 0.0 0.0 0.0 0.0 0.0 0.0
⋅ 0.184258 0.432745 0.686227 0.0 0.0 0.0 0.0 0.0
⋅ ⋅ 0.311502 0.977993 0.642646 0.0 0.0 0.0 0.0
⋅ ⋅ ⋅ 0.148787 0.285363 0.155638 0.0 0.0 0.0
⋅ ⋅ ⋅ ⋅ 0.0493197 0.259591 0.55198 0.0 0.0
⋅ ⋅ ⋅ ⋅ ⋅ 0.293538 0.124905 0.113931 0.0
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.769331 0.620623 0.106919
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.462947 0.723893
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.714449Presumably (?) it would be possible for the latter to also return something like a
Cholesky{Float64, SubArray{Float64, 2, BandedMatrix{Float64, Matrix{Float64}, Base.OneTo{Int64}}, Tuple{UnitRange{Int64}, UnitRange{Int64}}, false}}
which knows the structure. Not 100% sure how views propagate in all the code.
Metadata
Metadata
Assignees
Labels
No labels