20 "CImplicitWeightedSpecFeatures()",
"\n");
89 for (int32_t i=0; i<
degree; i++)
95 num_strings(orig.num_strings),
96 alphabet_size(orig.alphabet_size), spec_size(orig.spec_size)
124 uint16_t* vec2=sf->strings->get_feature_vector(vec_idx2, len2, free_vec2);
129 for (int32_t d=0; d<
degree; d++)
131 mask = mask | (1 << (degree-d-1));
138 while (left_idx < len1 && right_idx < len2)
140 uint16_t lsym=vec1[left_idx] & masked;
141 uint16_t rsym=vec2[right_idx] & masked;
145 int32_t old_left_idx=left_idx;
146 int32_t old_right_idx=right_idx;
148 while (left_idx<len1 && (vec1[left_idx] & masked) ==lsym)
151 while (right_idx<len2 && (vec2[right_idx] & masked) ==lsym)
154 result+=weight*(left_idx-old_left_idx)*(right_idx-old_right_idx);
164 sf->strings->free_feature_vector(vec2, vec_idx2, free_vec2);
184 for (int32_t j=0; j<len1; j++)
190 for (int32_t d=0; d<
degree; d++)
192 mask = mask | (1 << (degree-d-1));
222 for (int32_t j=0; j<len1; j++)
226 for (int32_t d=0; d<
degree; d++)
228 mask = mask | (1 << (degree-d-1));
257 SG_ERROR(
"Index out of bounds (number of strings %d, you "
261 wspec_feature_iterator* it=SG_MALLOC(wspec_feature_iterator, 1);
263 it->vidx=vector_index;
276 wspec_feature_iterator* it=(wspec_feature_iterator*) iterator;
280 if (it->j < it->vlen-1)
293 it->mask = it->mask | (1 << (
degree-d-1));
297 index=it->offs + idx;
307 wspec_feature_iterator* it=(wspec_feature_iterator*) iterator;
320 for (int32_t i=1; i<=
degree; i++)
SGVector< ST > get_feature_vector(int32_t num)
virtual int32_t get_nnz_features_for_vector(int32_t num)
ST shift_offset(ST offset, int32_t amount)
virtual bool get_next_feature(int32_t &index, float64_t &value, void *iterator)
virtual void * get_feature_iterator(int32_t vector_index)
virtual int32_t get_num_vectors() const
virtual float64_t dot(int32_t vec_idx1, CDotFeatures *df, int32_t vec_idx2)
void compute_normalization_const()
virtual int32_t get_dim_feature_space() const
#define SG_NOTIMPLEMENTED
virtual ~CImplicitWeightedSpecFeatures()
void free_feature_vector(ST *feat_vec, int32_t num, bool dofree)
floatmax_t get_original_num_symbols()
Features that support dot products among other operations.
bool set_weights(float64_t *w, int32_t d)
virtual float64_t dense_dot(int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)
EFeatureClass
shogun feature class
Features that compute the Weighted Spectrum Kernel feature space explicitly.
virtual CFeatures * duplicate() const
ST get_masked_symbols(ST symbol, uint8_t mask)
virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t *vec2, int32_t vec2_len, bool abs_val=false)
virtual EFeatureClass get_feature_class() const
virtual EFeatureClass get_feature_class() const =0
float64_t * normalization_factors
virtual void free_feature_iterator(void *iterator)
EFeatureType
shogun feature type
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_num_vectors() const
ST shift_symbol(ST symbol, int32_t amount)
virtual EFeatureType get_feature_type() const
static float32_t sqrt(float32_t x)
#define SG_UNSTABLE(func,...)
CImplicitWeightedSpecFeatures()
CStringFeatures< uint16_t > * strings
static int32_t pow(bool x, int32_t n)
virtual EFeatureType get_feature_type() const =0