From 58b206a24541fe55183676d11b225116a61c9bb7 Mon Sep 17 00:00:00 2001 From: James Hensman Date: Sun, 19 May 2013 19:16:25 +0100 Subject: [PATCH] enabled DSYR on feeble machines i.e. where numpy is compiled without proper blas linkage --- GPy/util/linalg.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/GPy/util/linalg.py b/GPy/util/linalg.py index fa7de8c1..abfb1900 100644 --- a/GPy/util/linalg.py +++ b/GPy/util/linalg.py @@ -236,7 +236,7 @@ def tdot(*args, **kwargs): else: return tdot_numpy(*args,**kwargs) -def DSYR(A,x,alpha=1.): +def DSYR_blas(A,x,alpha=1.): """ Performs a symmetric rank-1 update operation: A <- A + alpha * np.dot(x,x.T) @@ -258,6 +258,26 @@ def DSYR(A,x,alpha=1.): x_, byref(INCX), A_, byref(LDA)) symmetrify(A,upper=True) +def DSYR_numpy(A,x,alpha=1.): + """ + Performs a symmetric rank-1 update operation: + A <- A + alpha * np.dot(x,x.T) + + Arguments + --------- + :param A: Symmetric NxN np.array + :param x: Nx1 np.array + :param alpha: scalar + """ + A += alpha*np.dot(x[:,None],x[None,:]) + + +def DSYR(*args, **kwargs): + if _blas_available: + return DSYR_blas(*args,**kwargs) + else: + return DSYR_numpy(*args,**kwargs) + def symmetrify(A,upper=False): """ Take the square matrix A and make it symmetrical by copting elements from the lower half to the upper