Skip to content

Commit

Permalink
add some helper functions for director kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
Soeren Sonnenburg committed May 26, 2012
1 parent 676b942 commit d8a7270
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
28 changes: 28 additions & 0 deletions src/shogun/kernel/DirectorKernel.h
Expand Up @@ -67,6 +67,34 @@ IGNORE_IN_CLASSLIST class CDirectorKernel: public CKernel
return 0;
}

virtual void set_num_vec_lhs(int32_t num)
{
num_lhs=num;
}

virtual void set_num_vec_rhs(int32_t num)
{
num_rhs=num;
}

virtual bool has_features()
{
return true;
}

SGMatrix<float64_t> get_km()
{
SGMatrix<float64_t> km(num_lhs, num_rhs);

for (int32_t i=0; i<num_lhs; i++)
{
for (int32_t j=0; j<num_rhs; j++)
km[j*num_rhs+i]=kernel(i,j);
}

return km;
}

/** return what type of kernel we are
*
* @return kernel type DIRECTOR
Expand Down
6 changes: 3 additions & 3 deletions src/shogun/kernel/Kernel.h
Expand Up @@ -438,7 +438,7 @@ class CKernel : public CSGObject
*
* @return number of vectors of left-hand side
*/
virtual inline int32_t get_num_vec_lhs()
virtual int32_t get_num_vec_lhs()
{
return num_lhs;
}
Expand All @@ -447,7 +447,7 @@ class CKernel : public CSGObject
*
* @return number of vectors of right-hand side
*/
virtual inline int32_t get_num_vec_rhs()
virtual int32_t get_num_vec_rhs()
{
return num_rhs;
}
Expand All @@ -456,7 +456,7 @@ class CKernel : public CSGObject
*
* @return true if features are assigned
*/
virtual inline bool has_features()
virtual bool has_features()
{
return lhs && rhs;
}
Expand Down

0 comments on commit d8a7270

Please sign in to comment.