void CCombinedKernel::set_subkernel_weights(SGVector<float64_t> weights) { if (append_subkernel_weights) { int32_t i=0 ; CListElement* current = NULL ; CKernel* k = get_first_kernel(current); while(k) { int32_t num = k->get_num_subkernels() ; ASSERT(i<weights.vlen); k->set_subkernel_weights(SGVector<float64_t>(&weights.vector[i],num, false)); 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) { ASSERT(i<weights.vlen); k->set_combined_kernel_weight(weights.vector[i]); SG_UNREF(k); k = get_next_kernel(current); i++ ; } } }
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 ; }