def _K_computations(self, X, X2=None):
self._lengthscales=self.mapping.f(X)<EOL>self._lengthscales2=np.square(self._lengthscales)<EOL>if X2==None:<EOL><INDENT>self._lengthscales_two = self._lengthscales<EOL>self._lengthscales_two2 = self._lengthscales2<EOL>Xsquare = np.square(X).sum(<NUM_LIT:1>)<EOL>self._K_dist2 = -<NUM_LIT>*tdot(X) + Xsquare[:, None] + Xsquare[None, :]<EOL><DEDENT>else:<EOL><INDENT>self._lengthscales_two = self.mapping.f(X2)<EOL>self._lengthscales_two2 = np.square(self._lengthscales_two)<EOL>self._K_dist2 = -<NUM_LIT>*np.dot(X, X2.T) + np.square(X).sum(<NUM_LIT:1>)[:, None] + np.square(X2).sum(<NUM_LIT:1>)[None, :]<EOL><DEDENT>self._w2 = self._lengthscales2 + self._lengthscales_two2.T<EOL>prod_length = self._lengthscales*self._lengthscales_two.T<EOL>self._K_exponential = np.exp(-self._K_dist2/self._w2)<EOL>self._K_dvar = np.sign(prod_length)*(<NUM_LIT:2>*np.abs(prod_length)/self._w2)**(self.input_dim/<NUM_LIT>)*np.exp(-self._K_dist2/self._w2)<EOL>
Pre-computations for the covariance function (used both when computing the covariance and its gradients). Here self._dK_dvar and self._K_dist2 are updated.