 pinv(A) works for all dense matrices (not sparse).
         </p>
         <p>The explicit need for inv(A) (or S=A\eye(n), which is the same thing) is RARE.  If you ever find yourself multiplying by the
            inverse, then you know one thing for sure.  You know with certainty that you don't know what you're doing.
         </p><pre class="codeinput">A = rand (500) ;
tic ; S1 = inv (A) ;            ; toc
tic ; S2 = double (inverse (A)) ; toc
norm (S1-S2)

A = rand (500,400) ;
tic ; S1 = pinv (A)       