mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-06-05 14:55:15 +02:00
Added capability for sinc covariance via sympy kernel.
This commit is contained in:
parent
0d4fd01ae1
commit
e06d889d35
4 changed files with 72 additions and 1 deletions
32
GPy/util/symbolic.py
Normal file
32
GPy/util/symbolic.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
from sympy import Function, S, oo, I, cos, sin
|
||||
|
||||
|
||||
class sinc_grad(Function):
|
||||
nargs = 1
|
||||
|
||||
def fdiff(self, argindex=1):
|
||||
return ((2-x*x)*sin(self.args[0]) - 2*x*cos(x))/(x*x*x)
|
||||
|
||||
@classmethod
|
||||
def eval(cls, x):
|
||||
if 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):
|
||||
return sinc_grad(self.args[0])
|
||||
|
||||
@classmethod
|
||||
def eval(cls, x):
|
||||
if x is S.Zero:
|
||||
return S.One
|
||||
else:
|
||||
return sin(x)/x
|
||||
|
||||
def _eval_is_real(self):
|
||||
return self.args[0].is_real
|
||||
Loading…
Add table
Add a link
Reference in a new issue