def _psd_pinv_decomposed_log_pdet(mat, cond=None, rcond=None, lower=True, check_finite=True):
 (s, u) = scipy.linalg.eigh(mat, lower=lower, check_finite=check_finite)
 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)
 eps = (cond * np.max(abs(s)))
 if (np.min(s) < (- eps)):
  raise ValueError('the covariance matrix must be positive semidefinite')
 s_pinv = _pinv_1d(s, eps)
 U = np.multiply(u, np.sqrt(s_pinv))
 log_pdet = np.sum(np.log(s[(s > eps)]))
 return (U, log_pdet)

def _psd_pinv_decomposed_log_pdet ( mat , cond = None , rcond = None , lower = True , check_finite = True ) : ( s , u ) = scipy . linalg . eigh ( mat , lower = lower , check_finite = check_finite ) 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 ) eps = ( cond * np . max ( abs ( s ) ) ) if ( np . min ( s ) < ( - eps ) ) : raise ValueError ( 'the covariance matrix must be positive semidefinite' ) s_pinv = _pinv_1d ( s , eps ) U = np . multiply ( u , np . sqrt ( s_pinv ) ) log_pdet = np . sum ( np . log ( s [ ( s > eps ) ] ) ) return ( U , log_pdet )
compute a decomposition of the pseudo-inverse and the logarithm of the pseudo-determinant of a symmetric positive semi-definite matrix .