IntegralEquations / HMatrices.jl

A Julia library for hierarchical matrices
MIT License
41 stars 3 forks source link

log determinant of HMatrix #72

Open ngiann opened 4 months ago

ngiann commented 4 months ago

A question please: how do I go about calculating the log-determinant of an HMatrix? Thanks.

maltezfaria commented 3 months ago

It seems you can use the Cholesky decomposition:

\log(det(H)) = \log(det(L L^\top)) = \log(det(L)^2) = 2 \log(det(L))

Do you have a MWE example? You can call cholesky to factor an HMatrix, but you may need to tweak a bit with the internals to extract the diagonal of L.

Disclaimer: I know nothing about log determinants 😅

maltezfaria commented 2 months ago

@ngiann Did you manage to compute the logdet of an HMatrix? If you are still interested I think adding the functionality should be straightforward (essentially we need to overload the diag function to compute the diagonal of hierarchical matrices, and wrap cholesky + diagonal with the simple computation above to compute the logdet).