I earlier had a doubt regarding pseudo-inverse of a matrix, and earlier I was using pinv function. But one of the answers gave an alternative technique that is singular value decomposition method. I have a very little understanding of the method... can anyone please suggest some literature for understanding it properly so that I can understand the following code completely...or can explain the code in simple words..

please help..

% pseudo inverse of A
[m,n]   = size(R);
% get SVD
[U,S,V] = svd(R);
% check rank
r       = rank(S);
SR      = S(1:r,1:r);
% make complete if rank is not full
SRc     = [SR^-1 zeros(r,m-r);zeros(n-r,r) zeros(n-r,m-r)];
% create inverse
A_inv   = V*SRc*U.';

g1 = zeros(size(k31));
g2 = zeros(size(k31));
g3 = zeros(size(k31));

Wikipedia is your friend: Applications of the SVD. Look at the pseudo-inverse and rank sections.

| cite | improve this answer | |

The "pinv" function of matlab is using the singular value decomposition (SVD) as part of the "Moore-Penrose Pseudoinverse" as described here, so SVD is not neccessarily an alternative to "pinv".

The source code of the pinv function within Matlab is more simple than the code you posted, which may help with understanding it more easily.

Some more info that could help lead to an understanding:

Theoretical: https://hadrienj.github.io/posts/Deep-Learning-Book-Series-2.9-The-Moore-Penrose-Pseudoinverse/

Practical: https://www.dsprelated.com/showarticle/112.php

| cite | improve this answer | |

Every matrix $$ \mathbf{A} \in \mathbb{C}^{m\times n}_{\rho} $$ has a singular value decomposition $$ \mathbf{A} = \mathbf{U} \, \Sigma \, \mathbf{V}^{*} \\ $$

Putting this expansion into the least squares problem naturally produces the pseudoinverse solution as shown in How does the SVD solve the least squares problem?

The Moore-Penrose pseudoinverse is $$ \mathbf{A}^{\dagger} = \mathbf{V} \, \Sigma^{\dagger} \, \mathbf{U}^{*} \\ $$

This is the answer to the question "if given a matrix, how would I construct the Moore-Penrose pseudoinverse?"

But your question is different: "if given a matrix, and a data vector $b$ not in the null space, how would I find the Moore-Penrose solution?" As noted by @Shiyue, the pseudoinverse solution can be take less time than constructing the pseudoinverse:

What is the best way to compute the pseudoinverse of a matrix?

In summary, if you are trying to solve a system in the most efficient manner, rely on the intrinsic tools in MATLAB or Mathematica.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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