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]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to