18 SG_UNSTABLE(
"CWDFeatures::CWDFeatures() :CDotFeatures()",
57 degree(orig.degree), from_degree(orig.from_degree),
58 normalization_const(orig.normalization_const)
96 bool free_vec1, free_vec2;
99 uint8_t* vec2=wdf->strings->get_feature_vector(vec_idx2, len2, free_vec2);
105 for (int32_t i=0; i<len1; i++)
107 for (int32_t j=0; (i+j<len1) && (j<
degree); j++)
109 if (vec1[i+j]!=vec2[i+j])
115 wdf->strings->free_feature_vector(vec2, vec_idx2, free_vec2);
121 if (vec2_len !=
w_dim)
122 SG_ERROR(
"Dimensions don't match, vec2_dim=%d, w_dim=%d\n", vec2_len,
w_dim)
129 int32_t* val=SG_MALLOC(int32_t, len);
136 for (int32_t k=0; k<lim; k++)
141 for (int32_t i=0; i+k < len; i++)
143 val[i]+=asizem1*vec[i+k];
144 sum+=vec2[val[i]+o]*wd;
159 if (vec2_len !=
w_dim)
160 SG_ERROR(
"Dimensions don't match, vec2_dim=%d, w_dim=%d\n", vec2_len,
w_dim)
166 int32_t* val=SG_MALLOC(int32_t, len);
173 for (int32_t k=0; k<lim; k++)
181 for (int32_t i=0; i+k < len; i++)
183 val[i]+=asizem1*vec[i+k];
203 for (int32_t i=0; i<
degree; i++)
217 for (int32_t i=0; i<
degree; i++)
232 SG_ERROR(
"Index out of bounds (number of strings %d, you "
236 wd_feature_iterator* it=SG_MALLOC(wd_feature_iterator, 1);
240 it->vidx=vector_index;
243 it->val=SG_MALLOC(int32_t, it->vlen);
258 wd_feature_iterator* it=(wd_feature_iterator*) iterator;
260 if (it->i + it->k >= it->vlen)
262 if (it->k < it->lim-1)
264 it->offs+=it->asize*it->vlen;
277 #ifdef DEBUG_WDFEATURES
278 SG_PRINT(
"i=%d k=%d offs=%d o=%d asize=%d asizem1=%d\n", i, k, it->offs, it->o, it->asize, it->asizem1)
281 it->val[i]+=it->asizem1*it->vec[i+k];
283 index=it->val[i]+it->o;
284 #ifdef DEBUG_WDFEATURES
285 SG_PRINT(
"index=%d val=%f w_size=%d lim=%d vlen=%d\n", index, value,
w_dim, it->lim, it->vlen)
297 wd_feature_iterator* it=(wd_feature_iterator*) iterator;
346 for (int32_t i=0; i<
degree; i++)
virtual EFeatureClass get_feature_class() const
virtual int32_t get_max_vector_length()
SGVector< ST > get_feature_vector(int32_t num)
static void fill_vector(T *vec, int32_t len, T value)
float64_t get_normalization_const()
virtual float64_t dense_dot(int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)
virtual int32_t get_num_vectors() const
The class Alphabet implements an alphabet and alphabet utility functions.
virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t *vec2, int32_t vec2_len, bool abs_val=false)
void free_feature_vector(ST *feat_vec, int32_t num, bool dofree)
Features that compute the Weighted Degreee Kernel feature space explicitly.
Features that support dot products among other operations.
virtual float64_t dot(int32_t vec_idx1, CDotFeatures *df, int32_t vec_idx2)
EFeatureClass
shogun feature class
virtual int32_t get_dim_feature_space() const
void set_normalization_const(float64_t n=0)
int32_t get_num_symbols() const
virtual bool get_next_feature(int32_t &index, float64_t &value, void *iterator)
virtual EFeatureClass get_feature_class() const =0
CAlphabet * get_alphabet()
float64_t normalization_const
EFeatureType
shogun feature type
bool have_same_length(int32_t len=-1)
all of classes and functions are contained in the shogun namespace
The class Features is the base class of all feature objects.
virtual int32_t get_nnz_features_for_vector(int32_t num)
virtual void * get_feature_iterator(int32_t vector_index)
CStringFeatures< uint8_t > * strings
virtual CFeatures * duplicate() const
virtual int32_t get_num_vectors() const
virtual EFeatureType get_feature_type() const
static float32_t sqrt(float32_t x)
#define SG_UNSTABLE(func,...)
virtual void free_feature_iterator(void *iterator)
static int32_t pow(bool x, int32_t n)
virtual EFeatureType get_feature_type() const =0