62 for (int32_t i=0; i<num_vec; i++)
63 buf[i]=df->
dot(i,df, i);
68 CDotKernel::init(l, r);
84 void CPeriodicKernel::precompute_squared()
90 REQUIRE(dotlhs!=NULL,
"Left-hand-side features must be of type CDotFeatures\n")
92 precompute_squared_helper(
m_sq_lhs, dotlhs);
99 REQUIRE(dotrhs!=NULL,
"Left-hand-side features must be of type CDotFeatures\n")
101 precompute_squared_helper(
m_sq_rhs, dotrhs);
108 REQUIRE(
lhs,
"Left-hand-side features not set!\n")
109 REQUIRE(
rhs,
"Right-hand-side features not set!\n")
111 if (!strcmp(param->m_name,
"length_scale"))
123 derivative(j,k)=original*4.0*pow(sin(trig_arg),2)/pow(
m_length_scale,3);
129 else if (!strcmp(param->m_name,
"period"))
148 SG_ERROR(
"Can't compute derivative wrt %s parameter\n", param->m_name);
153 void CPeriodicKernel::init()
162 SG_ADD(&m_sq_lhs,
"sq_lhs",
163 "Vector of dot products of each left-hand-side vector with itself.",
MS_NOT_AVAILABLE);
165 "Vector of dot products of each right-hand-side vector with itself.",
MS_NOT_AVAILABLE);
static float64_t sin(float64_t x)
tanh(x), x being a complex128_t
SGVector< float64_t > m_sq_lhs
virtual bool init(CFeatures *l, CFeatures *r)
int32_t num_rhs
number of feature vectors on right hand side
virtual float64_t dot(int32_t vec_idx1, CDotFeatures *df, int32_t vec_idx2)=0
virtual int32_t get_num_vectors() const =0
The periodic kernel as described in The Kernel Cookbook by David Duvenaud: http://people.seas.harvard.edu/~dduvenaud/cookbook/.
virtual float64_t compute(int32_t idx_a, int32_t idx_b)
Features that support dot products among other operations.
Template class DotKernel is the base class for kernels working on DotFeatures.
#define M_PI
workaround for log2 being a define on cygwin
int32_t num_lhs
number of feature vectors on left hand side
virtual SGMatrix< float64_t > get_parameter_gradient(const TParameter *param, index_t index=-1)
virtual bool init_normalizer()
CFeatures * rhs
feature vectors to occur on right hand side
all of classes and functions are contained in the shogun namespace
virtual void set_period(float64_t period)
CFeatures * lhs
feature vectors to occur on left hand side
The class Features is the base class of all feature objects.
static float64_t exp(float64_t x)
virtual float64_t compute(int32_t idx_a, int32_t idx_b)
virtual float64_t distance(int32_t idx_a, int32_t idx_b)
SGVector< float64_t > m_sq_rhs
virtual void set_length_scale(float64_t length_scale)
static int32_t pow(bool x, int32_t n)