-
-
Notifications
You must be signed in to change notification settings - Fork 29
Closed
Description
The Cholesky factorization Tridiagonal
matrix should be Bidiagonal
. However, (at least) Julia 1.10 uses a dense matrix:
julia> using LinearAlgebra
julia> A = Tridiagonal(ones(4), 2 * ones(5), ones(4))
5×5 Tridiagonal{Float64, Vector{Float64}}:
2.0 1.0 ⋅ ⋅ ⋅
1.0 2.0 1.0 ⋅ ⋅
⋅ 1.0 2.0 1.0 ⋅
⋅ ⋅ 1.0 2.0 1.0
⋅ ⋅ ⋅ 1.0 2.0
julia> cholesky(A)
Cholesky{Float64, Matrix{Float64}}
U factor:
5×5 UpperTriangular{Float64, Matrix{Float64}}:
1.41421 0.707107 0.0 0.0 0.0
⋅ 1.22474 0.816497 0.0 0.0
⋅ ⋅ 1.1547 0.866025 0.0
⋅ ⋅ ⋅ 1.11803 0.894427
⋅ ⋅ ⋅ ⋅ 1.09545
julia> LinearAlgebra.cholcopy(A)
5×5 Matrix{Float64}:
2.0 1.0 0.0 0.0 0.0
1.0 2.0 1.0 0.0 0.0
0.0 1.0 2.0 1.0 0.0
0.0 0.0 1.0 2.0 1.0
0.0 0.0 0.0 1.0 2.0
The issue seems to be mostly related to cholcopy
, since the in-place factorization looks better (but I did not benchmark it in detail):
julia> cholesky!(A)
Cholesky{Float64, Tridiagonal{Float64, Vector{Float64}}}
U factor:
5×5 UpperTriangular{Float64, Tridiagonal{Float64, Vector{Float64}}}:
1.41421 0.707107 0.0 0.0 0.0
⋅ 1.22474 0.816497 0.0 0.0
⋅ ⋅ 1.1547 0.866025 0.0
⋅ ⋅ ⋅ 1.11803 0.894427
⋅ ⋅ ⋅ ⋅ 1.09545
I consider this to be a performance bug since this makes the cholesky
decomposition of a Tridiagonal
matrix as slow as that of a dense matrix.
Metadata
Metadata
Assignees
Labels
No labels