def _unscaled_dist(self, X, X2=None):
<EOL>if X2 is None:<EOL><INDENT>Xsq = np.sum(np.square(X),<NUM_LIT:1>)<EOL>r2 = -<NUM_LIT>*tdot(X) + (Xsq[:,None] + Xsq[None,:])<EOL>util.diag.view(r2)[:,]= <NUM_LIT:0.> <EOL>r2 = np.clip(r2, <NUM_LIT:0>, np.inf)<EOL>return np.sqrt(r2)<EOL><DEDENT>else:<EOL><INDENT>X1sq = np.sum(np.square(X),<NUM_LIT:1>)<EOL>X2sq = np.sum(np.square(X2),<NUM_LIT:1>)<EOL>r2 = -<NUM_LIT>*np.dot(X, X2.T) + (X1sq[:,None] + X2sq[None,:])<EOL>r2 = np.clip(r2, <NUM_LIT:0>, np.inf)<EOL>return np.sqrt(r2)<EOL><DEDENT>
Compute the Euclidean distance between each row of X and X2, or between
each pair of rows of X if X2 is None.