Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


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

share|cite|improve this question
In what way does it fail, do you get an error message and if so which? – Dennis Jaheruddin Nov 12 '12 at 14:29
Enter >>edit pinv you could see the key step here is singular value decomposition. – Shuhao Cao Jun 8 '13 at 17:32

Use the inbuilt function pinv(...).

share|cite|improve this answer
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. – justik Nov 11 '12 at 11:16
@justik Do you explicitly need the pseudoinverse, or do you just need the action of the pseudoinverse on a vector? – Daryl Nov 11 '12 at 11:45
Isn't there some library like LAPACK that already has what you want implemented for C++? – littleO Nov 11 '12 at 11:50
@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. – J. M. Jun 8 '13 at 17:12

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:

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.