From eca52182e468fad8cfb44c6dab221e3ab7c662b3 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 18 Sep 2020 17:22:15 -0700 Subject: [PATCH] Make inverting a PDSparseMat throw an error Alter the inv() method for PDSparseMat to fall through to the inv() method of its underlying matrix. If that is a SparseMatrixCSC, an error will be thrown asking the user to convert to a dense matrix first (the default behavior in LinearAlgebra). --- src/pdsparsemat.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pdsparsemat.jl b/src/pdsparsemat.jl index c97fe9a..4036076 100644 --- a/src/pdsparsemat.jl +++ b/src/pdsparsemat.jl @@ -51,7 +51,7 @@ end ### Algebra -Base.inv(a::PDSparseMat{T}) where {T<:Real} = PDMat( a\eye(T,a.dim) ) +Base.inv(a::PDSparseMat{T}) where {T<:Real} = PDMat(inv(a.mat)) LinearAlgebra.logdet(a::PDSparseMat) = logdet(a.chol) ### whiten and unwhiten