11 #ifndef _CUSTOMKERNEL_H___
12 #define _CUSTOMKERNEL_H___
68 virtual bool dummy_init(int32_t rows, int32_t cols);
103 virtual const char*
get_name()
const {
return "CustomKernel"; }
135 int64_t len = tri_kernel_matrix.
vlen;
136 int64_t cols = (int64_t) floor(-0.5 +
CMath::sqrt(0.25+2*len));
138 if (cols*(cols+1)/2 != len)
140 SG_ERROR(
"km should be a vector containing a lower triangle matrix, with len=cols*(cols+1)/2 elements\n");
145 SG_DEBUG(
"using custom kernel of size %dx%d\n", cols,cols);
152 for (int64_t i=0; i<len; i++)
155 dummy_init(cols,cols);
181 int32_t rows = full_kernel_matrix.
num_rows;
182 int32_t cols = full_kernel_matrix.
num_cols;
186 SG_DEBUG(
"using custom kernel of size %dx%d\n", cols,cols);
193 for (int64_t row=0; row<rows; row++)
195 for (int64_t col=row; col<cols; col++)
197 int64_t idx=row * cols - row*(row+1)/2 + col;
233 int32_t rows=full_kernel_matrix.
num_rows;
234 int32_t cols=full_kernel_matrix.
num_cols;
235 SG_DEBUG(
"using custom kernel of size %dx%d\n", rows,cols);
242 for (int32_t row=0; row<rows; row++)
244 for (int32_t col=0; col<cols; col++)
246 full_kernel_matrix.
matrix[int64_t(col)*rows+row];
317 void cleanup_custom();
virtual EKernelType get_kernel_type()
SGMatrix< float32_t > kmatrix
The Custom Kernel allows for custom user provided kernel matrices.
virtual bool has_features()
virtual int32_t get_num_vec_lhs()
bool set_triangle_kernel_matrix_from_full_generic(SGMatrix< T > full_kernel_matrix)
virtual int32_t get_num_vec_rhs()
EFeatureClass
shogun feature class
bool set_triangle_kernel_matrix_from_triangle(SGVector< float64_t > tri_kernel_matrix)
virtual EFeatureClass get_feature_class()
bool set_full_kernel_matrix_from_full(SGMatrix< float64_t > full_kernel_matrix)
virtual bool dummy_init(int32_t rows, int32_t cols)
virtual const char * get_name() const
EFeatureType
shogun feature type
virtual EFeatureType get_feature_type()
bool set_full_kernel_matrix_from_full(SGMatrix< float32_t > full_kernel_matrix)
The class Features is the base class of all feature objects.
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)
static float32_t sqrt(float32_t x)
x^0.5
virtual float64_t compute(int32_t row, int32_t col)
#define SG_MALLOC(type, len)
virtual void free_matrix()