18 SG_UNSTABLE(
"CHashedWDFeatures::CHashedWDFeatures()",
"\n")
38 int32_t start_order, int32_t order, int32_t from_order,
66 degree(orig.degree), start_degree(orig.start_degree),
67 from_degree(orig.from_degree), m_hash_bits(orig.m_hash_bits),
68 normalization_const(orig.normalization_const)
106 bool free_vec1, free_vec2;
109 uint8_t* vec2=wdf->strings->get_feature_vector(vec_idx2, len2, free_vec2);
115 for (int32_t i=0; i<len1; i++)
117 for (int32_t j=0; (i+j<len1) && (j<
degree); j++)
119 if (vec1[i+j]!=vec2[i+j])
126 wdf->strings->free_feature_vector(vec2, vec_idx2, free_vec2);
132 if (vec2_len !=
w_dim)
133 SG_ERROR(
"Dimensions don't match, vec2_dim=%d, w_dim=%d\n", vec2_len,
w_dim)
140 uint32_t* val=SG_MALLOC(uint32_t, len);
161 for (int32_t i=0; i+k < len; i++)
167 #ifdef DEBUG_HASHEDWD
168 SG_PRINT(
"vec[i]=%d, k=%d, offs=%d o=%d\n", vec[i], k,offs, o)
170 sum+=vec2[o+(h &
mask)]*wd;
186 if (vec2_len !=
w_dim)
187 SG_ERROR(
"Dimensions don't match, vec2_dim=%d, w_dim=%d\n", vec2_len,
w_dim)
193 uint32_t* val=SG_MALLOC(uint32_t, len);
217 for (int32_t i=0; i+k < len; i++)
223 #ifdef DEBUG_HASHEDWD
224 SG_PRINT(
"offs=%d o=%d h=%d \n", offs, o, h)
225 SG_PRINT(
"vec[i]=%d, k=%d, offs=%d o=%d\n", vec[i], k,offs, o)
227 vec2[o+(h &
mask)]+=wd;
251 for (int32_t i=0; i<
degree; i++)
254 SG_DEBUG(
"created HashedWDFeatures with d=%d (%d), alphabetsize=%d, "
255 "dim=%d partial_dim=%d num=%d, len=%d\n",
266 for (int32_t i=0; i<
degree; i++)
virtual int32_t get_max_vector_length()
SGVector< ST > get_feature_vector(int32_t num)
virtual void * get_feature_iterator(int32_t vector_index)
static void fill_vector(T *vec, int32_t len, T value)
virtual ~CHashedWDFeatures()
void set_normalization_const(float64_t n=0)
virtual int32_t get_nnz_features_for_vector(int32_t num)
virtual float64_t dense_dot(int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)
virtual float64_t dot(int32_t vec_idx1, CDotFeatures *df, int32_t vec_idx2)
virtual bool get_next_feature(int32_t &index, float64_t &value, void *iterator)
virtual int32_t get_num_vectors() const
CStringFeatures< uint8_t > * strings
#define SG_NOTIMPLEMENTED
The class Alphabet implements an alphabet and alphabet utility functions.
static uint32_t FinalizeIncrementalMurmurHash3(uint32_t h, uint32_t carry, uint32_t total_length)
void free_feature_vector(ST *feat_vec, int32_t num, bool dofree)
Features that support dot products among other operations.
static uint32_t MurmurHash3(uint8_t *data, int32_t len, uint32_t seed)
float64_t normalization_const
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 CFeatures * duplicate() const
Features that compute the Weighted Degreee Kernel feature space explicitly.
int32_t get_num_symbols() const
virtual EFeatureClass get_feature_class() const =0
CAlphabet * get_alphabet()
bool have_same_length(int32_t len=-1)
static void IncrementalMurmurHash3(uint32_t *hash, uint32_t *carry, uint8_t *data, int32_t len)
all of classes and functions are contained in the shogun namespace
The class Features is the base class of all feature objects.
virtual EFeatureClass get_feature_class() const
virtual EFeatureType get_feature_type() const
virtual void free_feature_iterator(void *iterator)
static float32_t sqrt(float32_t x)
#define SG_UNSTABLE(func,...)
virtual EFeatureType get_feature_type() const =0