36 using namespace shogun;
73 SG_ERROR(
"Kernel still initialized on destruction.\n")
78 SG_INFO(
"Kernel deleted (%p).\n",
this)
90 REQUIRE(l,
"CKernel::init(%p, %p): Left hand side features required!\n", l, r)
91 REQUIRE(r,
"CKernel::init(%p, %p): Right hand side features required!\n", l, r)
120 SG_DEBUG(
"leaving CKernel::init(%p, %p)\n", l, r)
170 SG_DEBUG(
"entering CKernel::remove_lhs_and_rhs\n")
182 SG_DEBUG(
"leaving CKernel::remove_lhs_and_rhs\n")
208 #define ENUM_CASE(n) case n: SG_INFO(#n " ") break;
215 "SLOWBUTMEMEFFICIENT");
326 int32_t count, int32_t *IDX,
float64_t * weights)
328 SG_ERROR(
"kernel does not support linadd optimization\n")
334 SG_ERROR(
"kernel does not support linadd optimization\n")
340 SG_ERROR(
"kernel does not support linadd optimization\n")
345 int32_t num_vec, int32_t* vec_idx,
float64_t* target, int32_t num_suppvec,
348 SG_ERROR(
"kernel does not support batch computation\n")
353 SG_ERROR(
"kernel does not support linadd optimization, add_to_normal not implemented\n")
358 SG_ERROR(
"kernel does not support linadd optimization, clear_normal not implemented\n")
367 int32_t vector_idx,
float64_t * subkernel_contrib)
369 SG_ERROR(
"kernel compute_by_subkernel not implemented\n")
389 SG_ERROR(
"number of subkernel weights should be one ...\n")
399 REQUIRE(casted,
"CKernel::obtain_from_generic(): Error, provided object"
400 " of class \"%s\" is not a subclass of CKernel!\n",
411 int32_t* sv_idx=SG_MALLOC(int32_t, num_suppvec);
414 for (int32_t i=0; i<num_suppvec; i++)
458 SG_ADD(&
num_lhs,
"num_lhs",
"Number of feature vectors on left hand side.",
460 SG_ADD(&
num_rhs,
"num_rhs",
"Number of feature vectors on right hand side.",
525 int32_t i_start=params->
start;
526 int32_t i_end=params->
end;
535 int64_t total=total_start;
537 for (int32_t i=i_start; i<i_end; i++)
544 for (int32_t j=j_start; j<n; j++)
549 if (symmetric && i!=j)
556 if (symmetric && i!=j)
582 int64_t total_num = int64_t(m)*n;
585 bool symmetric= (
lhs &&
lhs==
rhs && m==n);
589 result=SG_MALLOC(T, total_num);
591 int32_t num_threads=
parallel->get_num_threads();
605 get_kernel_matrix_helper<T>((
void*) ¶ms);
609 pthread_t* threads = SG_MALLOC(pthread_t, num_threads-1);
611 int64_t step= total_num/num_threads;
616 for (t=0; t<num_threads; t++)
619 params[t].
result = result;
629 int code=pthread_create(&threads[t], NULL,
630 CKernel::get_kernel_matrix_helper<T>, (
void*)¶ms[t]);
634 SG_WARNING(
"Thread creation failed (thread %d of %d) "
635 "with error:'%s'\n",t, num_threads, strerror(code));
642 params[t].
result = result;
651 get_kernel_matrix_helper<T>(¶ms[t]);
653 for (t=0; t<num_threads; t++)
655 if (pthread_join(threads[t], NULL) != 0)
656 SG_WARNING(
"pthread_join of thread %d/%d failed\n", t, num_threads)
665 return
SGMatrix<T>(result,m,n,true);