12 #ifndef _CUSTOMKERNEL_H___
13 #define _CUSTOMKERNEL_H___
86 virtual bool dummy_init(int32_t rows, int32_t cols);
126 virtual const char*
get_name()
const {
return "CustomKernel"; }
144 SG_ERROR(
"%s::set_triangle_kernel_matrix_from_triangle not"
145 " possible with subset. Remove first\n",
get_name());
167 SG_ERROR(
"%s::set_triangle_kernel_matrix_from_triangle_generic "
168 "not possible with subset. Remove first\n",
get_name());
172 int64_t len = tri_kernel_matrix.
vlen;
173 int64_t cols = (int64_t) floor(-0.5 +
CMath::sqrt(0.25+2*len));
175 if (cols*(cols+1)/2 != len)
177 SG_ERROR(
"km should be a vector containing a lower triangle matrix, with len=cols*(cols+1)/2 elements\n")
182 SG_DEBUG(
"using custom kernel of size %dx%d\n", cols,cols)
187 for (int64_t i=0; i<len; i++)
191 dummy_init(cols,cols);
223 SG_ERROR(
"%s::set_triangle_kernel_matrix_from_full_generic "
224 "not possible with subset. Remove first\n",
get_name());
227 int32_t rows = full_kernel_matrix.
num_rows;
228 int32_t cols = full_kernel_matrix.
num_cols;
232 SG_DEBUG(
"using custom kernel of size %dx%d\n", cols,cols)
237 for (int64_t row=0; row<rows; row++)
239 for (int64_t col=row; col<cols; col++)
241 int64_t idx=row * cols - row*(row+1)/2 + col;
268 SG_ERROR(
"%s::set_full_kernel_matrix_from_full "
269 "not possible with subset. Remove first\n",
get_name());
299 SG_ERROR(
"%s::set_full_kernel_matrix_from_full "
300 "not possible with subset. Remove first\n",
get_name());
304 int32_t rows=full_kernel_matrix.
num_rows;
305 int32_t cols=full_kernel_matrix.
num_cols;
306 SG_DEBUG(
"using custom kernel of size %dx%d\n", rows,cols)
311 for (int64_t i=0; i<int64_t(rows) * cols; i++)
321 #ifdef HAVE_LINALG_LIB
340 index_t block_size,
bool no_diag=
true);
365 index_t block_size_col,
bool no_diag=
false);
384 block_begin,
index_t block_size,
bool no_diag=
true);
442 #endif // HAVE_LINALG_LIB
554 "Not possible with row subset active! If you want to"
555 " create a %s from another one with a subset, use "
556 "get_kernel_matrix() and the SGMatrix constructor!\n",
560 "Not possible with collumn subset active! If you want to"
561 " create a %s from another one with a subset, use "
562 "get_kernel_matrix() and the SGMatrix constructor!\n",
588 if (real_row <= real_col)
600 return kmatrix(real_row, real_col);
virtual EKernelType get_kernel_type()
virtual void add_row_subset(SGVector< index_t > subset)
SGMatrix< float32_t > kmatrix
int32_t num_rhs
number of feature vectors on right hand side
The Custom Kernel allows for custom user provided kernel matrices.
virtual bool has_features()
SGMatrix< float32_t > get_float32_kernel_matrix()
virtual int32_t get_num_vec_lhs()
virtual float64_t sum_block(index_t block_begin_row, index_t block_begin_col, index_t block_size_row, index_t block_size_col, bool no_diag=false)
CSubsetStack * m_col_subset_stack
bool set_triangle_kernel_matrix_from_full_generic(SGMatrix< T > full_kernel_matrix)
virtual int32_t get_num_vec_rhs()
virtual void remove_all_row_subsets()
EFeatureClass
shogun feature class
class to add subset support to another class. A CSubsetStackStack instance should be added and wrappe...
virtual SGMatrix< float64_t > row_wise_sum_squared_sum_symmetric_block(index_t block_begin, index_t block_size, bool no_diag=true)
virtual void remove_col_subset()
bool set_triangle_kernel_matrix_from_triangle(SGVector< float64_t > tri_kernel_matrix)
virtual void remove_row_subset()
virtual void add_col_subset(SGVector< index_t > subset)
virtual void row_subset_changed_post()
virtual SGVector< float64_t > row_col_wise_sum_block(index_t block_begin_row, index_t block_begin_col, index_t block_size_row, index_t block_size_col, bool no_diag=false)
virtual EFeatureClass get_feature_class()
virtual float64_t sum_symmetric_block(index_t block_begin, index_t block_size, bool no_diag=true)
bool set_full_kernel_matrix_from_full(SGMatrix< float64_t > full_kernel_matrix, bool check_symmetry=false)
bool set_full_kernel_matrix_from_full(SGMatrix< float32_t > full_kernel_matrix, bool check_symmetry=false)
index_t subset_idx_conversion(index_t idx) const
virtual SGVector< float64_t > row_wise_sum_symmetric_block(index_t block_begin, index_t block_size, bool no_diag=true)
int32_t num_lhs
number of feature vectors on left hand side
virtual bool dummy_init(int32_t rows, int32_t cols)
virtual void remove_all_col_subsets()
virtual const char * get_name() const
EFeatureType
shogun feature type
all of classes and functions are contained in the shogun namespace
virtual EFeatureType get_feature_type()
The class Features is the base class of all feature objects.
virtual void col_subset_changed_post()
virtual bool has_subsets() const
bool set_triangle_kernel_matrix_from_full(SGMatrix< float64_t > full_kernel_matrix)
bool set_triangle_kernel_matrix_from_triangle_generic(SGVector< T > tri_kernel_matrix)
virtual void add_col_subset_in_place(SGVector< index_t > subset)
static float32_t sqrt(float32_t x)
virtual float64_t compute(int32_t row, int32_t col)
CSubsetStack * m_row_subset_stack
virtual void add_row_subset_in_place(SGVector< index_t > subset)