Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ end
LinearAlgebra.hermitian_type(::Type{SA}) where {T, S, SA<:SArray{S,T}} = Hermitian{T,SA}

function inv(A::Cholesky{T,<:StaticMatrix{N,N,T}}) where {N,T}
return A.U \ (A.U' \ SDiagonal{N}(I))
B = A.U \ (A.U' \ SDiagonal{N}(I))
return (B .+ B') ./ T(2)
end

function Base.:\(A::Cholesky{T,<:StaticMatrix{N,N,T}}, B::StaticVecOrMatLike) where {N,T}
Expand Down
5 changes: 5 additions & 0 deletions test/chol.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ using LinearAlgebra: PosDefException
c = cholesky(m)
@test (@inferred inv(c)) isa SMatrix{3,3,elty}
@test inv(c) ≈ SMatrix{3,3}(inv(m_a))
# Check special case of 2 × 2 inverse that used to trigger an
# error
c2 = cholesky(@SMatrix elty[π 3.1; 3.1 12.0])
d2 = inv(c2)
@test d2[1,2] == d2[2,1]
end

@testset "Division" begin
Expand Down