Moore-Penrose pseudo inverse algorithm implementation in Matlab

3.5k Views Asked by At

I am searching for a Matlab implementation of the Moore-Penrose algorithm (convertable to C++) computing pseudo-inverse matrix.

I tried several algorithms, "Fast Computation of Moore-Penrose Inverse Matrices" from Pierre Courrieu appeared good at the first look. However, the problem is that for large elements it produces badly scaled matrices and some internal operations fail.

It concerns the following steps:

L=L(:,1:r);
M=inv(L'*L);

I am trying to find a more robust solution which is easily implementable :-). Thanks for your help.

2

There are 2 best solutions below

4
On

Use the inbuilt function pinv(...).

0
On

It's not Matlab unfortunately but the open source numpy implements pinv in python, which may be of some use, code can be found here: https://github.com/numpy/numpy/blob/master/numpy/linalg/linalg.py#L1508