def pinv2(a, cond=None, rcond=None, return_rank=False, check_finite=True):
 a = _asarray_validated(a, check_finite=check_finite)
 (u, s, vh) = decomp_svd.svd(a, full_matrices=False, check_finite=False)
 if (rcond is not None):
  cond = rcond
 if (cond in [None, (-1)]):
  t = u.dtype.char.lower()
  factor = {'f': 1000.0, 'd': 1000000.0}
  cond = (factor[t] * np.finfo(t).eps)
 rank = np.sum((s > (cond * np.max(s))))
 u = u[:, :rank]
 u /= s[:rank]
 B = np.transpose(np.conjugate(np.dot(u, vh[:rank])))
 if return_rank:
  return (B, rank)
 else:
  return B

def pinv2 ( a , cond = None , rcond = None , return_rank = False , check_finite = True ) : a = _asarray_validated ( a , check_finite = check_finite ) ( u , s , vh ) = decomp_svd . svd ( a , full_matrices = False , check_finite = False ) if ( rcond is not None ) : cond = rcond if ( cond in [ None , ( - 1 ) ] ) : t = u . dtype . char . lower ( ) factor = { 'f' : 1000.0 , 'd' : 1000000.0 } cond = ( factor [ t ] * np . finfo ( t ) . eps ) rank = np . sum ( ( s > ( cond * np . max ( s ) ) ) ) u = u [ : , : rank ] u /= s [ : rank ] B = np . transpose ( np . conjugate ( np . dot ( u , vh [ : rank ] ) ) ) if return_rank : return ( B , rank ) else : return B
compute the pseudo-inverse of a matrix .