def pinvh(a, cond=None, rcond=None, lower=True, return_rank=False, check_finite=True):
 a = _asarray_validated(a, check_finite=check_finite)
 (s, u) = decomp.eigh(a, lower=lower, 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)
 above_cutoff = (abs(s) > (cond * np.max(abs(s))))
 psigma_diag = (1.0 / s[above_cutoff])
 u = u[:, above_cutoff]
 B = np.dot((u * psigma_diag), np.conjugate(u).T)
 if return_rank:
  return (B, len(psigma_diag))
 else:
  return B

def pinvh ( a , cond = None , rcond = None , lower = True , return_rank = False , check_finite = True ) : a = _asarray_validated ( a , check_finite = check_finite ) ( s , u ) = decomp . eigh ( a , lower = lower , 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 ) above_cutoff = ( abs ( s ) > ( cond * np . max ( abs ( s ) ) ) ) psigma_diag = ( 1.0 / s [ above_cutoff ] ) u = u [ : , above_cutoff ] B = np . dot ( ( u * psigma_diag ) , np . conjugate ( u ) . T ) if return_rank : return ( B , len ( psigma_diag ) ) else : return B
compute the pseudo-inverse of a hermitian matrix .