3 using namespace shogun;
16 register_parameters();
20 :
CDotFeatures(), m_multi_index(NULL), m_multinomial_coefficients(NULL),
21 m_normalization_values(NULL)
37 register_parameters();
117 float64_t* vec2 = pf->m_feat->get_feature_vector(vec_idx2, len2, do_free2);
128 out2*=vec2[m_multi_index[cnt]];
134 pf->m_feat->free_feature_vector(vec2, len2, do_free2);
151 for (
int j=0; j<vec2_len; j++)
182 for (
int j=0; j<vec2_len; j++)
193 vec2[j]+=alpha*output;
204 for (
int i=0; i<num_vec; i++)
237 exponents[feat_idx] = degree;
239 exponents[feat_idx] = 0;
241 for (j=0; j<feat_idx+1; j++)
242 for (i=0; i<exponents[j]; i++)
247 exponents[feat_idx] = 0;
251 for (k=0; k<=degree; k++)
253 exponents[feat_idx] = k;
331 for (i=0; i<len; i++)
334 ret *=
bico2(n, exps[i]);
344 static float64_t cof[6]={76.18009172947146, -86.50532032941677,
345 24.01409824083091, -1.231739572450155,
346 0.1208650973866179e-2,-0.5395239384953e-5};
351 tmp -= (x+0.5)*log(tmp);
352 ser=1.000000000190015;
353 for (j=0;j<=5;j++) ser += cof[j]/++y;
354 return -tmp+log(2.5066282746310005*ser/x);
361 if (n < 0)
SG_ERROR(
"Negative factorial in routine factln\n")
362 if (n <= 1)
return 0.0;
363 if (n <= 100)
return a[n] ? a[n] : (a[n]=
gammln(n+1.0));
364 else return gammln(n+1.0);
377 void CPolyFeatures::register_parameters()
380 "Features in original space.");
384 "Dimensions of the input space.");
386 "Dimensions of the feature space of the polynomial kernel.");
393 "Flattened matrix of all multi indices that sum do the"
394 " degree of the polynomial kernel.");
398 &multinomial_coefficients_length,
"multinomial_coefficients",
399 "Multinomial coefficients for all multi-indices.");
403 &normalization_values_length,
"normalization_values",
404 "Norm of each training example.");