# How to reduce time consuming for calculating pseudo inverse of large matrix in matlab?

I have a matrix

P = randn(45875x65536 );
Pi = pinv (P);


I tried to run this code in matlab, but it takes long time

is it possible to split the matrix into smaller matrices then calculate the pseudo inverse?

any suggestion to reduce the time ?

• your first line of code isn't valid Matlab... – Marcus Müller Nov 6 '18 at 9:58
• also, chances are that if you're trying to find an inverse to a $45875\times 65536$ matrix within a signal processing context, you might be doing something over the top. In which context are you planning to use Pi? – Marcus Müller Nov 6 '18 at 10:00
• By the way, that matrix is more 24 GB worth of numbers; I'm actually happy for you that your computer is able to construct that 3 billion-numbers matrix at all. I'm now almost certain you're trying to do something absurd. – Marcus Müller Nov 6 '18 at 10:02

Long story very short: No.

If that was possible, Matlab would likely be doing it already; in any case, the Matlab docs for pinv say that the singular value decomposition method is used; that might not be the fastest method, but it's relatively stable for many cases of P, so it's pretty much desirable unless you know exceptionally well what you're doing or your P has special structure (in which case you'd probably not want to use the Moore-Penrose Pseudoinverse in the first place, maybe?).

Longer story: typically, you multiply your Pi onto something to get the inverse operation to P executed.

To cite Matlab documentation itself:

You can replace most uses of pinv applied to a vector b, as in pinv(A)*b, with lsqminnorm(A,b) to get the minimum-norm least-squares solution of a system of linear equations. lsqminnorm is generally more efficient than pinv, and it also supports sparse matrices.

But whether you can do that depends on the actual reason you're using the Moore-Penrose Pseudoinverse; not all uses are just replaceable with something else.

• slight objection to Matlab would be doing it already... Depending on the version (that I'm using a very old one 6.0) sometimes (very occasionally) it doesn't. Just an example: Prony fuction is quite slow compared to hand calculation (especially for large signals). don't know the reason, havent looked at its m file. – Fat32 Nov 6 '18 at 9:37
• @Fat32 fair point; I'll weaken my claim, there. – Marcus Müller Nov 6 '18 at 9:41

You could try using a QR decomposition.

https://en.wikipedia.org/wiki/QR_decomposition#Using_for_solution_to_linear_inverse_problems

matlab has a qrupdate routine that works with sparse matrices as well.