From a2f67febb4337504bfed67cd33b19308857c7091 Mon Sep 17 00:00:00 2001 From: Teo de Campos Date: Tue, 6 Dec 2016 11:01:45 -0200 Subject: [PATCH] Changed the order of the operations, ensuring that the covariance matrix is symmetric despite numerical precision issues. Suggested by Alan. --- GPy/kern/src/stationary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GPy/kern/src/stationary.py b/GPy/kern/src/stationary.py index c10384bb..79d4b954 100644 --- a/GPy/kern/src/stationary.py +++ b/GPy/kern/src/stationary.py @@ -135,7 +135,7 @@ class Stationary(Kern): #X2, = self._slice_X(X2) X1sq = np.sum(np.square(X),1) X2sq = np.sum(np.square(X2),1) - r2 = -2.*np.dot(X, X2.T) + X1sq[:,None] + X2sq[None,:] + r2 = -2.*np.dot(X, X2.T) + (X1sq[:,None] + X2sq[None,:]) r2 = np.clip(r2, 0, np.inf) return np.sqrt(r2)