const float64_t* CCombinedKernel::get_subkernel_weights(int32_t& num_weights) { SG_DEBUG("entering CCombinedKernel::get_subkernel_weights()\n"); num_weights = get_num_subkernels() ; SG_FREE(subkernel_weights_buffer); subkernel_weights_buffer = SG_MALLOC(float64_t, num_weights); if (append_subkernel_weights) { SG_DEBUG("appending kernel weights\n"); int32_t i=0 ; CListElement* current = NULL ; CKernel* k = get_first_kernel(current); while(k) { int32_t num = -1 ; const float64_t *w = k->get_subkernel_weights(num); ASSERT(num==k->get_num_subkernels()); for (int32_t j=0; j<num; j++) subkernel_weights_buffer[i+j]=w[j] ; SG_UNREF(k); k = get_next_kernel(current); i += num ; } } else { SG_DEBUG("not appending kernel weights\n"); int32_t i=0 ; CListElement* current = NULL ; CKernel* k = get_first_kernel(current); while(k) { subkernel_weights_buffer[i] = k->get_combined_kernel_weight(); SG_UNREF(k); k = get_next_kernel(current); i++ ; } } SG_DEBUG("leaving CCombinedKernel::get_subkernel_weights()\n"); return subkernel_weights_buffer ; }
void CCombinedKernel::compute_by_subkernel( int32_t idx, float64_t * subkernel_contrib) { if (append_subkernel_weights) { int32_t i=0 ; CListElement* current = NULL ; CKernel* k = get_first_kernel(current); while(k) { int32_t num = -1 ; k->get_subkernel_weights(num); if (num>1) k->compute_by_subkernel(idx, &subkernel_contrib[i]) ; else subkernel_contrib[i] += k->get_combined_kernel_weight() * k->compute_optimized(idx) ; SG_UNREF(k); k = get_next_kernel(current); i += num ; } } else { int32_t i=0 ; CListElement* current = NULL ; CKernel* k = get_first_kernel(current); while(k) { if (k->get_combined_kernel_weight()!=0) subkernel_contrib[i] += k->get_combined_kernel_weight() * k->compute_optimized(idx) ; SG_UNREF(k); k = get_next_kernel(current); i++ ; } } }