16 using namespace shogun;
25 int32_t size,
bool us)
55 CCommWordStringKernel::init(l,r);
91 for (int32_t i=0; i<
degree; i++)
97 int32_t idx_a, int32_t idx_b,
bool do_sort)
100 bool free_avec, free_bvec;
116 memcpy(avec, av,
sizeof(uint16_t)*alen);
125 memcpy(bvec, bv,
sizeof(uint16_t)*blen);
136 SG_ERROR(
"not all preprocessors have been applied to training (%d/%d)"
145 for (int32_t d=0; d<
degree; d++)
147 mask = mask | (1 << (degree-d-1));
154 while (left_idx < alen && right_idx < blen)
156 uint16_t lsym=avec[left_idx] & masked;
157 uint16_t rsym=bvec[right_idx] & masked;
161 int32_t old_left_idx=left_idx;
162 int32_t old_right_idx=right_idx;
164 while (left_idx<alen && (avec[left_idx] & masked) ==lsym)
167 while (right_idx<blen && (bvec[right_idx] & masked) ==lsym)
170 result+=weight*(left_idx-old_left_idx)*(right_idx-old_right_idx);
201 for (int32_t j=0; j<len; j++)
205 for (int32_t d=0; d<
degree; d++)
207 mask = mask | (1 << (degree-d-1));
228 int32_t dic_size=1<<(
sizeof(uint16_t)*8);
230 memset(dic, 0,
sizeof(
float64_t)*dic_size);
232 for (uint32_t sym=0; sym<num_symbols; sym++)
237 for (int32_t d=0; d<
degree; d++)
239 mask = mask | (1 << (degree-d-1));
256 SG_ERROR(
"CCommWordStringKernel optimization not initialized\n");
268 for (int32_t j=0; j<len; j++)
272 for (int32_t d=0; d<
degree; d++)
274 mask = mask | (1 << (degree-d-1));
289 int32_t max_degree, int32_t& num_feat, int32_t& num_sym,
float64_t* target,
290 int32_t num_suppvec, int32_t* IDX,
float64_t* alphas,
bool do_init)
295 int32_t dic_size=1<<(
sizeof(uint16_t)*9);
301 num_sym, target, num_suppvec, IDX, alphas,
false);
310 void CWeightedCommWordStringKernel::init()
318 "weights for each of the subkernels of degree 1...d");