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

cholesky of a Symmetric KeyedArray strips out the Symmetric #97

Open
sdl1 opened this issue Nov 18, 2021 · 0 comments
Open

cholesky of a Symmetric KeyedArray strips out the Symmetric #97

sdl1 opened this issue Nov 18, 2021 · 0 comments

Comments

@sdl1
Copy link

sdl1 commented Nov 18, 2021

Hello, I got tripped up by this:

julia> X = Symmetric(KeyedArray([1.0 0.1; 0.2 1.0], ([:a, :b], [:a, :b])))
2×2 Symmetric{Float64, KeyedArray{Float64, 2, Matrix{Float64}, Tuple{Vector{Symbol}, Vector{Symbol}}}}:
 1.0  0.1
 0.1  1.0

julia> isposdef(X) # Doesn't give expected answer
false

julia> isposdef(collect(X)) # Gives expected answer
true

Note that

julia> X = Symmetric([1.0 0.1; 0.2 1.0])
2×2 Symmetric{Float64, Matrix{Float64}}:
 1.0  0.1
 0.1  1.0

julia> isposdef(X) # Gives expected answer
true

As far as I can tell, this is because we reach this method in this package:

LinearAlgebra.cholesky(A::Hermitian{T, <:KeyedArray{T}}; kwargs...) where {T} =
    cholesky(parent(A); kwargs...)

And

julia> parent(Hermitian(X))
2-dimensional KeyedArray(...) with keys:
   2-element Vector{Symbol}
   2-element Vector{Symbol}
And data, 2×2 Matrix{Float64}:
        (:a)  (:b)
  (:a)   1.0   0.1
  (:b)   0.2   1.0

which does not satisfy isposdef since it's not Hermitian.

This is with AxisKeys v0.1.22 and julia v1.6.0

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

No branches or pull requests

1 participant