def _decomp_quad(P, cond=None, rcond=None, lower=True, check_finite=True):
 (w, V) = LA.eigh(P, lower=lower, check_finite=check_finite)
 if (rcond is not None):
  cond = rcond
 if (cond in (None, (-1))):
  t = V.dtype.char.lower()
  factor = {'f': 1000.0, 'd': 1000000.0}
  cond = (factor[t] * np.finfo(t).eps)
 scale = max(np.absolute(w))
 w_scaled = (w / scale)
 maskp = (w_scaled > cond)
 maskn = (w_scaled < (- cond))
 if (np.any(maskp) and np.any(maskn)):
  warnings.warn('Forming a nonconvex expression quad_form(x, indefinite).')
 M1 = (V[:, maskp] * np.sqrt(w_scaled[maskp]))
 M2 = (V[:, maskn] * np.sqrt((- w_scaled[maskn])))
 return (scale, M1, M2)

def _decomp_quad ( P , cond = None , rcond = None , lower = True , check_finite = True ) : ( w , V ) = LA . eigh ( P , lower = lower , check_finite = check_finite ) if ( rcond is not None ) : cond = rcond if ( cond in ( None , ( - 1 ) ) ) : t = V . dtype . char . lower ( ) factor = { 'f' : 1000.0 , 'd' : 1000000.0 } cond = ( factor [ t ] * np . finfo ( t ) . eps ) scale = max ( np . absolute ( w ) ) w_scaled = ( w / scale ) maskp = ( w_scaled > cond ) maskn = ( w_scaled < ( - cond ) ) if ( np . any ( maskp ) and np . any ( maskn ) ) : warnings . warn ( 'Forming a nonconvex expression quad_form(x, indefinite).' ) M1 = ( V [ : , maskp ] * np . sqrt ( w_scaled [ maskp ] ) ) M2 = ( V [ : , maskn ] * np . sqrt ( ( - w_scaled [ maskn ] ) ) ) return ( scale , M1 , M2 )
compute a matrix decomposition .