12 #ifndef _CUSTOMKERNEL_H___
13 #define _CUSTOMKERNEL_H___
83 virtual bool dummy_init(int32_t rows, int32_t cols);
123 virtual const char*
get_name()
const {
return "CustomKernel"; }
141 SG_ERROR(
"%s::set_triangle_kernel_matrix_from_triangle not"
142 " possible with subset. Remove first\n",
get_name());
164 SG_ERROR(
"%s::set_triangle_kernel_matrix_from_triangle_generic "
165 "not possible with subset. Remove first\n",
get_name());
169 int64_t len = tri_kernel_matrix.
vlen;
170 int64_t cols = (int64_t) floor(-0.5 +
CMath::sqrt(0.25+2*len));
172 if (cols*(cols+1)/2 != len)
174 SG_ERROR(
"km should be a vector containing a lower triangle matrix, with len=cols*(cols+1)/2 elements\n")
179 SG_DEBUG(
"using custom kernel of size %dx%d\n", cols,cols)
184 for (int64_t i=0; i<len; i++)
187 dummy_init(cols,cols);
219 SG_ERROR(
"%s::set_triangle_kernel_matrix_from_full_generic "
220 "not possible with subset. Remove first\n",
get_name());
223 int32_t rows = full_kernel_matrix.
num_rows;
224 int32_t cols = full_kernel_matrix.
num_cols;
228 SG_DEBUG(
"using custom kernel of size %dx%d\n", cols,cols)
233 for (int64_t row=0; row<rows; row++)
235 for (int64_t col=row; col<cols; col++)
237 int64_t idx=row * cols - row*(row+1)/2 + col;
259 SG_ERROR(
"%s::set_full_kernel_matrix_from_full "
260 "not possible with subset. Remove first\n",
get_name());
282 SG_ERROR(
"%s::set_full_kernel_matrix_from_full "
283 "not possible with subset. Remove first\n",
get_name());
287 int32_t rows=full_kernel_matrix.
num_rows;
288 int32_t cols=full_kernel_matrix.
num_cols;
289 SG_DEBUG(
"using custom kernel of size %dx%d\n", rows,cols)
294 for (int64_t i=0; i<int64_t(rows) * cols; i++)
379 "Not possible with row subset active! If you want to"
380 " create a %s from another one with a subset, use "
381 "get_kernel_matrix() and the SGMatrix constructor!\n",
385 "Not possible with collumn subset active! If you want to"
386 " create a %s from another one with a subset, use "
387 "get_kernel_matrix() and the SGMatrix constructor!\n",
413 if (real_row <= real_col)
425 return kmatrix(real_row, real_col);