Reputation: 433
I have a matrix of size 10800x10800 in Matlab and I compute its inverse directly with the function:
inv(A)
It takes 3 to 4 minutes just one such computation. And that is part of an iterative algorithm which needs more than 20 iterations, so overall things would be very slow. Is there a better way to do this? Maybe some mathematical formulas or maybe a better Matlab function?
Edit: The matrix is diagonal. Each iteration the diagonal elements are updated based on formulas for fitting a factor analyzer. But that is irrelevant, the important thing is that it is a diagonal matrix and it changes each iteration.
THanks
Upvotes: 1
Views: 2129
Reputation: 9652
If your matrix is indeed diagonal, you can obviously just do
Ainv = diag(1./diag(A));
which should be very fast.
Upvotes: 5