1
$\begingroup$

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.

  • 0
    In what way does it fail, do you get an error message and if so which?2012-11-12
  • 0
    Enter `>>edit pinv` you could see the key step here is singular value decomposition.2013-06-08
  • 0
    Have you considered routines like LAPACK? http://www.netlib.org/lapack/lug/node32.html2017-03-23

3 Answers 3

1

Use the inbuilt function pinv(...).

  • 0
    Of course, there is. But it does not solve the problem. I would like to know, how it works and implement it in another SW.2012-11-11
  • 1
    @justik Do you explicitly need the pseudoinverse, or do you just need the action of the pseudoinverse on a vector?2012-11-11
  • 0
    Isn't there some library like LAPACK that already has what you want implemented for C++?2012-11-11
  • 0
    @justik, as long as your computing environment allows you to compute the singular value decomposition of a matrix, then it is not too hard to construct the Moore-Penrose inverse.2013-06-08
1

MATLAB uses the SVD for the pinv() function (Just do edit pinv.m in MATLAB).
The SVD, I believe, is basically a warpper around Intel MKL's SVD Function.

  • 0
    Thank you. I did not know the code is available by `edit pinv.m`.2018-09-23
0

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