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.");
virtual EFeatureType get_feature_type() const
void store_normalization_values()
virtual int32_t get_dim_feature_space() const
ST * get_feature_vector(int32_t num, int32_t &len, bool &dofree)
int32_t get_num_features() const
int32_t bico2(int32_t n, int32_t k)
int32_t bico(int32_t n, int32_t k)
void store_multinomial_coefficients()
int32_t m_output_dimensions
#define SG_NOTIMPLEMENTED
virtual float64_t dot(int32_t vec_idx1, CDotFeatures *df, int32_t vec_idx2)
virtual void free_feature_iterator(void *iterator)
virtual bool get_next_feature(int32_t &index, float64_t &value, void *iterator)
Features that support dot products among other operations.
EFeatureClass
shogun feature class
float32_t * m_normalization_values
void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t *vec2, int32_t vec2_len, bool abs_val)
void add(bool *param, const char *name, const char *description="")
Class SGObject is the base class of all shogun objects.
CFeatures * duplicate() const
virtual int32_t get_num_vectors() const
void enumerate_multi_index(const int32_t feat_idx, uint16_t **index, uint16_t *exponents, const int32_t degree)
float64_t * m_multinomial_coefficients
CDenseFeatures< float64_t > * m_feat
virtual int32_t get_nnz_features_for_vector(int32_t num)
virtual EFeatureClass get_feature_class() const =0
float64_t factln(int32_t n)
virtual void * get_feature_iterator(int32_t vector_index)
EFeatureType
shogun feature type
virtual int32_t get_num_vectors() const
float64_t dense_dot(int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)
int32_t calc_feature_space_dimensions(int32_t N, int32_t D)
void add_vector(bool **param, index_t *length, const char *name, const char *description="")
all of classes and functions are contained in the shogun namespace
void free_feature_vector(ST *feat_vec, int32_t num, bool dofree)
The class Features is the base class of all feature objects.
int32_t m_input_dimensions
float64_t gammln(float64_t xx)
virtual EFeatureClass get_feature_class() const
implement DotFeatures for the polynomial kernel
static float32_t sqrt(float32_t x)
virtual EFeatureType get_feature_type() const =0
int32_t multinomialcoef(int32_t *exps, int32_t len)