def pinv(a, cond=None, rcond=None, return_rank=False, check_finite=True):
 a = _asarray_validated(a, check_finite=check_finite)
 b = np.identity(a.shape[0], dtype=a.dtype)
 if (rcond is not None):
  cond = rcond
 (x, resids, rank, s) = lstsq(a, b, cond=cond, check_finite=False)
 if return_rank:
  return (x, rank)
 else:
  return x

def pinv ( a , cond = None , rcond = None , return_rank = False , check_finite = True ) : a = _asarray_validated ( a , check_finite = check_finite ) b = np . identity ( a . shape [ 0 ] , dtype = a . dtype ) if ( rcond is not None ) : cond = rcond ( x , resids , rank , s ) = lstsq ( a , b , cond = cond , check_finite = False ) if return_rank : return ( x , rank ) else : return x
compute the pseudo-inverse of a matrix .