Suppose I have a square matrix A like the toy below

set.seed(1234)
(A <- matrix(rnorm(9), nrow = 3))

I want to trace of the inverse of A. I could do

> sum(diag(solve(A)))
[1] 1.259641

Or I could also do

> sum(1/eigen(A)$values)
[1] 1.259641+0i

Now, my actual problem involves a very large, square dense matrix. Is step 2 still the best R-ish way of doing this or is there a smarter and fast implementation for such cases?

Harold


	[[alternative HTML version deleted]]

