Skip to content

Commit

Permalink
Merge pull request #1175 from karlnapf/develop
Browse files Browse the repository at this point in the history
added get_width and obtain_from_generic for Chi2 kernel
  • Loading branch information
karlnapf committed Jun 18, 2013
2 parents 3ff28a7 + 5e55448 commit 8d73e86
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/shogun/kernel/Chi2Kernel.cpp
Expand Up @@ -80,3 +80,21 @@ float64_t CChi2Kernel::compute(int32_t idx_a, int32_t idx_b)

return result;
}

float64_t CChi2Kernel::get_width()
{
return width;
}

CChi2Kernel* CChi2Kernel::obtain_from_generic(CKernel* kernel)
{
if (kernel->get_kernel_type()!=K_CHI2)
{
SG_SERROR("Provided kernel is "
"not of type CChi2Kernel!\n");
}

/* since an additional reference is returned */
SG_REF(kernel);
return (CChi2Kernel*)kernel;
}
9 changes: 9 additions & 0 deletions src/shogun/kernel/Chi2Kernel.h
Expand Up @@ -64,6 +64,15 @@ class CChi2Kernel: public CDotKernel
*/
virtual bool init(CFeatures* l, CFeatures* r);

/** @return width of the kernel */
virtual float64_t get_width();

/** @param kernel is casted to CChi2Kernel, error if not possible
* is SG_REF'ed
* @return casted CGaussianKernel object
*/
static CChi2Kernel* obtain_from_generic(CKernel* kernel);

/** return what type of kernel we are
*
* @return kernel type CHI2
Expand Down

0 comments on commit 8d73e86

Please sign in to comment.