Skip to content

Fix error message for LDL factorization failures#2956

Open
odow wants to merge 2 commits intomasterfrom
od/fix-ldl
Open

Fix error message for LDL factorization failures#2956
odow wants to merge 2 commits intomasterfrom
od/fix-ldl

Conversation

@odow
Copy link
Member

@odow odow commented Feb 27, 2026

@odow
Copy link
Member Author

odow commented Mar 1, 2026

I'm not sure what's going on here. LDLFactorizations.factorized returns false, but there is a valid factorisation:

julia> import LDLFactorizations

julia> import LinearAlgebra

julia> Q = [1.0 1.0; 1.0 1.0]
2×2 Matrix{Float64}:
 1.0  1.0
 1.0  1.0

julia> f = LDLFactorizations.ldl(Q)
LDLFactorizations.LDLFactorization{Float64, Int64, Int64, Int64}(true, false, false, 2, [2, -1], [1, 0], [2, 2], [1, 2], [1, 2], [1, 2, 2], Int64[], Int64[], [2], [1.0], [1.0, 0.0], [0.0, 0.0], [1, 1], 0.0, 0.0, 0.0, 2)

julia> @assert f.P == [1, 2]

julia> L = Matrix(f.L) .+ LinearAlgebra.I(2)
2×2 Matrix{Float64}:
 1.0  0.0
 1.0  1.0

julia> D = Matrix(f.D)
2×2 Matrix{Float64}:
 1.0  0.0
 0.0  0.0

julia> LDLFactorizations.factorized(f)
false

julia> L * D * L'
2×2 Matrix{Float64}:
 1.0  1.0
 1.0  1.0

cc @amontoison any ideas?

@amontoison
Copy link
Contributor

@odow I checked the code and we stop the factorization when we encounter D[k] == 0 and we return false for "factorized".

But if k == n, we reached the end of the factorization and we can return true.

@odow
Copy link
Member Author

odow commented Mar 1, 2026

Is that intentional or a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants