mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-18 13:55:14 +02:00
Merge with James's changes
This commit is contained in:
commit
c690256801
3 changed files with 5 additions and 52 deletions
|
|
@ -11,6 +11,7 @@ import tempfile
|
||||||
import pdb
|
import pdb
|
||||||
import ast
|
import ast
|
||||||
from kernpart import Kernpart
|
from kernpart import Kernpart
|
||||||
|
from ...util.config import config
|
||||||
|
|
||||||
class spkern(Kernpart):
|
class spkern(Kernpart):
|
||||||
"""
|
"""
|
||||||
|
|
@ -110,8 +111,9 @@ class spkern(Kernpart):
|
||||||
'headers':['"sympy_helpers.h"'],
|
'headers':['"sympy_helpers.h"'],
|
||||||
'sources':[os.path.join(current_dir,"parts/sympy_helpers.cpp")],
|
'sources':[os.path.join(current_dir,"parts/sympy_helpers.cpp")],
|
||||||
'extra_compile_args':extra_compile_args,
|
'extra_compile_args':extra_compile_args,
|
||||||
'extra_link_args':['-lgomp'],
|
'extra_link_args':[],
|
||||||
'verbose':True}
|
'verbose':True}
|
||||||
|
if config.getboolean('parallel', 'openmp'): self.weave_kwargs.append('-lgomp')
|
||||||
|
|
||||||
def __add__(self,other):
|
def __add__(self,other):
|
||||||
return spkern(self._sp_k+other._sp_k)
|
return spkern(self._sp_k+other._sp_k)
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class KernelTests(unittest.TestCase):
|
||||||
|
|
||||||
def test_eq_sympykernel(self):
|
def test_eq_sympykernel(self):
|
||||||
if SYMPY_AVAILABLE:
|
if SYMPY_AVAILABLE:
|
||||||
kern = GPy.kern.eq_sympy(5, 3, output_ind=4)
|
kern = GPy.kern.eq_sympy(5, 3)
|
||||||
self.assertTrue(GPy.kern.kern_test(kern, verbose=verbose))
|
self.assertTrue(GPy.kern.kern_test(kern, verbose=verbose))
|
||||||
|
|
||||||
def test_rbf_invkernel(self):
|
def test_rbf_invkernel(self):
|
||||||
|
|
|
||||||
|
|
@ -237,52 +237,3 @@ class erfcx(Function):
|
||||||
def eval(cls, arg):
|
def eval(cls, arg):
|
||||||
return erfc(arg)*exp(arg*arg)
|
return erfc(arg)*exp(arg*arg)
|
||||||
|
|
||||||
class sinc_grad(Function):
|
|
||||||
nargs = 1
|
|
||||||
|
|
||||||
def fdiff(self, argindex=1):
|
|
||||||
if argindex==1:
|
|
||||||
# Strictly speaking this should be computed separately, as it won't work when x=0. See http://calculus.subwiki.org/wiki/Sinc_function
|
|
||||||
return ((2-x*x)*sin(self.args[0]) - 2*x*cos(x))/(x*x*x)
|
|
||||||
else:
|
|
||||||
raise ArgumentIndexError(self, argindex)
|
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def eval(cls, x):
|
|
||||||
if x.is_Number:
|
|
||||||
if x is S.NaN:
|
|
||||||
return S.NaN
|
|
||||||
elif x is S.Zero:
|
|
||||||
return S.Zero
|
|
||||||
else:
|
|
||||||
return (x*cos(x) - sin(x))/(x*x)
|
|
||||||
|
|
||||||
class sinc(Function):
|
|
||||||
|
|
||||||
nargs = 1
|
|
||||||
|
|
||||||
def fdiff(self, argindex=1):
|
|
||||||
if argindex==1:
|
|
||||||
return sinc_grad(self.args[0])
|
|
||||||
else:
|
|
||||||
raise ArgumentIndexError(self, argindex)
|
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def eval(cls, arg):
|
|
||||||
if arg.is_Number:
|
|
||||||
if arg is S.NaN:
|
|
||||||
return S.NaN
|
|
||||||
elif arg is S.Zero:
|
|
||||||
return S.One
|
|
||||||
else:
|
|
||||||
return sin(arg)/arg
|
|
||||||
|
|
||||||
if arg.func is asin:
|
|
||||||
x = arg.args[0]
|
|
||||||
return x / arg
|
|
||||||
|
|
||||||
def _eval_is_real(self):
|
|
||||||
return self.args[0].is_real
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue