If your matrix is indeed diagonal, you can obviously just do
Ainv = diag(1./diag(A));
which should be very fast.
Frage
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
Lösung
If your matrix is indeed diagonal, you can obviously just do
Ainv = diag(1./diag(A));
which should be very fast.
Andere Tipps
The backslash operator \
is said to be faster and also could be more accurate. Without MATLAB really I cannot tell, but you could try to run A \ eye(10800)
instead of inv(A)
, and see if it works out.