def _project_correlation_factors(X):
 nm = np.sqrt((X * X).sum(1))
 ii = np.flatnonzero((nm > 1))
 if (len(ii) > 0):
  X[ii, :] /= nm[ii][:, None]

def _project_correlation_factors ( X ) : nm = np . sqrt ( ( X * X ) . sum ( 1 ) ) ii = np . flatnonzero ( ( nm > 1 ) ) if ( len ( ii ) > 0 ) : X [ ii , : ] /= nm [ ii ] [ : , None ]
project a matrix into the domain of matrices whose row-wise sums of squares are less than or equal to 1 .