3 using namespace shogun;
15 register_parameters();
19 :
CDotFeatures(), m_multi_index(NULL), m_multinomial_coefficients(NULL),
20 m_normalization_values(NULL)
36 register_parameters();
121 float64_t* vec2 = pf->m_feat->get_feature_vector(vec_idx2, len2, do_free2);
132 out2*=vec2[m_multi_index[cnt]];
138 pf->m_feat->free_feature_vector(vec2, len2, do_free2);
155 for (
int j=0; j<vec2_len; j++)
186 for (
int j=0; j<vec2_len; j++)
197 vec2[j]+=alpha*output;
208 for (
int i=0; i<num_vec; i++)
228 SG_ERROR(
"Error allocating mem \n");
241 exponents[feat_idx] = degree;
243 exponents[feat_idx] = 0;
245 for (j=0; j<feat_idx+1; j++)
246 for (i=0; i<exponents[j]; i++)
251 exponents[feat_idx] = 0;
255 for (k=0; k<=degree; k++)
257 exponents[feat_idx] = k;
271 SG_ERROR(
"Error allocating mem \n");
335 for (i=0; i<len; i++)
338 ret *=
bico2(n, exps[i]);
348 static float64_t cof[6]={76.18009172947146, -86.50532032941677,
349 24.01409824083091, -1.231739572450155,
350 0.1208650973866179e-2,-0.5395239384953e-5};
355 tmp -= (x+0.5)*log(tmp);
356 ser=1.000000000190015;
357 for (j=0;j<=5;j++) ser += cof[j]/++y;
358 return -tmp+log(2.5066282746310005*ser/x);
365 if (n < 0)
SG_ERROR(
"Negative factorial in routine factln\n");
366 if (n <= 1)
return 0.0;
367 if (n <= 100)
return a[n] ? a[n] : (a[n]=
gammln(n+1.0));
368 else return gammln(n+1.0);
381 void CPolyFeatures::register_parameters()
384 "Features in original space.");
388 "Dimensions of the input space.");
390 "Dimensions of the feature space of the polynomial kernel.");
397 "Flattened matrix of all multi indices that sum do the"
398 " degree of the polynomial kernel.");
402 &multinomial_coefficients_length,
"multinomial_coefficients",
403 "Multinomial coefficients for all multi-indices.");
407 &normalization_values_length,
"normalization_values",
408 "Norm of each training example.");