What is the best way of calculating the diagonal of the inverse of a symmetric dense matrix (2000 * 2000
)? Currently I calculate the inverse first using solve(x)
and then extract the diagonal (diag(y)
). Even though it works but I'm wondering whether there is a better way to do it so the code runs faster. I tried chol2inv()
but it didn't work since my matrix is not positive-definite.
Update: For anyone who may be interested, I was able to speed up the matrix inversion by using an optimized math library Intel MKL. It takes 3 seconds to inverse a 2000 * 2000 matrix on my machine. Intel MKL is available with Microsoft R Open.