Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matrix inverse fails for Cholesky factorizations of diagonal matrices #952

Closed
wzhorton opened this issue Sep 12, 2022 · 1 comment · Fixed by JuliaLang/julia#46763
Closed

Comments

@wzhorton
Copy link

wzhorton commented Sep 12, 2022

The strides function throws a method error when called from inv on Cholesky factorizations of diagonal matrices.

using LinearAlgebra
A = Diagonal([1,2,3])
cholA = cholesky(A)
inv(cholA) # 'no method matching strides(::Diagonal{Float64, Vector{Float64}})'

Issue 44053 might be related, but deals with construction, rather than a specific routine.

Although taking the Cholesky of a diagonal matrix is a trivial process, it makes sense to support it in the context of inverting a covariance matrix within a function, e.g. sympd_invert(Sigma) = inv(cholesky(Sigma)). Receiving a diagonal covariance Sigma is reasonable in several situations.


Version Info:
Julia Version 1.7.3
Commit 742b9abb4d (2022-05-06 12:58 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin21.4.0)
CPU: Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-12.0.1 (ORCJIT, skylake)

@giordano giordano added the bug Something isn't working label Sep 13, 2022
@dkarrasch
Copy link
Member

This is fixed on v1.8:

julia> inv(cholA)
3×3 Matrix{Float64}:
 1.0  0.0  0.0
 0.0  0.5  0.0
 0.0  0.0  0.333333

The question is whether we would like to specialize that to give a Diagonal result.

@dkarrasch dkarrasch removed the bug Something isn't working label Sep 14, 2022
@KristofferC KristofferC transferred this issue from JuliaLang/julia Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants