user2225930
user2225930

Reputation: 433

Fast way in Matlab to compute inverse of big matrix 10800x10800?

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

Answers (2)

3lectrologos
3lectrologos

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

zw324
zw324

Reputation: 27200

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.

Upvotes: 1

Related Questions