mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-03 16:52:39 +02:00
enabled DSYR on feeble machines
i.e. where numpy is compiled without proper blas linkage
This commit is contained in:
parent
3c12f85a28
commit
58b206a245
1 changed files with 21 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue