Skip to content

Commit

Permalink
add new constructor in gaussian kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
sanuj committed May 31, 2016
1 parent 3659533 commit 464c49c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/shogun/kernel/GaussianKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ CGaussianKernel::CGaussianKernel() : CDotKernel()
init();
}

CGaussianKernel::CGaussianKernel(float64_t w) : CDotKernel()
{
init();
set_width(w);
}

CGaussianKernel::CGaussianKernel(int32_t size, float64_t w) : CDotKernel(size)
{
init();
Expand Down
6 changes: 6 additions & 0 deletions src/shogun/kernel/GaussianKernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ class CGaussianKernel: public CDotKernel
/** default constructor */
CGaussianKernel();

/** constructor
*
* @param width width
*/
CGaussianKernel(float64_t width);

/** constructor
*
* @param size cache size
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/kernel/Kernel_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -448,3 +448,11 @@ TEST(Kernel, row_col_wise_sum_block_no_diag)
// cleanup
SG_UNREF(kernel);
}

TEST(Kernel, gaussian_kernel_width_constructor)
{
float64_t width = 5;
CGaussianKernel* kernel=new CGaussianKernel(width);
EXPECT_EQ(kernel->get_cache_size(), 10);
EXPECT_EQ(kernel->get_width(), width);
}

0 comments on commit 464c49c

Please sign in to comment.