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();