#NEWLINE# def _K_computations( self , X , X2 = None ) : #NEWLINE# #INDENT# '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.' #NEWLINE# self . _lengthscales = self . mapping . f ( X ) #NEWLINE# self . _lengthscales2 = np . square ( self . _lengthscales ) #NEWLINE# if ( X2 == None ) : #NEWLINE# #INDENT# self . _lengthscales_two = self . _lengthscales #NEWLINE# self . _lengthscales_two2 = self . _lengthscales2 #NEWLINE# Xsquare = np . square ( X ) . sum ( 1 ) #NEWLINE# self . _K_dist2 = ( ( ( ( - 2.0 ) * tdot ( X ) ) + Xsquare [ : , None ] ) + Xsquare [ None , : ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _lengthscales_two = self . mapping . f ( X2 ) #NEWLINE# self . _lengthscales_two2 = np . square ( self . _lengthscales_two ) #NEWLINE# self . _K_dist2 = ( ( ( ( - 2.0 ) * np . dot ( X , X2 . T ) ) + np . square ( X ) . sum ( 1 ) [ : , None ] ) + np . square ( X2 ) . sum ( 1 ) [ None , : ] ) #NEWLINE# #UNINDENT# self . _w2 = ( self . _lengthscales2 + self . _lengthscales_two2 . T ) #NEWLINE# prod_length = ( self . _lengthscales * self . _lengthscales_two . T ) #NEWLINE# self . _K_exponential = np . exp ( ( ( - self . _K_dist2 ) / self . _w2 ) ) #NEWLINE# self . _K_dvar = ( ( np . sign ( prod_length ) * ( ( ( 2 * np . abs ( prod_length ) ) / self . _w2 ) ** ( self . input_dim / 2.0 ) ) ) * np . exp ( ( ( - self . _K_dist2 ) / self . _w2 ) ) )