34 SG_DEBUG(
"CHammingWordDistance with sign: %d created\n", (sign) ? 1 : 0)
44 SG_DEBUG(
"CHammingWordDistance with sign: %d created\n", (sign) ? 1 : 0)
67 bool free_avec, free_bvec;
70 get_feature_vector(idx_a, alen, free_avec);
72 get_feature_vector(idx_b, blen, free_bvec);
82 while (left_idx < alen && right_idx < blen)
84 uint16_t sym=avec[left_idx];
85 if (avec[left_idx]==bvec[right_idx])
87 while (left_idx< alen && avec[left_idx]==sym)
90 while (right_idx< blen && bvec[right_idx]==sym)
93 else if (avec[left_idx]<bvec[right_idx])
97 while (left_idx< alen && avec[left_idx]==sym)
105 while (right_idx< blen && bvec[right_idx]==sym)
113 while (left_idx < alen && right_idx < blen)
115 uint16_t sym=avec[left_idx];
116 if (avec[left_idx]==bvec[right_idx])
118 int32_t old_left_idx=left_idx;
119 int32_t old_right_idx=right_idx;
121 while (left_idx< alen && avec[left_idx]==sym)
124 while (right_idx< blen && bvec[right_idx]==sym)
127 if ((left_idx-old_left_idx)!=(right_idx-old_right_idx))
130 else if (avec[left_idx]<bvec[right_idx])
134 while (left_idx< alen && avec[left_idx]==sym)
142 while (right_idx< blen && bvec[right_idx]==sym)
148 while (left_idx < alen)
150 uint16_t sym=avec[left_idx];
153 while (left_idx< alen && avec[left_idx]==sym)
157 while (right_idx < blen)
159 uint16_t sym=bvec[right_idx];
162 while (right_idx< blen && bvec[right_idx]==sym)
167 free_feature_vector(avec, idx_a, free_avec);
169 free_feature_vector(bvec, idx_b, free_bvec);
174 void CHammingWordDistance::init()
178 "If signum(counts) is used instead of counts.");
virtual ~CHammingWordDistance()
void add(bool *param, const char *name, const char *description="")
float64_t compute(int32_t idx_a, int32_t idx_b)
all of classes and functions are contained in the shogun namespace
CFeatures * lhs
feature vectors to occur on the left hand side
The class Features is the base class of all feature objects.
CFeatures * rhs
feature vectors to occur on the right hand side
virtual bool init(CFeatures *l, CFeatures *r)
template class StringDistance